Search in sources :

Example 1 with DomDocument

use of org.camunda.bpm.model.xml.instance.DomDocument in project camunda-xml-model by camunda.

the class ElementReferenceCollectionImpl method getView.

protected Collection<DomElement> getView(ModelElementInstanceImpl referenceSourceParentElement) {
    DomDocument document = referenceSourceParentElement.getModelInstance().getDocument();
    Collection<Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
    Collection<DomElement> referenceTargetElements = new ArrayList<DomElement>();
    for (Source referenceSourceElement : referenceSourceElements) {
        String identifier = getReferenceIdentifier(referenceSourceElement);
        DomElement referenceTargetElement = document.getElementById(identifier);
        if (referenceTargetElement != null) {
            referenceTargetElements.add(referenceTargetElement);
        } else {
            throw new ModelException("Unable to find a model element instance for id " + identifier);
        }
    }
    return referenceTargetElements;
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelException(org.camunda.bpm.model.xml.ModelException) ArrayList(java.util.ArrayList) DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Example 2 with DomDocument

use of org.camunda.bpm.model.xml.instance.DomDocument in project camunda-xml-model by camunda.

the class IdsElementReferenceCollectionImpl method getView.

@Override
protected Collection<DomElement> getView(ModelElementInstanceImpl referenceSourceParentElement) {
    DomDocument document = referenceSourceParentElement.getModelInstance().getDocument();
    Collection<Source> referenceSourceElements = getReferenceSourceCollection().get(referenceSourceParentElement);
    Collection<DomElement> referenceTargetElements = new ArrayList<DomElement>();
    for (Source referenceSourceElement : referenceSourceElements) {
        List<String> identifiers = getReferenceIdentifiers(referenceSourceElement);
        for (String identifier : identifiers) {
            DomElement referenceTargetElement = document.getElementById(identifier);
            if (referenceTargetElement != null) {
                referenceTargetElements.add(referenceTargetElement);
            } else {
                throw new ModelException("Unable to find a model element instance for id " + identifier);
            }
        }
    }
    return referenceTargetElements;
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelException(org.camunda.bpm.model.xml.ModelException) ArrayList(java.util.ArrayList) DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Example 3 with DomDocument

use of org.camunda.bpm.model.xml.instance.DomDocument in project camunda-xml-model by camunda.

the class AttributeReferenceCollection method getView.

private Collection<DomElement> getView(ModelElementInstance referenceSourceElement) {
    DomDocument document = referenceSourceElement.getModelInstance().getDocument();
    String identifier = getReferenceIdentifier(referenceSourceElement);
    List<String> references = StringUtil.splitListBySeparator(identifier, separator);
    Collection<DomElement> referenceTargetElements = new ArrayList<DomElement>();
    for (String reference : references) {
        DomElement referenceTargetElement = document.getElementById(reference);
        if (referenceTargetElement != null) {
            referenceTargetElements.add(referenceTargetElement);
        } else {
            throw new ModelException("Unable to find a model element instance for id " + identifier);
        }
    }
    return referenceTargetElements;
}
Also used : DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelException(org.camunda.bpm.model.xml.ModelException) ArrayList(java.util.ArrayList) DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Example 4 with DomDocument

use of org.camunda.bpm.model.xml.instance.DomDocument in project camunda-xml-model by camunda.

the class UnknownAnimalTest method validateModel.

@After
public void validateModel() {
    DomDocument document = modelInstance.getDocument();
    modelParser.validateModel(document);
}
Also used : DomDocument(org.camunda.bpm.model.xml.instance.DomDocument) After(org.junit.After)

Example 5 with DomDocument

use of org.camunda.bpm.model.xml.instance.DomDocument in project camunda-xml-model by camunda.

the class AbstractModelParser method parseModelFromStream.

public ModelInstance parseModelFromStream(InputStream inputStream) {
    DomDocument document = null;
    synchronized (documentBuilderFactory) {
        document = DomUtil.parseInputStream(documentBuilderFactory, inputStream);
    }
    validateModel(document);
    return createModelInstance(document);
}
Also used : DomDocument(org.camunda.bpm.model.xml.instance.DomDocument)

Aggregations

DomDocument (org.camunda.bpm.model.xml.instance.DomDocument)7 DomElement (org.camunda.bpm.model.xml.instance.DomElement)5 ArrayList (java.util.ArrayList)4 ModelException (org.camunda.bpm.model.xml.ModelException)3 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)2 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 After (org.junit.After)1