Search in sources :

Example 1 with WorkflowTaskDefinition

use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.

the class WorkflowModelBuilderTest method testBuildWorkflowTaskDetailed.

@SuppressWarnings("unchecked")
public void testBuildWorkflowTaskDetailed() throws Exception {
    Date date = new Date();
    WorkflowTask workflowTask = makeTask(date);
    Map<String, Object> model = builder.buildDetailed(workflowTask);
    Object id = model.get(WorkflowModelBuilder.TASK_ID);
    assertEquals(workflowTask.getId(), id);
    Object url = model.get(WorkflowModelBuilder.TASK_URL);
    assertEquals("api/task-instances/" + workflowTask.getId(), url);
    assertEquals(workflowTask.getName(), model.get(WorkflowModelBuilder.TASK_NAME));
    assertEquals(workflowTask.getTitle(), model.get(WorkflowModelBuilder.TASK_TITLE));
    assertEquals(workflowTask.getDescription(), model.get(WorkflowModelBuilder.TASK_DESCRIPTION));
    assertEquals(workflowTask.getState().name(), model.get(WorkflowModelBuilder.TASK_STATE));
    assertEquals(false, model.get(WorkflowModelBuilder.TASK_IS_POOLED));
    Map<String, Object> owner = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_OWNER);
    assertEquals(userName, owner.get(WorkflowModelBuilder.PERSON_USER_NAME));
    assertEquals(firstName, owner.get(WorkflowModelBuilder.PERSON_FIRST_NAME));
    assertEquals(lastName, owner.get(WorkflowModelBuilder.PERSON_LAST_NAME));
    Map<String, Object> props = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_PROPERTIES);
    assertEquals(workflowTask.getProperties().size() + 1, props.size());
    Map<String, Object> workflowInstance = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE);
    WorkflowInstance instance = workflowTask.getPath().getInstance();
    assertEquals(instance.getId(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_ID));
    assertEquals(instance.isActive(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_IS_ACTIVE));
    String startDateStr = ISO8601DateFormat.format(instance.getStartDate());
    String startDateBuilderStr = ISO8601DateFormat.formatToZulu((String) workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_START_DATE));
    assertEquals(startDateStr, startDateBuilderStr);
    WorkflowDefinition workflowDef = instance.getDefinition();
    assertEquals(workflowDef.getName(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_NAME));
    assertEquals(workflowDef.getTitle(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_TITLE));
    assertEquals(workflowDef.getDescription(), workflowInstance.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_DESCRIPTION));
    Map<String, Object> actualDefinition = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_DEFINITION);
    WorkflowTaskDefinition taskDef = workflowTask.getDefinition();
    assertEquals(taskDef.getId(), actualDefinition.get(WorkflowModelBuilder.TASK_DEFINITION_ID));
    Map<String, Object> actualType = (Map<String, Object>) actualDefinition.get(WorkflowModelBuilder.TASK_DEFINITION_TYPE);
    TypeDefinition taskType = taskDef.getMetadata();
    assertEquals(taskType.getName(), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_NAME));
    assertEquals(taskType.getTitle(dictionaryService), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_TITLE));
    assertEquals(taskType.getDescription(dictionaryService), actualType.get(WorkflowModelBuilder.TYPE_DEFINITION_DESCRIPTION));
    Map<String, Object> actualNode = (Map<String, Object>) actualDefinition.get(WorkflowModelBuilder.TASK_DEFINITION_NODE);
    WorkflowNode taskNode = taskDef.getNode();
    assertEquals(taskNode.getName(), actualNode.get(WorkflowModelBuilder.WORKFLOW_NODE_NAME));
    assertEquals(taskNode.getTitle(), actualNode.get(WorkflowModelBuilder.WORKFLOW_NODE_TITLE));
    assertEquals(taskNode.getDescription(), actualNode.get(WorkflowModelBuilder.WORKFLOW_NODE_DESCRIPTION));
    assertEquals(taskNode.isTaskNode(), actualNode.get(WorkflowModelBuilder.WORKFLOW_NODE_IS_TASK_NODE));
    List<Map<String, Object>> transitions = (List<Map<String, Object>>) actualNode.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITIONS);
    WorkflowTransition[] taskTransitions = taskNode.getTransitions();
    int i = 0;
    for (Map<String, Object> transition : transitions) {
        WorkflowTransition workflowTransition = taskTransitions[i];
        assertEquals(workflowTransition.getId(), transition.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITION_ID));
        assertEquals(workflowTransition.getTitle(), transition.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITION_TITLE));
        assertEquals(workflowTransition.getDescription(), transition.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITION_DESCRIPTION));
        assertEquals(workflowTransition.isDefault(), transition.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITION_IS_DEFAULT));
        assertEquals(false, transition.get(WorkflowModelBuilder.WORKFLOW_NODE_TRANSITION_IS_HIDDEN));
        i++;
    }
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) WorkflowInstance(org.alfresco.service.cmr.workflow.WorkflowInstance) WorkflowNode(org.alfresco.service.cmr.workflow.WorkflowNode) Date(java.util.Date) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with WorkflowTaskDefinition

