You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the command is sent to the model server, the model server will try and fail at resolving the references for #objectValues in method org.eclipse.emfcloud.jackson.databind.deser.ReferenceEntry.Base.resolve(DatabindContext, URIHandler).
In the general case, the AddCommand constructor can't possibly know where the command will be located in the resource. So I'm not sure what the best fix would be.
Possibilities I can think of :
Force the user to indicate where the command will be located, so that we directly insert the correct model reference.
Patching references automatically :
leave the constructor as is, with a big shouting warning that the reference may be incorrect
when constructing the CompoundCommand, patching all the model references in contained commands to prepend with the command uri (and also a big shouting warning)
A kind of mix, with the possibility to use relative uri fragments or placeholders, which will be patched later...
Not sure which approach is the best.
The text was updated successfully, but these errors were encountered:
vhemery
changed the title
AddCommand created with constructor can not be used only as root
AddCommand created with constructor can be used only as root
Jun 8, 2022
The fact that Typescript applications don't know much about the concept of Resources, URI and EMF in general is one of the reasons why, in V2, we're focusing more on Json and less on EMF, for Typescript client applications.
With V2, using Json Patches, you wouldn't have this kind of issue: all paths are computed based on their position in the Json Tree (Or, alternatively, based on their EMF URI Fragment, as specified by the Model Server - no guess work involved)
V2 is still not 100% ready for adoption (Especially, there are still a few inconsistencies related to the differences between Json and EMF, or how Json Patches are defined compared to EMF Commands).
For commands that need to reference newly created objects, we now rely on the concept of Transactions, so we never have to reference an object that doesn't exist yet (We first execute the initial command to create the object, then we create and execute the command that needs to reference the new element - all encapsulated in a single Transaction). However, at the moment, Transactions are only supported through the modelserver-node Facade (The Transactions are implemented in the Java Model Server, but this is an internal endpoint that isn't officially part of the API for now).
I'm not sure what the exact plan for XMI/EMF Commands in Typescript Applications will be, but we might start deprecating them (at least when V2 is stable enough).
So this would lean towards this "solution", I guess:
leave the constructor as is, with a big shouting warning that the reference may be incorrect
emfcloud-modelserver-theia/packages/modelserver-client/src/model/command-model.ts
Line 99 in 1c8e537
emfcloud-modelserver-theia/packages/modelserver-client/src/model/command-model.ts
Line 55 in 1c8e537
#objectValues
in methodorg.eclipse.emfcloud.jackson.databind.deser.ReferenceEntry.Base.resolve(DatabindContext, URIHandler)
.The cause is that the following line :
emfcloud-modelserver-theia/packages/modelserver-client/src/model/command-model.ts
Line 116 in 1c8e537
assigns the
#objectValues
, assuming that the command is the resource's root, with an absolute URI.In my particular use case, where command was at index 1 (2nd), post-treating the references like this did the trick :
but this fix is too specific to my use case.
In the general case, the AddCommand constructor can't possibly know where the command will be located in the resource. So I'm not sure what the best fix would be.
Possibilities I can think of :
Not sure which approach is the best.
The text was updated successfully, but these errors were encountered: