diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml
index 5d75a1ff3d..19358905b8 100644
--- a/config/alfresco/web-scripts-application-context.xml
+++ b/config/alfresco/web-scripts-application-context.xml
@@ -1825,6 +1825,7 @@
id="webscript.org.alfresco.repository.facet.facetable-properties.get"
class="org.alfresco.repo.web.scripts.facet.FacetablePropertiesGet"
parent="baseSolrFacetConfigAdminWebscript">
+
executeImpl(final WebScriptRequest req, final Status status, final Cache cache)
{
@@ -87,11 +91,11 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip
final SortedSet facetableProperties;
if (contentClassQName == null)
{
- facetableProperties = facetService.getFacetableProperties();
+ facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties());
}
else
{
- facetableProperties = facetService.getFacetableProperties(contentClassQName);
+ facetableProperties = toFacetablePropertyDataSet(facetService.getFacetableProperties(contentClassQName));
}
// The webscript allows for some further filtering of results:
@@ -156,4 +160,88 @@ public class FacetablePropertiesGet extends AbstractSolrFacetConfigAdminWebScrip
return filteredResult;
}
+
+ /** This method returns a {@link FacetablePropertyData} for the specified {@link PropertyDefinition}. */
+ private FacetablePropertyData toFacetablePropertyData(PropertyDefinition propDef)
+ {
+ String title = propDef.getTitle(dictionaryService);
+ return new FacetablePropertyData(propDef, title);
+ }
+
+ private SortedSet toFacetablePropertyDataSet(Collection propDefs)
+ {
+ SortedSet result = new TreeSet<>();
+ for (PropertyDefinition propDef : propDefs)
+ {
+ result.add(toFacetablePropertyData(propDef));
+ }
+ return result;
+ }
+
+ /** A simple POJO/DTO intended primarily for use in an FTL model and rendering in the JSON API. */
+ public static class FacetablePropertyData implements Comparable
+ {
+ private final PropertyDefinition propDef;
+ private final String localisedTitle;
+ private final String displayName;
+
+ public FacetablePropertyData(PropertyDefinition propDef, String localisedTitle)
+ {
+ this.propDef = propDef;
+ this.localisedTitle = localisedTitle;
+ this.displayName = propDef.getName().getPrefixString() +
+ (localisedTitle == null ? "" : " (" + localisedTitle + ")");
+ }
+
+ public PropertyDefinition getPropertyDefinition() { return this.propDef; }
+ public String getLocalisedTitle() { return this.localisedTitle; }
+ public String getDisplayName() { return this.displayName; }
+
+ @Override public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((displayName == null) ? 0 : displayName.hashCode());
+ result = prime * result + ((localisedTitle == null) ? 0 : localisedTitle.hashCode());
+ result = prime * result + ((propDef == null) ? 0 : propDef.hashCode());
+ return result;
+ }
+
+ @Override public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FacetablePropertyData other = (FacetablePropertyData) obj;
+ if (displayName == null)
+ {
+ if (other.displayName != null)
+ return false;
+ } else if (!displayName.equals(other.displayName))
+ return false;
+ if (localisedTitle == null)
+ {
+ if (other.localisedTitle != null)
+ return false;
+ } else if (!localisedTitle.equals(other.localisedTitle))
+ return false;
+ if (propDef == null)
+ {
+ if (other.propDef != null)
+ return false;
+ } else if (!propDef.equals(other.propDef))
+ return false;
+ return true;
+ }
+
+ @Override public int compareTo(FacetablePropertyData that)
+ {
+ final int modelComparison = this.propDef.getModel().getName().compareTo(that.propDef.getModel().getName());
+ return modelComparison != 0 ? modelComparison :
+ this.propDef.getName().compareTo(that.propDef.getName());
+ }
+ }
}