use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.

the class WorkflowModelBuilderTest method makeTaskDefinition.

private WorkflowTaskDefinition makeTaskDefinition() {
    String id = "The Definition Id";
    TypeDefinition metadata = makeTypeDefinition();
    WorkflowNode node = makeNode();
    return new WorkflowTaskDefinition(id, node, metadata);
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowNode(org.alfresco.service.cmr.workflow.WorkflowNode) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 3 with WorkflowTaskDefinition

use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.

the class WorkflowModelBuilderTest method testBuildWorkflowDefinition.

public void testBuildWorkflowDefinition() throws Exception {
    WorkflowTaskDefinition workflowTaskDefinition = makeTaskDefinition();
    WorkflowDefinition workflowDefinition = new WorkflowDefinition("The Id", "The Name", "The Version", "The Title", "The Description", workflowTaskDefinition);
    Map<String, Object> model = builder.buildSimple(workflowDefinition);
    assertEquals(workflowDefinition.getId(), model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_ID));
    assertEquals("api/workflow-definitions/" + workflowDefinition.getId(), model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_URL));
    assertEquals(workflowDefinition.getName(), model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_NAME));
    assertEquals(workflowDefinition.getTitle(), model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_TITLE));
    assertEquals(workflowDefinition.getDescription(), model.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_DESCRIPTION));
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Example 4 with WorkflowTaskDefinition

use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project acs-community-packaging by Alfresco.

the class StartWorkflowWizard method getPackageActionGroup.

/**
 * Returns the action group the current task uses for the workflow package
 *
 * @return action group id
 */
public String getPackageActionGroup() {
    String actionGroup = null;
    WorkflowDefinition flowDef = this.getWorkflows().get(this.selectedWorkflow);
    WorkflowTaskDefinition taskDef = flowDef.getStartTaskDefinition();
    if (taskDef != null) {
        PropertyDefinition propDef = taskDef.metadata.getProperties().get(WorkflowModel.PROP_PACKAGE_ACTION_GROUP);
        if (propDef != null) {
            actionGroup = propDef.getDefaultValue();
        }
    }
    return actionGroup;
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 5 with WorkflowTaskDefinition

use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project acs-community-packaging by Alfresco.

the class StartWorkflowWizard method next.

@Override
public String next() {
    String stepName = Application.getWizardManager().getCurrentStepName();
    if ("options".equals(stepName) && (this.selectedWorkflow.equals(this.previouslySelectedWorkflow) == false)) {
        // retrieve the start task for the selected workflow, get the task
        // definition and create a transient node to allow the property
        // sheet to collect the required data.
        WorkflowDefinition flowDef = this.getWorkflows().get(this.selectedWorkflow);
        if (logger.isDebugEnabled())
            logger.debug("Selected workflow: " + flowDef);
        WorkflowTaskDefinition taskDef = flowDef.getStartTaskDefinition();
        if (taskDef != null) {
            if (logger.isDebugEnabled())
                logger.debug("Start task definition: " + taskDef);
            // create an instance of a task from the data dictionary
            this.startTaskNode = TransientNode.createNew(getDictionaryService(), taskDef.metadata, "task_" + System.currentTimeMillis(), null);
        }
        // we also need to reset the resources list so that the actions get re-evaluated
        resetRichList();
    }
    return null;
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Aggregations

WorkflowTaskDefinition (org.alfresco.service.cmr.workflow.WorkflowTaskDefinition)10 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)5 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)2 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)2 WorkflowInstance (org.alfresco.service.cmr.workflow.WorkflowInstance)2 WorkflowNode (org.alfresco.service.cmr.workflow.WorkflowNode)2 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)2 QName (org.alfresco.service.namespace.QName)2 Serializable (java.io.Serializable)1 Date (java.util.Date)1 List (java.util.List)1 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)1 WorkflowTaskState (org.alfresco.service.cmr.workflow.WorkflowTaskState)1 WorkflowTransition (org.alfresco.service.cmr.workflow.WorkflowTransition)1 TransientNode (org.alfresco.web.bean.repository.TransientNode)1