Search in sources :

Example 1 with FormHandler

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

the class GetFormKeyCmd method execute.

public String execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessDefinition(processDefinition);
    }
    Expression formKeyExpression = null;
    if (taskDefinitionKey == null) {
        // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
        FormHandler formHandler = processDefinition.getStartFormHandler();
        if (formHandler instanceof DelegateStartFormHandler) {
            DelegateStartFormHandler delegateFormHandler = (DelegateStartFormHandler) formHandler;
            formHandler = delegateFormHandler.getFormHandler();
        }
        // form handler (for a startForm) has always to extend the DefaultStartFormHandler!
        if (formHandler instanceof DefaultStartFormHandler) {
            DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) formHandler;
            formKeyExpression = startFormHandler.getFormKey();
        }
    } else {
        TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
        formKeyExpression = taskDefinition.getFormKey();
    }
    String formKey = null;
    if (formKeyExpression != null) {
        formKey = formKeyExpression.getExpressionText();
    }
    return formKey;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) FormHandler(org.camunda.bpm.engine.impl.form.handler.FormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) 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)

Aggregations

Expression (org.camunda.bpm.engine.delegate.Expression)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DefaultStartFormHandler (org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler)1 DelegateStartFormHandler (org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler)1 FormHandler (org.camunda.bpm.engine.impl.form.handler.FormHandler)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)1