Search in sources :

Example 26 with ModelElementInstance

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;
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 27 with ModelElementInstance

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;
        }
    }
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 28 with ModelElementInstance

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;
        }
    }
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) BpmnEdge(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnEdge)

Example 29 with ModelElementInstance

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());
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 30 with ModelElementInstance

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();
}
Also used : RootElement(org.camunda.bpm.model.bpmn.instance.RootElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelResource(org.camunda.bpm.model.bpmn.util.BpmnModelResource) Test(org.junit.Test)

Aggregations

ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)55 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)8 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)8 Process (org.camunda.bpm.model.bpmn.instance.Process)5 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)5 ModelReferenceException (org.camunda.bpm.model.xml.ModelReferenceException)4 DomElement (org.camunda.bpm.model.xml.instance.DomElement)4 List (java.util.List)3 Model (org.camunda.bpm.model.xml.Model)3 Deployment (org.camunda.bpm.engine.test.Deployment)2 Event (org.camunda.bpm.model.bpmn.instance.Event)2 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)2 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)2 Case (org.camunda.bpm.model.cmmn.instance.Case)2 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)2 TestModelTest (org.camunda.bpm.model.xml.testmodel.TestModelTest)2 ModelElementValidator (org.camunda.bpm.model.xml.validation.ModelElementValidator)2 ValidationResult (org.camunda.bpm.model.xml.validation.ValidationResult)2