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);
}
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);
}
}
}
}
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;
}
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);
}
}
}
}
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();
}
Aggregations