use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class AbstractGatewayTest method getGateway.
@Before
@SuppressWarnings("unchecked")
public void getGateway() {
InputStream inputStream = ReflectUtil.getResourceAsStream("org/camunda/bpm/model/bpmn/GatewaysTest.xml");
Collection<ModelElementInstance> elementInstances = Bpmn.readModelFromStream(inputStream).getModelElementsByType(modelElementType);
assertThat(elementInstances).hasSize(1);
gateway = (G) elementInstances.iterator().next();
assertThat(gateway.getGatewayDirection()).isEqualTo(GatewayDirection.Mixed);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class ExtensionElementsImpl method addExtensionElement.
public ModelElementInstance addExtensionElement(String namespaceUri, String localName) {
ModelElementType extensionElementType = modelInstance.registerGenericType(namespaceUri, localName);
ModelElementInstance extensionElement = extensionElementType.newInstance(modelInstance);
addChildElement(extensionElement);
return extensionElement;
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class FlowNodeImpl method updateAfterReplacement.
@SuppressWarnings("rawtypes")
public void updateAfterReplacement() {
super.updateAfterReplacement();
Collection<Reference> incomingReferences = getIncomingReferencesByType(SequenceFlow.class);
for (Reference<?> reference : incomingReferences) {
for (ModelElementInstance sourceElement : reference.findReferenceSourceElements(this)) {
String referenceIdentifier = reference.getReferenceIdentifier(sourceElement);
if (referenceIdentifier != null && referenceIdentifier.equals(getId()) && reference instanceof AttributeReference) {
String attributeName = ((AttributeReference) reference).getReferenceSourceAttribute().getAttributeName();
if (attributeName.equals(BPMN_ATTRIBUTE_SOURCE_REF)) {
getOutgoing().add((SequenceFlow) sourceElement);
} else if (attributeName.equals(BPMN_ATTRIBUTE_TARGET_REF)) {
getIncoming().add((SequenceFlow) sourceElement);
}
}
}
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class ProcessDefinitionQueryImpl method addProcessDefinitionToCacheAndRetrieveDocumentation.
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));
}
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class BpmnModelInstanceCmdTest method testRepositoryService.
@Deployment(resources = "org/camunda/bpm/engine/test/repository/one.bpmn20.xml")
public void testRepositoryService() {
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_KEY).singleResult().getId();
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
assertNotNull(modelInstance);
Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
assertEquals(2, events.size());
Collection<ModelElementInstance> sequenceFlows = modelInstance.getModelElementsByType(modelInstance.getModel().getType(SequenceFlow.class));
assertEquals(1, sequenceFlows.size());
StartEvent startEvent = modelInstance.getModelElementById("start");
assertNotNull(startEvent);
}
Aggregations