Search in sources :

Example 56 with AssociationDefinition

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;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) QName(org.alfresco.service.namespace.QName) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Example 57 with AssociationDefinition

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);
}
Also used : Serializable(java.io.Serializable) AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) ActivitiScriptNode(org.alfresco.repo.workflow.activiti.ActivitiScriptNode) QName(org.alfresco.service.namespace.QName) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 58 with AssociationDefinition

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;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName)

Example 59 with AssociationDefinition

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;
}
Also used : AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) QName(org.alfresco.service.namespace.QName) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition)

Example 60 with AssociationDefinition

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;
}
Also used : MockClassAttributeDefinition(org.alfresco.repo.forms.processor.node.MockClassAttributeDefinition) AssociationDefinition(org.alfresco.service.cmr.dictionary.AssociationDefinition) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName)

Aggregations

AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)60 QName (org.alfresco.service.namespace.QName)46 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)24 ChildAssociationDefinition (org.alfresco.service.cmr.dictionary.ChildAssociationDefinition)19 NodeRef (org.alfresco.service.cmr.repository.NodeRef)17 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)15 HashMap (java.util.HashMap)13 Serializable (java.io.Serializable)11 ArrayList (java.util.ArrayList)11 ClassDefinition (org.alfresco.service.cmr.dictionary.ClassDefinition)9 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)7 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)6 AspectDefinition (org.alfresco.service.cmr.dictionary.AspectDefinition)6 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)6 Collection (java.util.Collection)5 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Map (java.util.Map)4 Pair (org.alfresco.util.Pair)3