org.activiti.engine.impl.form.FormEngine Java Examples

The following examples show how to use org.activiti.engine.impl.form.FormEngine. 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: GetRenderedStartFormCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object execute(CommandContext commandContext) {
  ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
  
  if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && 
      Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(processDefinition.getEngineVersion())) {
    
    return Activiti5Util.getActiviti5CompatibilityHandler().getRenderedStartForm(processDefinitionId, formEngineName); 
  }
  
  if (processDefinition == null) {
    throw new ActivitiObjectNotFoundException("Process Definition '" + processDefinitionId + "' not found", ProcessDefinition.class);
  }
  StartFormHandler startFormHandler = FormHandlerUtil.getStartFormHandler(commandContext, processDefinition); 
  if (startFormHandler == null) {
    return null;
  }

  FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);

  if (formEngine == null) {
    throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
  }

  StartFormData startForm = startFormHandler.createStartFormData(processDefinition);

  return formEngine.renderStartForm(startForm);
}
 
Example #2
Source File: GetRenderedTaskFormCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object execute(CommandContext commandContext) {
  
  if (taskId == null) {
    throw new ActivitiIllegalArgumentException("Task id should not be null");
  }
  
  TaskEntity task = commandContext.getTaskEntityManager().findById(taskId);
  if (task == null) {
    throw new ActivitiObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
  }
  
  TaskFormHandler taskFormHandler = FormHandlerUtil.getTaskFormHandlder(task);
  if (taskFormHandler != null) {
  
    FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);

    if (formEngine == null) {
      throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }

    TaskFormData taskForm = taskFormHandler.createTaskForm(task);

    return formEngine.renderTaskForm(taskForm);
  }
  
  return null;
}
 
Example #3
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void initFormEngines() {
    if (formEngines == null) {
        formEngines = new HashMap<>();
        FormEngine defaultFormEngine = new JuelFormEngine();
        formEngines.put(null, defaultFormEngine); // default form engine is looked up with null
        formEngines.put(defaultFormEngine.getName(), defaultFormEngine);
    }
    if (customFormEngines != null) {
        for (FormEngine formEngine : customFormEngines) {
            formEngines.put(formEngine.getName(), formEngine);
        }
    }
}
 
Example #4
Source File: GetRenderedStartFormCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
    ProcessDefinition processDefinition = commandContext
            .getProcessEngineConfiguration()
            .getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Process Definition '" + processDefinitionId + "' not found", ProcessDefinition.class);
    }
    StartFormHandler startFormHandler = ((ProcessDefinitionEntity) processDefinition).getStartFormHandler();
    if (startFormHandler == null) {
        return null;
    }

    FormEngine formEngine = commandContext
            .getProcessEngineConfiguration()
            .getFormEngines()
            .get(formEngineName);

    if (formEngine == null) {
        throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }

    StartFormData startForm = startFormHandler.createStartFormData(processDefinition);

    return formEngine.renderStartForm(startForm);
}
 
Example #5
Source File: GetRenderedTaskFormCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
    }

    if (task.getTaskDefinition() == null) {
        throw new ActivitiException("Task form definition for '" + taskId + "' not found");
    }

    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    if (taskFormHandler == null) {
        return null;
    }

    FormEngine formEngine = commandContext
            .getProcessEngineConfiguration()
            .getFormEngines()
            .get(formEngineName);

    if (formEngine == null) {
        throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }

    TaskFormData taskForm = taskFormHandler.createTaskForm(task);

    return formEngine.renderTaskForm(taskForm);
}
 
Example #6
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public Map<String, FormEngine> getFormEngines() {
    return formEngines;
}
 
Example #7
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setFormEngines(Map<String, FormEngine> formEngines) {
    this.formEngines = formEngines;
    return this;
}
 
Example #8
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public List<FormEngine> getCustomFormEngines() {
    return customFormEngines;
}
 
Example #9
Source File: ProcessEngineConfigurationImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessEngineConfigurationImpl setCustomFormEngines(List<FormEngine> customFormEngines) {
    this.customFormEngines = customFormEngines;
    return this;
}