use of org.eclipse.bpmn2.Escalation in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method setThrowEventProperties.
private void setThrowEventProperties(ThrowEvent event, Map<String, Object> properties, Definitions def) {
if (event.getInputSet() != null) {
List<DataInput> dataInputs = event.getInputSet().getDataInputRefs();
StringBuffer dinbuff = new StringBuffer();
for (DataInput din : dataInputs) {
dinbuff.append(din.getName());
String dtype = getAnyAttributeValue(din, "dtype");
if (dtype != null && !dtype.isEmpty()) {
dinbuff.append(":").append(dtype);
}
dinbuff.append(",");
}
if (dinbuff.length() > 0) {
dinbuff.setLength(dinbuff.length() - 1);
}
String datainput = dinbuff.toString();
properties.put(DATAINPUT, datainput);
StringBuilder associationBuff = new StringBuilder();
marshallDataInputAssociations(associationBuff, event.getDataInputAssociation());
String assignmentString = associationBuff.toString();
if (assignmentString.endsWith(",")) {
assignmentString = assignmentString.substring(0, assignmentString.length() - 1);
}
properties.put(DATAINPUTASSOCIATIONS, assignmentString);
setAssignmentsInfoProperty(datainput, null, null, null, assignmentString, properties);
}
// signal scope
String signalScope = Utils.getMetaDataValue(event.getExtensionValues(), "customScope");
if (signalScope != null) {
properties.put(SIGNALSCOPE, signalScope);
}
// event definitions
List<EventDefinition> eventdefs = event.getEventDefinitions();
for (EventDefinition ed : eventdefs) {
if (ed instanceof TimerEventDefinition) {
setTimerEventProperties((TimerEventDefinition) ed, properties);
} else if (ed instanceof SignalEventDefinition) {
if (((SignalEventDefinition) ed).getSignalRef() != null) {
// find signal with the corresponding id
boolean foundSignalRef = false;
List<RootElement> rootElements = def.getRootElements();
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) {
properties.put(SIGNALREF, ((Signal) re).getName());
foundSignalRef = true;
}
}
}
if (!foundSignalRef) {
properties.put(SIGNALREF, "");
}
} else {
properties.put(SIGNALREF, "");
}
} else if (ed instanceof ErrorEventDefinition) {
if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) {
properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode());
} else {
properties.put(ERRORREF, "");
}
} else if (ed instanceof ConditionalEventDefinition) {
FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed).getCondition();
if (conditionalExp != null) {
setConditionExpressionProperties(conditionalExp, properties, "drools");
}
} else if (ed instanceof EscalationEventDefinition) {
if (((EscalationEventDefinition) ed).getEscalationRef() != null) {
Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef();
if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) {
properties.put(ESCALATIONCODE, esc.getEscalationCode());
} else {
properties.put(ESCALATIONCODE, "");
}
}
} else if (ed instanceof MessageEventDefinition) {
if (((MessageEventDefinition) ed).getMessageRef() != null) {
Message msg = ((MessageEventDefinition) ed).getMessageRef();
properties.put(MESSAGEREF, msg.getName());
}
} else if (ed instanceof CompensateEventDefinition) {
if (((CompensateEventDefinition) ed).getActivityRef() != null) {
Activity act = ((CompensateEventDefinition) ed).getActivityRef();
properties.put(ACTIVITYREF, act.getName());
}
}
}
}
Aggregations