Search in sources :

Example 21 with DeploymentCache

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache 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)

Example 22 with DeploymentCache

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.

the class SubmitStartFormCmd method execute.

@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();
    }
    // 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;
}
Also used : ProcessInstanceStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) 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)

Example 23 with DeploymentCache

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.

the class CallableElementUtil method getDecisionDefinitionToCall.

public static DecisionDefinition getDecisionDefinitionToCall(VariableScope execution, BaseCallableElement callableElement) {
    String decisionDefinitionKey = callableElement.getDefinitionKey(execution);
    String tenantId = callableElement.getDefinitionTenantId(execution);
    DeploymentCache deploymentCache = getDeploymentCache();
    DecisionDefinition decisionDefinition = null;
    if (callableElement.isLatestBinding()) {
        decisionDefinition = deploymentCache.findDeployedLatestDecisionDefinitionByKeyAndTenantId(decisionDefinitionKey, tenantId);
    } else if (callableElement.isDeploymentBinding()) {
        String deploymentId = callableElement.getDeploymentId();
        decisionDefinition = deploymentCache.findDeployedDecisionDefinitionByDeploymentAndKey(deploymentId, decisionDefinitionKey);
    } else if (callableElement.isVersionBinding()) {
        Integer version = callableElement.getVersion(execution);
        decisionDefinition = deploymentCache.findDeployedDecisionDefinitionByKeyVersionAndTenantId(decisionDefinitionKey, version, tenantId);
    }
    return decisionDefinition;
}
Also used : DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 24 with DeploymentCache

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.

the class CaseDefinitionEntity method loadCaseDefinition.

/**
 * 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;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 25 with DeploymentCache

use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.

the class CreateCaseInstanceCmd method find.

protected CaseDefinitionEntity find(CommandContext commandContext) {
    DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
    // Find the case definition
    CaseDefinitionEntity caseDefinition = null;
    if (caseDefinitionId != null) {
        caseDefinition = findById(deploymentCache, caseDefinitionId);
        ensureNotNull(CaseDefinitionNotFoundException.class, "No case definition found for id = '" + caseDefinitionId + "'", "caseDefinition", caseDefinition);
    } else {
        caseDefinition = findByKey(deploymentCache, caseDefinitionKey);
        ensureNotNull(CaseDefinitionNotFoundException.class, "No case definition found for key '" + caseDefinitionKey + "'", "caseDefinition", caseDefinition);
    }
    return caseDefinition;
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)

Aggregations

DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)41 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)18 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)15 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)10 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)5 Test (org.junit.Test)5 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)4 RepositoryService (org.camunda.bpm.engine.RepositoryService)4 Command (org.camunda.bpm.engine.impl.interceptor.Command)4 ArrayList (java.util.ArrayList)3 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)3 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)3 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)3 DecisionRequirementsDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionRequirementsDefinitionEntity)2 StartFormHandler (org.camunda.bpm.engine.impl.form.handler.StartFormHandler)2 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)2 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)2