mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged 1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4392 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4399 . svn resolved root\projects\repository\source\java\org\alfresco\repo\jscript\Node.java git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4660 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -130,12 +130,20 @@ public class LinkCategoryActionExecuter extends ActionExecuterAbstractBase
|
||||
{
|
||||
// Append the category value to the existing values
|
||||
Serializable value = this.nodeService.getProperty(actionedUponNodeRef, categoryProperty);
|
||||
Collection<NodeRef> categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value);
|
||||
if (categories.contains(categoryValue) == false)
|
||||
Collection<NodeRef> categories = null;
|
||||
if (value == null)
|
||||
{
|
||||
categories.add(categoryValue);
|
||||
this.nodeService.setProperty(actionedUponNodeRef, categoryProperty, (Serializable)categories);
|
||||
categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, categoryValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value);
|
||||
if (categories.contains(categoryValue) == false)
|
||||
{
|
||||
categories.add(categoryValue);
|
||||
}
|
||||
}
|
||||
this.nodeService.setProperty(actionedUponNodeRef, categoryProperty, (Serializable)categories);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,8 @@
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -193,9 +195,17 @@ public final class Search implements Scopeable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* Removes any duplicates that may be present (ID can cause duplicates - it is better to remove them here)
|
||||
*
|
||||
* @param search
|
||||
* @return
|
||||
*/
|
||||
private Node[] query(String search)
|
||||
{
|
||||
Node[] nodes = null;
|
||||
{
|
||||
LinkedHashSet<Node> set = new LinkedHashSet<Node> ();
|
||||
|
||||
// perform the search against the repo
|
||||
ResultSet results = null;
|
||||
@@ -208,13 +218,10 @@ public final class Search implements Scopeable
|
||||
|
||||
if (results.length() != 0)
|
||||
{
|
||||
nodes = new Node[results.length()];
|
||||
int count = 0;
|
||||
for (ResultSetRow row: results)
|
||||
{
|
||||
NodeRef nodeRef = row.getNodeRef();
|
||||
nodes[count] = new Node(nodeRef, services, this.imageResolver, this.scope);
|
||||
count++;
|
||||
set.add(new Node(nodeRef, services, this.imageResolver, this.scope));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,7 +236,7 @@ public final class Search implements Scopeable
|
||||
results.close();
|
||||
}
|
||||
}
|
||||
|
||||
return nodes != null ? nodes : new Node[0];
|
||||
|
||||
return set.toArray(new Node[(set.size())]);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package org.alfresco.repo.template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -29,8 +30,7 @@ import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
|
||||
/**
|
||||
* Class providing the base Search Query services to execute a search returning a list of
|
||||
* TemplateNode objects from a Lucene search string.
|
||||
* Class providing the base Search Query services to execute a search returning a list of TemplateNode objects from a Lucene search string.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
@@ -39,8 +39,10 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param parent The parent TemplateNode to execute searches from
|
||||
* @param services The ServiceRegistry to use
|
||||
* @param parent
|
||||
* The parent TemplateNode to execute searches from
|
||||
* @param services
|
||||
* The ServiceRegistry to use
|
||||
*/
|
||||
public BaseSearchResultsMap(TemplateNode parent, ServiceRegistry services)
|
||||
{
|
||||
@@ -48,12 +50,13 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a SearchService query with the given Lucene search string
|
||||
* Perform a SearchService query with the given Lucene search string
|
||||
*/
|
||||
protected List<TemplateNode> query(String search)
|
||||
{
|
||||
List<TemplateNode> nodes = null;
|
||||
|
||||
HashSet<NodeRef> nodeRefs = new HashSet<NodeRef>();
|
||||
|
||||
// check if a full Lucene search string has been supplied or extracted from XML
|
||||
if (search != null && search.length() != 0)
|
||||
{
|
||||
@@ -61,18 +64,20 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
||||
ResultSet results = null;
|
||||
try
|
||||
{
|
||||
results = this.services.getSearchService().query(
|
||||
this.parent.getNodeRef().getStoreRef(),
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
search);
|
||||
|
||||
results = this.services.getSearchService().query(this.parent.getNodeRef().getStoreRef(),
|
||||
SearchService.LANGUAGE_LUCENE, search);
|
||||
|
||||
if (results.length() != 0)
|
||||
{
|
||||
nodes = new ArrayList<TemplateNode>(results.length());
|
||||
for (ResultSetRow row: results)
|
||||
for (ResultSetRow row : results)
|
||||
{
|
||||
NodeRef nodeRef = row.getNodeRef();
|
||||
nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
|
||||
if (!nodeRefs.contains(nodeRef))
|
||||
{
|
||||
nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
|
||||
nodeRefs.add(nodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +93,7 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodes != null ? nodes : (List)Collections.emptyList();
|
||||
|
||||
return nodes != null ? nodes : (List) Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user