Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#getDeploymentCache()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#getDeploymentCache() . 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: GetDeploymentCmmnModelInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public CmmnModelInstance execute(CommandContext commandContext) {
  ensureNotNull("caseDefinitionId", caseDefinitionId);

  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  final DeploymentCache deploymentCache = configuration.getDeploymentCache();

  CaseDefinitionEntity caseDefinition = deploymentCache.findDeployedCaseDefinitionById(caseDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadCaseDefinition(caseDefinition);
  }

  CmmnModelInstance modelInstance = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache()
      .findCmmnModelInstanceForCaseDefinition(caseDefinitionId);

  ensureNotNull(CmmnModelInstanceNotFoundException.class, "No CMMN model instance found for case definition id " + caseDefinitionId, "modelInstance", modelInstance);
  return modelInstance;
}
 
Example 2
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static TestProvider decisionRequirementsDefinitionTestProvider() {
  return new TestProvider() {

    @Override
    public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
      return new Command<ProcessApplicationReference>() {

        public ProcessApplicationReference execute(CommandContext commandContext) {
          ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
          DeploymentCache deploymentCache = configuration.getDeploymentCache();
          DecisionRequirementsDefinitionEntity definition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(definitionId);
          return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
        }
      };
    }

    @Override
    public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
      return repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionKey(key).latestVersion().singleResult().getId();
    }

  };
}
 
Example 3
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static TestProvider decisionDefinitionTestProvider() {
  return new TestProvider() {

    @Override
    public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
      return new Command<ProcessApplicationReference>() {

        public ProcessApplicationReference execute(CommandContext commandContext) {
          ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
          DeploymentCache deploymentCache = configuration.getDeploymentCache();
          DecisionDefinitionEntity definition = deploymentCache.findDeployedDecisionDefinitionById(definitionId);
          return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
        }
      };
    }

    @Override
    public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
      return repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).latestVersion().singleResult().getId();
    }

  };
}
 
Example 4
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static TestProvider caseDefinitionTestProvider() {
  return new TestProvider() {

    @Override
    public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
      return new Command<ProcessApplicationReference>() {

        public ProcessApplicationReference execute(CommandContext commandContext) {
          ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
          DeploymentCache deploymentCache = configuration.getDeploymentCache();
          CaseDefinitionEntity definition = deploymentCache.findDeployedCaseDefinitionById(definitionId);
          return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
        }
      };
    }

    @Override
    public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
      return repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId();
    }

  };
}
 
Example 5
Source File: RedeploymentRegistrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static TestProvider processDefinitionTestProvider() {
  return new TestProvider() {

    @Override
    public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
      return new Command<ProcessApplicationReference>() {

        public ProcessApplicationReference execute(CommandContext commandContext) {
          ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
          DeploymentCache deploymentCache = configuration.getDeploymentCache();
          ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId);
          return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
        }
      };
    }

    @Override
    public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
      return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId();
    }

  };
}
 
Example 6
Source File: DecisionRequirementsDefinitionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the cached version if exists; does not update the entity from the database in that case
 */
protected DecisionRequirementsDefinitionEntity loadDecisionRequirementsDefinition(String decisionRequirementsDefinitionId) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = configuration.getDeploymentCache();

  DecisionRequirementsDefinitionEntity decisionRequirementsDefinition = deploymentCache.findDecisionRequirementsDefinitionFromCache(decisionRequirementsDefinitionId);

  if (decisionRequirementsDefinition == null) {
    CommandContext commandContext = Context.getCommandContext();
    DecisionRequirementsDefinitionManager manager = commandContext.getDecisionRequirementsDefinitionManager();
    decisionRequirementsDefinition = manager.findDecisionRequirementsDefinitionById(decisionRequirementsDefinitionId);

    if (decisionRequirementsDefinition != null) {
      decisionRequirementsDefinition = deploymentCache.resolveDecisionRequirementsDefinition(decisionRequirementsDefinition);
    }
  }

  return decisionRequirementsDefinition;
}
 
Example 7
Source File: DecisionDefinitionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the cached version if exists; does not update the entity from the database in that case
 */
protected DecisionDefinitionEntity loadDecisionDefinition(String decisionDefinitionId) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = configuration.getDeploymentCache();

  DecisionDefinitionEntity decisionDefinition = deploymentCache.findDecisionDefinitionFromCache(decisionDefinitionId);

  if (decisionDefinition == null) {
    CommandContext commandContext = Context.getCommandContext();
    DecisionDefinitionManager decisionDefinitionManager = commandContext.getDecisionDefinitionManager();
    decisionDefinition = decisionDefinitionManager.findDecisionDefinitionById(decisionDefinitionId);

    if (decisionDefinition != null) {
      decisionDefinition = deploymentCache.resolveDecisionDefinition(decisionDefinition);
    }
  }

  return decisionDefinition;

}
 
