001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.ubt.report.data.file.raw;
006:
007: import com.sun.portal.ubt.report.data.*;
008:
009: import java.util.TreeMap;
010: import java.util.TreeSet;
011: import java.util.Vector;
012:
013: /**
014: *
015: */
016: public class ChannelWiseUserActionsMiner extends DataMinerAdapter {
017: TreeSet actionsSet = UBTActions.getProviderValidSet();
018: TreeMap channelWiseUserActionsDistribution = new TreeMap(); //Map(container, Map(Channel, Map(User, Map(Action,Count))))
019: String component;
020:
021: public ChannelWiseUserActionsMiner() {
022: }
023:
024: private Vector miners;
025:
026: public void setValidActions(TreeSet set) {
027: this .actionsSet = set;
028: }
029:
030: public void setComponent(String component) {
031: this .component = component;
032: }
033:
034: public void setMinerCollection(MinerCollection collection) {
035: miners = collection.getCollection();
036: }
037:
038: public void mine(UBTLogLine logLine) throws Exception {
039: if (!UBTLogConstants.EVENT_USER_CLICK_CHN.equals(logLine
040: .getEventID()))
041: return;
042: if (component != null
043: && !component.equals(logLine.getComponentName()))
044: return;
045: String channelName = logLine.getChannelName();
046: String action = logLine.getAction();
047: String userID = new UserID(logLine.getUserID()).getUid();
048: String containerName = logLine.getContainerName();
049: if (containerName == null)
050: return;//dealing with top container actions, not covered here
051: if (userID == null || channelName == null
052: || !actionsSet.contains(action))
053: return;
054:
055: if (channelWiseUserActionsDistribution
056: .containsKey(containerName)) {
057: TreeMap containerMap = (TreeMap) channelWiseUserActionsDistribution
058: .get(containerName);
059: if (containerMap.containsKey(channelName)) {
060: TreeMap channelMap = (TreeMap) containerMap
061: .get(channelName);
062: if (channelMap.containsKey(userID)) {
063: TreeMap userMap = (TreeMap) channelMap.get(userID);
064: if (userMap.containsKey(action)) {
065: Integer count = (Integer) userMap.get(action);
066: userMap.put(action, new Integer(count
067: .intValue() + 1));
068: } else {
069: //add a new action
070: userMap.put(action, new Integer(1));
071: }
072: } else {
073: //add a new user
074: TreeMap userMap = new TreeMap();
075: userMap.put(action, new Integer(1));
076: channelMap.put(userID, userMap);
077: }
078: } else {
079: //add a new channel
080: TreeMap channelMap = new TreeMap();
081: TreeMap userMap = new TreeMap();
082: userMap.put(action, new Integer(1));
083: channelMap.put(userID, userMap);
084: containerMap.put(channelName, channelMap);
085: }
086: } else {
087: TreeMap containerMap = new TreeMap();
088: TreeMap channelMap = new TreeMap();
089: TreeMap userMap = new TreeMap();
090: userMap.put(action, new Integer(1));
091: channelMap.put(userID, userMap);
092: containerMap.put(channelName, channelMap);
093: channelWiseUserActionsDistribution.put(containerName,
094: containerMap);
095: }
096: }
097:
098: public Object getData() {
099: return channelWiseUserActionsDistribution;
100: }
101:
102: public void setData(Object data) {
103: channelWiseUserActionsDistribution = (TreeMap) data;
104: }
105:
106: public TreeSet getActionsSet() {
107: return actionsSet;
108: }
109: }
|