Java Code Examples for org.activiti.engine.form.StartFormData#getFormKey()

The following examples show how to use org.activiti.engine.form.StartFormData#getFormKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Convert a {@link ProcessDefinition} into a {@link WorkflowDefinition}.
 * @param definition ProcessDefinition
 * @return WorkflowDefinition
 */
public WorkflowDefinition convert(ProcessDefinition definition)
{
    if(definition==null)
        return null;
    
    String defId = definition.getId();
    String defName = definition.getKey();
    int version = definition.getVersion();
    String defaultTitle = definition.getName();
    
    String startTaskName = null;
    StartFormData startFormData = getStartFormData(defId, defName);
    if(startFormData != null) 
    {
        startTaskName = startFormData.getFormKey();
    }
    
    ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(defId);
    PvmActivity startEvent = def.getInitial();
    WorkflowTaskDefinition startTask = getTaskDefinition(startEvent, startTaskName, definition.getKey(), true);
    
    return factory.createDefinition(defId,
                defName, version, defaultTitle,
                null, startTask);
}
 
Example 2
Source File: JuelFormEngine.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object renderStartForm(StartFormData startForm) {
  if (startForm.getFormKey()==null) {
    return null;
  }
  String formTemplateString = getFormTemplateString(startForm, startForm.getFormKey());
  ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
  return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, null);
}
 
Example 3
Source File: JuelFormEngine.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object renderStartForm(StartFormData startForm) {
  if (startForm.getFormKey() == null) {
    return null;
  }
  String formTemplateString = getFormTemplateString(startForm, startForm.getFormKey());
  ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
  return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, null);
}
 
Example 4
Source File: ActivitiUtil.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getStartTaskTypeName(String processDefinitionId)
{
    String startTaskName = null;
    StartFormData startFormData = formService.getStartFormData(processDefinitionId);
    if (startFormData != null) 
    {
        startTaskName = startFormData.getFormKey();
    }
    return startTaskName;
}
 
Example 5
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
* {@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;
}
 
Example 6
Source File: TasksImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void addVariables(Task task, Boolean includeProcessVariables, Boolean includeTaskVariables, 
        Map<String, Object> processVariables, Map<String, Object> taskVariables, Map<String, TypeDefinition> definitionTypeMap)
{
    TypeDefinition startFormTypeDefinition = null;
    if (includeProcessVariables != null && includeProcessVariables) 
    {
        if (definitionTypeMap.containsKey(task.getProcessDefinitionId()) == false)
        {
            StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(task.getProcessDefinitionId());
            if (startFormData != null)
            {
                String formKey = startFormData.getFormKey();
                definitionTypeMap.put(task.getProcessDefinitionId(), getWorkflowFactory().getTaskFullTypeDefinition(formKey, true));
            }
        }
        
        if (definitionTypeMap.containsKey(task.getProcessDefinitionId()))
        {
            startFormTypeDefinition = definitionTypeMap.get(task.getProcessDefinitionId());
        }
    }
    
    TypeDefinition taskTypeDefinition = null;
    if (includeTaskVariables != null && includeTaskVariables) 
    {
        taskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(task.getFormResourceKey(), false);
    }
    
    List<TaskVariable> variables = restVariableHelper.getTaskVariables(taskVariables, processVariables, 
            startFormTypeDefinition, taskTypeDefinition);
    task.setVariables(variables);
}
 
Example 7
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
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);
}
 
Example 8
Source File: ProcessesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public CollectionWithPagingInfo<Variable> getVariables(String processId, Paging paging)
{
    CollectionWithPagingInfo<Variable> result = null;
    
    // Check if user is allowed to get variables
    List<HistoricVariableInstance> variableInstances = validateIfUserAllowedToWorkWithProcess(processId);
    Map<String, Object> variables = new HashMap<String, Object>();
    for (HistoricVariableInstance variable : variableInstances)
    {
        variables.put(variable.getVariableName(), variable.getValue());
    }
    
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(processId)
            .singleResult();
    
    String processDefinitionId = null;
    
    if (processInstance != null)
    {
        processDefinitionId = processInstance.getProcessDefinitionId();
    }
    else
    {
        // Completed process instance
        HistoricProcessInstance historicInstance = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processId).singleResult();
        
        if (historicInstance == null)
        {
            throw new EntityNotFoundException(processId);
        }
        
        processDefinitionId = historicInstance.getProcessDefinitionId();
    }

    // Get start-task definition for explicit typing of variables submitted at the start
    String formKey = null;
    StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processDefinitionId);
    if (startFormData != null)
    {
        formKey = startFormData.getFormKey();
    }
    
    TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
    
    // Convert raw variables to Variable objects
    List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);
    result = CollectionWithPagingInfo.asPaged(paging, resultingVariables);
    return result;
}