Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getStartFormHandler()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getStartFormHandler() . 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 camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 2
Source File: GetFormKeyCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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();
    }

    // Sorry!!! In case of a custom start form handler (which does not extend
    // the DefaultFormHandler) a formKey would never be returned. So a custom
    // 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;
}
 
Example 3
Source File: GetStartFormCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public StartFormData execute(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
  ensureNotNull("No process definition found for id '" + processDefinitionId + "'", "processDefinition", processDefinition);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
  ensureNotNull("No startFormHandler defined in process '" + processDefinitionId + "'", "startFormHandler", startFormHandler);

  return startFormHandler.createStartFormData(processDefinition);
}
 
Example 4
Source File: FormPropertyHelper.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void initFormPropertiesOnScope(VariableMap variables, PvmExecutionImpl execution) {
  ProcessDefinitionEntity pd = (ProcessDefinitionEntity) execution.getProcessDefinition();
  StartFormHandler startFormHandler = pd.getStartFormHandler();
  startFormHandler.submitFormVariables(variables, execution);
}