Skip to content

AddCommand created with constructor can be used only as root #108

@vhemery

Description

@vhemery
  1. Create an AddCommand with one of the constructors of class
    export class AddCommand extends ModelServerCommand {
  2. Then, try and insert it in a CompoundCommand with constructor of
    export class CompoundCommand extends ModelServerCommand {
  3. 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).

The cause is that the following line :

(o, i) => new ModelServerReferenceDescription(o.eClass, `//@objectsToAdd.${i}`)

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 :

addCommand.objectValues?.forEach(v => {
     v.$ref = v.$ref.replace('//@objectsToAdd.', '//@commands.1/@objectsToAdd.');
});

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 :

  • Force the user to indicate where the command will be located, so that we directly insert the correct model reference.
  • Patching references automatically :
    1. leave the constructor as is, with a big shouting warning that the reference may be incorrect
    2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodelserverEMF.cloud Model Server Theia

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions