01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.ubt.report.data.file.raw;
06:
07: import com.sun.portal.ubt.report.data.MinerCollection;
08: import com.sun.portal.ubt.report.data.UBTActions;
09: import com.sun.portal.ubt.report.data.UBTLogConstants;
10: import com.sun.portal.ubt.report.data.UBTLogLine;
11:
12: import java.util.TreeMap;
13: import java.util.TreeSet;
14:
15: /**
16: * if component is set gets actions only for that else
17: * for event USER_CLICK_CHN
18: */
19: public class ChannelWiseActionsMiner extends DataMinerAdapter {
20: TreeSet actionsSet = UBTActions.getProviderValidSet();
21: private TreeMap channelWiseActionsDistribution = new TreeMap(); //Map(container, Map(channel, Map(action, count)))
22: private String component;
23:
24: public void setMinerCollection(MinerCollection collection) {
25: }
26:
27: public void setValidActions(TreeSet set) {
28: this .actionsSet = set;
29: }
30:
31: public void setComponent(String component) {
32: this .component = component;
33: }
34:
35: public void mine(UBTLogLine logLine) throws Exception {
36: if (logLine.getEventID() == null
37: || !logLine.getEventID().equals(
38: UBTLogConstants.EVENT_USER_CLICK_CHN))
39: return;
40: if (component != null
41: && !component.equals(logLine.getComponentName()))
42: return;
43: String channelName = logLine.getChannelName();
44: String action = logLine.getAction();
45: String containerName = logLine.getContainerName();
46: if (containerName == null)
47: return; // that means it was a toplevel container
48: if (channelName == null || action == null
49: || !actionsSet.contains(action))
50: return;
51: if (channelWiseActionsDistribution.containsKey(containerName)) {
52: TreeMap containerMap = (TreeMap) channelWiseActionsDistribution
53: .get(containerName);
54: if (containerMap.containsKey(channelName)) {
55: TreeMap channelMap = (TreeMap) containerMap
56: .get(channelName);
57: if (channelMap.containsKey(action)) {
58: Integer count = (Integer) channelMap.get(action);
59: channelMap.put(action, new Integer(
60: count.intValue() + 1));
61: } else {
62: //put it with one
63: channelMap.put(action, new Integer(1));
64: }
65: } else {
66: //put a new map
67: TreeMap channelMap = new TreeMap();
68: channelMap.put(action, new Integer(1));
69: containerMap.put(channelName, channelMap);
70: }
71: } else {
72: //add new containerName
73: TreeMap containerMap = new TreeMap();
74: TreeMap channelMap = new TreeMap();
75: channelMap.put(action, new Integer(1));
76: containerMap.put(channelName, channelMap);
77: channelWiseActionsDistribution.put(containerName,
78: containerMap);
79: }
80: }
81:
82: public Object getData() {
83: return channelWiseActionsDistribution;
84: }
85:
86: public void setData(Object data) {
87: channelWiseActionsDistribution = (TreeMap) data;
88: }
89:
90: public TreeSet getActionsSet() {
91: return actionsSet;
92: }
93:
94: }
|