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
This commit is contained in:
Mark Rogers
2014-09-20 09:08:52 +00:00
parent 2731b9a7bb
commit 48dbf73041
2 changed files with 22 additions and 10 deletions

View File

@@ -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.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/** /**
* Solr Facet service configuration API. * Solr Facet service configuration API.
@@ -108,17 +109,17 @@ public interface SolrFacetService
/** /**
* This method offers a convenient access point for getting all Facetable * This method offers a convenient access point for getting all Facetable
* content properties defined in the repository. * 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<title, propDef>.
* @see Facetable * @see Facetable
*/ */
public Set<PropertyDefinition> getFacetableProperties(); public Set<Pair<String, PropertyDefinition>> getFacetableProperties();
/** /**
* This method offers a convenient access point for getting all Facetable * This method offers a convenient access point for getting all Facetable
* content properties defined on the specified content class (type or aspect). * 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. * @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<title, propDef>.
* @see Facetable * @see Facetable
*/ */
public Set<PropertyDefinition> getFacetableProperties(QName contentClass); public Set<Pair<String, PropertyDefinition>> getFacetableProperties(QName contentClass);
} }

View File

@@ -66,6 +66,7 @@ import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.alfresco.util.collections.CollectionUtils; import org.alfresco.util.collections.CollectionUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -769,9 +770,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
} }
} }
@Override public Set<PropertyDefinition> getFacetableProperties() @Override public Set<Pair<String, PropertyDefinition>> getFacetableProperties()
{ {
final Set<PropertyDefinition> result = new HashSet<>(); final Set<Pair<String, PropertyDefinition>> result = new HashSet<>();
final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes()); final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
@@ -783,9 +784,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
return result; return result;
} }
@Override public Set<PropertyDefinition> getFacetableProperties(QName contentClass) @Override public Set<Pair<String, PropertyDefinition>> getFacetableProperties(QName contentClass)
{ {
final Set<PropertyDefinition> result = new HashSet<>(); final Set<Pair<String, PropertyDefinition>> result = new HashSet<>();
final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass); final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
@@ -798,7 +799,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
switch (propIsFacetable) switch (propIsFacetable)
{ {
case TRUE: case TRUE:
result.add(prop.getValue()); result.add(toTitledPropDef(prop.getValue()));
break; break;
case FALSE: case FALSE:
// The value is not facetable. Do nothing. // The value is not facetable. Do nothing.
@@ -808,7 +809,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
final DataTypeDefinition datatype = prop.getValue().getDataType(); final DataTypeDefinition datatype = prop.getValue().getDataType();
if (isNumeric(datatype) || isDateLike(datatype) || isFacetableText(datatype)) if (isNumeric(datatype) || isDateLike(datatype) || isFacetableText(datatype))
{ {
result.add(prop.getValue()); result.add(toTitledPropDef(prop.getValue()));
break; break;
} }
break; break;
@@ -822,6 +823,16 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
return result; return result;
} }
/**
* This method returns a {@link Pair} of the user-displayable property title (if available)
* and the {@link PropertyDefinition} itself.
*/
private Pair<String, PropertyDefinition> toTitledPropDef(PropertyDefinition propDef)
{
String title = propDef.getTitle(dictionaryService);
return new Pair<>(title, propDef);
}
// TODO Consider moving into dictionary code. // TODO Consider moving into dictionary code.
private boolean isNumeric(DataTypeDefinition datatype) private boolean isNumeric(DataTypeDefinition datatype)
{ {