Search in sources :

Example 1 with ModelElementTypeImpl

use of org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl in project camunda-xml-model by camunda.

the class ModelUtil method calculateAllBaseTypes.

/**
 * Calculate a collection of all base types for the given type
 */
public static Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type) {
    List<ModelElementType> baseTypes = new ArrayList<ModelElementType>();
    ModelElementTypeImpl typeImpl = (ModelElementTypeImpl) type;
    typeImpl.resolveBaseTypes(baseTypes);
    return baseTypes;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Example 2 with ModelElementTypeImpl

use of org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl in project camunda-xml-model by camunda.

the class ElementReferenceCollectionBuilderImpl method performModelBuild.

@SuppressWarnings("unchecked")
public void performModelBuild(Model model) {
    ModelElementTypeImpl referenceTargetType = (ModelElementTypeImpl) model.getType(referenceTargetClass);
    ModelElementTypeImpl referenceSourceType = (ModelElementTypeImpl) model.getType(childElementType);
    elementReferenceCollectionImpl.setReferenceTargetElementType(referenceTargetType);
    elementReferenceCollectionImpl.setReferenceSourceElementType(referenceSourceType);
    // 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(elementReferenceCollectionImpl);
        elementReferenceCollectionImpl.setReferenceTargetAttribute(idAttribute);
    } else {
        throw new ModelException("Unable to find id attribute of " + referenceTargetClass);
    }
}
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)

Example 3 with ModelElementTypeImpl

use of org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl in project camunda-xml-model by camunda.

the class ModelUtil method getModelElement.

protected static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, String namespaceUri) {
    String localName = domElement.getLocalName();
    ModelElementTypeImpl modelType = (ModelElementTypeImpl) modelInstance.getModel().getTypeForName(namespaceUri, localName);
    if (modelType == null) {
        Model model = modelInstance.getModel();
        String actualNamespaceUri = model.getActualNamespace(namespaceUri);
        if (actualNamespaceUri != null) {
            modelType = getModelElement(domElement, modelInstance, actualNamespaceUri);
        } else {
            modelType = (ModelElementTypeImpl) modelInstance.registerGenericType(namespaceUri, localName);
        }
    }
    return modelType;
}
Also used : Model(org.camunda.bpm.model.xml.Model) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Example 4 with ModelElementTypeImpl

use of org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl in project camunda-xml-model by camunda.

the class ModelUtil method getModelElement.

/**
 * Returns the {@link ModelElementInstanceImpl ModelElement} for a DOM element.
 * If the model element does not yet exist, it is created and linked to the DOM.
 *
 * @param domElement the child element to create a new {@link ModelElementInstanceImpl ModelElement} for
 * @return the child model element
 */
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance) {
    ModelElementInstance modelElement = domElement.getModelElementInstance();
    if (modelElement == null) {
        ModelElementTypeImpl modelType = getModelElement(domElement, modelInstance, domElement.getNamespaceURI());
        modelElement = modelType.newInstance(modelInstance, domElement);
        domElement.setModelElementInstance(modelElement);
    }
    return modelElement;
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Example 5 with ModelElementTypeImpl

use of org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl in project camunda-xml-model by camunda.

the class ModelUtil method calculateAllExtendingTypes.

/**
 * Calculate a collection of all extending types for the given base types
 *
 * @param baseTypes the collection of types to calculate the union of all extending types
 */
public static Collection<ModelElementType> calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes) {
    Set<ModelElementType> allExtendingTypes = new HashSet<ModelElementType>();
    for (ModelElementType baseType : baseTypes) {
        ModelElementTypeImpl modelElementTypeImpl = (ModelElementTypeImpl) model.getType(baseType.getInstanceType());
        modelElementTypeImpl.resolveExtendingTypes(allExtendingTypes);
    }
    return allExtendingTypes;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelElementTypeImpl(org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)

Aggregations

ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)7 ModelException (org.camunda.bpm.model.xml.ModelException)3 AttributeImpl (org.camunda.bpm.model.xml.impl.type.attribute.AttributeImpl)3 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)2 Model (org.camunda.bpm.model.xml.Model)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1