Subversion Repositories SmartDukaan

Rev

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

Rev 2669 Rev 2670
Line 28... Line 28...
28
 
28
 
29
        Query q = new Query("DataLog");
29
        Query q = new Query("DataLog");
30
        q.addFilter("eventType", Query.FilterOperator.EQUAL, "PRODUCT_COMPARE");
30
        q.addFilter("eventType", Query.FilterOperator.EQUAL, "PRODUCT_COMPARE");
31
        
31
        
32
        PreparedQuery pq = datastore.prepare(q);
32
        PreparedQuery pq = datastore.prepare(q);
33
        
-
 
34
        Map<Long, Map<Long, Long>> comparisonStats = new HashMap<Long, Map<Long, Long>>();
33
        Map<Long, Map<Long, Long>> comparisonStats = new HashMap<Long, Map<Long, Long>>();
35
        
34
        
36
        try {
35
        try {
37
            for (Entity result : pq.asIterable()) {
36
            for (Entity result : pq.asIterable()) {
-
 
37
            	List<Long> itemIds;
-
 
38
            	try{
38
                List<Long> itemIds =  (List<Long>) result.getProperty("itemIds");
39
            		itemIds =  (List<Long>) result.getProperty("itemIds");
-
 
40
            	}catch (ClassCastException ce) {
-
 
41
					System.out.println("Unable to cast itemIds to List");
-
 
42
					continue;
-
 
43
				}
39
                if(itemIds != null && !itemIds.isEmpty()){
44
                if(itemIds != null && !itemIds.isEmpty()){
40
                	for(int i=0; i<itemIds.size(); i++){
45
                	for(int i=0; i<itemIds.size(); i++){
41
                		for(int j=0; j<i; j++){
46
                		for(int j=0; j<i; j++){
42
                			Long itemOne = itemIds.get(i);
47
                			Long itemOne = itemIds.get(i);
43
                			Long itemTwo = itemIds.get(j);
48
                			Long itemTwo = itemIds.get(j);
Line 64... Line 69...
64
                				comparedItems.put(itemOne, 1L);
69
                				comparedItems.put(itemOne, 1L);
65
                			}
70
                			}
66
                		}
71
                		}
67
                	}
72
                	}
68
                }
73
                }
69
                //resp.getWriter().println(comparisonStats);
-
 
70
            }
74
            }
71
            
75
            
72
            JSONObject comparisonStatsJson = new JSONObject(comparisonStats);
76
            JSONObject comparisonStatsJson = new JSONObject(comparisonStats);
73
            resp.getWriter().println(comparisonStatsJson);
77
            resp.getWriter().println(comparisonStatsJson);
74
            	
78
            	
75
        } catch (IOException e) {
79
        } catch (IOException e) {
76
            e.printStackTrace();
80
            System.out.println("Unable to write at output stream");
77
        }
81
        }
78
    }
82
    }
79
    
83
    
80
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
84
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
81
        doPost(req, resp);
85
        doPost(req, resp);