mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9252 - SVC 58: Apply contribution for category management services
* Contribution from Jan Pfitzner * Merged Util methods into core category JS API * Light refactor of category web scripts to align them better with other Alfresco web scripts and add them to the repository API * Minor bug fixes/tweaks to UI (added title, I18N, adjust to use modified webscripts, etc) TODO: modify results from webscripts to bring inline with other webscripts in API (will take into consideration tag manager first) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29264 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,12 +35,14 @@ import org.mozilla.javascript.Scriptable;
|
|||||||
*/
|
*/
|
||||||
public class CategoryNode extends ScriptNode
|
public class CategoryNode extends ScriptNode
|
||||||
{
|
{
|
||||||
|
/** Serial version UID */
|
||||||
|
private static final long serialVersionUID = 5757485873550742331L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param nodeRef
|
* @param nodeRef node reference
|
||||||
* @param services
|
* @param services service registry
|
||||||
* @param resolver
|
|
||||||
*/
|
*/
|
||||||
public CategoryNode(NodeRef nodeRef, ServiceRegistry services)
|
public CategoryNode(NodeRef nodeRef, ServiceRegistry services)
|
||||||
{
|
{
|
||||||
@@ -50,10 +52,9 @@ public class CategoryNode extends ScriptNode
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param nodeRef
|
* @param nodeRef node reference
|
||||||
* @param services
|
* @param services service registry
|
||||||
* @param resolver
|
* @param scope scriptable scope
|
||||||
* @param scope
|
|
||||||
*/
|
*/
|
||||||
public CategoryNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
public CategoryNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
|
||||||
{
|
{
|
||||||
@@ -119,6 +120,25 @@ public class CategoryNode extends ScriptNode
|
|||||||
{
|
{
|
||||||
return new CategoryNode(services.getCategoryService().createCategory(getNodeRef(), name), this.services, this.scope);
|
return new CategoryNode(services.getCategoryService().createCategory(getNodeRef(), name), this.services, this.scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames the category.
|
||||||
|
*
|
||||||
|
* @param name new cateogory name
|
||||||
|
*/
|
||||||
|
public void rename(String name)
|
||||||
|
{
|
||||||
|
// Rename the category node
|
||||||
|
services.getNodeService().setProperty(getNodeRef(), ContentModel.PROP_NAME, name);
|
||||||
|
|
||||||
|
// ALF-1788 Need to rename the association
|
||||||
|
ChildAssociationRef assocRef = services.getNodeService().getPrimaryParent(nodeRef);
|
||||||
|
if (assocRef != null)
|
||||||
|
{
|
||||||
|
QName qname = QName.createQName(assocRef.getQName().getNamespaceURI(), QName.createValidLocalName(name));
|
||||||
|
services.getNodeService().moveNode(assocRef.getChildRef(), assocRef.getParentRef(), assocRef.getTypeQName(), qname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove this category
|
* Remove this category
|
||||||
@@ -128,12 +148,23 @@ public class CategoryNode extends ScriptNode
|
|||||||
services.getCategoryService().deleteCategory(getNodeRef());
|
services.getCategoryService().deleteCategory(getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this is a category or not.
|
||||||
|
*
|
||||||
|
* @return boolean true if category, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getIsCategory()
|
public boolean getIsCategory()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build category nodes from collection of association references.
|
||||||
|
*
|
||||||
|
* @param cars
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private CategoryNode[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
private CategoryNode[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
||||||
{
|
{
|
||||||
CategoryNode[] categoryNodes = new CategoryNode[cars.size()];
|
CategoryNode[] categoryNodes = new CategoryNode[cars.size()];
|
||||||
@@ -145,6 +176,12 @@ public class CategoryNode extends ScriptNode
|
|||||||
return categoryNodes;
|
return categoryNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build script nodes from a collection of association references.
|
||||||
|
*
|
||||||
|
* @param cars
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private ScriptNode[] buildNodes(Collection<ChildAssociationRef> cars)
|
private ScriptNode[] buildNodes(Collection<ChildAssociationRef> cars)
|
||||||
{
|
{
|
||||||
ScriptNode[] nodes = new ScriptNode[cars.size()];
|
ScriptNode[] nodes = new ScriptNode[cars.size()];
|
||||||
@@ -156,6 +193,12 @@ public class CategoryNode extends ScriptNode
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build script nodes and category nodes from a mixed collection of association references.
|
||||||
|
*
|
||||||
|
* @param cars
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private ScriptNode[] buildMixedNodes(Collection<ChildAssociationRef> cars)
|
private ScriptNode[] buildMixedNodes(Collection<ChildAssociationRef> cars)
|
||||||
{
|
{
|
||||||
ScriptNode[] nodes = new ScriptNode[cars.size()];
|
ScriptNode[] nodes = new ScriptNode[cars.size()];
|
||||||
|
@@ -21,6 +21,7 @@ package org.alfresco.repo.jscript;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -105,6 +106,24 @@ public final class Classification extends BaseScopableProcessorExtension
|
|||||||
|
|
||||||
return categoryNode;
|
return categoryNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the category node from the category node reference.
|
||||||
|
*
|
||||||
|
* @param categoryRef category node reference
|
||||||
|
* @return {@link CategoryNode} category node
|
||||||
|
*/
|
||||||
|
public CategoryNode getCategory(String categoryRef)
|
||||||
|
{
|
||||||
|
CategoryNode result = null;
|
||||||
|
NodeRef categoryNodeRef = new NodeRef(categoryRef);
|
||||||
|
if (services.getNodeService().exists(categoryNodeRef) == true &&
|
||||||
|
services.getDictionaryService().isSubClass(ContentModel.TYPE_CATEGORY, services.getNodeService().getType(categoryNodeRef)) == true)
|
||||||
|
{
|
||||||
|
result = new CategoryNode(categoryNodeRef, this.services, getScope());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the root categories in a classification.
|
* Get the root categories in a classification.
|
||||||
@@ -139,6 +158,12 @@ public final class Classification extends BaseScopableProcessorExtension
|
|||||||
return Context.getCurrentContext().newArray(getScope(), tags);
|
return Context.getCurrentContext().newArray(getScope(), tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build category nodes.
|
||||||
|
*
|
||||||
|
* @param cars list of associations to category nodes
|
||||||
|
* @return {@link Object}[] array of category nodes
|
||||||
|
*/
|
||||||
private Object[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
private Object[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
||||||
{
|
{
|
||||||
Object[] categoryNodes = new Object[cars.size()];
|
Object[] categoryNodes = new Object[cars.size()];
|
||||||
@@ -150,6 +175,12 @@ public final class Classification extends BaseScopableProcessorExtension
|
|||||||
return categoryNodes;
|
return categoryNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create QName from string
|
||||||
|
*
|
||||||
|
* @param s QName string value
|
||||||
|
* @return {@link QName} qualified name object
|
||||||
|
*/
|
||||||
private QName createQName(String s)
|
private QName createQName(String s)
|
||||||
{
|
{
|
||||||
QName qname;
|
QName qname;
|
||||||
|
Reference in New Issue
Block a user