mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Workflow:
- additional task model properties for task action groups - fix issue persisting and retrieving noderef lists in jbpm (as found by Gav) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3566 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<!-- Imports are required to allow references to definitions in other models -->
|
<!-- Imports are required to allow references to definitions in other models -->
|
||||||
<imports>
|
<imports>
|
||||||
<!-- Import Alfresco Dictionary Definitions -->
|
<!-- Import Alfresco Dictionary Definitions -->
|
||||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
||||||
<!-- Import Alfresco Content Domain Model Definitions -->
|
<!-- Import Alfresco Content Domain Model Definitions -->
|
||||||
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
|
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
|
||||||
@@ -76,6 +76,7 @@
|
|||||||
<title>Task Identifier</title>
|
<title>Task Identifier</title>
|
||||||
<type>d:long</type>
|
<type>d:long</type>
|
||||||
<protected>true</protected>
|
<protected>true</protected>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -103,6 +104,8 @@
|
|||||||
<title>Status</title>
|
<title>Status</title>
|
||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
<protected>true</protected>
|
<protected>true</protected>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<default>Not Yet Started</default>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint ref="bpm:allowedStatus"/>
|
<constraint ref="bpm:allowedStatus"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -110,6 +113,8 @@
|
|||||||
<property name="bpm:priority">
|
<property name="bpm:priority">
|
||||||
<title>Priority</title>
|
<title>Priority</title>
|
||||||
<type>d:int</type>
|
<type>d:int</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<default>2</default>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint ref="bpm:allowedPriority"/>
|
<constraint ref="bpm:allowedPriority"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -117,6 +122,8 @@
|
|||||||
<property name="bpm:percentComplete">
|
<property name="bpm:percentComplete">
|
||||||
<title>Percentage Complete</title>
|
<title>Percentage Complete</title>
|
||||||
<type>d:int</type>
|
<type>d:int</type>
|
||||||
|
<mandatory>true</mandatory>
|
||||||
|
<default>0</default>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint ref="bpm:percentage"/>
|
<constraint ref="bpm:percentage"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -176,23 +183,35 @@
|
|||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
<!-- Task Context -->
|
<!-- Task Context -->
|
||||||
<!-- e.g. Space, Document -->
|
<!-- e.g. Space, Document -->
|
||||||
<!-- -->
|
|
||||||
<property name="bpm:context">
|
<property name="bpm:context">
|
||||||
<title>Task Context</title>
|
<title>Task Context</title>
|
||||||
<type>d:noderef</type>
|
<type>d:noderef</type>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<!-- Task Outcome -->
|
||||||
|
<property name="bpm:outcome">
|
||||||
|
<title>Task Outcome</title>
|
||||||
|
<type>d:text</type> <!-- Transition id -->
|
||||||
|
</property>
|
||||||
|
|
||||||
<!-- Items within package marked as complete -->
|
<!-- Items within package marked as complete -->
|
||||||
<property name="bpm:completedItems">
|
<property name="bpm:completedItems">
|
||||||
<type>d:noderef</type>
|
<type>d:noderef</type>
|
||||||
<multiple>true</multiple>
|
<multiple>true</multiple>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<!-- TODO: Add Package Action Group -->
|
<!-- Applicable actions for workflow package -->
|
||||||
|
<property name="bpm:packageActionGroup">
|
||||||
|
<type>d:text</type>
|
||||||
|
</property>
|
||||||
|
|
||||||
|
<!-- Applicable actions for workflow package item -->
|
||||||
|
<property name="bpm:packageItemActionGroup">
|
||||||
|
<type>d:text</type>
|
||||||
|
<default>workflow_item_read_actions</default>
|
||||||
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<associations>
|
<associations>
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
<property name="wf:reviewPriority">
|
<property name="wf:reviewPriority">
|
||||||
<title>Review Priority</title>
|
<title>Review Priority</title>
|
||||||
<type>d:int</type>
|
<type>d:int</type>
|
||||||
|
<default>2</default>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint ref="bpm:allowedPriority"/>
|
<constraint ref="bpm:allowedPriority"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -60,6 +61,37 @@
|
|||||||
|
|
||||||
</associations>
|
</associations>
|
||||||
|
|
||||||
|
<overrides>
|
||||||
|
|
||||||
|
<property name="wf:packageActionGroup">
|
||||||
|
<default>workflow_collection_actions</default>
|
||||||
|
</property>
|
||||||
|
|
||||||
|
<property name="wf:packageItemActionGroup">
|
||||||
|
<default>workflow_item_collection_actions</default>
|
||||||
|
</property>
|
||||||
|
|
||||||
|
</overrides>
|
||||||
|
|
||||||
|
</type>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Basic Review & Approve Tasks -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<type name="wf:reviewTask">
|
||||||
|
<title>Review Task</title>
|
||||||
|
<parent>bpm:workflowTask</parent>
|
||||||
|
|
||||||
|
<overrides>
|
||||||
|
|
||||||
|
<property name="wf:packageItemActionGroup">
|
||||||
|
<default>workflow_item_edit_actions</default>
|
||||||
|
</property>
|
||||||
|
|
||||||
|
</overrides>
|
||||||
|
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
</types>
|
</types>
|
||||||
|
@@ -20,6 +20,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -39,6 +40,7 @@ import org.alfresco.repo.workflow.WorkflowModel;
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
@@ -1131,10 +1133,20 @@ public class JBPMEngine extends BPMEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert property value
|
// convert property value
|
||||||
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
|
if (value instanceof Collection)
|
||||||
if (value instanceof NodeRef)
|
|
||||||
{
|
{
|
||||||
value = new JBPMNode((NodeRef)value, serviceRegistry);
|
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), (Collection)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert NodeRefs to JBPMNodes
|
||||||
|
DataTypeDefinition dataTypeDef = propDef.getDataType();
|
||||||
|
if (dataTypeDef.getName().equals(DataTypeDefinition.NODE_REF))
|
||||||
|
{
|
||||||
|
value = convertNodeRefs(propDef.isMultiValued(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// map property to specific jBPM task instance field
|
// map property to specific jBPM task instance field
|
||||||
@@ -1173,7 +1185,7 @@ public class JBPMEngine extends BPMEngine
|
|||||||
if (assocDef != null)
|
if (assocDef != null)
|
||||||
{
|
{
|
||||||
// convert association to JBPMNodes
|
// convert association to JBPMNodes
|
||||||
value = convertAssociation(assocDef, value);
|
value = convertNodeRefs(assocDef.isTargetMany(), value);
|
||||||
|
|
||||||
// map association to specific jBPM task instance field
|
// map association to specific jBPM task instance field
|
||||||
if (key.equals(WorkflowModel.ASSOC_POOLED_ACTORS))
|
if (key.equals(WorkflowModel.ASSOC_POOLED_ACTORS))
|
||||||
@@ -1222,14 +1234,12 @@ public class JBPMEngine extends BPMEngine
|
|||||||
/**
|
/**
|
||||||
* Convert a Repository association to JBPMNodeList or JBPMNode
|
* Convert a Repository association to JBPMNodeList or JBPMNode
|
||||||
*
|
*
|
||||||
* @param assocDef association definition
|
* @param isMany true => force conversion to list
|
||||||
* @param value value to convert
|
* @param value value to convert
|
||||||
* @return JBPMNodeList or JBPMNode
|
* @return JBPMNodeList or JBPMNode
|
||||||
*/
|
*/
|
||||||
private Serializable convertAssociation(AssociationDefinition assocDef, Serializable value)
|
private Serializable convertNodeRefs(boolean isMany, Serializable value)
|
||||||
{
|
{
|
||||||
boolean isMany = assocDef.isTargetMany();
|
|
||||||
|
|
||||||
if (value instanceof NodeRef)
|
if (value instanceof NodeRef)
|
||||||
{
|
{
|
||||||
if (isMany)
|
if (isMany)
|
||||||
@@ -1244,8 +1254,7 @@ public class JBPMEngine extends BPMEngine
|
|||||||
value = new JBPMNode((NodeRef)value, serviceRegistry);
|
value = new JBPMNode((NodeRef)value, serviceRegistry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (value instanceof List)
|
||||||
if (value instanceof List)
|
|
||||||
{
|
{
|
||||||
if (isMany)
|
if (isMany)
|
||||||
{
|
{
|
||||||
|
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.jbpm.context.exe.Converter;
|
import org.jbpm.context.exe.converter.SerializableToByteArrayConverter;
|
||||||
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
import org.springframework.beans.factory.access.BeanFactoryLocator;
|
||||||
import org.springframework.beans.factory.access.BeanFactoryReference;
|
import org.springframework.beans.factory.access.BeanFactoryReference;
|
||||||
import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
||||||
@@ -32,7 +32,7 @@ import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
|||||||
*
|
*
|
||||||
* @author davidc
|
* @author davidc
|
||||||
*/
|
*/
|
||||||
public class NodeListConverter implements Converter
|
public class NodeListConverter extends SerializableToByteArrayConverter
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -65,7 +65,7 @@ public class NodeListConverter implements Converter
|
|||||||
{
|
{
|
||||||
values.add(node.getNodeRef());
|
values.add(node.getNodeRef());
|
||||||
}
|
}
|
||||||
converted = values;
|
converted = super.convert(values);
|
||||||
}
|
}
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
@@ -79,10 +79,10 @@ public class NodeListConverter implements Converter
|
|||||||
Object reverted = null;
|
Object reverted = null;
|
||||||
if (o != null)
|
if (o != null)
|
||||||
{
|
{
|
||||||
|
List<NodeRef> nodeRefs = (List<NodeRef>)super.revert(o);
|
||||||
BeanFactoryReference factory = jbpmFactoryLocator.useBeanFactory(null);
|
BeanFactoryReference factory = jbpmFactoryLocator.useBeanFactory(null);
|
||||||
ServiceRegistry serviceRegistry = (ServiceRegistry)factory.getFactory().getBean(ServiceRegistry.SERVICE_REGISTRY);
|
ServiceRegistry serviceRegistry = (ServiceRegistry)factory.getFactory().getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
|
|
||||||
List<NodeRef> nodeRefs = (List<NodeRef>)o;
|
|
||||||
JBPMNodeList nodes = new JBPMNodeList();
|
JBPMNodeList nodes = new JBPMNodeList();
|
||||||
for (NodeRef nodeRef : nodeRefs)
|
for (NodeRef nodeRef : nodeRefs)
|
||||||
{
|
{
|
||||||
|
@@ -119,6 +119,34 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
assertEquals(reviewDueDate, assignedTasks.get(0).properties.get(WorkflowModel.PROP_DUE_DATE));
|
assertEquals(reviewDueDate, assignedTasks.get(0).properties.get(WorkflowModel.PROP_DUE_DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCompletedItems()
|
||||||
|
{
|
||||||
|
WorkflowDefinition workflowDef = testWorkflowDef;
|
||||||
|
|
||||||
|
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
||||||
|
nodeRefs.add(testNodeRef);
|
||||||
|
nodeRefs.add(testNodeRef);
|
||||||
|
|
||||||
|
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
||||||
|
params.put(WorkflowModel.ASSOC_PACKAGE, testNodeRef);
|
||||||
|
params.put(WorkflowModel.PROP_COMPLETED_ITEMS, (Serializable)nodeRefs);
|
||||||
|
Date reviewDueDate = new Date();
|
||||||
|
params.put(QName.createQName("http://www.alfresco.org/model/workflow/1.0", "reviewDueDate"), reviewDueDate);
|
||||||
|
NodeRef reviewer = personService.getPerson("admin");
|
||||||
|
params.put(QName.createQName("http://www.alfresco.org/model/workflow/1.0", "reviewer"), reviewer);
|
||||||
|
|
||||||
|
WorkflowPath path = workflowComponent.startWorkflow(workflowDef.id, params);
|
||||||
|
assertNotNull(path);
|
||||||
|
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.id);
|
||||||
|
assertNotNull(tasks1);
|
||||||
|
assertEquals(1, tasks1.size());
|
||||||
|
|
||||||
|
WorkflowTask task = tasks1.get(0);
|
||||||
|
assertTrue(task.properties.containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
||||||
|
assertEquals(2, ((List)task.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter task list by workflow instance
|
* Filter task list by workflow instance
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user