Search in sources :

Example 21 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CaseHandlerTest method testCaseDefinitionKey.

@Test
public void testCaseDefinitionKey() {
    // given: a caseDefinition
    // when
    CaseDefinitionEntity activity = (CaseDefinitionEntity) handler.handleElement(caseDefinition, context);
    // then
    assertEquals(caseDefinition.getId(), activity.getKey());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Test(org.junit.Test)

Example 22 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity 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)

Example 23 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class CreateCaseInstanceCmd method execute.

public CaseInstance execute(CommandContext commandContext) {
    ensureAtLeastOneNotNull("caseDefinitionId and caseDefinitionKey are null", caseDefinitionId, caseDefinitionKey);
    CaseDefinitionEntity caseDefinition = find(commandContext);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkCreateCaseInstance(caseDefinition);
    }
    // Start the case instance
    CaseExecutionEntity caseInstance = (CaseExecutionEntity) caseDefinition.createCaseInstance(businessKey);
    caseInstance.create(variables);
    return caseInstance;
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 24 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeActivity.

@Override
protected void initializeActivity(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    // execute standard initialization
    super.initializeActivity(element, activity, context);
    // create a taskDefinition
    TaskDefinition taskDefinition = createTaskDefinition(element, context);
    // get the caseDefinition...
    CaseDefinitionEntity caseDefinition = (CaseDefinitionEntity) context.getCaseDefinition();
    // ... and taskDefinition to caseDefinition
    caseDefinition.getTaskDefinitions().put(taskDefinition.getKey(), taskDefinition);
    ExpressionManager expressionManager = context.getExpressionManager();
    // create decorator
    TaskDecorator taskDecorator = new TaskDecorator(taskDefinition, expressionManager);
    // set taskDecorator on behavior
    HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
    behavior.setTaskDecorator(taskDecorator);
    // task listeners
    initializeTaskListeners(element, activity, context, taskDefinition);
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) TaskDecorator(org.camunda.bpm.engine.impl.task.TaskDecorator) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) HumanTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)

Example 25 with CaseDefinitionEntity

use of org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity in project camunda-bpm-platform by camunda.

the class GetDeploymentCmmnModelInstanceCmd method execute.

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;
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Aggregations

CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)31 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)6 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)5 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)4 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)4 InputStream (java.io.InputStream)3 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)3 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)2 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 Case (org.camunda.bpm.model.cmmn.instance.Case)2 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)2 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)2