use of org.camunda.bpm.model.xml.impl.ModelInstanceImpl in project camunda-xml-model by camunda.
the class ElementReferenceCollectionImpl method performAddOperation.
protected void performAddOperation(ModelElementInstanceImpl referenceSourceParentElement, Target referenceTargetElement) {
ModelInstanceImpl modelInstance = referenceSourceParentElement.getModelInstance();
String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingElement = modelInstance.getModelElementById(referenceTargetIdentifier);
if (existingElement == null || !existingElement.equals(referenceTargetElement)) {
throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
} else {
Collection<Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
Source referenceSourceElement = modelInstance.newInstance(referenceSourceType);
referenceSourceElements.add(referenceSourceElement);
setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
}
}
Aggregations