use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project acs-community-packaging by Alfresco.
the class ManageTaskDialog method init.
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters) {
super.init(parameters);
// reset variables
this.task = null;
this.taskNode = null;
this.workflowInstance = null;
this.transitions = null;
this.workflowPackage = null;
this.resources = null;
this.itemsToAdd = null;
this.packageItemsToAdd = null;
this.packageItemsToRemove = null;
this.isItemBeingAdded = false;
if (this.packageItemsRichList != null) {
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
// get the task details
String taskId = this.parameters.get("id");
this.task = this.getWorkflowService().getTaskById(taskId);
if (this.task != null) {
// setup a transient node to represent the task we're managing
WorkflowTaskDefinition taskDef = this.task.definition;
this.taskNode = new TransientNode(taskDef.metadata.getName(), "task_" + System.currentTimeMillis(), this.task.properties);
// get access to the workflow instance for the task
this.workflowInstance = this.task.path.instance;
// setup the workflow package for the task
this.workflowPackage = (NodeRef) this.task.properties.get(WorkflowModel.ASSOC_PACKAGE);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Task: " + this.task);
LOGGER.debug("Trasient node: " + this.taskNode);
Boolean isSystemPackage = (Boolean) this.getNodeService().getProperty(this.workflowPackage, WorkflowModel.PROP_IS_SYSTEM_PACKAGE);
LOGGER.debug("Workflow package: " + this.workflowPackage + " system package: " + isSystemPackage);
}
}
}
use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project acs-community-packaging by Alfresco.
the class StartWorkflowWizard method getPackageItemActionGroup.
/**
* Returns the action group the current task uses for each workflow package item
*
* @return action group id
*/
public String getPackageItemActionGroup() {
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_ITEM_ACTION_GROUP);
if (propDef != null) {
actionGroup = propDef.getDefaultValue();
}
}
return actionGroup;
}
use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilder method buildDetailed.
/**
* Returns a detailed representation of a {@link WorkflowDefinition}.
*
* @param workflowDefinition the WorkflowDefinition object to be represented.
* @return Map
*/
public Map<String, Object> buildDetailed(WorkflowDefinition workflowDefinition) {
Map<String, Object> model = buildSimple(workflowDefinition);
model.put(WORKFLOW_DEFINITION_START_TASK_DEFINITION_URL, getUrl(workflowDefinition.getStartTaskDefinition().getMetadata()));
model.put(WORKFLOW_DEFINITION_START_TASK_DEFINITION_TYPE, workflowDefinition.getStartTaskDefinition().getMetadata().getName());
ArrayList<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
for (WorkflowTaskDefinition taskDefinition : workflowService.getTaskDefinitions(workflowDefinition.getId())) {
if (taskDefinition.getId().equals(workflowDefinition.getStartTaskDefinition().getId())) {
continue;
}
Map<String, Object> result = new HashMap<String, Object>();
result.put(TASK_DEFINITION_URL, getUrl(taskDefinition.getMetadata()));
result.put(TASK_DEFINITION_TYPE, taskDefinition.getMetadata().getName());
results.add(result);
}
model.put(WORKFLOW_DEFINITION_TASK_DEFINITIONS, results);
return model;
}
use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method makeTask.
private WorkflowTask makeTask(Date date) {
String description = "Task Desc";
String id = "testId$1";
String name = "Task Name";
WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS;
String title = "Task Title";
WorkflowPath path = makePath();
WorkflowTaskDefinition definition = makeTaskDefinition();
HashMap<QName, Serializable> properties = makeTaskProperties(date);
return new WorkflowTask(id, definition, name, title, description, state, path, properties);
}
use of org.alfresco.service.cmr.workflow.WorkflowTaskDefinition in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method testBuildWorkflowInstanceDetailed.
@SuppressWarnings("unchecked")
public void testBuildWorkflowInstanceDetailed() throws Exception {
WorkflowTaskDefinition workflowTaskDefinition = makeTaskDefinition();
QName taskTypeName = WorkflowModel.TYPE_WORKFLOW_TASK;
when(workflowTaskDefinition.getMetadata().getName()).thenReturn(taskTypeName);
when(workflowTaskDefinition.getMetadata().getTitle(dictionaryService)).thenReturn("The Type Title");
when(workflowTaskDefinition.getMetadata().getDescription(dictionaryService)).thenReturn("The Type Description");
WorkflowInstance workflowInstance = makeWorkflowInstance(workflowTaskDefinition);
Map<String, Object> model = builder.buildDetailed(workflowInstance, true);
assertEquals(workflowInstance.getId(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_ID));
assertEquals(workflowInstance.getDefinition().getName(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_NAME));
assertEquals(workflowInstance.getDefinition().getTitle(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_TITLE));
assertEquals(workflowInstance.getDefinition().getDescription(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_DESCRIPTION));
assertEquals(workflowInstance.isActive(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_IS_ACTIVE));
String startDateStr = ISO8601DateFormat.format(workflowInstance.getStartDate());
String endDateStr = ISO8601DateFormat.format(workflowInstance.getEndDate());
String startDateBuilderStr = ISO8601DateFormat.formatToZulu((String) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_START_DATE));
String endDateBuilderStr = ISO8601DateFormat.formatToZulu((String) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_END_DATE));
assertEquals(startDateStr, startDateBuilderStr);
assertEquals(endDateStr, endDateBuilderStr);
Map<String, Object> initiator = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_INITIATOR);
if (initiator != null) {
assertEquals(userName, initiator.get(WorkflowModelBuilder.PERSON_USER_NAME));
assertEquals(firstName, initiator.get(WorkflowModelBuilder.PERSON_FIRST_NAME));
assertEquals(lastName, initiator.get(WorkflowModelBuilder.PERSON_LAST_NAME));
}
assertEquals(workflowInstance.getContext().toString(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_CONTEXT));
assertEquals(workflowInstance.getWorkflowPackage().toString(), model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_PACKAGE));
Map<String, Object> taskInstanceModel = (Map<String, Object>) model.get(WorkflowModelBuilder.TASK_WORKFLOW_INSTANCE_DEFINITION);
assertEquals(workflowInstance.getDefinition().getVersion(), taskInstanceModel.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_VERSION));
assertEquals(workflowInstance.getDefinition().getStartTaskDefinition().getMetadata().getName(), taskInstanceModel.get(WorkflowModelBuilder.WORKFLOW_DEFINITION_START_TASK_DEFINITION_TYPE));
}
Aggregations