Example 8
Source File: DeploymentManager.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void deleteDecisionRequirementDeployment(String deploymentId) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  if (processEngineConfiguration.isDmnEnabled()) {
    DecisionRequirementsDefinitionManager manager = getDecisionRequirementsDefinitionManager();
    List<DecisionRequirementsDefinition> decisionRequirementsDefinitions =
        manager.findDecisionRequirementsDefinitionByDeploymentId(deploymentId);

    // delete decision requirements definitions from db
    manager.deleteDecisionRequirementsDefinitionsByDeploymentId(deploymentId);

    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();

    for (DecisionRequirementsDefinition decisionRequirementsDefinition : decisionRequirementsDefinitions) {
      String decisionDefinitionId = decisionRequirementsDefinition.getId();

      // remove decision requirements definitions from cache:
      deploymentCache.removeDecisionRequirementsDefinition(decisionDefinitionId);
    }
  }
}
 
Example 9
Source File: ProcessDefinitionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the cached version if exists; does not update the entity from the database in that case
 */
protected ProcessDefinitionEntity loadProcessDefinition(String processDefinitionId) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = configuration.getDeploymentCache();

  ProcessDefinitionEntity processDefinition = deploymentCache.findProcessDefinitionFromCache(processDefinitionId);

  if (processDefinition == null) {
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();
    processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

    if (processDefinition != null) {
      processDefinition = deploymentCache.resolveProcessDefinition(processDefinition);
    }
  }

  return processDefinition;

}
 
Example 10
Source File: CaseDefinitionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the cached version if exists; does not update the entity from the database in that case
 */
protected CaseDefinitionEntity loadCaseDefinition(String caseDefinitionId) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = configuration.getDeploymentCache();

  CaseDefinitionEntity caseDefinition = deploymentCache.findCaseDefinitionFromCache(caseDefinitionId);

  if (caseDefinition == null) {
    CommandContext commandContext = Context.getCommandContext();
    CaseDefinitionManager caseDefinitionManager = commandContext.getCaseDefinitionManager();
    caseDefinition = caseDefinitionManager.findCaseDefinitionById(caseDefinitionId);

    if (caseDefinition != null) {
      caseDefinition = deploymentCache.resolveCaseDefinition(caseDefinition);
    }
  }

  return caseDefinition;

}
 
Example 11
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 12
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void deleteProcessDefinitions(ProcessDefinitionGroup group) {
  ProcessDefinitionEntity newLatestProcessDefinition = findNewLatestProcessDefinition(group);

  CommandContext commandContext = Context.getCommandContext();
  UserOperationLogManager userOperationLogManager = commandContext.getOperationLogManager();
  ProcessDefinitionManager definitionManager = commandContext.getProcessDefinitionManager();

  List<ProcessDefinitionEntity> processDefinitions = group.processDefinitions;
  for (ProcessDefinitionEntity processDefinition : processDefinitions) {
    String processDefinitionId = processDefinition.getId();

    if (writeUserOperationLog) {
      userOperationLogManager.logProcessDefinitionOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, processDefinitionId, processDefinition.getKey(),
          new PropertyChange("cascade", false, cascadeToHistory));
    }

    definitionManager.deleteProcessDefinition(processDefinition, processDefinitionId, cascadeToHistory, cascadeToInstances, skipCustomListeners, skipIoMappings);
  }

  if (newLatestProcessDefinition != null) {
    ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = configuration.getDeploymentCache();
    newLatestProcessDefinition = deploymentCache.resolveProcessDefinition(newLatestProcessDefinition);

    List<Deployer> deployers = configuration.getDeployers();
    for (Deployer deployer : deployers) {
      if (deployer instanceof BpmnDeployer) {
        ((BpmnDeployer) deployer).addEventSubscriptions(newLatestProcessDefinition);
      }
    }
  }
}
 
Example 13
Source File: GetDeploymentBpmnModelInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public BpmnModelInstance execute(CommandContext commandContext) {
  ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
  final DeploymentCache deploymentCache = configuration.getDeploymentCache();

  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

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

  BpmnModelInstance modelInstance = deploymentCache.findBpmnModelInstanceForProcessDefinition(processDefinitionId);

  ensureNotNull("no BPMN model instance found for process definition id " + processDefinitionId, "modelInstance", modelInstance);
  return modelInstance;
}
 
Example 14
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 15
Source File: SubmitStartFormCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstance 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.checkCreateProcessInstance(processDefinition);
  }

  ExecutionEntity processInstance = null;
  if (businessKey != null) {
    processInstance = processDefinition.createProcessInstance(businessKey);
  } else {
    processInstance = processDefinition.createProcessInstance();
  }

  // if the start event is async, we have to set the variables already here
  // since they are lost after the async continuation otherwise
  // see CAM-2828
  if (processDefinition.getInitial().isAsyncBefore()) {
    // avoid firing history events
    processInstance.setStartContext(new ProcessInstanceStartContext(processInstance.getActivity()));
    FormPropertyHelper.initFormPropertiesOnScope(variables, processInstance);
    processInstance.start();

  } else {
    processInstance.startWithFormProperties(variables);

  }


  return processInstance;
}
 
Example 16
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 17
Source File: GetDeployedStartFormCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkAuthorization(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
  for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }
}