Search in sources :

Example 1 with PlanItemDefinition

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

the class SimpleTest method shouldGetElements.

@Test
@CmmnModelResource
public void shouldGetElements() {
    ModelElementInstance modelElementById = cmmnModelInstance.getModelElementById("Case_1");
    assertThat(modelElementById).isNotNull();
    Collection<Case> caseElements = cmmnModelInstance.getDefinitions().getCases();
    assertThat(caseElements).hasSize(1);
    Case caseElement = caseElements.iterator().next();
    assertThat(caseElement.getId()).isEqualTo("Case_1");
    assertThat(caseElement.getName()).isNull();
    CasePlanModel casePlanModel = caseElement.getCasePlanModel();
    assertThat(casePlanModel).isNotNull();
    assertThat(casePlanModel.getId()).isEqualTo("CasePlanModel_1");
    Collection<PlanItemDefinition> planItemDefinitions = casePlanModel.getPlanItemDefinitions();
    assertThat(planItemDefinitions).hasSize(1);
    PlanItemDefinition planItemDefinition = planItemDefinitions.iterator().next();
    assertThat(planItemDefinition).isInstanceOf(HumanTask.class);
    assertThat(planItemDefinition.getId()).isEqualTo("HumanTask_1");
    assertThat(planItemDefinition.getName()).isEqualTo("A HumanTask");
    Collection<PlanItem> planItems = casePlanModel.getPlanItems();
    PlanItem planItem = planItems.iterator().next();
    assertThat(planItem.getId()).isEqualTo("PI_HumanTask_1");
    assertThat(planItem.getDefinition()).isEqualTo(planItemDefinition);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) CmmnModelResource(org.camunda.bpm.model.cmmn.util.CmmnModelResource) Test(org.junit.Test)

Example 2 with PlanItemDefinition

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

the class ItemHandler method initializeVariableListeners.

protected void initializeVariableListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemDefinition definition = getDefinition(element);
    List<CamundaVariableListener> listeners = queryExtensionElementsByClass(definition, CamundaVariableListener.class);
    for (CamundaVariableListener listener : listeners) {
        CaseVariableListener variableListener = initializeVariableListener(element, activity, context, listener);
        String eventName = listener.getCamundaEvent();
        if (eventName != null) {
            activity.addVariableListener(eventName, variableListener);
        } else {
            for (String event : DEFAULT_VARIABLE_EVENTS) {
                activity.addVariableListener(event, variableListener);
            }
        }
    }
}
Also used : PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) CamundaVariableListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableListener) ExpressionCaseVariableListener(org.camunda.bpm.engine.impl.variable.listener.ExpressionCaseVariableListener) DelegateExpressionCaseVariableListener(org.camunda.bpm.engine.impl.variable.listener.DelegateExpressionCaseVariableListener) CaseVariableListener(org.camunda.bpm.engine.delegate.CaseVariableListener) ScriptCaseVariableListener(org.camunda.bpm.engine.impl.variable.listener.ScriptCaseVariableListener) ClassDelegateCaseVariableListener(org.camunda.bpm.engine.impl.variable.listener.ClassDelegateCaseVariableListener) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 3 with PlanItemDefinition

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

the class ItemHandler method getDesciption.

protected String getDesciption(CmmnElement element) {
    String description = element.getDescription();
    if (description == null) {
        PlanItemDefinition definition = getDefinition(element);
        description = definition.getDescription();
    }
    return description;
}
Also used : PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 4 with PlanItemDefinition

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

the class ItemHandler method initializeCaseExecutionListeners.

protected void initializeCaseExecutionListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemDefinition definition = getDefinition(element);
    List<CamundaCaseExecutionListener> listeners = queryExtensionElementsByClass(definition, CamundaCaseExecutionListener.class);
    for (CamundaCaseExecutionListener listener : listeners) {
        CaseExecutionListener caseExecutionListener = initializeCaseExecutionListener(element, activity, context, listener);
        String eventName = listener.getCamundaEvent();
        if (eventName != null) {
            activity.addListener(eventName, caseExecutionListener);
        } else {
            for (String event : getStandardEvents(element)) {
                activity.addListener(event, caseExecutionListener);
            }
        }
    }
}
Also used : CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener) DelegateExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener) ScriptCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener) ClassDelegateCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener) CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) CaseExecutionListener(org.camunda.bpm.engine.delegate.CaseExecutionListener) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 5 with PlanItemDefinition

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

the class ItemHandler method getDocumentation.

protected String getDocumentation(CmmnElement element) {
    Collection<Documentation> documentations = element.getDocumentations();
    if (documentations.isEmpty()) {
        PlanItemDefinition definition = getDefinition(element);
        documentations = definition.getDocumentations();
    }
    if (documentations.isEmpty()) {
        return null;
    }
    StringBuilder builder = new StringBuilder();
    for (Documentation doc : documentations) {
        String content = doc.getTextContent();
        if (content == null || content.isEmpty()) {
            continue;
        }
        if (builder.length() != 0) {
            builder.append("\n\n");
        }
        builder.append(content.trim());
    }
    return builder.toString();
}
Also used : PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) Documentation(org.camunda.bpm.model.cmmn.instance.Documentation) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Aggregations

PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)10 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)7 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)2 Stage (org.camunda.bpm.model.cmmn.instance.Stage)2 Collection (java.util.Collection)1 CaseExecutionListener (org.camunda.bpm.engine.delegate.CaseExecutionListener)1 CaseVariableListener (org.camunda.bpm.engine.delegate.CaseVariableListener)1 ItemHandler (org.camunda.bpm.engine.impl.cmmn.handler.ItemHandler)1 ClassDelegateCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener)1 DelegateExpressionCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener)1 ExpressionCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener)1 ScriptCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener)1 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)1 ClassDelegateCaseVariableListener (org.camunda.bpm.engine.impl.variable.listener.ClassDelegateCaseVariableListener)1 DelegateExpressionCaseVariableListener (org.camunda.bpm.engine.impl.variable.listener.DelegateExpressionCaseVariableListener)1 ExpressionCaseVariableListener (org.camunda.bpm.engine.impl.variable.listener.ExpressionCaseVariableListener)1 ScriptCaseVariableListener (org.camunda.bpm.engine.impl.variable.listener.ScriptCaseVariableListener)1 Case (org.camunda.bpm.model.cmmn.instance.Case)1 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)1 CaseTask (org.camunda.bpm.model.cmmn.instance.CaseTask)1