Rev 2418 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.datalogger.event;import in.shop2020.datalogger.EventType;import java.util.ArrayList;import java.util.List;import java.util.StringTokenizer;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;public class ShippingAccess extends Event{private Long cartId;private List<Long> itemIds;public ShippingAccess(String[] eventFileds) {super(eventFileds);cartId = Long.parseLong(eventFileds[5].trim());itemIds = new ArrayList<Long>();if (eventFileds.length > 5) {StringTokenizer tokenizer = new StringTokenizer(eventFileds[5].trim(), "_");while (tokenizer.hasMoreTokens()) {itemIds.add(Long.parseLong(tokenizer.nextToken().trim()));}}}public ShippingAccess(EventType eType, String sessionId, long userId, String email, String[] logData) {super(eType, sessionId, userId, email);cartId = Long.parseLong(logData[0].trim());itemIds = new ArrayList<Long>();if (logData.length > 1) {StringTokenizer tokenizer = new StringTokenizer(logData[1].trim(), "_");while (tokenizer.hasMoreTokens()) {itemIds.add(Long.parseLong(tokenizer.nextToken().trim()));}}}public String toString() {StringBuilder sb = new StringBuilder();sb.append(eventType.name() + ", ");sb.append("userEmail : " + userEmail);sb.append(" cartId : " + cartId);sb.append(" itemIds : " + itemIds);sb.append(" time : " + time);sb.append(" session : " + sessionId);return sb.toString();}@Overridepublic JSONObject getLogDataInJson() {JSONObject logDataInJson = new JSONObject();try {logDataInJson.put("cartId_long", cartId);JSONArray itemIdsJson = new JSONArray(itemIds);logDataInJson.put("itemIds_long_list", itemIdsJson);} catch (JSONException e) {e.printStackTrace();}return logDataInJson;}public Long getCartId() {return cartId;}public void setCartId(Long cartId) {this.cartId = cartId;}public List<Long> getItemIds() {return itemIds;}public void setItemIds(List<Long> itemIds) {this.itemIds = itemIds;}}