Search in sources :

Example 6 with Case

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

the class DeployCmd method retrieveProcessKeysFromResources.

protected Set<String> retrieveProcessKeysFromResources(Map<String, ResourceEntity> resources) {
    Set<String> keys = new HashSet<String>();
    for (ResourceEntity resource : resources.values()) {
        if (isBpmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            BpmnModelInstance model = Bpmn.readModelFromStream(byteStream);
            for (Process process : model.getDefinitions().getChildElementsByType(Process.class)) {
                keys.add(process.getId());
            }
        } else if (isCmmnResource(resource)) {
            ByteArrayInputStream byteStream = new ByteArrayInputStream(resource.getBytes());
            CmmnModelInstance model = Cmmn.readModelFromStream(byteStream);
            for (Case cmmnCase : model.getDefinitions().getCases()) {
                keys.add(cmmnCase.getId());
            }
        }
    }
    return keys;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) HashSet(java.util.HashSet) Case(org.camunda.bpm.model.cmmn.instance.Case)

Example 7 with Case

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

the class CmmnDeployerTest method createCmmnModelInstance.

protected static CmmnModelInstance createCmmnModelInstance() {
    final CmmnModelInstance modelInstance = Cmmn.createEmptyModel();
    org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(org.camunda.bpm.model.cmmn.instance.Definitions.class);
    definitions.setTargetNamespace("http://camunda.org/examples");
    modelInstance.setDefinitions(definitions);
    Case caseElement = modelInstance.newInstance(Case.class);
    caseElement.setId("a-case");
    definitions.addChildElement(caseElement);
    CasePlanModel casePlanModel = modelInstance.newInstance(CasePlanModel.class);
    caseElement.setCasePlanModel(casePlanModel);
    Cmmn.writeModelToStream(System.out, modelInstance);
    return modelInstance;
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Case(org.camunda.bpm.model.cmmn.instance.Case) PluggableProcessEngineTestCase(org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)

Example 8 with Case

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

the class CmmnTransform method transformCase.

protected CaseDefinitionEntity transformCase(Case element) {
    // get CaseTransformer
    CmmnElementHandler<Case, CmmnActivity> caseTransformer = getDefinitionHandler(Case.class);
    CmmnActivity definition = caseTransformer.handleElement(element, context);
    context.setCaseDefinition((CmmnCaseDefinition) definition);
    context.setParent(definition);
    CasePlanModel casePlanModel = element.getCasePlanModel();
    transformCasePlanModel(casePlanModel);
    for (CmmnTransformListener transformListener : transformListeners) {
        transformListener.transformCase(element, (CmmnCaseDefinition) definition);
    }
    return (CaseDefinitionEntity) definition;
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Case(org.camunda.bpm.model.cmmn.instance.Case)

Example 9 with Case

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

the class CreateModelTest method createCaseWithOneStageAndNestedHumanTask.

@Test
public void createCaseWithOneStageAndNestedHumanTask() {
    // create process
    Case caseInstance = createElement(definitions, "case-with-one-human-task", Case.class);
    // create case plan model
    CasePlanModel casePlanModel = createElement(caseInstance, "casePlanModel_1", CasePlanModel.class);
    // create a stage
    Stage stage = createElement(casePlanModel, "Stage_1", Stage.class);
    // create elements
    HumanTask humanTask = createElement(stage, "HumanTask_1", HumanTask.class);
    // create a plan item
    PlanItem planItem = createElement(stage, "PlanItem_1", PlanItem.class);
    // set definition to human task
    planItem.setDefinition(humanTask);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Stage(org.camunda.bpm.model.cmmn.instance.Stage) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Example 10 with Case

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

the class GenerateIdTest method shouldGenerateIdsOnCreate.

@Test
public void shouldGenerateIdsOnCreate() {
    CmmnModelInstance modelInstance = Cmmn.createEmptyModel();
    Definitions definitions = modelInstance.newInstance(Definitions.class);
    assertThat(definitions.getId()).isNotNull();
    Case caseElement = modelInstance.newInstance(Case.class);
    assertThat(caseElement.getId()).isNotNull();
    CasePlanModel casePlanModel = modelInstance.newInstance(CasePlanModel.class);
    assertThat(casePlanModel.getId()).isNotNull();
    HumanTask humanTask = modelInstance.newInstance(HumanTask.class);
    assertThat(humanTask.getId()).isNotNull();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Definitions(org.camunda.bpm.model.cmmn.instance.Definitions) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Aggregations

Case (org.camunda.bpm.model.cmmn.instance.Case)11 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)7 Test (org.junit.Test)6 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)4 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)3 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)3 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)1 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)1 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)1 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)1 PluggableProcessEngineTestCase (org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1 Process (org.camunda.bpm.model.bpmn.instance.Process)1 CaseRole (org.camunda.bpm.model.cmmn.instance.CaseRole)1 CaseRoles (org.camunda.bpm.model.cmmn.instance.CaseRoles)1 PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)1 Stage (org.camunda.bpm.model.cmmn.instance.Stage)1