Search in sources :

Example 21 with ModelElementInstance

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

Example 22 with ModelElementInstance

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

Example 23 with ModelElementInstance

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);
                }
            }
        }
    }
}
Also used : AttributeReference(org.camunda.bpm.model.xml.type.reference.AttributeReference) Reference(org.camunda.bpm.model.xml.type.reference.Reference) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) AttributeReference(org.camunda.bpm.model.xml.type.reference.AttributeReference) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow)

Example 24 with ModelElementInstance

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));
        }
    }
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Documentation(org.camunda.bpm.model.bpmn.instance.Documentation) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 25 with ModelElementInstance

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);
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) SequenceFlow(org.camunda.bpm.model.bpmn.instance.SequenceFlow) StartEvent(org.camunda.bpm.model.bpmn.instance.StartEvent) Event(org.camunda.bpm.model.bpmn.instance.Event) StartEvent(org.camunda.bpm.model.bpmn.instance.StartEvent) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

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