use of org.camunda.bpm.model.xml.ModelException 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;
}
use of org.camunda.bpm.model.xml.ModelException 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;
}
use of org.camunda.bpm.model.xml.ModelException in project camunda-xml-model by camunda.
the class ReflectUtil method createInstance.
/**
* Create a new instance of the provided type
*
* @param type the class to create a new instance of
* @param parameters the parameters to pass to the constructor
* @return the created instance
*/
public static <T> T createInstance(Class<T> type, Object... parameters) {
// get types for parameters
Class<?>[] parameterTypes = new Class<?>[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
parameterTypes[i] = parameter.getClass();
}
try {
// create instance
Constructor<T> constructor = type.getConstructor(parameterTypes);
return constructor.newInstance(parameters);
} catch (Exception e) {
throw new ModelException("Exception while creating an instance of type " + type, e);
}
}
use of org.camunda.bpm.model.xml.ModelException in project camunda-xml-model by camunda.
the class DomElementImpl method replaceChild.
public void replaceChild(DomElement newChildDomElement, DomElement existingChildDomElement) {
synchronized (document) {
Element newElement = ((DomElementImpl) newChildDomElement).getElement();
Element existingElement = ((DomElementImpl) existingChildDomElement).getElement();
try {
element.replaceChild(newElement, existingElement);
} catch (DOMException e) {
throw new ModelException("Unable to replace child <" + existingElement + "> of element <" + element + "> with element <" + newElement + ">", e);
}
}
}
use of org.camunda.bpm.model.xml.ModelException in project camunda-xml-model by camunda.
the class ChildElementCollectionBuilderImpl method performModelBuild.
public void performModelBuild(Model model) {
ModelElementType elementType = model.getType(childElementType);
if (elementType == null) {
throw new ModelException(parentElementType + " declares undefined child element of type " + childElementType + ".");
}
parentElementType.registerChildElementType(elementType);
parentElementType.registerChildElementCollection(collection);
for (ModelBuildOperation modelBuildOperation : modelBuildOperations) {
modelBuildOperation.performModelBuild(model);
}
}
Aggregations