Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root types have disappeared #228

Closed
jeromesimeon opened this issue Feb 3, 2021 · 6 comments
Closed

Root types have disappeared #228

jeromesimeon opened this issue Feb 3, 2021 · 6 comments
Assignees
Labels

Comments

@jeromesimeon
Copy link
Member

jeromesimeon commented Feb 3, 2021

Describe the bug

Types Participant, Event, Transaction have disappeared in the 1.0.0 release.

To Reproduce

CTO file:

namespace org.test

transaction T {
}

participant P {
}

event E {
}

concept Foo {
  o Transaction t
  o Participant p
  o Event e
}

JSON:

{
  "$class": "org.test.Foo",
  "t": { "$class": "org.test.T" },
  "p": { "$class": "org.test.P" },
  "e": { "$class": "org.test.E" }
}

Should validate, but loading the model throws an error:

zsh-5.8$ ./index.js validate --ctoFiles test.cto --sample test.json
3:37:50 PM - ERROR: Undeclared type Transaction in property org.test.Foo.t File 'test.cto': 
@dselman
Copy link
Contributor

dselman commented Feb 9, 2021

The linked PR adds the abstract types to the concerto namespace. You will have to import the types/ns to reference them in a CTO file.

@dselman
Copy link
Contributor

dselman commented Feb 9, 2021

Fixed.

@dselman dselman closed this as completed Feb 9, 2021
@jeromesimeon
Copy link
Member Author

jeromesimeon commented Mar 18, 2021

I'm unclear that this is properly fixed. A few questions/issues.

  1. it's confusing that Concept is automatically imported but not the other root types (that's also an unnecessary breaking change imo)
  2. it's unclear that the root types for Transaction etc are properly placed in the type hierarchy. (See example below)

Example

CTO file

namespace org.test

// Should not be needed
import concerto.Transaction
import concerto.Participant
import concerto.Event

concept C {
}

transaction T {
}

participant P {
}

event E {
}

concept Foo {
  o Concept c
  o Transaction t // Validation error when containing a class T
  o Participant p
  o Event e
}

data

{
  "$class": "org.test.Foo",
  "c": { "$class": "org.test.C" },
  "t": { "$class": "org.test.T" },
  "p": { "$class": "org.test.P" },
  "e": { "$class": "org.test.E" }
}

Error

zsh-5.8$ ./index.js validate --ctoFiles test.cto --sample test.json 
2:38:20 PM - ERROR: Instance org.test.C#null has property t with type org.test.T that is not derived from concerto.Transaction

@jeromesimeon jeromesimeon reopened this Mar 18, 2021
@dselman
Copy link
Contributor

dselman commented Mar 18, 2021

I can pick this one up.

@jeromesimeon
Copy link
Member Author

I can pick this one up.

@dselman Sorry I only saw this while I was well on my way there... I've open a PR #237 and maybe with luck you didn't do too much work on this yet. This PR absolutely could benefit from your review and even possibly a bit of a chat.

@jeromesimeon
Copy link
Member Author

Addressed in #246:

zsh-5.8$ more test.cto
namespace org.test

transaction T {
}

participant P {
}

event E {
}

concept Foo {
  o Transaction t
  o Participant p
  o Event e
}
zsh-5.8$ more test.json
{
  "$class": "org.test.Foo",
  "t": { "$class": "org.test.T" },
  "p": { "$class": "org.test.P" },
  "e": { "$class": "org.test.E" }
}
zsh-5.8$ ./index.js validate --model test.cto --input test.json
2:21:14 PM - INFO: Input is valid
2:21:14 PM - INFO: 
{
  "$class": "org.test.Foo",
  "t": {
    "$class": "org.test.T",
    "$timestamp": "2021-03-28T18:21:14.245Z"
  },
  "p": {
    "$class": "org.test.P",
    "$identifier": "e111ea37-0567-41e2-a8ba-bd9aeeb2df31"
  },
  "e": {
    "$class": "org.test.E",
    "$timestamp": "2021-03-28T18:21:14.245Z"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants