mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
84950: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 83670: Moved the FacetablePropertyData inner class from SolrFacetService (Java API layer) into FacetablePropertiesGet (REST API layer) as that is a better place for it. ACE-2639. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85267 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
1d5aa5d15c
commit
bbbbfc1dbe
@ -20,7 +20,6 @@
|
|||||||
package org.alfresco.repo.search.impl.solr.facet;
|
package org.alfresco.repo.search.impl.solr.facet;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
import org.alfresco.repo.dictionary.Facetable;
|
import org.alfresco.repo.dictionary.Facetable;
|
||||||
import org.alfresco.repo.search.impl.solr.facet.Exceptions.DuplicateFacetId;
|
import org.alfresco.repo.search.impl.solr.facet.Exceptions.DuplicateFacetId;
|
||||||
@ -34,6 +33,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* Solr Facet service configuration API.
|
* Solr Facet service configuration API.
|
||||||
*
|
*
|
||||||
* @author Jamal Kaabi-Mofrad
|
* @author Jamal Kaabi-Mofrad
|
||||||
|
* @author Neil Mc Erlean
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface SolrFacetService
|
public interface SolrFacetService
|
||||||
@ -108,84 +108,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 FacetablePropertyData}s.
|
* @return a collection of facetable {@link PropertyDefinition}s.
|
||||||
* @see Facetable
|
* @see Facetable
|
||||||
*/
|
*/
|
||||||
public SortedSet<FacetablePropertyData> getFacetableProperties();
|
public List<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 FacetablePropertyData}s.
|
* @return a collection of facetable {@link PropertyDefinition}s.
|
||||||
* @see Facetable
|
* @see Facetable
|
||||||
*/
|
*/
|
||||||
public SortedSet<FacetablePropertyData> getFacetableProperties(QName contentClass);
|
public List<PropertyDefinition> 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 implements Comparable<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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -769,9 +769,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public SortedSet<FacetablePropertyData> getFacetableProperties()
|
@Override public List<PropertyDefinition> getFacetableProperties()
|
||||||
{
|
{
|
||||||
final SortedSet<FacetablePropertyData> result = new TreeSet<>();
|
final List<PropertyDefinition> result = new ArrayList<>();
|
||||||
|
|
||||||
final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
|
final List<QName> allContentClasses = CollectionUtils.flatten(dictionaryService.getAllAspects(), dictionaryService.getAllTypes());
|
||||||
|
|
||||||
@ -783,9 +783,9 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public SortedSet<FacetablePropertyData> getFacetableProperties(QName contentClass)
|
@Override public List<PropertyDefinition> getFacetableProperties(QName contentClass)
|
||||||
{
|
{
|
||||||
final SortedSet<FacetablePropertyData> result = new TreeSet<>();
|
final List<PropertyDefinition> result = new ArrayList<>();
|
||||||
|
|
||||||
final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
|
final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
|
||||||
|
|
||||||
@ -798,7 +798,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
switch (propIsFacetable)
|
switch (propIsFacetable)
|
||||||
{
|
{
|
||||||
case TRUE:
|
case TRUE:
|
||||||
result.add(toFacetablePropertyData(prop.getValue()));
|
result.add(prop.getValue());
|
||||||
break;
|
break;
|
||||||
case FALSE:
|
case FALSE:
|
||||||
// The value is not facetable. Do nothing.
|
// The value is not facetable. Do nothing.
|
||||||
@ -808,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(toFacetablePropertyData(prop.getValue()));
|
result.add(prop.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -822,13 +822,6 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Consider moving into dictionary code.
|
// TODO Consider moving into dictionary code.
|
||||||
private boolean isNumeric(DataTypeDefinition datatype)
|
private boolean isNumeric(DataTypeDefinition datatype)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user