mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
84922: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 83457: Refactoring the facetable properties.get response and some of the service API. Part of ACE-2639. This checkin changes the JSON structure slightly (array, not map), adds a displayName. The localised title and displayName are still in the server locale. I'll fix that to client locale next. Also need to add paging. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85239 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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.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.
|
||||||
@@ -109,17 +108,78 @@ 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, as follows: Pair<title, propDef>.
|
* @return a collection of facetable {@link FacetablePropertyData}s.
|
||||||
* @see Facetable
|
* @see Facetable
|
||||||
*/
|
*/
|
||||||
public Set<Pair<String, PropertyDefinition>> getFacetableProperties();
|
public Set<FacetablePropertyData> 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, as follows: Pair<title, propDef>.
|
* @return a collection of facetable {@link FacetablePropertyData}s.
|
||||||
* @see Facetable
|
* @see Facetable
|
||||||
*/
|
*/
|
||||||
public Set<Pair<String, PropertyDefinition>> getFacetableProperties(QName contentClass);
|
public Set<FacetablePropertyData> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,6 @@ 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;
|
||||||
@@ -770,9 +769,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Set<Pair<String, PropertyDefinition>> getFacetableProperties()
|
@Override public Set<FacetablePropertyData> getFacetableProperties()
|
||||||
{
|
{
|
||||||
final Set<Pair<String, PropertyDefinition>> result = new HashSet<>();
|
final Set<FacetablePropertyData> result = new HashSet<>();
|
||||||
|
|
||||||
final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
|
final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
|
||||||
|
|
||||||
@@ -784,9 +783,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Set<Pair<String, PropertyDefinition>> getFacetableProperties(QName contentClass)
|
@Override public Set<FacetablePropertyData> getFacetableProperties(QName contentClass)
|
||||||
{
|
{
|
||||||
final Set<Pair<String, PropertyDefinition>> result = new HashSet<>();
|
final Set<FacetablePropertyData> result = new HashSet<>();
|
||||||
|
|
||||||
final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
|
final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
|
||||||
|
|
||||||
@@ -799,7 +798,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
switch (propIsFacetable)
|
switch (propIsFacetable)
|
||||||
{
|
{
|
||||||
case TRUE:
|
case TRUE:
|
||||||
result.add(toTitledPropDef(prop.getValue()));
|
result.add(toFacetablePropertyData(prop.getValue()));
|
||||||
break;
|
break;
|
||||||
case FALSE:
|
case FALSE:
|
||||||
// The value is not facetable. Do nothing.
|
// The value is not facetable. Do nothing.
|
||||||
@@ -809,7 +808,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(toTitledPropDef(prop.getValue()));
|
result.add(toFacetablePropertyData(prop.getValue()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -823,14 +822,11 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** This method returns a {@link FacetablePropertyData} for the specified {@link PropertyDefinition}. */
|
||||||
* This method returns a {@link Pair} of the user-displayable property title (if available)
|
private FacetablePropertyData toFacetablePropertyData(PropertyDefinition propDef)
|
||||||
* and the {@link PropertyDefinition} itself.
|
|
||||||
*/
|
|
||||||
private Pair<String, PropertyDefinition> toTitledPropDef(PropertyDefinition propDef)
|
|
||||||
{
|
{
|
||||||
String title = propDef.getTitle(dictionaryService);
|
String title = propDef.getTitle(dictionaryService);
|
||||||
return new Pair<>(title, propDef);
|
return new FacetablePropertyData(propDef, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Consider moving into dictionary code.
|
// TODO Consider moving into dictionary code.
|
||||||
|
Reference in New Issue
Block a user