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)
80643: Merged WAT1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 76831: Enhancement to the /api/solr/facet-config REST endpoint to support facet reordering. If you add a query parameter like so: /api/solr/facet-config/{filterID}?relativePos={relativePos?} then the specified filterID will be moved by the specified relative position. '3' means move it 3 places down the list. '-1' means move it one place up the list. Note that currently you cannot provide a HTTP request body (JSON) at the same time as the relativePos param, in other words you cannot update the facet metadata and reposition in in one REST call. It is either or. We may enhance the webscript to support simultaneous edits of metadata and position at a future date. Also added automatic management of facet position on facet create and delete. New facets are put at the end of the list - this can easily be changed if it is not what's wanted. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82937 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -102,7 +102,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
||||
private SimpleCache<String, Object> singletonCache; // eg. for facetsHomeNodeRef
|
||||
private final String KEY_FACETS_HOME_NODEREF = "key.facetshome.noderef";
|
||||
private SimpleCache<String, NodeRef> facetNodeRefCache; // for filterID to nodeRef lookup
|
||||
private NavigableMap<Integer, SolrFacetProperties> facetsMap = new ConcurrentSkipListMap<>();
|
||||
private NavigableMap<Integer, SolrFacetProperties> facetsMap = new ConcurrentSkipListMap<>(); // TODO
|
||||
private int maxAllowedFilters = 100;
|
||||
|
||||
/**
|
||||
@@ -455,8 +455,6 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
||||
{
|
||||
logger.debug("Deleted [" + filterID + "] facet.");
|
||||
}
|
||||
|
||||
// TODO Remove the matching filterID from the property list on the container.
|
||||
}
|
||||
|
||||
private Map<QName, Serializable> createNodeProperties(SolrFacetProperties facetProperties)
|
||||
@@ -652,6 +650,17 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
||||
SolrFacetProperties fp = getFacetProperties(childAssocRef.getChildRef());
|
||||
this.facetsMap.put(fp.getIndex(), fp);
|
||||
this.facetNodeRefCache.put(fp.getFilterID(), childAssocRef.getChildRef());
|
||||
|
||||
// We must also add the new filterID to the facetOrder property.
|
||||
final NodeRef facetsRoot = getFacetsRoot();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<String> facetOrder = (ArrayList<String>) nodeService.getProperty(facetsRoot, SolrFacetModel.PROP_FACET_ORDER);
|
||||
|
||||
// We'll put it at the end (arbitrarily).
|
||||
facetOrder.add(fp.getFilterID());
|
||||
|
||||
nodeService.setProperty(facetsRoot, SolrFacetModel.PROP_FACET_ORDER, facetOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -662,6 +671,17 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
|
||||
|
||||
this.facetsMap.remove(index);
|
||||
this.facetNodeRefCache.remove(filterID);
|
||||
|
||||
// We must also remove the filterID from the facetOrder property.
|
||||
final NodeRef facetsRoot = getFacetsRoot();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<String> facetOrder = (ArrayList<String>) nodeService.getProperty(facetsRoot, SolrFacetModel.PROP_FACET_ORDER);
|
||||
|
||||
if (facetOrder.remove(filterID))
|
||||
{
|
||||
nodeService.setProperty(facetsRoot, SolrFacetModel.PROP_FACET_ORDER, facetOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user