Subversion Repositories SmartDukaan

Rev

Rev 3073 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3073 Rev 3077
Line 6... Line 6...
6
import org.json.JSONObject;
6
import org.json.JSONObject;
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 String productId;
11
    private Long itemId;
12
 
12
 
13
    public ProductView(String[] eventFileds) {
13
    public ProductView(String[] eventFileds) {
14
        super(eventFileds);
14
        super(eventFileds);
15
        productName = eventFileds[5].trim();
15
        productName = eventFileds[5].trim();
16
        if (eventFileds.length > 6) {
16
        if (eventFileds.length > 6) {
17
            productName = eventFileds[6].trim();
17
            itemId = Long.parseLong(eventFileds[6].trim());
18
        }
18
        }
19
    }
19
    }
20
    
20
    
21
    public ProductView(EventType eType, String sessionId, long userId, String email, String[] logData) {
21
    public ProductView(EventType eType, String sessionId, long userId, String email, String[] logData) {
22
        super(eType, sessionId, userId, email);
22
        super(eType, sessionId, userId, email);
23
        productName = logData[0].trim();
23
        productName = logData[0].trim();
24
        productId = logData[1].trim();
24
        itemId = Long.parseLong(logData[1].trim());;
25
    }
25
    }
26
 
26
 
27
    public String toString() {
27
    public String toString() {
28
        StringBuilder sb = new StringBuilder();
28
        StringBuilder sb = new StringBuilder();
29
        sb.append(eventType.name() + ", ");
29
        sb.append(eventType.name() + ", ");
Line 38... Line 38...
38
    @Override
38
    @Override
39
    public JSONObject getLogDataInJson() {
39
    public JSONObject getLogDataInJson() {
40
        JSONObject logDataInJson = new JSONObject();
40
        JSONObject logDataInJson = new JSONObject();
41
        try {
41
        try {
42
            logDataInJson.put("productName", productName);
42
            logDataInJson.put("productName", productName);
43
            logDataInJson.put("productId_long", productId);
43
            logDataInJson.put("itemId_long", itemId);
44
        } catch (JSONException e) {
44
        } catch (JSONException e) {
45
            e.printStackTrace();
45
            e.printStackTrace();
46
        }
46
        }
47
        return logDataInJson;
47
        return logDataInJson;
48
    }
48
    }