01: package com.sun.portal.ubt.report.data.file.aggregate;
02:
03: import com.sun.portal.ubt.report.data.file.raw.ContainerWiseActionsMiner;
04:
05: import java.util.TreeMap;
06: import java.util.Iterator;
07:
08: /**
09: *
10: */
11: public class ContainerWiseActionsMinerAggregator extends
12: DataMinerAggregatorAdapter {
13: private TreeMap portalCustomizationAggregate = new TreeMap();
14: private TreeMap portalCustomizationIntentionsAggregate = new TreeMap(); //Map(container, count)
15: private TreeMap portalCustomizationSuccessfulAggregate = new TreeMap(); //Map(container, count)
16:
17: public ContainerWiseActionsMinerAggregator() {
18: this .minerClassName = ContainerWiseActionsMiner.class.getName();
19: portalCustomizationAggregate.put(
20: ContainerWiseActionsMiner.INTENTIONS,
21: portalCustomizationIntentionsAggregate);
22: portalCustomizationAggregate.put(
23: ContainerWiseActionsMiner.SUCCESSFUL,
24: portalCustomizationSuccessfulAggregate);
25: }
26:
27: protected void add(Object o) {
28: TreeMap portalCustomization = (TreeMap) o;
29: TreeMap portalCustomizationIntentions = (TreeMap) portalCustomization
30: .get(ContainerWiseActionsMiner.INTENTIONS);
31: TreeMap portalCustomizationSuccessful = (TreeMap) portalCustomization
32: .get(ContainerWiseActionsMiner.SUCCESSFUL);
33: add((TreeMap) portalCustomizationAggregate
34: .get(ContainerWiseActionsMiner.INTENTIONS),
35: portalCustomizationIntentions);
36: add((TreeMap) portalCustomizationAggregate
37: .get(ContainerWiseActionsMiner.SUCCESSFUL),
38: portalCustomizationSuccessful);
39: }
40:
41: private void add(TreeMap aggregateData, TreeMap minerData) {
42: Iterator containerIt = minerData.keySet().iterator();
43: while (containerIt.hasNext()) {
44: Object container = containerIt.next();
45: if (aggregateData.containsKey(container)) {
46: //elaborate
47: aggregateData.put(container, new Integer(
48: ((Integer) minerData.get(container)).intValue()
49: + ((Integer) aggregateData
50: .get(container)).intValue()));
51: } else {
52: aggregateData.put(container, minerData.get(container));
53: }
54: }
55: }
56:
57: public Object getData() {
58: return portalCustomizationAggregate;
59: }
60:
61: public void setData(Object data) {
62: portalCustomizationAggregate = (TreeMap) data;
63: this .portalCustomizationIntentionsAggregate = (TreeMap) this .portalCustomizationAggregate
64: .get(ContainerWiseActionsMiner.INTENTIONS);
65: this .portalCustomizationSuccessfulAggregate = (TreeMap) this.portalCustomizationAggregate
66: .get(ContainerWiseActionsMiner.SUCCESSFUL);
67: }
68: }
|