Search in sources :

Example 1 with Reference

use of org.camunda.bpm.model.xml.type.reference.Reference 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 2 with Reference

use of org.camunda.bpm.model.xml.type.reference.Reference in project camunda-bpmn-model by camunda.

the class BaseElementImpl method getIncomingReferencesByType.

@SuppressWarnings("rawtypes")
public Collection<Reference> getIncomingReferencesByType(Class<? extends ModelElementInstance> referenceSourceTypeClass) {
    Collection<Reference> references = new ArrayList<Reference>();
    // we traverse all incoming references in reverse direction
    for (Reference<?> reference : idAttribute.getIncomingReferences()) {
        ModelElementType sourceElementType = reference.getReferenceSourceElementType();
        Class<? extends ModelElementInstance> sourceInstanceType = sourceElementType.getInstanceType();
        // if the referencing element (source element) is a BPMNDI element, dig deeper
        if (referenceSourceTypeClass.isAssignableFrom(sourceInstanceType)) {
            references.add(reference);
        }
    }
    return references;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Reference(org.camunda.bpm.model.xml.type.reference.Reference) ArrayList(java.util.ArrayList)

Aggregations

Reference (org.camunda.bpm.model.xml.type.reference.Reference)2 ArrayList (java.util.ArrayList)1 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)1 AttributeReference (org.camunda.bpm.model.xml.type.reference.AttributeReference)1