Search in sources :

Example 11 with ModelException

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

the class AttributeReferenceCollectionBuilderImpl method performModelBuild.

@SuppressWarnings("unchecked")
public void performModelBuild(Model model) {
    // register declaring type as a referencing type of referenced type
    ModelElementTypeImpl referenceTargetType = (ModelElementTypeImpl) model.getType(referenceTargetElement);
    // the actual referenced type
    attributeReferenceCollection.setReferenceTargetElementType(referenceTargetType);
    // the referenced attribute may be declared on a base type of the referenced type.
    AttributeImpl<String> idAttribute = (AttributeImpl<String>) referenceTargetType.getAttribute("id");
    if (idAttribute != null) {
        idAttribute.registerIncoming(attributeReferenceCollection);
        attributeReferenceCollection.setReferenceTargetAttribute(idAttribute);
    } else {
        throw new ModelException("Element type " + referenceTargetType.getTypeNamespace() + ":" + referenceTargetType.getTypeName() + " has no id attribute");
    }
}
Also used : ModelException(org.camunda.bpm.model.xml.ModelException) AttributeImpl(org.camunda.bpm.model.xml.impl.type.attribute.AttributeImpl) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Aggregations

ModelException (org.camunda.bpm.model.xml.ModelException)11 DomElement (org.camunda.bpm.model.xml.instance.DomElement)4 ArrayList (java.util.ArrayList)3 ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)3 AttributeImpl (org.camunda.bpm.model.xml.impl.type.attribute.AttributeImpl)3 DomDocument (org.camunda.bpm.model.xml.instance.DomDocument)3 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)2 URISyntaxException (java.net.URISyntaxException)1 ModelBuildOperation (org.camunda.bpm.model.xml.impl.ModelBuildOperation)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1