Subversion Repositories SmartDukaan

Rev

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

Rev 3077 Rev 4632
Line 7... Line 7...
7
 
7
 
8
public class ProductView extends Event{
8
public class ProductView extends Event{
9
    
9
    
10
    private String productName;
10
    private String productName;
11
    private Long itemId;
11
    private Long itemId;
-
 
12
    private String refererUrl;
12
 
13
 
13
    public ProductView(String[] eventFileds) {
14
    public ProductView(String[] eventFileds) {
14
        super(eventFileds);
15
        super(eventFileds);
15
        productName = eventFileds[5].trim();
16
        productName = eventFileds[5].trim();
16
        if (eventFileds.length > 6) {
17
        if (eventFileds.length > 6){
17
            itemId = Long.parseLong(eventFileds[6].trim());
18
        	itemId = Long.parseLong(eventFileds[6].trim());
-
 
19
        }
-
 
20
        if (eventFileds.length > 7){
-
 
21
        	refererUrl = eventFileds[7].trim();
18
        }
22
        }
19
    }
23
    }
20
    
24
    
21
    public ProductView(EventType eType, String sessionId, long userId, String email, String[] logData) {
25
    public ProductView(EventType eType, String sessionId, long userId, String email, String[] logData) {
22
        super(eType, sessionId, userId, email);
26
        super(eType, sessionId, userId, email);
23
        productName = logData[0].trim();
27
        productName = logData[0].trim();
24
        itemId = Long.parseLong(logData[1].trim());;
28
        itemId = Long.parseLong(logData[1].trim());
-
 
29
        refererUrl = logData[2].trim();
25
    }
30
    }
26
 
31
 
27
    public String toString() {
32
    public String toString() {
28
        StringBuilder sb = new StringBuilder();
33
        StringBuilder sb = new StringBuilder();
29
        sb.append(eventType.name() + ", ");
34
        sb.append(eventType.name() + ", ");
30
        sb.append("userEmail : " + userEmail);
35
        sb.append("userEmail : " + userEmail);
31
        sb.append(" productName : " + productName);
36
        sb.append(" productName : " + productName);
-
 
37
        sb.append("itemId : " + itemId);
32
        sb.append(" time : " + time);
38
        sb.append(" time : " + time);
33
        sb.append(" session : " + sessionId);
39
        sb.append(" session : " + sessionId);
34
        
40
        sb.append("refererUrl : " + refererUrl);
35
        return sb.toString();
41
        return sb.toString();
36
    }
42
    }
37
    
43
    
38
    @Override
44
    @Override
39
    public JSONObject getLogDataInJson() {
45
    public JSONObject getLogDataInJson() {
40
        JSONObject logDataInJson = new JSONObject();
46
        JSONObject logDataInJson = new JSONObject();
41
        try {
47
        try {
42
            logDataInJson.put("productName", productName);
48
            logDataInJson.put("productName", productName);
43
            logDataInJson.put("itemId_long", itemId);
49
            logDataInJson.put("itemId_long", itemId);
-
 
50
            logDataInJson.put("refererUrl", refererUrl);
44
        } catch (JSONException e) {
51
        } catch (JSONException e) {
45
            e.printStackTrace();
52
            e.printStackTrace();
46
        }
53
        }
47
        return logDataInJson;
54
        return logDataInJson;
48
    }
55
    }