Subversion Repositories SmartDukaan

Rev

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

Rev 2262 Rev 2418
Line 3... Line 3...
3
import in.shop2020.datalogger.EventType;
3
import in.shop2020.datalogger.EventType;
4
 
4
 
5
import java.text.ParseException;
5
import java.text.ParseException;
6
import java.text.SimpleDateFormat;
6
import java.text.SimpleDateFormat;
7
import java.util.Date;
7
import java.util.Date;
-
 
8
 
-
 
9
import org.json.JSONObject;
8
public class Event {
10
public class Event {
9
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss.SSS/zzz");
11
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss.SSS/zzz");
10
    protected Date time;
12
    protected Date time;
11
    protected String sessionId;
13
    protected String sessionId;
12
    protected Long userId;
14
    protected Long userId;
Line 33... Line 35...
33
            e.printStackTrace();
35
            e.printStackTrace();
34
        }
36
        }
35
        
37
        
36
    }
38
    }
37
    
39
    
-
 
40
    public Event(EventType eType, String aSessionId, long aUserId, String email) {
-
 
41
        eventType = eType;
-
 
42
        sessionId = aSessionId;
-
 
43
        userId = aUserId;
-
 
44
        userEmail = email;
-
 
45
    }
-
 
46
 
-
 
47
    public static Event createEvent(EventType eType, String sessionId, long userId, String email, String[] logData) {
-
 
48
        if(eType == EventType.ADD_ADDRESS) {
-
 
49
            return new AddAddress(eType, sessionId, userId, email, logData);
-
 
50
        }
-
 
51
        if(eType == EventType.DELETE_ADDRESS) {
-
 
52
            return new DeleteAddress(eType, sessionId, userId, email, logData);
-
 
53
        }
-
 
54
        if(eType == EventType.SET_DEFAULT_ADDRESS) {
-
 
55
            return new SetDefaultAddress(eType, sessionId, userId, email, logData);
-
 
56
        }
-
 
57
        if(eType == EventType.ADD_TO_CART) {
-
 
58
            return new AddToCart(eType, sessionId, userId, email, logData);
-
 
59
        }
-
 
60
        if(eType == EventType.DELETE_FROM_CART) {
-
 
61
            return new DeleteFromCart(eType, sessionId, userId, email, logData);
-
 
62
        }
-
 
63
        if(eType == EventType.UPDATE_CART_QUANTITY) {
-
 
64
            return new UpdateCartQuantity(eType, sessionId, userId, email, logData);
-
 
65
        }
-
 
66
        if(eType == EventType.UPDATE_CART_QUANTITY_FAILED) {
-
 
67
            return new UpdateCartQuantityFailed(eType, sessionId, userId, email, logData);
-
 
68
        }
-
 
69
        if(eType == EventType.PAYMENT_SUCCESS) {
-
 
70
            return new PaymentSuccess(eType, sessionId, userId, email, logData);
-
 
71
        }
-
 
72
        if(eType == EventType.PAYMENT_FAILURE) {
-
 
73
            return new PaymentFailure(eType, sessionId, userId, email, logData);
-
 
74
        }
-
 
75
        if(eType == EventType.PRODUCT_VIEW) {
-
 
76
            return new ProductView(eType, sessionId, userId, email, logData);
-
 
77
        }
-
 
78
        if(eType == EventType.PRODUCT_SEARCH) {
-
 
79
            return new ProductSearch(eType, sessionId, userId, email, logData);
-
 
80
        }
-
 
81
        if(eType == EventType.PRODUCT_COMPARE) {
-
 
82
            return new ProductCompare(eType, sessionId, userId, email, logData);
-
 
83
        }
-
 
84
        if(eType == EventType.RESEARCH_ADD) {
-
 
85
            return new ResearchAdd(eType, sessionId, userId, email, logData);
-
 
86
        }
-
 
87
        if(eType == EventType.RESEARCH_DELETE) {
-
 
88
            return new ResearchDelete(eType, sessionId, userId, email, logData);
-
 
89
        }
-
 
90
        if(eType == EventType.REGISTER_SUCCESS) {
-
 
91
            return new RegisterSuccess(eType, sessionId, userId, email, logData);
-
 
92
        }
-
 
93
        if(eType == EventType.REGISTER_FAILED_USER_EXISTS) {
-
 
94
            return new RegisterFailedUserExists(eType, sessionId, userId, email, logData);
-
 
95
        }
-
 
96
        if(eType == EventType.REGISTER_DATA_INCOMPLETE) {
-
 
97
            return new RegisterDataIncomplete(eType, sessionId, userId, email, logData);
-
 
98
        }
-
 
99
        if(eType == EventType.SHIPPINIG_ACCESS) {
-
 
100
            return new ShippingAccess(eType, sessionId, userId, email, logData);
-
 
101
        }
-
 
102
        if(eType == EventType.SHIPPINIG_ADD_ADDRESS) {
-
 
103
            return new ShippingAddAddress(eType, sessionId, userId, email, logData);
-
 
104
        }
-
 
105
        if(eType == EventType.SHIPPINIG_ADD_CHANGE) {
-
 
106
            return new ShippingAddressChange(eType, sessionId, userId, email, logData);
-
 
107
        }
-
 
108
        if(eType == EventType.ORDER_CREATION) {
-
 
109
            return new OrderCreation(eType, sessionId, userId, email, logData);
-
 
110
        }
-
 
111
        return new Event(eType, sessionId, userId, email);
-
 
112
    }
-
 
113
    
38
    public static Event createEvent(String[] eventFileds) {
114
    public static Event createEvent(String[] eventFileds) {
39
        EventType eType = EventType.valueOf(eventFileds[1].trim());
115
        EventType eType = EventType.valueOf(eventFileds[1].trim());
40
        if(eType == EventType.ADD_ADDRESS) {
116
        if(eType == EventType.ADD_ADDRESS) {
41
            return new AddAddress(eventFileds);
117
            return new AddAddress(eventFileds);
42
        }
118
        }
Line 111... Line 187...
111
        sb.append(" session : " + sessionId);
187
        sb.append(" session : " + sessionId);
112
        
188
        
113
        return sb.toString();
189
        return sb.toString();
114
    }
190
    }
115
 
191
 
-
 
192
    public JSONObject getLogDataInJson() {
-
 
193
        return null;
-
 
194
    }
-
 
195
    
116
    public Date getTime() {
196
    public Date getTime() {
117
        return time;
197
        return time;
118
    }
198
    }
119
 
199
 
120
    public void setTime(Date time) {
200
    public void setTime(Date time) {