Subversion Repositories SmartDukaan

Rev

Rev 555 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 555 Rev 569
Line 62... Line 62...
62
	 * 
62
	 * 
63
	 */
63
	 */
64
	private List<String[]> crumbs;
64
	private List<String[]> crumbs;
65
	
65
	
66
	private String  query;
66
	private String  query;
67
	
-
 
-
 
67
	private String sortOrder = null;
68
	private Double minPrice = null;
68
	private Double minPrice = null;
69
	private Double maxPrice = null;
69
	private Double maxPrice = null;
70
 
70
 
71
	private long windowSize = 10;
71
	private long windowSize = 10;
72
	private long page = 1;
72
	private long page = 1;
73
	private long totalResults;
73
	private long totalResults;
74
	private long beginIndex = 0;
74
	private long beginIndex = 0;
75
	private String url;
75
	private String url;
76
	private String priceUrl;
76
	private String priceUrl;
-
 
77
	private long categoryId=10000;
-
 
78
	private String sortUrl;
77
	/**
79
	/**
78
	 * 
80
	 * 
79
	 * @return
81
	 * @return
80
	 * @throws UnsupportedEncodingException
82
	 * @throws UnsupportedEncodingException
81
	 */
83
	 */
Line 87... Line 89...
87
		htmlSnippets.put("HEADER", pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getNameOfUser()));
89
		htmlSnippets.put("HEADER", pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getNameOfUser()));
88
		htmlSnippets.put("MAIN_MENU", pageLoader.getMainMenuHtml());
90
		htmlSnippets.put("MAIN_MENU", pageLoader.getMainMenuHtml());
89
		htmlSnippets.put("SEARCH_BAR", pageLoader.getSearchBarHtml(userinfo.getTotalItems(), 10000));
91
		htmlSnippets.put("SEARCH_BAR", pageLoader.getSearchBarHtml(userinfo.getTotalItems(), 10000));
90
		htmlSnippets.put("CUSTOMER_SERVICE", pageLoader.getCustomerServiceHtml());
92
		htmlSnippets.put("CUSTOMER_SERVICE", pageLoader.getCustomerServiceHtml());
91
		htmlSnippets.put("MY_RESEARCH", pageLoader.getMyResearchHtml(userinfo.getUserId(), userinfo.isSessionId()));
93
		htmlSnippets.put("MY_RESEARCH", pageLoader.getMyResearchHtml(userinfo.getUserId(), userinfo.isSessionId()));
-
 
94
		htmlSnippets.put("BROWSE_HISTORY", pageLoader.getBrowseHistoryHtml(userinfo.getUserId(), userinfo.isSessionId()));
92
		htmlSnippets.put("FOOTER",pageLoader.getFooterHtml());
95
		htmlSnippets.put("FOOTER",pageLoader.getFooterHtml());
93
		htmlSnippets.put("FOOTER",pageLoader.getFooterHtml());
96
		htmlSnippets.put("FOOTER",pageLoader.getFooterHtml());
94
		htmlSnippets.put("SEARCH_HEADER","");
97
		htmlSnippets.put("SEARCH_HEADER","");
95
		htmlSnippets.put("SEARCH_DETAILS","");
98
		htmlSnippets.put("SEARCH_DETAILS","");
96
		
99
		
Line 98... Line 101...
98
		log.info("this.request=" + this.request);
101
		log.info("this.request=" + this.request);
99
    	
102
    	
100
    	//url = this.request.getRequestURL();
103
    	//url = this.request.getRequestURL();
101
		query = this.request.getParameter("q");
104
		query = this.request.getParameter("q");
102
		url = "q="+ URLEncoder.encode(query, "UTF-8");
105
		url = "q="+ URLEncoder.encode(query, "UTF-8");
-
 
106
 
-
 
107
 
-
 
108
		if(this.request.getParameter("category") != null){
-
 
109
    		this.categoryId = Long.parseLong(this.request.getParameter("category"));
-
 
110
    		url= url + "&category=" + this.request.getParameter("category");
-
 
111
    	}
-
 
112
		sortUrl = url;
-
 
113
		if(this.request.getParameter("sort") != null){
-
 
114
    		url= url + "&sort=" + this.request.getParameter("sort");
-
 
115
    		sortOrder = this.request.getParameter("sort");
-
 
116
    	}
103
		priceUrl = url;
117
		priceUrl = url;
104
    	if(this.request.getParameter("page") != null){
118
    	if(this.request.getParameter("page") != null){
105
    		this.page = Long.parseLong(this.request.getParameter("page"));
119
    		this.page = Long.parseLong(this.request.getParameter("page"));
106
    		this.beginIndex = this.windowSize * (this.page-1);
120
    		this.beginIndex = this.windowSize * (this.page-1);
107
    	}
121
    	}
