Commit 16bdea18 authored by Romain Bioteau's avatar Romain Bioteau

fix emf model updater for expression referencedElements

parent 89d7d934
......@@ -135,34 +135,32 @@ public class EMFModelUpdater<T extends EObject> {
@SuppressWarnings("unchecked")
private void handleManyCase(EObject source, EObject target, EStructuralFeature feature) {
source.eSet(feature, target.eGet(feature));
/// ===> BROKEN
// List sourceList = (List) source.eGet(feature);
// List targetList = (List) target.eGet(feature);
//
// sourceList.removeIf(
// sourceElement -> findEObject(targetList, getEObjectID((EObject) sourceElement)) == null);
//
// for (Object sourceElement : sourceList) {
// EObject targetElement = findEObject(targetList, getEObjectID((EObject) sourceElement));
// if (sourceElement instanceof EObject
// && targetElement instanceof EObject) {
// deepEObjectUpdate((EObject) sourceElement,
// targetElement);
// }
// }
//
// for (Object targetElement : targetList) {
// if (targetElement instanceof EObject
// && getEObjectID((EObject) targetElement) == null) {//Add new Object
// sourceList.add(targetList.indexOf(targetElement), EcoreUtil.copy((T) targetElement));
// }
// }
List sourceList = (List) source.eGet(feature);
List targetList = (List) target.eGet(feature);
sourceList.removeIf(
sourceElement -> findEObject(targetList, getEObjectID((EObject) sourceElement)) == null);
for (Object sourceElement : sourceList) {
EObject targetElement = findEObject(targetList, getEObjectID((EObject) sourceElement));
if (sourceElement instanceof EObject
&& targetElement instanceof EObject) {
deepEObjectUpdate((EObject) sourceElement,
targetElement);
targetList.remove(targetElement);
}
}
for (Object targetElement : targetList) {
if (targetElement instanceof EObject
&& getEObjectID((EObject) targetElement) == null) {//Add new Object
sourceList.add(targetList.indexOf(targetElement), EcoreUtil.copy((T) targetElement));
}
}
}
private EObject findEObject(List<EObject> targetList, String eObjectID) {
return targetList.stream()
return eObjectID == null ? null : targetList.stream()
.filter(eObject -> Objects.equals(eObjectID, getEObjectID(eObject)))
.findFirst()
.orElse(null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment