mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Added the notion of actions only being applicable for certain node types
- 'Run Action' is now available on folder details page git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2837 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
*/
|
||||
package org.alfresco.repo.action;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Rule action implementation class
|
||||
@@ -35,6 +38,9 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
|
||||
* The rule action executor
|
||||
*/
|
||||
private String ruleActionExecutor;
|
||||
|
||||
/** List of applicable types */
|
||||
private List<QName> applicableTypes;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -65,4 +71,24 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
|
||||
{
|
||||
return ruleActionExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of applicable types
|
||||
*
|
||||
* @return the list of qnames
|
||||
*/
|
||||
public List<QName> getApplicableTypes()
|
||||
{
|
||||
return this.applicableTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of applicable types
|
||||
*
|
||||
* @param applicableTypes the applicable types
|
||||
*/
|
||||
public void setApplicableTypes(List<QName> applicableTypes)
|
||||
{
|
||||
this.applicableTypes = applicableTypes;
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.action.ActionServiceException;
|
||||
import org.alfresco.service.cmr.action.CompositeAction;
|
||||
import org.alfresco.service.cmr.action.ParameterizedItem;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -98,6 +99,9 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
||||
*/
|
||||
private SearchService searchService;
|
||||
|
||||
/** The dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/** The authentication component */
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
@@ -161,6 +165,16 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
||||
this.authenticationComponent = authenticationComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary service
|
||||
*
|
||||
* @param dictionaryService the dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the asynchronous action execution queue
|
||||
*
|
||||
@@ -217,6 +231,44 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
|
||||
{
|
||||
return new ArrayList<ActionDefinition>(this.actionDefinitions.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ActionService#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
return getActionDefinitions();
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO for now we will only filter by type, we will introduce filtering by aspect later
|
||||
QName nodeType = this.nodeService.getType(nodeRef);
|
||||
List<ActionDefinition> result = new ArrayList<ActionDefinition>();
|
||||
for (ActionDefinition actionDefinition : getActionDefinitions())
|
||||
{
|
||||
List<QName> appliciableTypes = actionDefinition.getApplicableTypes();
|
||||
if (appliciableTypes != null && appliciableTypes.isEmpty() == false)
|
||||
{
|
||||
for (QName applicableType : actionDefinition.getApplicableTypes())
|
||||
{
|
||||
if (this.dictionaryService.isSubClass(nodeType, applicableType))
|
||||
{
|
||||
result.add(actionDefinition);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.add(actionDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ActionService#getActionConditionDefinition(java.lang.String)
|
||||
|
@@ -55,6 +55,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
||||
private static final String BAD_NAME = "badName";
|
||||
|
||||
private NodeRef nodeRef;
|
||||
private NodeRef folder;
|
||||
|
||||
@Override
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
@@ -71,6 +72,12 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
||||
this.nodeRef,
|
||||
ContentModel.PROP_CONTENT,
|
||||
new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
|
||||
this.folder = this.nodeService.createNode(
|
||||
this.rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}testFolder"),
|
||||
ContentModel.TYPE_FOLDER).getChildRef();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,11 +101,17 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
||||
List<ActionDefinition> defintions = this.actionService.getActionDefinitions();
|
||||
assertNotNull(defintions);
|
||||
assertFalse(defintions.isEmpty());
|
||||
int totalCount = defintions.size();
|
||||
|
||||
for (ActionDefinition definition : defintions)
|
||||
{
|
||||
System.out.println(definition.getTitle());
|
||||
}
|
||||
|
||||
// Get the action defintions for a folder type (there should be less than the total available)
|
||||
List<ActionDefinition> definitions = this.actionService.getActionDefinitions(this.folder);
|
||||
assertNotNull(definitions);
|
||||
assertTrue(totalCount > definitions.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,11 +16,15 @@
|
||||
*/
|
||||
package org.alfresco.repo.action.executer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.action.ActionDefinitionImpl;
|
||||
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Rule action executor abstract base.
|
||||
@@ -38,6 +42,9 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
||||
* Indicated whether the action is public or internal
|
||||
*/
|
||||
protected boolean publicAction = true;
|
||||
|
||||
/** List of types and aspects for which this action is applicable */
|
||||
protected List<QName> applicableTypes = new ArrayList<QName>();
|
||||
|
||||
/**
|
||||
* Init method
|
||||
@@ -59,6 +66,19 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
||||
{
|
||||
this.publicAction = publicAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of types for which this action is applicable
|
||||
*
|
||||
* @param applicableTypes arry of applicable types
|
||||
*/
|
||||
public void setApplicableTypes(String[] applicableTypes)
|
||||
{
|
||||
for (String type : applicableTypes)
|
||||
{
|
||||
this.applicableTypes.add(QName.createQName(type));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rule action definition
|
||||
@@ -75,6 +95,7 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
||||
((ActionDefinitionImpl)this.actionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
|
||||
((ActionDefinitionImpl)this.actionDefinition).setRuleActionExecutor(this.name);
|
||||
((ActionDefinitionImpl)this.actionDefinition).setParameterDefinitions(getParameterDefintions());
|
||||
((ActionDefinitionImpl)this.actionDefinition).setApplicableTypes(this.applicableTypes);
|
||||
}
|
||||
return this.actionDefinition;
|
||||
}
|
||||
|
Reference in New Issue
Block a user