Line 112... Line 126...
112
    	if(this.request.getParameter("max-price") != null){
126
    	if(this.request.getParameter("max-price") != null){
113
    		this.maxPrice = (new Double(this.request.getParameter("max-price")));
127
    		this.maxPrice = (new Double(this.request.getParameter("max-price")));
114
    		url= url + "&max-price=" + this.request.getParameter("max-price");
128
    		url= url + "&max-price=" + this.request.getParameter("max-price");
115
    	}    	
129
    	}    	
116
    	
130
    	
-
 
131
    	
117
    	String[] fqrys = this.request.getParameterValues("fq");
132
    	String[] fqrys = this.request.getParameterValues("fq");
118
    	
133
    	
119
    	this.crumbs = new ArrayList<String[]>();
134
    	this.crumbs = new ArrayList<String[]>();
120
    	
135
    	
-
 
136
    	/*
121
    	String strCrumb = "";
137
    	String strCrumb = "";
122
    	String urlCrumb = "";
138
    	String urlCrumb = "";
123
    	if(query != null) {
139
    	if(query != null) {
124
	    	strCrumb = query;
140
	    	strCrumb = query;
125
	    	urlCrumb = url; 
141
	    	urlCrumb = url; 
Line 127... Line 143...
127
			log.info("acrumb=" + 
143
			log.info("acrumb=" + 
128
					Arrays.toString(new String[] { strCrumb, urlCrumb }));
144
					Arrays.toString(new String[] { strCrumb, urlCrumb }));
129
    	}else {
145
    	}else {
130
    		
146
    		
131
    	}
147
    	}
-
 
148
    	*/
-
 
149
    	
-
 
150
    	String[] facetDefIDs = new String[] {"F_50010","F_50011","F_50002","F_50001",  "F_50006", "F_50007" };
-
 
151
    	String[] facetLabels = new String[] {"Category","Category","Price",
-
 
152
    	    	"Brand", "Data Connectivity", "Camera Resolution"
-
 
153
        	};
-
 
154
    	
-
 
155
    	String urlCrumb = "";
-
 
156
    	if(query != null) {
-
 
157
	    	urlCrumb = url; 
-
 
158
	    }else {
-
 
159
    		
-
 
160
    	}
132
    	
161
    	
