Subversion Repositories SmartDukaan

Rev

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

Rev 6975 Rev 6998
Line 79... Line 79...
79
 
79
 
80
    	String urlCrumb = url;
80
    	String urlCrumb = url;
81
    	
81
    	
82
    	this.crumbs = new HashMap<String, List<List<String>>>();
82
    	this.crumbs = new HashMap<String, List<List<String>>>();
83
    	
83
    	
84
    	String[] facetLabels = Utils.facetLabels;
-
 
85
    	List<String> arrList = Arrays.asList(Utils.facetDefIDs);
-
 
86
    	
-
 
87
    	if(fqrys!= null){
84
    	if(fqrys!= null){
88
    		log.info("fqrys=" + Arrays.toString(fqrys));
85
    		log.info("fqrys=" + Arrays.toString(fqrys));
89
	    	String filterUrl = "";
86
	    	String filterUrl = "";
90
	    	for(int i=0; i<fqrys.length; i++){
87
	    	for(int i=0; i<fqrys.length; i++){
91
	    		urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
88
	    		urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
92
	    		priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
89
	    		priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
93
	    		sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
90
	    		sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
94
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
91
	    		String facetName = StringUtils.split(fqrys[i], ":")[0];
95
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
92
	    		String facetValue = StringUtils.split(fqrys[i], ":")[1];
96
	    		String facetLabel = facetLabels[arrList.indexOf(facetName)];
93
	    		String facetLabel = Utils.FACET_LABEL_MAP.get(facetName);
97
	    		filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8"); 
94
	    		filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8"); 
98
	    		List<String> acrumb = Arrays.asList(facetValue, filterUrl);
95
	    		List<String> acrumb = Arrays.asList(facetValue, filterUrl);
99
	    		if(!crumbs.containsKey(facetLabel)) {
96
	    		if(!crumbs.containsKey(facetLabel)) {
100
	    			crumbs.put(facetLabel, new ArrayList<List<String>>());
97
	    			crumbs.put(facetLabel, new ArrayList<List<String>>());
101
	    		}
98
	    		}
Line 134... Line 131...
134
    	if (type!=0) {
131
    	if (type!=0) {
135
    		query = "*&fq=F_50029:"+query;
132
    		query = "*&fq=F_50029:"+query;
136
    	}
133
    	}
137
    		
134
    		
138
    	
135
    	
139
    	SolrSearchService search = new SolrSearchService(query, fqrys, Utils.facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice, 10000, "F_50028+asc," + sortOrder, sourceId);
136
    	SolrSearchService search = new SolrSearchService(query, fqrys, (page-1)*windowSize, windowSize, minPrice, maxPrice, "F_50028+asc," + sortOrder, sourceId);
140
    	this.results =  search.getResultMap(); 
137
    	this.results =  search.getResultMap(); 
141
    	this.dynamicSearchMap = search.getDynamicPriceMap();
138
    	this.dynamicSearchMap = search.getDynamicPriceMap();
142
    	setFacet(Arrays.asList(fqrys), search);
139
    	setFacet(Arrays.asList(fqrys), search);
143
 
140
 
144
 
141
 
Line 263... Line 260...
263
			e.printStackTrace();
260
			e.printStackTrace();
264
		}
261
		}
265
		return tagSnippets;
262
		return tagSnippets;
266
	}
263
	}
267
	
264
	
268
    private void setFacet(List<String> fqs, SolrSearchService search) throws Exception{
-
 
269
    	String[] toshowfacetDefIDs;
-
 
270
    	String[] toshowfacetLabels;
-
 
271
    	
-
 
272
		toshowfacetDefIDs = Utils.facetDefIDs;
-
 
273
		toshowfacetLabels = Utils.facetLabels;
-
 
274
 
-
 
275
    	this.facets = new LinkedHashMap<String, List<String[]>>();
-
 
276
    	for (int i=0; i<toshowfacetDefIDs.length; i++) {
-
 
277
    		String facetDefID = toshowfacetDefIDs[i];
-
 
278
    		String facetLabel = toshowfacetLabels[i];
-
 
279
    		
-
 
280
    		Map<String, Integer> facetDetailMap = search.getFacetDetails(facetDefID);
-
 
281
    		if(facetDetailMap==null)
-
 
282
    			continue;
-
 
283
    		List<String[]> values = new ArrayList<String[]>();
-
 
284
    		for(Entry<String, Integer> facetEntry : facetDetailMap.entrySet()){
-
 
285
    			String selected = "";
-
 
286
    			if(fqs.contains(facetDefID + ":" + facetEntry.getKey())) {
-
 
287
    				selected = "checked=\"checked\"";
-
 
288
    			}
-
 
289
    		    String facet = facetEntry.getKey();
-
 
290
      			String drilldownURL = "&fq=" +  
-
 
291
    				URLEncoder.encode( facetDefID + ":" + facet, "UTF-8"); 
-
 
292
      			String[] afacet = new String[] { facet, 
-
 
293
      			      facetEntry.getValue().toString(), drilldownURL,  selected};
-
 
294
      			values.add(afacet);    
-
 
295
    		}
-
 
296
    		
-
 
297
    		this.facets.put(facetLabel, values);
-
 
298
    	}
-
 
299
	}
-
 
300
    
265
    
301
    public List<String> getChildren(String categoryLabel) {
266
    public List<String> getChildren(String categoryLabel) {
302
    	return SearchController.getCategoriesChildren().get(categoryLabel);
267
    	return SearchController.getCategoriesChildren().get(categoryLabel);
303
    }
268
    }
304
    
269
    
Line 319... Line 284...
319
	}
284
	}
320
 
285
 
321
	public String getUri(){
286
	public String getUri(){
322
		return this.uri;
287
		return this.uri;
323
	}
288
	}
-
 
289
	
-
 
290
	private void setFacet(List<String> fqs, SolrSearchService search) throws Exception{
-
 
291
 
-
 
292
    	this.facets = new LinkedHashMap<String, List<String[]>>();
-
 
293
    	List<String> filtrableFacets = search.getFilterableFacets();
-
 
294
    	for (String filtrableFacet : filtrableFacets) {
-
 
295
    		
-
 
296
    		Map<String, Integer> facetDetailMap = search.getFacetDetails(filtrableFacet);
-
 
297
    		if(facetDetailMap==null)
-
 
298
    			continue;
-
 
299
    		List<String[]> values = new ArrayList<String[]>();
-
 
300
    		for(Entry<String, Integer> facetEntry : facetDetailMap.entrySet()){
-
 
301
    			String selected = "";
-
 
302
    			if(fqs.contains(filtrableFacet + ":" + facetEntry.getKey())) {
-
 
303
    				selected = "checked=\"checked\"";
-
 
304
    			}
-
 
305
    		    String facet = facetEntry.getKey();
-
 
306
      			String drilldownURL = "&fq=" +  
-
 
307
    				URLEncoder.encode( filtrableFacet + ":" + facet, "UTF-8"); 
-
 
308
      			String[] afacet = new String[] { facet, 
-
 
309
      			      facetEntry.getValue().toString(), drilldownURL,  selected};
-
 
310
      			values.add(afacet);    
-
 
311
    		}
-
 
312
    		
-
 
313
    		this.facets.put(Utils.FACET_LABEL_MAP.get(filtrableFacet), values);
-
 
314
    	}
-
 
315
	}
324
}
316
}