Subversion Repositories SmartDukaan

Rev

Rev 3172 | Rev 3208 | 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 {
3184 vikas 37
            if (source.length() > 500) {
38
                source = source.substring(0, 500);
39
            }
40
            logDataInJson.put("source", source);
2636 vikas 41
        } catch (JSONException e) {
42
            e.printStackTrace();
43
        }
44
        return logDataInJson;
45
    }
46
 
47
    public String getSource() {
48
        return source;
49
    }
50
 
51
    public void setSource(String source) {
52
        this.source = source;
53
    }
54
}