| Line 121... |
Line 121... |
| 121 |
@Action("/speaker"),
|
121 |
@Action("/speaker"),
|
| 122 |
@Action("/hard-disk-drive"),
|
122 |
@Action("/hard-disk-drive"),
|
| 123 |
@Action("/external-hard-disks"),
|
123 |
@Action("/external-hard-disks"),
|
| 124 |
@Action("/headphones"),
|
124 |
@Action("/headphones"),
|
| 125 |
@Action("/portable-music-players"),
|
125 |
@Action("/portable-music-players"),
|
| - |
|
126 |
@Action("/data-cards"),
|
| 126 |
|
127 |
|
| 127 |
@Action("/category")
|
128 |
@Action("/category")
|
| 128 |
})
|
129 |
})
|
| 129 |
|
130 |
|
| 130 |
public HttpHeaders show() throws Exception {
|
131 |
public HttpHeaders show() throws Exception {
|
| Line 139... |
Line 140... |
| 139 |
else {
|
140 |
else {
|
| 140 |
this.categoryTitle = this.categoryName.replace("Phones", "Mobile Phones");
|
141 |
this.categoryTitle = this.categoryName.replace("Phones", "Mobile Phones");
|
| 141 |
}
|
142 |
}
|
| 142 |
String[] fqrys = this.request.getParameterValues("fq");
|
143 |
String[] fqrys = this.request.getParameterValues("fq");
|
| 143 |
|
144 |
|
| 144 |
String[] facetDefIDs = Utils.rootfacetDefIDs;
|
- |
|
| 145 |
String[] facetLabels = Utils.rootfacetLabels;
|
- |
|
| 146 |
if((getChildren(this.categoryName) == null || getChildren(this.categoryName).size() == 1) || (this.request.getQueryString() != null && this.request.getQueryString().contains("F_50011"))) {
|
- |
|
| 147 |
facetDefIDs = Utils.facetDefIDs;
|
- |
|
| 148 |
facetLabels = Utils.facetLabels;
|
- |
|
| 149 |
}
|
- |
|
| 150 |
|
- |
|
| 151 |
|
- |
|
| 152 |
url = "?";
|
145 |
url = "?";
|
| 153 |
|
146 |
|
| 154 |
query = "*";
|
147 |
query = "*";
|
| 155 |
|
148 |
|
| 156 |
int length = 1;
|
149 |
int length = 1;
|
| 157 |
|
150 |
|
| Line 176... |
Line 169... |
| 176 |
|
169 |
|
| 177 |
}
|
170 |
}
|
| 178 |
|
171 |
|
| 179 |
if(fqrys != null) {
|
172 |
if(fqrys != null) {
|
| 180 |
log.info("fqrys=" + Arrays.toString(fqrys));
|
173 |
log.info("fqrys=" + Arrays.toString(fqrys));
|
| 181 |
List<String> arrList = Arrays.asList(facetDefIDs);
|
- |
|
| 182 |
String filterUrl = "";
|
174 |
String filterUrl = "";
|
| 183 |
for(int i=0; i<fqrys.length; i++){
|
175 |
for(int i=0; i<fqrys.length; i++){
|
| 184 |
newfqrys[i+1] = fqrys[i];
|
176 |
newfqrys[i+1] = fqrys[i];
|
| 185 |
urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
177 |
urlCrumb += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
| 186 |
priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
178 |
priceUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
| 187 |
sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
179 |
sortUrl += "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
| 188 |
String facetName = StringUtils.split(fqrys[i], ":")[0];
|
180 |
String facetName = StringUtils.split(fqrys[i], ":")[0];
|
| 189 |
String facetValue = StringUtils.split(fqrys[i], ":")[1];
|
181 |
String facetValue = StringUtils.split(fqrys[i], ":")[1];
|
| 190 |
String facetLabel = facetLabels[arrList.indexOf(facetName)];
|
182 |
String facetLabel = Utils.FACET_LABEL_MAP.get(facetName);
|
| 191 |
filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
183 |
filterUrl = "&fq=" + URLEncoder.encode(fqrys[i], "UTF-8");
|
| 192 |
List<String> acrumb = Arrays.asList(facetValue, filterUrl);
|
184 |
List<String> acrumb = Arrays.asList(facetValue, filterUrl);
|
| 193 |
if(!crumbs.containsKey(facetLabel)) {
|
185 |
if(!crumbs.containsKey(facetLabel)) {
|
| 194 |
crumbs.put(facetLabel, new ArrayList<List<String>>());
|
186 |
crumbs.put(facetLabel, new ArrayList<List<String>>());
|
| 195 |
}
|
187 |
}
|
| Line 217... |
Line 209... |
| 217 |
if(request.getParameter("sort")!=null){
|
209 |
if(request.getParameter("sort")!=null){
|
| 218 |
url= url + "&sort=" + this.request.getParameter("sort");
|
210 |
url= url + "&sort=" + this.request.getParameter("sort");
|
| 219 |
sortOrder = this.request.getParameter("sort");
|
211 |
sortOrder = this.request.getParameter("sort");
|
| 220 |
}
|
212 |
}
|
| 221 |
|
213 |
|
| 222 |
SolrSearchService search = new SolrSearchService(query, newfqrys, facetDefIDs, (page-1)*windowSize, windowSize, minPrice, maxPrice, Utils.ROOT_CATEGORY, "F_50028+asc," + sortOrder, sourceId);
|
214 |
SolrSearchService search = new SolrSearchService(query, newfqrys, (page-1)*windowSize, windowSize, minPrice, maxPrice, "F_50028+asc," + sortOrder, sourceId);
|
| 223 |
this.results = search.getResultMap();
|
215 |
this.results = search.getResultMap();
|
| 224 |
this.dynamicSearchMap = search.getDynamicPriceMap();
|
216 |
this.dynamicSearchMap = search.getDynamicPriceMap();
|
| 225 |
|
217 |
|
| 226 |
setFacet(Arrays.asList(newfqrys), search);
|
218 |
setFacet(Arrays.asList(newfqrys), search);
|
| 227 |
|
219 |
|
| Line 364... |
Line 356... |
| 364 |
public String getCartWidgetSnippet() {
|
356 |
public String getCartWidgetSnippet() {
|
| 365 |
return pageLoader.getCartWidgetSnippet(userinfo.getTotalItems(), userinfo.getTotalAmount(),categoryId);
|
357 |
return pageLoader.getCartWidgetSnippet(userinfo.getTotalItems(), userinfo.getTotalAmount(),categoryId);
|
| 366 |
}
|
358 |
}
|
| 367 |
|
359 |
|
| 368 |
private void setFacet(List<String> fqs, SolrSearchService search) throws Exception{
|
360 |
private void setFacet(List<String> fqs, SolrSearchService search) throws Exception{
|
| 369 |
String[] toshowfacetDefIDs;
|
- |
|
| 370 |
String[] toshowfacetLabels;
|
361 |
List<String> filtrableFacets = search.getFilterableFacets();
|
| 371 |
|
- |
|
| 372 |
toshowfacetDefIDs = Utils.facetDefIDs;
|
- |
|
| 373 |
toshowfacetLabels = Utils.facetLabels;
|
- |
|
| 374 |
|
- |
|
| 375 |
this.facets = new LinkedHashMap<String, List<String[]>>();
|
362 |
this.facets = new LinkedHashMap<String, List<String[]>>();
|
| 376 |
for (int i=0; i<toshowfacetDefIDs.length; i++) {
|
363 |
for (String filtrableFacet : filtrableFacets) {
|
| 377 |
String facetDefID = toshowfacetDefIDs[i];
|
- |
|
| 378 |
String facetLabel = toshowfacetLabels[i];
|
- |
|
| 379 |
|
364 |
|
| 380 |
Map<String, Integer> facetDetailMap = search.getFacetDetails(facetDefID);
|
365 |
Map<String, Integer> facetDetailMap = search.getFacetDetails(filtrableFacet);
|
| 381 |
if(facetDetailMap==null)
|
366 |
if(facetDetailMap==null)
|
| 382 |
continue;
|
367 |
continue;
|
| 383 |
List<String[]> values = new ArrayList<String[]>();
|
368 |
List<String[]> values = new ArrayList<String[]>();
|
| 384 |
for(Entry<String, Integer> facetEntry : facetDetailMap.entrySet()){
|
369 |
for(Entry<String, Integer> facetEntry : facetDetailMap.entrySet()){
|
| 385 |
String selected = "";
|
370 |
String selected = "";
|
| 386 |
if(fqs.contains(facetDefID + ":" + facetEntry.getKey())) {
|
371 |
if(fqs.contains(filtrableFacet + ":" + facetEntry.getKey())) {
|
| 387 |
selected = "checked=\"checked\"";
|
372 |
selected = "checked=\"checked\"";
|
| 388 |
}
|
373 |
}
|
| 389 |
String facet = facetEntry.getKey();
|
374 |
String facet = facetEntry.getKey();
|
| 390 |
String drilldownURL = "&fq=" +
|
375 |
String drilldownURL = "&fq=" +
|
| 391 |
URLEncoder.encode( facetDefID + ":" + facet, "UTF-8");
|
376 |
URLEncoder.encode(filtrableFacet + ":" + facet, "UTF-8");
|
| 392 |
String[] afacet = new String[] { facet,
|
377 |
String[] afacet = new String[] { facet,
|
| 393 |
facetEntry.getValue().toString(), drilldownURL, selected};
|
378 |
facetEntry.getValue().toString(), drilldownURL, selected};
|
| 394 |
values.add(afacet);
|
379 |
values.add(afacet);
|
| 395 |
}
|
380 |
}
|
| 396 |
|
381 |
|
| 397 |
this.facets.put(facetLabel, values);
|
382 |
this.facets.put(Utils.FACET_LABEL_MAP.get(filtrableFacet), values);
|
| 398 |
}
|
383 |
}
|
| 399 |
}
|
384 |
}
|
| 400 |
|
385 |
|
| 401 |
public List<String> getChildren(String categoryLabel) {
|
386 |
public List<String> getChildren(String categoryLabel) {
|
| 402 |
return SearchController.getCategoriesChildren().get(categoryLabel);
|
387 |
return SearchController.getCategoriesChildren().get(categoryLabel);
|