use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class ModifiableBpmnModelInstance method removeFlowNode.
public ModifiableBpmnModelInstance removeFlowNode(String flowNodeId) {
FlowNode flowNode = getModelElementById(flowNodeId);
ModelElementInstance scope = flowNode.getParentElement();
for (SequenceFlow outgoingFlow : flowNode.getOutgoing()) {
removeBpmnEdge(outgoingFlow);
scope.removeChildElement(outgoingFlow);
}
for (SequenceFlow incomingFlow : flowNode.getIncoming()) {
removeBpmnEdge(incomingFlow);
scope.removeChildElement(incomingFlow);
}
Collection<Association> associations = scope.getChildElementsByType(Association.class);
for (Association association : associations) {
if (flowNode.equals(association.getSource()) || flowNode.equals(association.getTarget())) {
removeBpmnEdge(association);
scope.removeChildElement(association);
}
}
removeBpmnShape(flowNode);
scope.removeChildElement(flowNode);
return this;
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class ModifiableBpmnModelInstance method removeBpmnShape.
protected void removeBpmnShape(FlowNode flowNode) {
Collection<BpmnShape> bpmnShapes = modelInstance.getModelElementsByType(BpmnShape.class);
for (BpmnShape shape : bpmnShapes) {
if (shape.getBpmnElement().equals(flowNode)) {
ModelElementInstance bpmnPlane = shape.getParentElement();
bpmnPlane.removeChildElement(shape);
break;
}
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class ModifiableBpmnModelInstance method removeBpmnEdge.
protected void removeBpmnEdge(BaseElement element) {
Collection<BpmnEdge> edges = modelInstance.getModelElementsByType(BpmnEdge.class);
for (BpmnEdge edge : edges) {
if (edge.getBpmnElement().equals(element)) {
ModelElementInstance bpmnPlane = edge.getParentElement();
bpmnPlane.removeChildElement(edge);
break;
}
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class UserTaskBpmnModelExecutionContextTest method assertModelInstance.
private void assertModelInstance() {
BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance;
assertNotNull(modelInstance);
Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
assertEquals(2, events.size());
Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
assertEquals(1, tasks.size());
Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
assertEquals(PROCESS_ID, process.getId());
assertTrue(process.isExecutable());
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class ProcessTest method shouldImportProcess.
@Test
@BpmnModelResource
public void shouldImportProcess() {
ModelElementInstance modelElementById = bpmnModelInstance.getModelElementById("exampleProcessId");
assertThat(modelElementById).isNotNull();
Collection<RootElement> rootElements = bpmnModelInstance.getDefinitions().getRootElements();
assertThat(rootElements).hasSize(1);
org.camunda.bpm.model.bpmn.instance.Process process = (Process) rootElements.iterator().next();
assertThat(process.getId()).isEqualTo("exampleProcessId");
assertThat(process.getName()).isNull();
assertThat(process.getProcessType()).isEqualTo(ProcessType.None);
assertThat(process.isExecutable()).isFalse();
assertThat(process.isClosed()).isFalse();
}
Aggregations