use of org.camunda.bpm.model.cmmn.instance.PlanItemOnPart in project camunda-cmmn-model by camunda.
the class PlanItemOnPartImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(PlanItemOnPart.class, CMMN_ELEMENT_PLAN_ITEM_ON_PART).extendsType(OnPart.class).namespaceUri(CMMN11_NS).instanceProvider(new ModelTypeInstanceProvider<PlanItemOnPart>() {
public PlanItemOnPart newInstance(ModelTypeInstanceContext instanceContext) {
return new PlanItemOnPartImpl(instanceContext);
}
});
sourceRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_SOURCE_REF).idAttributeReference(PlanItem.class).build();
exitCriterionRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_EXIT_CRITERION_REF).idAttributeReference(ExitCriterion.class).build();
sentryRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_SENTRY_REF).namespace(CMMN10_NS).idAttributeReference(Sentry.class).build();
SequenceBuilder sequenceBuilder = typeBuilder.sequence();
standardEventChild = sequenceBuilder.element(PlanItemTransitionStandardEvent.class).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.cmmn.instance.PlanItemOnPart in project camunda-bpm-platform by camunda.
the class SentryHandler method handleElement.
public CmmnSentryDeclaration handleElement(Sentry element, CmmnHandlerContext context) {
String id = element.getId();
Collection<OnPart> onParts = element.getOnParts();
IfPart ifPart = element.getIfPart();
List<CamundaVariableOnPart> variableOnParts = queryExtensionElementsByClass(element, CamundaVariableOnPart.class);
if ((ifPart == null || ifPart.getConditions().isEmpty()) && variableOnParts.isEmpty()) {
if (onParts == null || onParts.isEmpty()) {
LOG.ignoredSentryWithMissingCondition(id);
return null;
} else {
boolean atLeastOneOnPartsValid = false;
for (OnPart onPart : onParts) {
if (onPart instanceof PlanItemOnPart) {
PlanItemOnPart planItemOnPart = (PlanItemOnPart) onPart;
if (planItemOnPart.getSource() != null && planItemOnPart.getStandardEvent() != null) {
atLeastOneOnPartsValid = true;
break;
}
}
}
if (!atLeastOneOnPartsValid) {
LOG.ignoredSentryWithInvalidParts(id);
return null;
}
}
}
CmmnSentryDeclaration sentryDeclaration = new CmmnSentryDeclaration(id);
// the ifPart will be initialized immediately
initializeIfPart(ifPart, sentryDeclaration, context);
// the variableOnParts will be initialized immediately as it does not have any dependency
initializeVariableOnParts(element, sentryDeclaration, context, variableOnParts);
// ...whereas the onParts will be initialized later because the
// the reference to the plan items (sourceRef) and the reference
// to the sentry (sentryRef) cannot be set in this step. To set
// the corresponding reference (sourceRef or sentryRef) on the
// transformed sentry all planned items and all sentries inside
// the current stage should be already transformed.
CmmnActivity parent = context.getParent();
if (parent != null) {
parent.addSentry(sentryDeclaration);
}
return sentryDeclaration;
}
Aggregations