Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue imixs#181
  • Loading branch information
rsoika committed Feb 17, 2023
1 parent 95aac59 commit 6f7d606
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.eclipse.glsp.server.operations.DeleteOperation;
import org.openbpmn.bpmn.elements.Association;
import org.openbpmn.bpmn.elements.BPMNProcess;
import org.openbpmn.bpmn.elements.Lane;
import org.openbpmn.bpmn.elements.Message;
import org.openbpmn.bpmn.elements.MessageFlow;
import org.openbpmn.bpmn.elements.Participant;
import org.openbpmn.bpmn.elements.SequenceFlow;
Expand All @@ -32,6 +32,11 @@

import com.google.inject.Inject;

/**
* Default Delete handler for all BPMN elements including all BPMN Node, Edges,
* Lanes, Processes and
* Messages.
*/
public class BPMNDeleteNodeHandler extends AbstractOperationHandler<DeleteOperation> {
private static Logger logger = Logger.getLogger(BPMNDeleteNodeHandler.class.getName());

Expand Down Expand Up @@ -59,20 +64,25 @@ public void executeOperation(final DeleteOperation operation) {
// find the bpmnBaseElement
BPMNElement bpmnElement = modelState.getBpmnModel().findElementById(id);
if (bpmnElement == null) {
logger.warning("...no BPMN elmenet with id: " + id + " found!");
logger.warning("...no BPMN element with id: " + id + " found!");
continue;
}
if (bpmnElement instanceof Lane) {
// delete lane
Lane lane = (Lane) bpmnElement;
lane.getBpmnProcess().deleteLane(id);

// Message nodes and edges are handled by the BPMNModel
if (bpmnElement instanceof Message) {
bpmnElement.getModel().deleteMessage(id);
continue;
}
if (bpmnElement instanceof MessageFlow) {
bpmnElement.getModel().deleteMessageFlow(id);
continue;
}

// Check if the element is a BPMNElementNode...
if (bpmnElement instanceof BPMNElementNode) {
// open the corresponding process
BPMNProcess process = ((BPMNElementNode) bpmnElement).getBpmnProcess();
process.deleteBPMNElementNode(id);
process.deleteElementNode(id);
continue;
}

Expand All @@ -91,10 +101,6 @@ public void executeOperation(final DeleteOperation operation) {
continue;
}

if (bpmnElement instanceof MessageFlow) {
bpmnElement.getModel().deleteMessageFlow(id);
}

}

// reset model state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ public void deleteSignal(String id) {
/**
* Deletes a Message element from this diagram.
* <p>
* The method removes the message element and the corresponding shape element.
*
* @param id
*/
Expand Down Expand Up @@ -918,10 +919,13 @@ public void deleteMessage(String id) {
}
}

// delete the element from teh definitions
// delete the element from the definitions and also the shape
this.definitions.removeChild(message.getElementNode());
if (message.getBpmnShape() != null) {
getBpmnPlane().removeChild(message.getBpmnShape());
}

// finally we remove the signal object form the signals list
// finally we remove the message object form the message list
getMessages().remove(message);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.logging.Logger;

import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNNS;
Expand Down Expand Up @@ -41,6 +42,8 @@
*/
public class BPMNProcess extends BPMNElement {

private static Logger logger = Logger.getLogger(BPMNProcess.class.getName());

protected String processType = BPMNTypes.PROCESS_TYPE_NONE;
protected Set<Activity> activities = null;
protected Set<DataObject> dataObjects = null;
Expand All @@ -53,7 +56,7 @@ public class BPMNProcess extends BPMNElement {
protected Set<Lane> lanes = null;
protected Element laneSet = null;

private boolean initalized = false;
private boolean initialized = false;

/**
* The method creates a BPMNProcess instance form a bpmn2:process model element.
Expand Down Expand Up @@ -93,7 +96,7 @@ public void setProcessType(String processType) {
* @throws BPMNModelException
*/
public void init() throws BPMNModelException {
if (!initalized) {
if (!initialized) {
// now find all relevant bpmn meta elements
NodeList childs = this.getElementNode().getChildNodes();
for (int j = 0; j < childs.getLength(); j++) {
Expand Down Expand Up @@ -127,7 +130,7 @@ public void init() throws BPMNModelException {
// unsupported node type
}
}
initalized = true;
initialized = true;
}
}

Expand Down Expand Up @@ -745,18 +748,21 @@ public void deleteLane(String id) {
}

/**
* Deletes a BPMN Element from this process
* Deletes a BPMN Element from this process. This will also remove all edges
* connected with this element. In case the element id is a BPMN lane, all
* referred elements for this lane will be deleted too.
*
* @param id
*/
public void deleteElementNode(String id) {
BPMNElementNode bpmnElement = findElementNodeById(id);
if (bpmnElement == null) {
// does not exist
logger.warning("Element '" + id + "' does not exists in current process!");
return;
}

// test if the elmen tis a lane
// test if the element is a lane
Lane lane = this.findLaneById(id);
if (lane != null) {
this.deleteLane(id);
Expand Down Expand Up @@ -790,41 +796,13 @@ public void deleteElementNode(String id) {
}
}

/**
* Deletes a BPMNBase element from this process
*
* @param id
*/
public void deleteBPMNElementNode(String id) {

BPMNElementNode baseElement = findElementNodeById(id);
if (baseElement instanceof Lane) {
this.deleteLane(id);
return;
}
if (baseElement instanceof Activity) {
this.deleteTask(id);
return;
}
if (baseElement instanceof Event) {
this.deleteEvent(id);
return;
}
if (baseElement instanceof Gateway) {
this.deleteGateway(id);
return;
}

}

/**
* Deletes a SquenceFlow from this context.
* <p>
*
* @param id
*/
public void deleteSequenceFlow(String id) {

BPMNElementEdge bpmnEdge = (BPMNElementEdge) findElementEdgeById(id);
if (bpmnEdge != null && bpmnEdge instanceof SequenceFlow) {
removeElementEdge(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public double getDefaultWidth() {
}

@Override
public double getDefaultHeigth() {
public double getDefaultHeight() {
return DEFAULT_HEIGHT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public double getDefaultWidth() {
}

@Override
public double getDefaultHeigth() {
public double getDefaultHeight() {
return DEFAULT_HEIGHT;
}
}

0 comments on commit 6f7d606

Please sign in to comment.