Subversion Repositories SmartDukaan

Rev

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

Rev 2418 Rev 3208
Line 1... Line 1...
1
package in.shop2020.datalogger.event;
1
package in.shop2020.datalogger.event;
2
 
2
 
3
import in.shop2020.datalogger.EventType;
3
import in.shop2020.datalogger.EventType;
4
 
4
 
-
 
5
import java.util.ArrayList;
-
 
6
import java.util.List;
-
 
7
import java.util.StringTokenizer;
-
 
8
 
-
 
9
import org.json.JSONArray;
5
import org.json.JSONException;
10
import org.json.JSONException;
6
import org.json.JSONObject;
11
import org.json.JSONObject;
7
 
12
 
8
public class PaymentSuccess extends Event{
13
public class PaymentSuccess extends Event{
9
    
14
    
10
    private long paymentId;
15
    private long paymentId;
-
 
16
    private List<Long> itemIds;
11
 
17
 
12
    public PaymentSuccess(String[] eventFileds) {
18
    public PaymentSuccess(String[] eventFileds) {
13
        super(eventFileds);
19
        super(eventFileds);
14
        paymentId = Long.parseLong(eventFileds[5].trim());
20
        paymentId = Long.parseLong(eventFileds[5].trim());
-
 
21
        itemIds = new ArrayList<Long>();
-
 
22
        if (eventFileds.length > 5) {
-
 
23
            StringTokenizer tokenizer = new StringTokenizer(eventFileds[5].trim(), "_");
-
 
24
            while (tokenizer.hasMoreTokens()) {
-
 
25
                itemIds.add(Long.parseLong(tokenizer.nextToken().trim())); 
-
 
26
            }
-
 
27
        }
15
    }
28
    }
16
    
29
    
17
    public PaymentSuccess(EventType eType, String sessionId, long userId, String email, String[] logData) {
30
    public PaymentSuccess(EventType eType, String sessionId, long userId, String email, String[] logData) {
18
        super(eType, sessionId, userId, email);
31
        super(eType, sessionId, userId, email);
19
        paymentId = Long.parseLong(logData[0].trim());
32
        paymentId = Long.parseLong(logData[0].trim());
-
 
33
        itemIds = new ArrayList<Long>();
-
 
34
        if (logData.length > 1) {
-
 
35
            StringTokenizer tokenizer = new StringTokenizer(logData[1].trim(), "_");
-
 
36
            while (tokenizer.hasMoreTokens()) {
-
 
37
                itemIds.add(Long.parseLong(tokenizer.nextToken().trim())); 
-
 
38
            }
-
 
39
        }
20
    }
40
    }
21
 
41
 
22
    public String toString() {
42
    public String toString() {
23
        StringBuilder sb = new StringBuilder();
43
        StringBuilder sb = new StringBuilder();
24
        sb.append(eventType.name() + ", ");
44
        sb.append(eventType.name() + ", ");
25
        sb.append("userEmail : " + userEmail);
45
        sb.append("userEmail : " + userEmail);
26
        sb.append(" paymentId : " + paymentId);
46
        sb.append(" paymentId : " + paymentId);
-
 
47
        sb.append(" itemIds : " + itemIds);
27
        sb.append(" time : " + time);
48
        sb.append(" time : " + time);
28
        sb.append(" session : " + sessionId);
49
        sb.append(" session : " + sessionId);
29
        
50
        
30
        return sb.toString();
51
        return sb.toString();
31
    }
52
    }
Line 33... Line 54...
33
    @Override
54
    @Override
34
    public JSONObject getLogDataInJson() {
55
    public JSONObject getLogDataInJson() {
35
        JSONObject logDataInJson = new JSONObject();
56
        JSONObject logDataInJson = new JSONObject();
36
        try {
57
        try {
37
            logDataInJson.put("paymentId_long", paymentId);
58
            logDataInJson.put("paymentId_long", paymentId);
-
 
59
            JSONArray itemIdsJson = new JSONArray(itemIds);
-
 
60
            logDataInJson.put("itemIds_long_list", itemIdsJson);
38
        } catch (JSONException e) {
61
        } catch (JSONException e) {
39
            e.printStackTrace();
62
            e.printStackTrace();
40
        }
63
        }
41
        return logDataInJson;
64
        return logDataInJson;
42
    }
65
    }
Line 46... Line 69...
46
    }
69
    }
47
 
70
 
48
    public void setPaymentId(long paymentId) {
71
    public void setPaymentId(long paymentId) {
49
        this.paymentId = paymentId;
72
        this.paymentId = paymentId;
50
    }
73
    }
-
 
74
    
-
 
75
    public List<Long> getItemIds() {
-
 
76
        return itemIds;
-
 
77
    }
-
 
78
 
-
 
79
    public void setItemIds(List<Long> itemIds) {
-
 
80
        this.itemIds = itemIds;
-
 
81
    }
51
}
82
}