01: package com.sun.portal.ubt.report.data.file.aggregate;
02:
03: import com.sun.portal.ubt.report.data.file.raw.ChannelWiseActionsMiner;
04:
05: import java.util.TreeMap;
06: import java.util.Iterator;
07:
08: /**
09: *
10: */
11: public class ChannelWiseActionsMinerAggregator extends
12: DataMinerAggregatorAdapter {
13: private TreeMap channelWiseActionsDistribution = new TreeMap(); //Map(container, Map(channel, Map(action, count)))
14:
15: public ChannelWiseActionsMinerAggregator() {
16: this .minerClassName = ChannelWiseActionsMiner.class.getName();
17: }
18:
19: protected void add(Object o) {
20: TreeMap minerData = (TreeMap) o;
21: Iterator containerIt = minerData.keySet().iterator();
22: while (containerIt.hasNext()) {
23: Object container = containerIt.next();
24: if (channelWiseActionsDistribution.containsKey(container)) {
25: //elaborate
26: TreeMap aggergateContainerMap = (TreeMap) channelWiseActionsDistribution
27: .get(container);
28: TreeMap containerMap = (TreeMap) minerData
29: .get(container);
30: Iterator channelIt = containerMap.keySet().iterator();
31: while (channelIt.hasNext()) {
32: Object channel = channelIt.next();
33: if (aggergateContainerMap.containsKey(channel)) {
34: //elaborate
35: TreeMap aggregateChannelMap = (TreeMap) aggergateContainerMap
36: .get(channel);
37: TreeMap channelMap = (TreeMap) containerMap
38: .get(channel);
39: Iterator userIt = channelMap.keySet()
40: .iterator();
41: while (userIt.hasNext()) {
42: Object action = userIt.next();
43: if (aggregateChannelMap.containsKey(action)) {
44: //elaborate
45: Integer aggregateCount = (Integer) aggregateChannelMap
46: .get(action);
47: Integer count = (Integer) channelMap
48: .get(action);
49: aggregateChannelMap.put(action,
50: new Integer(aggregateCount
51: .intValue()
52: + count.intValue()));
53: } else {
54: aggregateChannelMap.put(action,
55: channelMap.get(action));
56: }
57: }
58: } else {
59: aggergateContainerMap.put(channel, containerMap
60: .get(channel));
61: }
62: }
63:
64: } else {
65: channelWiseActionsDistribution.put(container, minerData
66: .get(container));
67: }
68: }
69:
70: }
71:
72: public Object getData() {
73: return channelWiseActionsDistribution;
74: }
75:
76: public void setData(Object data) {
77: channelWiseActionsDistribution = (TreeMap) data;
78: }
79: }
|