List of usage examples for java.text Collator TERTIARY
int TERTIARY
To view the source code for java.text Collator TERTIARY.
Click Source Link
From source file:org.jahia.services.search.facets.SimpleJahiaJcrFacets.java
private NamedList<Object> sortValuesAfterChoiceListRenderer(NamedList<Object> values, ChoiceListRenderer renderer, ExtendedPropertyDefinition fieldPropertyType, Locale locale) { try {/*from w w w . j a v a 2s . c o m*/ //use case-insensitive and locale aware collator Collator collator = Collator.getInstance(locale); collator.setStrength(Collator.TERTIARY); Map<String, Integer> sortedLabels = new TreeMap<>(collator); int i = 0; boolean resolveReference = renderer instanceof NodeReferenceChoiceListRenderer ? true : false; JCRSessionWrapper currentUserSession = resolveReference ? JCRSessionFactory.getInstance().getCurrentUserSession(session.getWorkspace().getName(), locale) : null; for (Map.Entry<String, Object> facetValueEntry : values) { String facetValueKey = facetValueEntry.getKey(); sortedLabels.put(renderer.getStringRendering(locale, fieldPropertyType, resolveReference ? currentUserSession .getNode(StringUtils.substring(facetValueKey, facetValueKey.indexOf('/'))) : facetValueKey), i++); } NamedList<Object> sortedValues = new NamedList<>(); for (Integer index : sortedLabels.values()) { sortedValues.add(values.getName(index), values.getVal(index)); } return sortedValues; } catch (RepositoryException | UnsupportedOperationException e) { logger.warn("Exception while sorting label rendered facet values, fallback to default sorting", e); return values; } }