Subversion Repositories SmartDukaan

Rev

Rev 2636 | Rev 3184 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2636 vikas 1
package in.shop2020.datalogger.event;
2
 
3
import in.shop2020.datalogger.EventType;
4
 
5
import org.json.JSONException;
6
import org.json.JSONObject;
7
 
8
public class NewSession extends Event{
9
 
10
    private String source;
11
 
12
    public NewSession(String[] eventFileds) {
13
        super(eventFileds);
14
        source = eventFileds[5].trim();
15
    }
16
 
17
    public NewSession(EventType eType, String sessionId, long userId, String email, String[] logData) {
18
        super(eType, sessionId, userId, email);
19
        source = logData[0].trim();
20
    }
21
 
22
    public String toString() {
23
        StringBuilder sb = new StringBuilder();
24
        sb.append(eventType.name() + ", ");
25
        sb.append("userEmail : " + userEmail);
26
        sb.append(" source : " + source);
27
        sb.append(" time : " + time);
28
        sb.append(" session : " + sessionId);
29
 
30
        return sb.toString();
31
    }
32
 
33
    @Override
34
    public JSONObject getLogDataInJson() {
35
        JSONObject logDataInJson = new JSONObject();
36
        try {
3172 vikas 37
            logDataInJson.put("source", source.substring(0, 500));
2636 vikas 38
        } catch (JSONException e) {
39
            e.printStackTrace();
40
        }
41
        return logDataInJson;
42
    }
43
 
44
    public String getSource() {
45
        return source;
46
    }
47
 
48
    public void setSource(String source) {
49
        this.source = source;
50
    }
51
}