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:
@@ -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