Tagging Service: Complete JS and Java APIs

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9689 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-07-08 16:58:56 +00:00
parent 0d61ec6542
commit 8f1c38fcf7
13 changed files with 660 additions and 44 deletions

View File

@@ -26,6 +26,7 @@ package org.alfresco.repo.jscript;
import java.io.StringReader;
import java.util.LinkedHashSet;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
@@ -354,6 +355,36 @@ public final class Search extends BaseScopableProcessorExtension
return Context.getCurrentContext().newArray(getScope(), 0);
}
}
/**
* Searchs the store for all nodes with the given tag applied.
*
* @param store store ref string, default used if null provided
* @param tag tag name
* @return ScriptNode[] nodes with tag applied
*/
public ScriptNode[] tagSearch(String store, String tag)
{
StoreRef searchStoreRef = null;
if (store != null)
{
searchStoreRef = new StoreRef(store);
}
else
{
searchStoreRef = this.storeRef;
}
List<NodeRef> nodeRefs = this.services.getTaggingService().findTaggedNodes(searchStoreRef, tag);
ScriptNode[] nodes = new ScriptNode[nodeRefs.size()];
int index = 0;
for (NodeRef node : nodeRefs)
{
nodes[index] = new ScriptNode(node, this.services, getScope());
index ++;
}
return nodes;
}
/**
* Execute the query