eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
72 stars 48 forks source link

Support for model composition/cross-references during import/export #721

Open jadelkhoury opened 3 years ago

jadelkhoury commented 3 years ago

Currently, I have problems handling models that are composed of multiple EMF resources. Is this something that Sirius Web is expected to handle?

Below I describe the problem when trying to download such models. I face similar problems when uploading such models.

Steps to reproduce

  1. Create a model M1
  2. In the same project, create another model M2
  3. In M2, specify some properties that relate to entities from M1.
  4. Download M1. No problems.
  5. Download M2. An exception occurs.
2021-09-03 23:13:24.816 ERROR 8328 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: resolve against non-hierarchical or relative base] with root cause

java.lang.IllegalArgumentException: resolve against non-hierarchical or relative base
        at org.eclipse.emf.common.util.URI$Hierarchical.resolve(URI.java:3548) ~[org.eclipse.emf.common-2.21.0.jar!/:na]
        at org.eclipse.emf.common.util.URI.resolve(URI.java:5580) ~[org.eclipse.emf.common-2.21.0.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.JsonHelper.resolve(JsonHelper.java:928) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.getPackageForURI(GsonEObjectDeserializer.java:677) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeMultipleNonContainmentEReference(GsonEObjectDeserializer.java:587) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeEReference(GsonEObjectDeserializer.java:453) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeData(GsonEObjectDeserializer.java:428) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeEClassifier(GsonEObjectDeserializer.java:404) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.loadObject(GsonEObjectDeserializer.java:367) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeMultipleContainmentEReference(GsonEObjectDeserializer.java:765) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeEReference(GsonEObjectDeserializer.java:447) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
        at org.eclipse.sirius.emfjson.utils.GsonEObjectDeserializer.deserializeData(GsonEObjectDeserializer.java:428) ~[org.eclipse.sirius.emfjson-2.3.1-SNAPSHOT.jar!/:na]
...

Similar problem occur when uploading model(s) with dependencies.

pcdavid commented 3 years ago

Confirmed.

Yes this is a scenario we want (and need) to support, but knowing how the current implementation works it does not surprise me.

org.eclipse.sirius.web.spring.controllers.DocumentController.getDocument(String, String) and and org.eclipse.sirius.web.services.documents.DocumentService.getBytes(Document, String) assume a given document (model) can be loaded/saved all by itself, but as soon as there are cross-model references we need to load the whole editing context / resource set for references to make sense.

pcdavid commented 3 years ago

Note that trying to download the whole project's content fails in the same way (it treats models one by one instead of as a whole).

jadelkhoury commented 2 years ago

From a user perspective, it would be nice if I can upload a number of models (instead of just 1), which I know fit together. and if I upload 1 (or more) models that are not complete, I get a warning of the missing models.

jadelkhoury commented 2 years ago

Hi I was wondering if there is any planned progess on this issue? We are also thinking if the following short term solution would be of benefit (until bug is fixed): When uploading a model with a proxy object, instead of loading the missing/referenced EMF resource, simply remove that proxy reference? (and preferably mark the object as missing). This means that one can still upload a model with proxy objects. Even if not 100% perfect, it can still be of value to have a less complete model.