Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

80709: Merged WAT1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      78667: ACE-1582: Made the facet config service and the relevant web scripts to accept single/multiple value(s) update (to support inline edits).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@83007 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Will Abson
2014-09-03 16:41:45 +00:00
parent 930f2a2edf
commit bc794cda30
4 changed files with 16 additions and 60 deletions

View File

@@ -326,7 +326,7 @@ public class SolrFacetConfig extends AbstractLifecycleBean
{
if (additionalProps == null)
{
return Collections.emptySet();
return null;
}
Set<CustomProperties> customProps = new HashSet<>();

View File

@@ -69,7 +69,7 @@ public class SolrFacetProperties implements Serializable
this.isEnabled = builder.isEnabled;
this.isDefault = builder.isDefault;
this.scopedSites = Collections.unmodifiableSet(new HashSet<String>(builder.scopedSites));
this.customProperties = Collections.unmodifiableSet(new HashSet<CustomProperties>(builder.customProperties));
this.customProperties = (builder.customProperties == null) ? null : Collections.unmodifiableSet(new HashSet<CustomProperties>(builder.customProperties));
}
/**
@@ -173,13 +173,13 @@ public class SolrFacetProperties implements Serializable
}
/**
* Returns an unmodifiable view of the custom properties set. Never null.
* Returns an unmodifiable view of the custom properties set or <i>null</i>.
*
* @return the customProperties
*/
public Set<CustomProperties> getCustomProperties()
{
return Collections.unmodifiableSet(new HashSet<CustomProperties>(this.customProperties));
return (this.customProperties == null) ? null : Collections.unmodifiableSet(new HashSet<CustomProperties>(this.customProperties));
}
/*
@@ -260,7 +260,7 @@ public class SolrFacetProperties implements Serializable
private Set<String> scopedSites = Collections.emptySet();
private Boolean isEnabled;
private boolean isDefault;
private Set<CustomProperties> customProperties = Collections.emptySet();
private Set<CustomProperties> customProperties;
public Builder()
{
@@ -365,10 +365,7 @@ public class SolrFacetProperties implements Serializable
public Builder customProperties(Set<CustomProperties> customProperties)
{
if (customProperties != null)
{
this.customProperties = customProperties;
}
this.customProperties = customProperties;
return this;
}

View File

@@ -313,7 +313,8 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
Set<CustomProperties> extraProps = null;
Map<QName, Serializable> customProperties = getFacetCustomProperties(properties);
if (customProperties.isEmpty())
boolean hasAspect = nodeService.hasAspect(nodeRef, SolrFacetModel.ASPECT_CUSTOM_PROPERTIES);
if (!hasAspect && customProperties.isEmpty())
{
extraProps = defaultFacet.getCustomProperties();
}
@@ -433,7 +434,10 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
{
Map<QName, Serializable> properties = createNodeProperties(facetProperties);
// Set the updated properties back onto the facet node reference
this.nodeService.setProperties(facetNodeRef, properties);
for (Entry<QName, Serializable> prop : properties.entrySet())
{
this.nodeService.setProperty(facetNodeRef, prop.getKey(), prop.getValue());
}
}
if (logger.isDebugEnabled())
{
@@ -441,51 +445,6 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
}
}
private SolrFacetProperties makeValidFacetPropObj(SolrFacetProperties newFP)
{
SolrFacetProperties bootstraptedFP = defaultFacetsMap.get(newFP.getFilterID());
// null means there is no default facet
if(bootstraptedFP == null)
{
return new SolrFacetProperties.Builder(newFP).isDefault(false).build();
}
QName fieldQName = getValue(bootstraptedFP.getFacetQName(), newFP.getFacetQName(), null);
String displayName = getValue(bootstraptedFP.getDisplayName(), newFP.getDisplayName(), null);
String displayControl = getValue(bootstraptedFP.getDisplayControl(), newFP.getDisplayControl(), null);
int maxFilters = getValue(bootstraptedFP.getMaxFilters(), newFP.getMaxFilters(), -1);
int hitThreshold = getValue(bootstraptedFP.getHitThreshold(), newFP.getHitThreshold(), -1);
int minFilterValueLength = getValue(bootstraptedFP.getMinFilterValueLength(), newFP.getMinFilterValueLength(), -1);
String sortBy = getValue(bootstraptedFP.getSortBy(), newFP.getSortBy(), null);
String scope = getValue(bootstraptedFP.getScope(), newFP.getScope(), null);
Boolean isEnabled = getValue(bootstraptedFP.isEnabled(), newFP.isEnabled(), null);
Set<String> scopedSites = getValue(bootstraptedFP.getScopedSites(), newFP.getScopedSites(), null);
Set<CustomProperties> extraProps = getValue(bootstraptedFP.getCustomProperties(), newFP.getCustomProperties(), null);
// Construct the FacetProperty object
SolrFacetProperties fp = new SolrFacetProperties.Builder()
.filterID(newFP.getFilterID())
.facetQName(fieldQName)
.displayName(displayName)
.displayControl(displayControl)
.maxFilters(maxFilters)
.hitThreshold(hitThreshold)
.minFilterValueLength(minFilterValueLength)
.sortBy(sortBy)
.scope(scope)
.isEnabled(isEnabled)
.isDefault(true)
.scopedSites(scopedSites)
.customProperties(extraProps).build();
return fp;
}
private <T> T getValue(T originalValue, T newValue, T defaultValueIfEquals)
{
return (originalValue.equals(newValue) ? defaultValueIfEquals : newValue);
}
@Override
public void deleteFacet(String filterID)
{
@@ -514,12 +473,11 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
throw new SolrFacetConfigException("Filter Id cannot be null.");
}
// construct a valid facet property object
facetProperties = makeValidFacetPropObj(facetProperties);
boolean isDefaultFP = defaultFacetsMap.containsKey(facetProperties.getFilterID());
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(15);
properties.put(ContentModel.PROP_NAME, facetProperties.getFilterID());
properties.put(SolrFacetModel.PROP_IS_DEFAULT, facetProperties.isDefault());
properties.put(SolrFacetModel.PROP_IS_DEFAULT, isDefaultFP);
addNodeProperty(properties, SolrFacetModel.PROP_FIELD_TYPE, facetProperties.getFacetQName());
addNodeProperty(properties, SolrFacetModel.PROP_FIELD_LABEL, facetProperties.getDisplayName());
@@ -533,7 +491,7 @@ public class SolrFacetServiceImpl extends AbstractLifecycleBean implements SolrF
addNodeProperty(properties, SolrFacetModel.PROP_IS_ENABLED, facetProperties.isEnabled());
Set<CustomProperties> customProperties = facetProperties.getCustomProperties();
if(customProperties.size() > 0)
if (customProperties != null)
{
properties.put(SolrFacetModel.PROP_EXTRA_INFORMATION, new ArrayList<>(customProperties));
}