use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.
the class WorkflowFormProcessorTest method makeTypeDef.
private TypeDefinition makeTypeDef() {
TypeDefinition typeDef = mock(TypeDefinition.class);
QName name = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, TASK_DEF_NAME);
when(typeDef.getName()).thenReturn(name);
// Set up task property definitions
Map<QName, PropertyDefinition> propertyDefs = makeTaskPropertyDefs();
when(typeDef.getProperties()).thenReturn(propertyDefs);
// Set up task association definitions.
Map<QName, AssociationDefinition> associationDefs = makeTaskAssociationDefs();
when(typeDef.getAssociations()).thenReturn(associationDefs);
return typeDef;
}
use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.
the class ActivitiPropertyConverter method getStartTaskProperties.
public Map<QName, Serializable> getStartTaskProperties(HistoricProcessInstance historicProcessInstance, String taskDefId, boolean completed) {
TypeDefinition taskDef = typeManager.getStartTaskDefinition(taskDefId);
Map<QName, PropertyDefinition> taskProperties = taskDef.getProperties();
Map<QName, AssociationDefinition> taskAssociations = taskDef.getAssociations();
Map<String, Object> variables = getStartVariables(historicProcessInstance);
// Map all the properties
Map<QName, Serializable> properties = mapArbitraryProperties(variables, variables, taskProperties, taskAssociations);
// Map activiti task instance fields to properties
properties.put(WorkflowModel.PROP_TASK_ID, ActivitiConstants.START_TASK_PREFIX + historicProcessInstance.getId());
properties.put(WorkflowModel.PROP_START_DATE, historicProcessInstance.getStartTime());
// Use workflow due-date at the time of starting the process
String wfDueDateKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_DUE_DATE);
String dueDateKey = factory.mapQNameToName(WorkflowModel.PROP_DUE_DATE);
Serializable dueDate = (Serializable) variables.get(wfDueDateKey);
if (dueDate == null) {
dueDate = (Serializable) variables.get(dueDateKey);
}
properties.put(WorkflowModel.PROP_DUE_DATE, dueDate);
// TODO: is it okay to use start-date?
properties.put(WorkflowModel.PROP_COMPLETION_DATE, historicProcessInstance.getStartTime());
// Use workflow priority at the time of starting the process
String priorityKey = factory.mapQNameToName(WorkflowModel.PROP_PRIORITY);
Serializable priority = (Serializable) variables.get(priorityKey);
if (priority == null) {
String wfPriorityKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_PRIORITY);
priority = (Serializable) variables.get(wfPriorityKey);
}
properties.put(WorkflowModel.PROP_PRIORITY, priority);
properties.put(ContentModel.PROP_CREATED, historicProcessInstance.getStartTime());
// Use initiator username as owner
ActivitiScriptNode ownerNode = (ActivitiScriptNode) variables.get(WorkflowConstants.PROP_INITIATOR);
if (ownerNode != null && ownerNode.exists()) {
properties.put(ContentModel.PROP_OWNER, (Serializable) ownerNode.getProperties().get("userName"));
}
if (completed) {
// Override default 'Not Yet Started' when start-task is completed
properties.put(WorkflowModel.PROP_STATUS, WorkflowConstants.TASK_STATUS_COMPLETED);
// Outcome is default transition
properties.put(WorkflowModel.PROP_OUTCOME, ActivitiConstants.DEFAULT_TRANSITION_NAME);
}
return filterTaskProperties(properties);
}
use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.
the class FieldProcessorTest method makeAssociationDefs.
private Map<QName, AssociationDefinition> makeAssociationDefs() {
QName targetClass = QName.createQName(URI, "Target");
AssociationDefinition assocDef1 = MockClassAttributeDefinition.mockAssociationDefinition(qName1, targetClass, // Defalt title, so sets label to be same as name.
null, DESCRIPTION1, false, false, false);
MockClassAttributeDefinition assocDef2 = MockClassAttributeDefinition.mockAssociationDefinition(qName2, targetClass, TITLE, DESCRIPTION2, true, true, true);
Map<QName, AssociationDefinition> assocDefs = new HashMap<QName, AssociationDefinition>();
assocDefs.put(qName1, assocDef1);
assocDefs.put(qName2, assocDef2);
return assocDefs;
}
use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.
the class TaskFormProcessorTest method makeTypeDef.
private TypeDefinition makeTypeDef() {
TypeDefinition typeDef = mock(TypeDefinition.class);
QName name = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, TASK_DEF_NAME);
when(typeDef.getName()).thenReturn(name);
// Set up task property definitions
Map<QName, PropertyDefinition> propertyDefs = makeTaskPropertyDefs();
when(typeDef.getProperties()).thenReturn(propertyDefs);
// Set up task association definitions.
Map<QName, AssociationDefinition> associationDefs = makeTaskAssociationDefs();
when(typeDef.getAssociations()).thenReturn(associationDefs);
return typeDef;
}
use of org.alfresco.service.cmr.dictionary.AssociationDefinition in project alfresco-repository by Alfresco.
the class FormProcessorTest method makeTaskAssociationDefs.
protected Map<QName, AssociationDefinition> makeTaskAssociationDefs() {
Map<QName, AssociationDefinition> associations = new HashMap<QName, AssociationDefinition>();
QName actorName = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "Actor");
// Add Assigneee association
MockClassAttributeDefinition assigneeDef = MockClassAttributeDefinition.mockAssociationDefinition(ASSIGNEE_NAME, actorName);
associations.put(ASSIGNEE_NAME, assigneeDef);
// Add Assigneee association
MockClassAttributeDefinition actorsDef = MockClassAttributeDefinition.mockAssociationDefinition(ACTORS_NAME, actorName);
associations.put(ACTORS_NAME, actorsDef);
// Add association with _
MockClassAttributeDefinition with_ = MockClassAttributeDefinition.mockAssociationDefinition(ASSOC_WITH_, actorName);
associations.put(ASSOC_WITH_, with_);
return associations;
}
Aggregations