Open JPercival opened 3 years ago
The annotations work for JSON because of an opposite bug:
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
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: