Java Code Examples for org.camunda.bpm.model.xml.instance.ModelElementInstance#getChildElementsByType()
The following examples show how to use
org.camunda.bpm.model.xml.instance.ModelElementInstance#getChildElementsByType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnknownAnimalTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testAddUnknownAnimal() { ModelInstanceImpl modelInstanceImpl = (ModelInstanceImpl) modelInstance; ModelElementType unknownAnimalType = modelInstanceImpl.registerGenericType(MODEL_NAMESPACE, "unknownAnimal"); ModelElementType animalsType = modelInstance.getModel().getType(Animals.class); ModelElementType animalType = modelInstance.getModel().getType(Animal.class); ModelElementInstance unknownAnimal = modelInstance.newInstance(unknownAnimalType); assertThat(unknownAnimal).isNotNull(); unknownAnimal.setAttributeValue("id", "new-animal", true); unknownAnimal.setAttributeValue("gender", "Unknown"); unknownAnimal.setAttributeValue("species", "unknown"); ModelElementInstance animals = modelInstance.getModelElementsByType(animalsType).iterator().next(); List<ModelElementInstance> childElementsByType = new ArrayList<ModelElementInstance>(animals.getChildElementsByType(animalType)); animals.insertElementAfter(unknownAnimal, childElementsByType.get(2)); assertThat(animals.getChildElementsByType(unknownAnimalType)).hasSize(3); }
Example 2
Source File: ProcessDefinitionQueryImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void addProcessDefinitionToCacheAndRetrieveDocumentation(List<ProcessDefinition> list) { for (ProcessDefinition processDefinition : list) { BpmnModelInstance bpmnModelInstance = Context.getProcessEngineConfiguration() .getDeploymentCache() .findBpmnModelInstanceForProcessDefinition((ProcessDefinitionEntity) processDefinition); ModelElementInstance processElement = bpmnModelInstance.getModelElementById(processDefinition.getKey()); if (processElement != null) { Collection<Documentation> documentations = processElement.getChildElementsByType(Documentation.class); List<String> docStrings = new ArrayList<String>(); for (Documentation documentation : documentations) { docStrings.add(documentation.getTextContent()); } ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition; processDefinitionEntity.setProperty(BpmnParse.PROPERTYNAME_DOCUMENTATION, BpmnParse.parseDocumentation(docStrings)); } } }
Example 3
Source File: ModifiableBpmnModelInstance.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: AlternativeNsTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void getChildElementsByTypeForAlternativeNs() { ModelElementInstance birdo = modelInstance.getModelElementById("birdo"); assertThat(birdo, is(notNullValue())); Collection<Wings> elements = birdo.getChildElementsByType(Wings.class); assertThat(elements.size(), is(1)); assertThat(elements.iterator().next().getTextContent(), is("zisch")); }
Example 5
Source File: AlternativeNsTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void getChildElementsByTypeForSecondAlternativeNs() { // given ModelElementInstance donald = modelInstance.getModelElementById("donald"); // when Collection<Wings> elements = donald.getChildElementsByType(Wings.class); // then assertThat(elements.size(), is(1)); assertThat(elements.iterator().next().getTextContent(), is("flappy")); }