Search in sources :

Example 21 with StartFormData

use of org.activiti.engine.form.StartFormData in project alfresco-repository by Alfresco.

the class ActivitiUtil method getStartTaskTypeName.

public String getStartTaskTypeName(String processDefinitionId) {
    String startTaskName = null;
    StartFormData startFormData = formService.getStartFormData(processDefinitionId);
    if (startFormData != null) {
        startTaskName = startFormData.getFormKey();
    }
    return startTaskName;
}
Also used : StartFormData(org.activiti.engine.form.StartFormData)

Example 22 with StartFormData

use of org.activiti.engine.form.StartFormData in project alfresco-repository by Alfresco.

the class ActivitiWorkflowEngine method getTaskDefinitions.

/**
 * {@inheritDoc}
 */
public List<WorkflowTaskDefinition> getTaskDefinitions(String workflowDefinitionId) {
    List<WorkflowTaskDefinition> defs = new ArrayList<WorkflowTaskDefinition>();
    String processDefinitionId = createLocalId(workflowDefinitionId);
    // This should return all task definitions, including the start-task
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) repoService).getDeployedProcessDefinition(processDefinitionId);
    String processName = ((ProcessDefinition) processDefinition).getKey();
    factory.checkDomain(processName);
    // Process start task definition
    PvmActivity startEvent = processDefinition.getInitial();
    String startTaskName = null;
    StartFormData startFormData = formService.getStartFormData(processDefinition.getId());
    if (startFormData != null) {
        startTaskName = startFormData.getFormKey();
    }
    // Add start task definition
    defs.add(typeConverter.getTaskDefinition(startEvent, startTaskName, processDefinition.getId(), true));
    // Now, continue through process, finding all user-tasks
    Collection<PvmActivity> taskActivities = typeConverter.findUserTasks(startEvent);
    for (PvmActivity act : taskActivities) {
        String formKey = typeConverter.getFormKey(act, processDefinition);
        defs.add(typeConverter.getTaskDefinition(act, formKey, processDefinition.getId(), false));
    }
    return defs;
}
Also used : StartFormData(org.activiti.engine.form.StartFormData) WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) ArrayList(java.util.ArrayList) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.activiti.engine.impl.RepositoryServiceImpl) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity)

Example 23 with StartFormData

use of org.activiti.engine.form.StartFormData in project alfresco-repository by Alfresco.

the class ActivitiTypeConverter method getVirtualStartTask.

private WorkflowTask getVirtualStartTask(ProcessInstance processInstance, boolean inProgress) {
    String processInstanceId = processInstance.getId();
    if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !isCorrectTenantRuntime(processInstanceId)) {
        return null;
    }
    String id = ActivitiConstants.START_TASK_PREFIX + processInstanceId;
    WorkflowTaskState state = null;
    if (inProgress) {
        state = WorkflowTaskState.IN_PROGRESS;
    } else {
        state = WorkflowTaskState.COMPLETED;
    }
    WorkflowPath path = convert((Execution) processInstance);
    // Convert start-event to start-task Node
    String definitionId = processInstance.getProcessDefinitionId();
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(definitionId);
    WorkflowNode startNode = convert(procDef.getInitial(), true);
    String key = ((ProcessDefinition) procDef).getKey();
    StartFormData startFormData = getStartFormData(definitionId, key);
    String taskDefId = null;
    if (startFormData != null) {
        taskDefId = startFormData.getFormKey();
    }
    WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, startNode, taskDefId, true);
    // Add properties based on HistoricProcessInstance
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Map<QName, Serializable> properties = propertyConverter.getStartTaskProperties(historicProcessInstance, taskDefId, !inProgress);
    // TODO: Figure out what name/description should be used for the start-task, start event's name?
    String defaultTitle = null;
    String defaultDescription = null;
    return factory.createTask(id, taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
}
Also used : Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) StartFormData(org.activiti.engine.form.StartFormData) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowPath(org.alfresco.service.cmr.workflow.WorkflowPath) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) WorkflowTaskState(org.alfresco.service.cmr.workflow.WorkflowTaskState) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) WorkflowNode(org.alfresco.service.cmr.workflow.WorkflowNode)

Aggregations

StartFormData (org.activiti.engine.form.StartFormData)23 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)8 HashMap (java.util.HashMap)7 FormProperty (org.activiti.engine.form.FormProperty)7 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)7 Map (java.util.Map)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)5 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)4 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)4 QName (org.alfresco.service.namespace.QName)4 ArrayList (java.util.ArrayList)3 TaskFormData (org.activiti.engine.form.TaskFormData)3 ReadOnlyProcessDefinition (org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition)3 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 Deployment (org.activiti.engine.test.Deployment)3 WorkflowTaskDefinition (org.alfresco.service.cmr.workflow.WorkflowTaskDefinition)3 InvalidQNameException (org.alfresco.service.namespace.InvalidQNameException)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2