mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
FIXED : ALF-11167: An image isn't displayed.
Now sets invalid priority values to the default value git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32753 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.alfresco.repo.workflow.AbstractWorkflowServiceIntegrationTest;
|
import org.alfresco.repo.workflow.AbstractWorkflowServiceIntegrationTest;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
||||||
@@ -101,6 +103,35 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ
|
|||||||
assertEquals("bpm_foo_task", taskName);
|
assertEquals("bpm_foo_task", taskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually tests if the priority is the default value. This is based on the assumption that custom
|
||||||
|
* tasks are defaulted to a priority of 50 (which is invalid). I'm testing that the code I wrote decides this is an
|
||||||
|
* invalid number and sets it to the default value (2).
|
||||||
|
*/
|
||||||
|
public void testPriorityIsValid()
|
||||||
|
{
|
||||||
|
WorkflowDefinition definition = deployDefinition("activiti/testCustomActiviti.bpmn20.xml");
|
||||||
|
|
||||||
|
personManager.setUser(USER1);
|
||||||
|
|
||||||
|
// Start the Workflow
|
||||||
|
WorkflowPath path = workflowService.startWorkflow(definition.getId(), null);
|
||||||
|
String instanceId = path.getInstance().getId();
|
||||||
|
|
||||||
|
// Check the Start Task is completed.
|
||||||
|
WorkflowTask startTask = workflowService.getStartTask(instanceId);
|
||||||
|
assertEquals(WorkflowTaskState.COMPLETED, startTask.getState());
|
||||||
|
|
||||||
|
List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId());
|
||||||
|
for (WorkflowTask workflowTask : tasks)
|
||||||
|
{
|
||||||
|
Map<QName, Serializable> props = workflowTask.getProperties();
|
||||||
|
TypeDefinition typeDefinition = workflowTask.getDefinition().getMetadata();
|
||||||
|
Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties();
|
||||||
|
PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY);
|
||||||
|
assertEquals(props.get(WorkflowModel.PROP_PRIORITY),Integer.valueOf(priorDef.getDefaultValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void checkTaskQueryStartTaskCompleted(String workflowInstanceId, WorkflowTask startTask)
|
protected void checkTaskQueryStartTaskCompleted(String workflowInstanceId, WorkflowTask startTask)
|
||||||
{
|
{
|
||||||
|
@@ -58,6 +58,8 @@ import org.alfresco.repo.workflow.activiti.ActivitiTaskTypeManager;
|
|||||||
import org.alfresco.repo.workflow.activiti.ActivitiUtil;
|
import org.alfresco.repo.workflow.activiti.ActivitiUtil;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.ClassAttributeDefinition;
|
import org.alfresco.service.cmr.dictionary.ClassAttributeDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ConstraintException;
|
||||||
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;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -70,6 +72,8 @@ import org.alfresco.util.collections.CollectionUtils;
|
|||||||
import org.alfresco.util.collections.EntryTransformer;
|
import org.alfresco.util.collections.EntryTransformer;
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nick Smith
|
* @author Nick Smith
|
||||||
@@ -77,6 +81,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class ActivitiPropertyConverter
|
public class ActivitiPropertyConverter
|
||||||
{
|
{
|
||||||
|
private static Log logger = LogFactory.getLog(ActivitiPropertyConverter.class);
|
||||||
private static final String ERR_CONVERT_VALUE = "activiti.engine.convert.value.error";
|
private static final String ERR_CONVERT_VALUE = "activiti.engine.convert.value.error";
|
||||||
private static final String ERR_SET_TASK_PROPS_INVALID_VALUE = "activiti.engine.set.task.properties.invalid.value";
|
private static final String ERR_SET_TASK_PROPS_INVALID_VALUE = "activiti.engine.set.task.properties.invalid.value";
|
||||||
private static final String ERR_MANDATORY_TASK_PROPERTIES_MISSING = "activiti.engine.mandatory.properties.missing";
|
private static final String ERR_MANDATORY_TASK_PROPERTIES_MISSING = "activiti.engine.mandatory.properties.missing";
|
||||||
@@ -376,6 +381,26 @@ public class ActivitiPropertyConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special case for property priorities
|
||||||
|
PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY);
|
||||||
|
Serializable existingValue = existingValues.get(WorkflowModel.PROP_PRIORITY);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (ConstraintDefinition constraintDef : priorDef.getConstraints())
|
||||||
|
{
|
||||||
|
constraintDef.getConstraint().evaluate(existingValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ConstraintException ce)
|
||||||
|
{
|
||||||
|
Integer defaultVal = Integer.valueOf(priorDef.getDefaultValue());
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Task priority value ("+existingValue+") was invalid so it was set to the default value of "+defaultVal+". Task:"+task.getName());
|
||||||
|
}
|
||||||
|
defaultValues.put(WorkflowModel.PROP_PRIORITY, defaultVal);
|
||||||
|
}
|
||||||
|
|
||||||
// Special case for task description default value
|
// Special case for task description default value
|
||||||
String description = (String) existingValues.get(WorkflowModel.PROP_DESCRIPTION);
|
String description = (String) existingValues.get(WorkflowModel.PROP_DESCRIPTION);
|
||||||
if (description == null || description.length() == 0)
|
if (description == null || description.length() == 0)
|
||||||
|
13
source/test-resources/activiti/testCustomActiviti.bpmn20.xml
Normal file
13
source/test-resources/activiti/testCustomActiviti.bpmn20.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
|
||||||
|
<process id="MyProcess" name="MyProcess">
|
||||||
|
<documentation>Custom activiti, created to test that the priority is automatically set to an allowed value e.g. change from 50 to 2.</documentation>
|
||||||
|
<startEvent id="alfrescoStartevent1" name="Alfresco start"></startEvent>
|
||||||
|
<userTask id="alfrescoUsertask1" name="Alfresco User Task">
|
||||||
|
<documentation>hello e</documentation>
|
||||||
|
</userTask>
|
||||||
|
<sequenceFlow id="flow1" name="" sourceRef="alfrescoStartevent1" targetRef="alfrescoUsertask1"></sequenceFlow>
|
||||||
|
<endEvent id="endevent1" name="End"></endEvent>
|
||||||
|
<sequenceFlow id="flow3" name="" sourceRef="alfrescoUsertask1" targetRef="endevent1"></sequenceFlow>
|
||||||
|
</process>
|
||||||
|
</definitions>
|
Reference in New Issue
Block a user