From 48dbf73041674a948bc7c7a4930c11178cd8fa5b Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Sat, 20 Sep 2014 09:08:52 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 84917: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 83444: ACE-2639. Added property title (where available) to JSON rsp. As the title can only be retrieved using a getTitle(MessageLookup) call, I had to get the titles from the Java layer, rather than a straight get call in the FTL. Makes the API a bit messier. I may get to tidy it as part of ongoing work on ACE-2639. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../impl/solr/facet/SolrFacetService.java | 9 ++++---- .../impl/solr/facet/SolrFacetServiceImpl.java | 23 ++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) 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 013274909d..0e2cdb60e3 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,6 +29,7 @@ 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. @@ -108,17 +109,17 @@ 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. + * @return a collection of facetable {@link PropertyDefinition}s, as follows: Pair. * @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. + * @return a collection of facetable {@link PropertyDefinition}s, as follows: Pair. * @see Facetable */ - public Set getFacetableProperties(QName contentClass); + public Set> getFacetableProperties(QName contentClass); } 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 753baf2f9c..3ba284fb96 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,6 +66,7 @@ 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; @@ -769,9 +770,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()); @@ -783,9 +784,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); @@ -798,7 +799,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF switch (propIsFacetable) { case TRUE: - result.add(prop.getValue()); + result.add(toTitledPropDef(prop.getValue())); break; case FALSE: // The value is not facetable. Do nothing. @@ -808,7 +809,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF final DataTypeDefinition datatype = prop.getValue().getDataType(); if (isNumeric(datatype) || isDateLike(datatype) || isFacetableText(datatype)) { - result.add(prop.getValue()); + result.add(toTitledPropDef(prop.getValue())); break; } break; @@ -822,6 +823,16 @@ 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) + { + String title = propDef.getTitle(dictionaryService); + return new Pair<>(title, propDef); + } + // TODO Consider moving into dictionary code. private boolean isNumeric(DataTypeDefinition datatype) {