Subversion Repositories SmartDukaan

Rev

Rev 2437 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2437 Rev 5552
Line 11... Line 11...
11
import org.json.JSONObject;
11
import org.json.JSONObject;
12
 
12
 
13
public class ResearchAdd extends Event{
13
public class ResearchAdd extends Event{
14
    
14
    
15
    private List<Long> itemIds;
15
    private List<Long> itemIds;
-
 
16
    private String source;
16
 
17
 
17
    public ResearchAdd(String[] eventFileds) {
18
    public ResearchAdd(String[] eventFileds) {
18
        super(eventFileds);
19
        super(eventFileds);
19
        itemIds = new ArrayList<Long>();
20
        itemIds = new ArrayList<Long>();
20
        StringTokenizer tokenizer = new StringTokenizer(eventFileds[5].trim(), "_");
21
        StringTokenizer tokenizer = new StringTokenizer(eventFileds[5].trim(), "_");
Line 28... Line 29...
28
        itemIds = new ArrayList<Long>();
29
        itemIds = new ArrayList<Long>();
29
        StringTokenizer tokenizer = new StringTokenizer(logData[0].trim(), "_");
30
        StringTokenizer tokenizer = new StringTokenizer(logData[0].trim(), "_");
30
        while (tokenizer.hasMoreTokens()) {
31
        while (tokenizer.hasMoreTokens()) {
31
            itemIds.add(Long.parseLong(tokenizer.nextToken().trim())); 
32
            itemIds.add(Long.parseLong(tokenizer.nextToken().trim())); 
32
        }
33
        }
-
 
34
        setSource(logData[1].trim());
33
    }
35
    }
34
 
36
 
35
    public String toString() {
37
    public String toString() {
36
        StringBuilder sb = new StringBuilder();
38
        StringBuilder sb = new StringBuilder();
37
        sb.append(eventType.name() + ", ");
39
        sb.append(eventType.name() + ", ");
38
        sb.append("userEmail : " + userEmail);
40
        sb.append("userEmail : " + userEmail);
39
        sb.append(" itemIds : " + itemIds);
41
        sb.append(" itemIds : " + itemIds);
40
        sb.append(" time : " + time);
42
        sb.append(" time : " + time);
41
        sb.append(" session : " + sessionId);
43
        sb.append(" session : " + sessionId);
-
 
44
        sb.append(" source : " + source);
42
        
45
        
43
        return sb.toString();
46
        return sb.toString();
44
    }
47
    }
45
    
48
    
46
    @Override
49
    @Override
47
    public JSONObject getLogDataInJson() {
50
    public JSONObject getLogDataInJson() {
48
        JSONObject logDataInJson = new JSONObject();
51
        JSONObject logDataInJson = new JSONObject();
49
        try {
52
        try {
50
            JSONArray itemIdsJson = new JSONArray(itemIds);
53
            JSONArray itemIdsJson = new JSONArray(itemIds);
51
            logDataInJson.put("itemIds_long_list", itemIdsJson);
54
            logDataInJson.put("itemIds_long_list", itemIdsJson);
-
 
55
            logDataInJson.put("source", source);
52
        } catch (JSONException e) {
56
        } catch (JSONException e) {
53
            e.printStackTrace();
57
            e.printStackTrace();
54
        }
58
        }
55
        return logDataInJson;
59
        return logDataInJson;
56
    }
60
    }
Line 60... Line 64...
60
    }
64
    }
61
 
65
 
62
    public void setItemIds(List<Long> itemIds) {
66
    public void setItemIds(List<Long> itemIds) {
63
        this.itemIds = itemIds;
67
        this.itemIds = itemIds;
64
    }
68
    }
-
 
69
 
-
 
70
	public void setSource(String source) {
-
 
71
		this.source = source;
-
 
72
	}
-
 
73
 
-
 
74
	public String getSource() {
-
 
75
		return source;
-
 
76
	}
65
}
77
}