use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-cmmn-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;
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-cmmn-model by camunda.
the class ExtensionElementsImpl method addExtensionElement.
public <T extends ModelElementInstance> T addExtensionElement(Class<T> extensionElementClass) {
ModelElementInstance extensionElement = modelInstance.newInstance(extensionElementClass);
addChildElement(extensionElement);
return extensionElementClass.cast(extensionElement);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ElementReferenceImpl method getReferenceTargetElement.
@SuppressWarnings("unchecked")
public Target getReferenceTargetElement(ModelElementInstanceImpl referenceSourceParentElement) {
Source referenceSource = getReferenceSource(referenceSourceParentElement);
if (referenceSource != null) {
String identifier = getReferenceIdentifier(referenceSource);
ModelElementInstance referenceTargetElement = referenceSourceParentElement.getModelInstance().getModelElementById(identifier);
if (referenceTargetElement != null) {
return (Target) referenceTargetElement;
} else {
throw new ModelException("Unable to find a model element instance for id " + identifier);
}
} else {
return null;
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-xml-model by camunda.
the class ReferenceImpl method getReferenceTargetElement.
/**
* Get the reference target model element instance
*
* @param referenceSourceElement the reference source model element instance
* @return the reference target model element instance or null if not set
*/
@SuppressWarnings("unchecked")
public T getReferenceTargetElement(ModelElementInstance referenceSourceElement) {
String identifier = getReferenceIdentifier(referenceSourceElement);
ModelElementInstance referenceTargetElement = referenceSourceElement.getModelInstance().getModelElementById(identifier);
if (referenceTargetElement != null) {
try {
return (T) referenceTargetElement;
} catch (ClassCastException e) {
throw new ModelReferenceException("Element " + referenceSourceElement + " references element " + referenceTargetElement + " of wrong type. " + "Expecting " + referenceTargetAttribute.getOwningElementType() + " got " + referenceTargetElement.getElementType());
}
} else {
return null;
}
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance 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;
}
Aggregations