1 | |
package org.paneris.jammyjoes.mvp; |
2 | |
|
3 | |
import java.util.HashMap; |
4 | |
import java.util.Map; |
5 | |
import java.util.Vector; |
6 | |
|
7 | |
import org.melati.template.ServletTemplateContext; |
8 | |
|
9 | |
public class AffiliateStatsPresenter extends AbstractPresenter implements Presenter { |
10 | |
|
11 | |
private Map _monthMap; |
12 | |
private Vector _results; |
13 | |
private TimesliceValue _max; |
14 | |
private TimesliceFactory _timesliceFactory; |
15 | |
private final Selection selection; |
16 | |
private final boolean detail; |
17 | |
private AffiliateTotals _total; |
18 | |
|
19 | |
public AffiliateStatsPresenter(String name, ServletTemplateContext context, |
20 | 0 | TimesliceFactory timesliceFactory, Selection selection, boolean detail) { |
21 | 0 | this.selection = selection; |
22 | 0 | this.detail = detail; |
23 | 0 | _monthMap = new HashMap(); |
24 | 0 | _results = new Vector(); |
25 | 0 | _timesliceFactory = timesliceFactory; |
26 | 0 | _max = new TimesliceValue(_timesliceFactory.create(null),0); |
27 | 0 | _total = new AffiliateTotals(); |
28 | 0 | context.put(name + "_max", _max); |
29 | 0 | context.put(name + "_results", _results); |
30 | 0 | context.put(name + "_months", _monthMap); |
31 | 0 | context.put(name + "_total", _total); |
32 | 0 | context.put(name + "_sorter", new CollectionSorter()); |
33 | 0 | } |
34 | |
|
35 | |
public Selection createSelection() { |
36 | 0 | return selection; |
37 | |
} |
38 | |
|
39 | |
public Command createCommand() { |
40 | 0 | if (detail) { |
41 | 0 | return new CopyIntoContextCommand(_results, _total); |
42 | |
} else { |
43 | 0 | return new CollectingCommand(_monthMap, _max, _timesliceFactory, _total); |
44 | |
} |
45 | |
} |
46 | |
|
47 | |
} |