/**
*
*/
public SearchFacetViewBean buildViewBeanStoreSearchFacet(final RequestData requestData, final FacetField facetField) throws Exception {
final SearchFacetViewBean searchFacetViewBean = new SearchFacetViewBean();
// TODO : Denis : facet like country ? city ? online/corner etc
if(StoreResponseBean.STORE_DEFAULT_FACET_FIELD.equalsIgnoreCase(facetField.getName())){
searchFacetViewBean.setName(facetField.getName());
List<ValueBean> values = new ArrayList<ValueBean>();
for (Iterator<Count> iterator = facetField.getValues().iterator(); iterator.hasNext();) {
Count count = (Count) iterator.next();
ValueBean valueBean = new ValueBean();
valueBean.setValue(count.getName()+ "(" + count.getCount() + ")");
valueBean.setKey(count.getName());
values.add(valueBean);
}
Collections.sort(values, new Comparator<ValueBean>() {
@Override
public int compare(ValueBean o1, ValueBean o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
searchFacetViewBean.setValues(values);
}
if(StoreResponseBean.STORE_SECOND_FACET_FIELD.equalsIgnoreCase(facetField.getName())){
searchFacetViewBean.setName(facetField.getName());
List<ValueBean> values = new ArrayList<ValueBean>();
for (Iterator<Count> iterator = facetField.getValues().iterator(); iterator.hasNext();) {
Count count = (Count) iterator.next();
ValueBean valueBean = new ValueBean();
valueBean.setValue(count.getName()+ "(" + count.getCount() + ")");
valueBean.setKey(count.getName());
values.add(valueBean);
}
Collections.sort(values, new Comparator<ValueBean>() {
@Override
public int compare(ValueBean o1, ValueBean o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
searchFacetViewBean.setValues(values);
}
return searchFacetViewBean;
}