Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
Issue #245
  • Loading branch information
rsoika committed May 12, 2023
1 parent 02554a8 commit 79c4ab9
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNTypes;
import org.openbpmn.bpmn.elements.BPMNProcess;
import org.openbpmn.bpmn.elements.core.BPMNElementNode;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.glsp.bpmn.BPMNGNode;
import org.openbpmn.glsp.elements.CreateBPMNEdgeOperationHandler;
Expand Down Expand Up @@ -96,18 +97,20 @@ protected void executeOperation(final CreateEdgeOperation operation) {
}

if (BPMNTypes.ASSOCIATION.equals(edgeType)) {
// if one of the processes is the default, than we assign the association to the
// default process
String sourceProcessId = modelState.getBpmnModel().findElementNodeById(sourceId).getProcessId();
String targetProcessId = modelState.getBpmnModel().findElementNodeById(targetId).getProcessId();
BPMNProcess sourceProcess = modelState.getBpmnModel().openProcess(sourceProcessId);
BPMNProcess targetProcess = modelState.getBpmnModel().openProcess(targetProcessId);
// if one of the element nodes is assigned to the default process, than we
// assign the association also to the default process
BPMNElementNode sourceElementNode = (BPMNElementNode) modelState.getBpmnModel()
.findElementById(sourceId);
BPMNElementNode targetElementNode = (BPMNElementNode) modelState.getBpmnModel()
.findElementById(targetId);
BPMNProcess sourceProcess = sourceElementNode.getBpmnProcess();
BPMNProcess targetProcess = targetElementNode.getBpmnProcess();
if (sourceProcess.isPublicProcess()) {
sourceProcess.addAssociation(BPMNModel.generateShortID("association"), sourceId, targetId);
} else {
// in any case this is the best match now
targetProcess.addAssociation(BPMNModel.generateShortID("association"), sourceId, targetId);
}

}

if (BPMNTypes.MESSAGE_FLOW.equals(edgeType)) {
Expand Down

0 comments on commit 79c4ab9

Please sign in to comment.