001: package com.sun.portal.ubt.report.data.file.aggregate;
002:
003: import com.sun.portal.ubt.report.data.file.raw.ChannelWiseUserActionsMiner;
004:
005: import java.util.TreeMap;
006: import java.util.Iterator;
007:
008: /**
009: *
010: */
011: public class ChannelWiseUserActionsMinerAggregator extends
012: DataMinerAggregatorAdapter {
013: TreeMap channelWiseUserActionsDistribution = new TreeMap(); //Map(container, Map(Channel, Map(User, Map(Action,Count))))
014:
015: public ChannelWiseUserActionsMinerAggregator() {
016: this .minerClassName = ChannelWiseUserActionsMiner.class
017: .getName();
018: }
019:
020: protected void add(Object o) {
021: TreeMap minerData = (TreeMap) o;
022: Iterator containerIt = minerData.keySet().iterator();
023: while (containerIt.hasNext()) {
024: Object container = containerIt.next();
025: if (channelWiseUserActionsDistribution
026: .containsKey(container)) {
027: //elaborate
028: TreeMap aggergateContainerMap = (TreeMap) channelWiseUserActionsDistribution
029: .get(container);
030: TreeMap containerMap = (TreeMap) minerData
031: .get(container);
032: Iterator channelIt = containerMap.keySet().iterator();
033: while (channelIt.hasNext()) {
034: Object channel = channelIt.next();
035: if (aggergateContainerMap.containsKey(channel)) {
036: //elaborate
037: TreeMap aggregateChannelMap = (TreeMap) aggergateContainerMap
038: .get(channel);
039: TreeMap channelMap = (TreeMap) containerMap
040: .get(channel);
041: Iterator userIt = channelMap.keySet()
042: .iterator();
043: while (userIt.hasNext()) {
044: Object user = userIt.next();
045: if (aggregateChannelMap.containsKey(user)) {
046: //elaborate
047: TreeMap aggregateUserMap = (TreeMap) aggregateChannelMap
048: .get(user);
049: TreeMap userMap = (TreeMap) channelMap
050: .get(user);
051: Iterator actionIt = userMap.keySet()
052: .iterator();
053: while (actionIt.hasNext()) {
054: Object action = actionIt.next();
055: if (aggregateUserMap
056: .containsKey(action)) {
057: //elaborate
058: Integer aggregateCount = (Integer) aggregateUserMap
059: .get(action);
060: Integer count = (Integer) userMap
061: .get(action);
062: aggregateUserMap
063: .put(
064: action,
065: new Integer(
066: aggregateCount
067: .intValue()
068: + count
069: .intValue()));
070:
071: } else {
072: aggregateUserMap.put(action,
073: userMap.get(action));
074: }
075: }
076: } else {
077: aggregateChannelMap.put(user,
078: channelMap.get(user));
079: }
080: }
081: } else {
082: aggergateContainerMap.put(channel, containerMap
083: .get(channel));
084: }
085: }
086:
087: } else {
088: channelWiseUserActionsDistribution.put(container,
089: minerData.get(container));
090: }
091: }
092:
093: }
094:
095: public Object getData() {
096: return channelWiseUserActionsDistribution;
097: }
098:
099: public void setData(Object data) {
100: channelWiseUserActionsDistribution = (TreeMap) data;
101: }
102: }
|