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,15 +130,23 @@ public class LinkCategoryActionExecuter extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
// Append the category value to the existing values
|
// Append the category value to the existing values
|
||||||
Serializable value = this.nodeService.getProperty(actionedUponNodeRef, categoryProperty);
|
Serializable value = this.nodeService.getProperty(actionedUponNodeRef, categoryProperty);
|
||||||
Collection<NodeRef> categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value);
|
Collection<NodeRef> categories = null;
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, categoryValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value);
|
||||||
if (categories.contains(categoryValue) == false)
|
if (categories.contains(categoryValue) == false)
|
||||||
{
|
{
|
||||||
categories.add(categoryValue);
|
categories.add(categoryValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.nodeService.setProperty(actionedUponNodeRef, categoryProperty, (Serializable)categories);
|
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;
|
package org.alfresco.repo.jscript;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
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)
|
private Node[] query(String search)
|
||||||
{
|
{
|
||||||
Node[] nodes = null;
|
LinkedHashSet<Node> set = new LinkedHashSet<Node> ();
|
||||||
|
|
||||||
// perform the search against the repo
|
// perform the search against the repo
|
||||||
ResultSet results = null;
|
ResultSet results = null;
|
||||||
@@ -208,13 +218,10 @@ public final class Search implements Scopeable
|
|||||||
|
|
||||||
if (results.length() != 0)
|
if (results.length() != 0)
|
||||||
{
|
{
|
||||||
nodes = new Node[results.length()];
|
|
||||||
int count = 0;
|
|
||||||
for (ResultSetRow row: results)
|
for (ResultSetRow row: results)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = row.getNodeRef();
|
NodeRef nodeRef = row.getNodeRef();
|
||||||
nodes[count] = new Node(nodeRef, services, this.imageResolver, this.scope);
|
set.add(new Node(nodeRef, services, this.imageResolver, this.scope));
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,6 +237,6 @@ public final class Search implements Scopeable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
@@ -29,8 +30,7 @@ import org.alfresco.service.cmr.search.ResultSetRow;
|
|||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class providing the base Search Query services to execute a search returning a list of
|
* Class providing the base Search Query services to execute a search returning a list of TemplateNode objects from a Lucene search string.
|
||||||
* TemplateNode objects from a Lucene search string.
|
|
||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
@@ -39,8 +39,10 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param parent The parent TemplateNode to execute searches from
|
* @param parent
|
||||||
* @param services The ServiceRegistry to use
|
* The parent TemplateNode to execute searches from
|
||||||
|
* @param services
|
||||||
|
* The ServiceRegistry to use
|
||||||
*/
|
*/
|
||||||
public BaseSearchResultsMap(TemplateNode parent, ServiceRegistry services)
|
public BaseSearchResultsMap(TemplateNode parent, ServiceRegistry services)
|
||||||
{
|
{
|
||||||
@@ -53,6 +55,7 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
|||||||
protected List<TemplateNode> query(String search)
|
protected List<TemplateNode> query(String search)
|
||||||
{
|
{
|
||||||
List<TemplateNode> nodes = null;
|
List<TemplateNode> nodes = null;
|
||||||
|
HashSet<NodeRef> nodeRefs = new HashSet<NodeRef>();
|
||||||
|
|
||||||
// check if a full Lucene search string has been supplied or extracted from XML
|
// check if a full Lucene search string has been supplied or extracted from XML
|
||||||
if (search != null && search.length() != 0)
|
if (search != null && search.length() != 0)
|
||||||
@@ -61,18 +64,20 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
|
|||||||
ResultSet results = null;
|
ResultSet results = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
results = this.services.getSearchService().query(
|
results = this.services.getSearchService().query(this.parent.getNodeRef().getStoreRef(),
|
||||||
this.parent.getNodeRef().getStoreRef(),
|
SearchService.LANGUAGE_LUCENE, search);
|
||||||
SearchService.LANGUAGE_LUCENE,
|
|
||||||
search);
|
|
||||||
|
|
||||||
if (results.length() != 0)
|
if (results.length() != 0)
|
||||||
{
|
{
|
||||||
nodes = new ArrayList<TemplateNode>(results.length());
|
nodes = new ArrayList<TemplateNode>(results.length());
|
||||||
for (ResultSetRow row: results)
|
for (ResultSetRow row : results)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = row.getNodeRef();
|
NodeRef nodeRef = row.getNodeRef();
|
||||||
|
if (!nodeRefs.contains(nodeRef))
|
||||||
|
{
|
||||||
nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
|
nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
|
||||||
|
nodeRefs.add(nodeRef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +94,6 @@ 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