133
    	if(fqrys != null) {
162
    	if(fqrys != null) {
134
	    	log.info("fqrys=" + Arrays.toString(fqrys));
163
	    	log.info("fqrys=" + Arrays.toString(fqrys));
-
 
164
	    	List<String> arrList = Arrays.asList(facetDefIDs);
-
 
165
	    	for(int i=0; i<fqrys.length; i++){
-
 
166
	    		urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
-
 
167
	    		priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
-
 
168
	    		sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
-
 
169
	    		String filterUrl = url;
-
 
170
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
-
 
171
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
-
 
172
	    		String facetLabel = facetLabels[arrList.indexOf(facetName)];  
-
 
173
	    		for(int j=0; j<fqrys.length; j++) {
-
 
174
	    			if(i==j){
-
 
175
	    				continue;
-
 
176
	    			}
-
 
177
	    			filterUrl += "&fq=" + URLEncoder.encode(fqrys[j], "UTF-8");
-
 
178
		    	}
-
 
179
	    		String[] acrumb = new String[] { facetLabel, facetValue, filterUrl };
-
 
180
	    		log.info("acrumb=" + Arrays.toString(acrumb));
-
 
181
	    		this.crumbs.add(acrumb);
-
 
182
	    	}
135
    	
183
    	}
-
 
184
    	url = urlCrumb;
-
 
185
    	/*
-
 
186
    	if(fqrys != null) {
-
 
187
	    	log.info("fqrys=" + Arrays.toString(fqrys));
136
	    	for(int i=0; i<fqrys.length; i++) {
188
    		for(int i=0; i<fqrys.length; i++) {
137
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
189
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
138
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
190
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
139
	//    		facetqueries.put(StringUtils.split(fqrys[i], ":")[0], StringUtils.split(fqrys[i], ":")[1]);
191
	//    		facetqueries.put(StringUtils.split(fqrys[i], ":")[0], StringUtils.split(fqrys[i], ":")[1]);
140
	    		//strCrumb += " " + facetValue;
192
	    		//strCrumb += " " + facetValue;
141
	    		strCrumb =  facetValue;
193
	    		strCrumb =  facetValue;
Line 145... Line 197...
145
	    		log.info("acrumb=" + Arrays.toString(acrumb));
197
	    		log.info("acrumb=" + Arrays.toString(acrumb));
146
	    		this.crumbs.add(acrumb);
198
	    		this.crumbs.add(acrumb);
147
	    	}
199
	    	}
148
    	}
200
    	}
149
    	url = urlCrumb;
201
    	url = urlCrumb;
-
 
202
    	*/
-
 
203
    	
150
    	/**
204
    	/**
151
		 * FIXME facet definition ids
205
		 * FIXME facet definition ids
152
		 */
206
		 */
153
    	// Hard coded for now
207
    	// Hard coded for now
154
//    	long[] facetDefIDs = new long[] {50001, 50003, 50004, 50005, 50006, 
208
//    	long[] facetDefIDs = new long[] {50001, 50003, 50004, 50005, 50006, 
155
//    			50007, 50008, 50009};
209
//    			50007, 50008, 50009};
156
    	
210
    	
157
    	String[] facetDefIDs = new String[] {"F_50010","F_50011","F_50002","F_50001",  "F_50006", "F_50007" };
-
 
-
 
211
    	
158
    	
212
    	
159
    	/* All facets. Removing 5 of them
213
    	/* All facets. Removing 5 of them
160
    	String[] facetDefIDs = new String[] {"Category","F_50002","F_50001", "F_50003", "F_50004", "F_50005", "F_50006", 
214
    	String[] facetDefIDs = new String[] {"Category","F_50002","F_50001", "F_50003", "F_50004", "F_50005", "F_50006", 
161
    			"F_50007", "F_50008", "F_50009"};
215
    			"F_50007", "F_50008", "F_50009"};
162
    	*/		
216
    	*/		
Line 171... Line 225...
171
    	    	"Brand", "Form Factor", "Carry In Pocket", "Cellular Technologies", 
225
    	    	"Brand", "Form Factor", "Carry In Pocket", "Cellular Technologies", 
172
    	    	"Data Connectivity", "Camera Resolution", "Built-in Memory", 
226
    	    	"Data Connectivity", "Camera Resolution", "Built-in Memory", 
173
    	    	"Talk time"
227
    	    	"Talk time"
174
        	};
228
        	};
175
    	*/
229
    	*/
-
 
230
 
176
    	
231
    	
177
    	String[] facetLabels = new String[] {"Category","Category","Price",
-
 
178
    	    	"Brand", "Data Connectivity", "Camera Resolution"
-
 
179
        	};
-
 
180
    	
232
    	
181
    	SolrSearchService search = new SolrSearchService(query, fqrys, facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice);
233
    	SolrSearchService search = new SolrSearchService(query, fqrys, facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice, categoryId, sortOrder);
182
    	this.results = new LinkedHashMap<String, String[]>();
234
    	this.results = new LinkedHashMap<String, String[]>();
183
    	this.results =  search.getResultMap(); 
235
    	this.results =  search.getResultMap(); 
184
    	
236
    	
185
    	// Facets
237
    	// Facets
186
    	
238
    	
Line 268... Line 320...
268
 
320
 
269
    public String getPriceUrl(){
321
    public String getPriceUrl(){
270
    	return this.priceUrl;
322
    	return this.priceUrl;
271
    }
323
    }
272
    
324
    
-
 
325
    public String getSortUrl(){
-
 
326
    	return this.sortUrl;
-
 
327
    }
-
 
328
    
273
	public long getBeginIndex(){
329
	public long getBeginIndex(){
274
		if(totalResults>0)
330
		if(totalResults>0)
275
			return beginIndex+1;
331
			return beginIndex+1;
276
		return beginIndex;
332
		return beginIndex;
277
	}
333
	}
Line 329... Line 385...
329
	}
385
	}
330
	
386
	
331
	public String getMyResearchSnippet(){
387
	public String getMyResearchSnippet(){
332
		return htmlSnippets.get("MY_RESEARCH");
388
		return htmlSnippets.get("MY_RESEARCH");
333
	}
389
	}
-
 
390
 
-
 
391
	public String getBrowseHistorySnippet(){
-
 
392
		return htmlSnippets.get("BROWSE_HISTORY");
334
				
393
	}
-
 
394
	
335
	public String getFooterSnippet(){
395
	public String getFooterSnippet(){
336
		return htmlSnippets.get("FOOTER");
396
		return htmlSnippets.get("FOOTER");
337
	}
397
	}
338
	
398
	
339
	public String getJsFileSnippet(){
399
	public String getJsFileSnippet(){