Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process act

BaseElement parsedElement = convertXMLToElement(xtr, model);

if (parsedElement instanceof Artifact) {
Artifact currentArtifact = (Artifact) parsedElement;
if (parsedElement instanceof Artifact currentArtifact) {
currentArtifact.setId(elementId);

if (!activeSubProcessList.isEmpty()) {
Expand All @@ -107,39 +106,34 @@ public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process act
}
}

if (parsedElement instanceof FlowElement) {
if (parsedElement instanceof FlowElement currentFlowElement) {

FlowElement currentFlowElement = (FlowElement) parsedElement;
currentFlowElement.setId(elementId);
if (currentFlowElement.getName() == null) {
currentFlowElement.setName(elementName);
}

if (currentFlowElement instanceof FlowNode) {
FlowNode flowNode = (FlowNode) currentFlowElement;
if (currentFlowElement instanceof FlowNode flowNode) {
flowNode.setAsynchronous(async);
flowNode.setAsynchronousLeave(asyncLeave);
flowNode.setNotExclusive(notExclusive);
flowNode.setAsynchronousLeaveNotExclusive(asyncLeaveNotExclusive);

if (currentFlowElement instanceof Activity) {
if (currentFlowElement instanceof Activity activity) {

Activity activity = (Activity) currentFlowElement;
activity.setForCompensation(isForCompensation);
if (StringUtils.isNotEmpty(defaultFlow)) {
activity.setDefaultFlow(defaultFlow);
}
}

if (currentFlowElement instanceof Gateway) {
Gateway gateway = (Gateway) currentFlowElement;
if (currentFlowElement instanceof Gateway gateway) {
if (StringUtils.isNotEmpty(defaultFlow)) {
gateway.setDefaultFlow(defaultFlow);
}
}

if (currentFlowElement instanceof ServiceTask) {
ServiceTask serviceTask = (ServiceTask) currentFlowElement;
if (currentFlowElement instanceof ServiceTask serviceTask) {
serviceTask.setTriggerable(triggerable);
}
}
Expand Down Expand Up @@ -175,8 +169,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel
}
}

if (baseElement instanceof FlowNode) {
final FlowNode flowNode = (FlowNode) baseElement;
if (baseElement instanceof FlowNode flowNode) {

if (flowNode.isAsynchronous()) {
writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
Expand All @@ -191,8 +184,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel
}
}

if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
if (baseElement instanceof Activity activity) {
if (activity.isForCompensation()) {
writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw);
}
Expand All @@ -204,8 +196,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel
}
}

if (baseElement instanceof Gateway) {
final Gateway gateway = (Gateway) baseElement;
if (baseElement instanceof Gateway gateway) {
if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
if (defaultFlowElement instanceof SequenceFlow) {
Expand All @@ -217,8 +208,7 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel

writeAdditionalAttributes(baseElement, model, xtw);

if (baseElement instanceof FlowElement) {
final FlowElement flowElement = (FlowElement) baseElement;
if (baseElement instanceof FlowElement flowElement) {
if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {

xtw.writeStartElement(ELEMENT_DOCUMENTATION);
Expand All @@ -234,17 +224,15 @@ public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel
didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, model.getNamespaces(), xtw);
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
if (baseElement instanceof Activity activity) {
didWriteExtensionStartElement = FailedJobRetryCountExport.writeFailedJobRetryCount(activity, didWriteExtensionStartElement, xtw);
}

if (didWriteExtensionStartElement) {
xtw.writeEndElement();
}

if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
if (baseElement instanceof Activity activity) {
MultiInstanceExport.writeMultiInstance(activity, model, xtw);

for (DataAssociation dataInputAssociation : activity.getDataInputAssociations()) {
Expand Down Expand Up @@ -663,15 +651,14 @@ protected void writeTerminateDefinition(Event parentEvent, TerminateEventDefinit
protected boolean writeVariableListenerDefinition(Event parentEvent, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
if (parentEvent.getEventDefinitions().size() == 1) {
EventDefinition eventDefinition = parentEvent.getEventDefinitions().iterator().next();
if (eventDefinition instanceof VariableListenerEventDefinition) {
if (eventDefinition instanceof VariableListenerEventDefinition variableListenerEventDefinition) {
if (!didWriteExtensionStartElement) {
xtw.writeStartElement(ELEMENT_EXTENSIONS);
didWriteExtensionStartElement = true;
}

xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_EVENT_VARIABLELISTENERDEFINITION, FLOWABLE_EXTENSIONS_NAMESPACE);

VariableListenerEventDefinition variableListenerEventDefinition = (VariableListenerEventDefinition) eventDefinition;
if (StringUtils.isNotEmpty(variableListenerEventDefinition.getVariableName())) {
writeDefaultAttribute(ATTRIBUTE_VARIABLE_NAME, variableListenerEventDefinition.getVariableName(), xtw);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {
} else if (ELEMENT_COMPLETION_CONDITION.equals(xtr.getLocalName())) {
if (!activeSubProcessList.isEmpty()) {
SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1);
if (subProcess instanceof AdhocSubProcess) {
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
if (subProcess instanceof AdhocSubProcess adhocSubProcess) {
adhocSubProcess.setCompletionCondition(xtr.getElementText());
}
}
Expand Down Expand Up @@ -472,8 +471,7 @@ public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {

protected void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
for (FlowElement flowElement : flowElementList) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (flowElement instanceof SequenceFlow sequenceFlow) {
FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
if (sourceNode != null) {
sourceNode.getOutgoingFlows().add(sequenceFlow);
Expand All @@ -486,17 +484,14 @@ protected void processFlowElements(Collection<FlowElement> flowElementList, Base
sequenceFlow.setTargetFlowElement(targetNode);
}

} else if (flowElement instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
} else if (flowElement instanceof BoundaryEvent boundaryEvent) {
FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
if (attachedToElement instanceof Activity) {
Activity attachedActivity = (Activity) attachedToElement;
if (attachedToElement instanceof Activity attachedActivity) {
boundaryEvent.setAttachedToRef(attachedActivity);
attachedActivity.getBoundaryEvents().add(boundaryEvent);
}

} else if (flowElement instanceof SubProcess) {
SubProcess subProcess = (SubProcess) flowElement;
} else if (flowElement instanceof SubProcess subProcess) {
Collection<FlowElement> childFlowElements = subProcess.getFlowElements();
processFlowElements(childFlowElements, subProcess);
}
Expand Down Expand Up @@ -579,9 +574,8 @@ public byte[] convertToXML(BpmnModel model, String encoding) {

protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception {

if (flowElement instanceof SubProcess) {
if (flowElement instanceof SubProcess subProcess) {

SubProcess subProcess = (SubProcess) flowElement;
if (flowElement instanceof Transaction) {
xtw.writeStartElement(ELEMENT_TRANSACTION);
} else if (flowElement instanceof AdhocSubProcess) {
Expand All @@ -602,8 +596,7 @@ protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWrit
if (subProcess instanceof EventSubProcess) {
xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE);

} else if (subProcess instanceof AdhocSubProcess) {
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
} else if (subProcess instanceof AdhocSubProcess adhocSubProcess) {
BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_CANCEL_REMAINING_INSTANCES, String.valueOf(adhocSubProcess.isCancelRemainingInstances()), xtw);
if (StringUtils.isNotEmpty(adhocSubProcess.getOrdering())) {
BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_ORDERING, adhocSubProcess.getOrdering(), xtw);
Expand Down Expand Up @@ -648,8 +641,7 @@ protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWrit
createXML(subElement, model, xtw);
}

if (subProcess instanceof AdhocSubProcess) {
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
if (subProcess instanceof AdhocSubProcess adhocSubProcess) {
if (StringUtils.isNotEmpty(adhocSubProcess.getCompletionCondition())) {
xtw.writeStartElement(ELEMENT_COMPLETION_CONDITION);
xtw.writeCData(adhocSubProcess.getCompletionCondition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ public String getElementName() {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof Lane)) {
if (!(parentElement instanceof Lane lane)) {
return;
}

Lane lane = (Lane) parentElement;
lane.getFlowReferences().add(xtr.getElementText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ public class FlowableCollectionParser extends BaseChildElementParser {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof MultiInstanceLoopCharacteristics)) {
if (!(parentElement instanceof MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics)) {
return;
}

MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = (MultiInstanceLoopCharacteristics) parentElement;

CollectionHandler collectionHandler = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp

BpmnXMLUtil.addCustomAttributes(xtr, parameter, defaultInParameterAttributes);

} else if (parentElement instanceof CallActivity) {
CallActivity callActivity = (CallActivity) parentElement;
} else if (parentElement instanceof CallActivity callActivity) {

String variables = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_VARIABLES);
if ("all".equalsIgnoreCase(variables)) {
Expand All @@ -95,4 +94,4 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp
((HasOutParameters) parentElement).addOutParameter(parameter);
}

} else if (parentElement instanceof CallActivity) {
CallActivity callActivity = (CallActivity) parentElement;
} else if (parentElement instanceof CallActivity callActivity) {

String variables = xtr.getAttributeValue(null, ATTRIBUTE_IOPARAMETER_VARIABLES);
if ("all".equalsIgnoreCase(variables)) {
Expand All @@ -84,4 +83,4 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ public String getElementName() {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof TimerEventDefinition)) {
if (!(parentElement instanceof TimerEventDefinition eventDefinition)) {
return;
}

TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement;

if (StringUtils.isNotEmpty(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_END_DATE, xtr))) {
eventDefinition.setEndDate(BpmnXMLUtil.getAttributeValue(ATTRIBUTE_END_DATE, xtr));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ public String getElementName() {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof TimerEventDefinition)) {
if (!(parentElement instanceof TimerEventDefinition eventDefinition)) {
return;
}

TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement;
eventDefinition.setTimeDate(xtr.getElementText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ public String getElementName() {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof TimerEventDefinition)) {
if (!(parentElement instanceof TimerEventDefinition eventDefinition)) {
return;
}

TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement;
eventDefinition.setTimeDuration(xtr.getElementText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ public class VariableAggregationDefinitionParser extends BaseChildElementParser

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof MultiInstanceLoopCharacteristics)) {
if (!(parentElement instanceof MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics)) {
return;
}

MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = (MultiInstanceLoopCharacteristics) parentElement;

VariableAggregationDefinition aggregationDefinition = new VariableAggregationDefinition();

if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_TASK_SERVICE_CLASS))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public String getElementName() {

@Override
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof Event)) {
if (!(parentElement instanceof Event event)) {
throw new FlowableException("variableListenerEventDefinition is only supported for events, not for activity id " + parentElement.getId());
}

Expand All @@ -49,8 +49,7 @@ public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, Bp

String variableChangeType = xtr.getAttributeValue(null, ATTRIBUTE_VARIABLE_CHANGE_TYPE);
eventDefinition.setVariableChangeType(variableChangeType);

Event event = (Event) parentElement;

event.addEventDefinition(eventDefinition);

model.addActivityIdForVariableListenerName(variableName, parentElement.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ public static void writeBPMNDI(BpmnModel model, XMLStreamWriter xtw) throws Exce
for (String elementId : model.getLocationMap().keySet()) {
FlowElement flowElement = model.getFlowElement(elementId);

if (flowElement instanceof SubProcess) {
if (flowElement instanceof SubProcess subProcess) {
String flowId = flowElement.getId();
GraphicInfo gi = model.getGraphicInfo(flowId);
Boolean isExpanded = gi.getExpanded();
if (isExpanded != null && isExpanded == false) {
SubProcess subProcess = (SubProcess) flowElement;
for (FlowElement element : subProcess.getFlowElements()) {
// the key is the element. the value is the collapsed subprocess.
collapsedSubProcessChildren.put(element.getId(), elementId);
Expand All @@ -78,15 +77,13 @@ public static void writeBPMNDI(BpmnModel model, XMLStreamWriter xtw) throws Exce
for (String elementId : model.getFlowLocationMap().keySet()) {
FlowElement flowElement = model.getFlowElement(elementId);
String belongsTo = null;
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (flowElement instanceof SequenceFlow sequenceFlow) {
belongsTo = collapsedSubProcessChildren.get(sequenceFlow.getTargetRef());

} else if (flowElement == null) {
// check if its an artifact
Artifact artifact = model.getArtifact(elementId);
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (artifact instanceof Association association) {
belongsTo = collapsedSubProcessChildren.get(association.getTargetRef());
}
}
Expand Down
Loading