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

Library XML deserializer doesn't include annotations #931

Open
JPercival opened this issue Dec 23, 2020 · 2 comments
Open

Library XML deserializer doesn't include annotations #931

JPercival opened this issue Dec 23, 2020 · 2 comments
Assignees
Labels

Comments

@JPercival
Copy link
Contributor

When deserializing an XML ELM library the annotations are omitted and you get null instead. This makes it impossible to check for valid translator options on an XML ELM library, among other things.

There is schema in the project for cqlannotations here:

https://github.com/DBCG/cql_engine/blob/develop/engine/src/main/resources/cql-lm/schema/elm/cqlannotations.xsd

However, that schema is never run through code-gen and there no classes are generated for it:

https://github.com/DBCG/cql_engine/blob/develop/engine/pom.xml#L95

The JAXB deserializer is not configured to know how deserialize those nonexistent classes. The Jackson deseralizer automatically maps the annotations to a HashMap so it does preserve the annotations, albeit in a JSON-y format.

The ELM deseralizer regression suite only checks for exceptions and not the validity of the resulting libraries. There are no tests for the presence of annotations. The regression suite also does only a basic comparison of the results of the JSON and XML deseralizers, so the the fact that the JSON libraries are good and the XML libraries are bad is not detected:

https://github.com/DBCG/cql_engine/blob/develop/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ElmTests.java#L137

So, we need to:

  1. Add code-gen for the cqlannotations.xsd
  2. Register those classes appropriately for the XML and JSON deserializers
  3. Add direct tests for annotations to the XML and JSON deserializer test suite
  4. Add comparison tests for XML and JSON annotations to the test suite
@JPercival
Copy link
Contributor Author

The annotations work for JSON because of an opposite bug:

https://github.com/DBCG/cql_engine/issues/453

@vitorpamplona
Copy link
Contributor

vitorpamplona commented Apr 22, 2022

I noticed that in some cases Jackson generates an empty string as translatorOptions

    "annotation" : [ {
      "translatorOptions" : ""
    } ]

This breaks the expectations of the TranslatorOptionsUtil, triggering:

java.lang.IllegalArgumentException: No enum constant org.cqframework.cql.cql2elm.CqlTranslator.Options.
at java.lang.Enum.valueOf(Enum.java:257)
at org.cqframework.cql.cql2elm.CqlTranslator$Options.valueOf(CqlTranslator.java:38)
at org.opencds.cqf.cql.evaluator.engine.util.TranslatorOptionsUtil.parseTranslatorOptions(TranslatorOptionsUtil.java:117)
at org.opencds.cqf.cql.evaluator.engine.util.TranslatorOptionsUtil.getTranslatorOptions(TranslatorOptionsUtil.java:41)

The solution is perhaps to check for empty strings on TranslatorOptionsUtil.parseTranslatorOptions

@JPercival JPercival transferred this issue from cqframework/cql-engine Dec 21, 2022
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