PlanItem source = onPart.getSource();
PlanItemTransition standardEvent = onPart.getStandardEvent();
if (source != null && standardEvent != null) {
CmmnOnPartDeclaration onPartDeclaration = new CmmnOnPartDeclaration();
// initialize standardEvent
String standardEventName = standardEvent.name();
onPartDeclaration.setStandardEvent(standardEventName);
// initialize sourceRef
String sourceId = source.getId();
CmmnActivity sourceActivity = parent.findActivity(sourceId);
if (sourceActivity != null) {
onPartDeclaration.setSource(sourceActivity);
}
// initialize sentryRef
Sentry sentryRef = onPart.getSentry();
if (sentryRef != null) {
String sentryRefId = sentryRef.getId();
CmmnSentryDeclaration sentryRefDeclaration = parent.getSentry(sentryRefId);
onPartDeclaration.setSentry(sentryRefDeclaration);
}
// add onPartDeclaration to sentryDeclaration
sentryDeclaration.addOnPart(onPartDeclaration);
}