diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetService.java b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetService.java
index 0e2cdb60e3..02eb7ceb92 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetService.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetService.java
@@ -29,7 +29,6 @@ import org.alfresco.repo.search.impl.solr.facet.Exceptions.UnrecognisedFacetId;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
-import org.alfresco.util.Pair;
/**
* Solr Facet service configuration API.
@@ -109,17 +108,78 @@ public interface SolrFacetService
/**
* This method offers a convenient access point for getting all Facetable
* content properties defined in the repository.
- * @return a collection of facetable {@link PropertyDefinition}s, as follows: Pair
.
+ * @return a collection of facetable {@link FacetablePropertyData}s.
* @see Facetable
*/
- public Set> getFacetableProperties();
+ public Set getFacetableProperties();
/**
* This method offers a convenient access point for getting all Facetable
* content properties defined on the specified content class (type or aspect).
* @param contentClass the QName of an aspect or type, whose facetable properties are sought.
- * @return a collection of facetable {@link PropertyDefinition}s, as follows: Pair.
+ * @return a collection of facetable {@link FacetablePropertyData}s.
* @see Facetable
*/
- public Set> getFacetableProperties(QName contentClass);
+ public Set getFacetableProperties(QName contentClass);
+
+ /** A simple POJO/DTO intended primarily for use in an FTL model and rendering in the JSON API. */
+ public static class FacetablePropertyData
+ {
+ 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;
+ }
+ }
+
}
diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
index 3ba284fb96..aa8d13abe6 100644
--- a/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/SolrFacetServiceImpl.java
@@ -66,7 +66,6 @@ import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
-import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.collections.CollectionUtils;
import org.apache.commons.logging.Log;
@@ -770,9 +769,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
}
}
- @Override public Set> getFacetableProperties()
+ @Override public Set getFacetableProperties()
{
- final Set> result = new HashSet<>();
+ final Set result = new HashSet<>();
final List allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
@@ -784,9 +783,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
return result;
}
- @Override public Set> getFacetableProperties(QName contentClass)
+ @Override public Set getFacetableProperties(QName contentClass)
{
- final Set> result = new HashSet<>();
+ final Set result = new HashSet<>();
final Map propertyDefs = dictionaryService.getPropertyDefs(contentClass);
@@ -799,7 +798,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
switch (propIsFacetable)
{
case TRUE:
- result.add(toTitledPropDef(prop.getValue()));
+ result.add(toFacetablePropertyData(prop.getValue()));
break;
case FALSE:
// The value is not facetable. Do nothing.
@@ -809,7 +808,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
final DataTypeDefinition datatype = prop.getValue().getDataType();
if (isNumeric(datatype) || isDateLike(datatype) || isFacetableText(datatype))
{
- result.add(toTitledPropDef(prop.getValue()));
+ result.add(toFacetablePropertyData(prop.getValue()));
break;
}
break;
@@ -823,14 +822,11 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
return result;
}
- /**
- * This method returns a {@link Pair} of the user-displayable property title (if available)
- * and the {@link PropertyDefinition} itself.
- */
- private Pair toTitledPropDef(PropertyDefinition propDef)
+ /** This method returns a {@link FacetablePropertyData} for the specified {@link PropertyDefinition}. */
+ private FacetablePropertyData toFacetablePropertyData(PropertyDefinition propDef)
{
String title = propDef.getTitle(dictionaryService);
- return new Pair<>(title, propDef);
+ return new FacetablePropertyData(propDef, title);
}
// TODO Consider moving into dictionary code.