Search in sources :

Example 1 with FormEngine

use of org.camunda.bpm.engine.impl.form.engine.FormEngine in project camunda-bpm-platform by camunda.

the class GetRenderedTaskFormCmd method execute.

public Object execute(CommandContext commandContext) {
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Task '" + taskId + "' not found", "task", task);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadTask(task);
    }
    ensureNotNull("Task form definition for '" + taskId + "' not found", "task.getTaskDefinition()", task.getTaskDefinition());
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    if (taskFormHandler == null) {
        return null;
    }
    FormEngine formEngine = Context.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);
    TaskFormData taskForm = taskFormHandler.createTaskForm(task);
    return formEngine.renderTaskForm(taskForm);
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskFormHandler(org.camunda.bpm.engine.impl.form.handler.TaskFormHandler) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) FormEngine(org.camunda.bpm.engine.impl.form.engine.FormEngine)

Example 2 with FormEngine

use of org.camunda.bpm.engine.impl.form.engine.FormEngine in project camunda-bpm-platform by camunda.

the class ProcessEngineConfigurationImpl method initFormEngines.

protected void initFormEngines() {
    if (formEngines == null) {
        formEngines = new HashMap<String, FormEngine>();
        // html form engine = default form engine
        FormEngine defaultFormEngine = new HtmlFormEngine();
        // default form engine is looked up with null
        formEngines.put(null, defaultFormEngine);
        formEngines.put(defaultFormEngine.getName(), defaultFormEngine);
        FormEngine juelFormEngine = new JuelFormEngine();
        formEngines.put(juelFormEngine.getName(), juelFormEngine);
    }
    if (customFormEngines != null) {
        for (FormEngine formEngine : customFormEngines) {
            formEngines.put(formEngine.getName(), formEngine);
        }
    }
}
Also used : JuelFormEngine(org.camunda.bpm.engine.impl.form.engine.JuelFormEngine) HtmlFormEngine(org.camunda.bpm.engine.impl.form.engine.HtmlFormEngine) FormEngine(org.camunda.bpm.engine.impl.form.engine.FormEngine) HtmlFormEngine(org.camunda.bpm.engine.impl.form.engine.HtmlFormEngine) JuelFormEngine(org.camunda.bpm.engine.impl.form.engine.JuelFormEngine)

Example 3 with FormEngine

use of org.camunda.bpm.engine.impl.form.engine.FormEngine in project camunda-bpm-platform by camunda.

the class GetRenderedStartFormCmd method execute.

public Object execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    ensureNotNull("Process Definition '" + processDefinitionId + "' not found", "processDefinition", processDefinition);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessDefinition(processDefinition);
    }
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
        return null;
    }
    FormEngine formEngine = Context.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);
    StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
    Object renderedStartForm = null;
    try {
        renderedStartForm = formEngine.renderStartForm(startForm);
    } catch (ScriptEvaluationException e) {
        LOG.exceptionWhenStartFormScriptEvaluation(processDefinitionId, e);
    }
    return renderedStartForm;
}
Also used : StartFormHandler(org.camunda.bpm.engine.impl.form.handler.StartFormHandler) ScriptEvaluationException(org.camunda.bpm.engine.ScriptEvaluationException) StartFormData(org.camunda.bpm.engine.form.StartFormData) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) FormEngine(org.camunda.bpm.engine.impl.form.engine.FormEngine)

Aggregations

FormEngine (org.camunda.bpm.engine.impl.form.engine.FormEngine)3 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 ScriptEvaluationException (org.camunda.bpm.engine.ScriptEvaluationException)1 StartFormData (org.camunda.bpm.engine.form.StartFormData)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 HtmlFormEngine (org.camunda.bpm.engine.impl.form.engine.HtmlFormEngine)1 JuelFormEngine (org.camunda.bpm.engine.impl.form.engine.JuelFormEngine)1 StartFormHandler (org.camunda.bpm.engine.impl.form.handler.StartFormHandler)1 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)1