Search in sources :

Example 16 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance 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)

Example 17 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-bpm-platform by camunda.

the class CmmnModelElementInstanceCmdTest method testRepositoryService.

@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testRepositoryService() {
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_KEY).singleResult().getId();
    CmmnModelInstance modelInstance = repositoryService.getCmmnModelInstance(caseDefinitionId);
    assertNotNull(modelInstance);
    Collection<ModelElementInstance> humanTasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(HumanTask.class));
    assertEquals(1, humanTasks.size());
    Collection<ModelElementInstance> planItems = modelInstance.getModelElementsByType(modelInstance.getModel().getType(PlanItem.class));
    assertEquals(1, planItems.size());
    Collection<ModelElementInstance> cases = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Case.class));
    assertEquals(1, cases.size());
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Case(org.camunda.bpm.model.cmmn.instance.Case) PluggableProcessEngineTestCase(org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 18 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldGetDescription.

@Test
public void shouldGetDescription() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    String description = casePlanModel.getDescription();
    assertThat(description).isEqualTo("This is a description...");
    Collection<Documentation> documentations = casePlanModel.getDocumentations();
    assertThat(documentations).isEmpty();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Documentation(org.camunda.bpm.model.cmmn.instance.Documentation) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Example 19 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldNotAbleToAddNewElement.

@Test
public void shouldNotAbleToAddNewElement() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    HumanTask humanTask = modelInstance.newInstance(HumanTask.class);
    casePlanModel.getPlanItemDefinitions().add(humanTask);
    try {
        Cmmn.writeModelToStream(System.out, modelInstance);
        fail("cannot save cmmn 1.0 model");
    } catch (Exception e) {
    // expected exception
    }
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Example 20 with CmmnModelInstance

use of org.camunda.bpm.model.cmmn.CmmnModelInstance in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldGetCasePlanModelExitCriterion.

@Test
public void shouldGetCasePlanModelExitCriterion() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    Collection<Sentry> exitCriterias = casePlanModel.getExitCriterias();
    assertThat(exitCriterias).hasSize(1);
    Collection<Sentry> exitCriteria = casePlanModel.getExitCriteria();
    assertThat(exitCriteria).hasSize(1);
    Collection<ExitCriterion> exitCriterions = casePlanModel.getExitCriterions();
    assertThat(exitCriterions).isEmpty();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Test(org.junit.Test)

Aggregations

CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)22 Test (org.junit.Test)14 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)6 Case (org.camunda.bpm.model.cmmn.instance.Case)4 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)4 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)2 PluggableProcessEngineTestCase (org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)2 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)2 Event (org.camunda.bpm.model.cmmn.instance.Event)2 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)2 TimerEvent (org.camunda.bpm.model.cmmn.instance.TimerEvent)2 UserEvent (org.camunda.bpm.model.cmmn.instance.UserEvent)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)1