From 0f9525dbbbbd234cd45275935d333ce7b76190b7 Mon Sep 17 00:00:00 2001 From: Bryn Rhodes Date: Thu, 16 Jun 2022 15:28:20 -0600 Subject: [PATCH] #576: Updated the translator to version 2.0.0 --- .../java/org/hl7/fhirpath/TestFhirPath.java | 14 +++++--------- .../org/hl7/fhirpath/TestLibraryLoader.java | 6 +++--- .../engine/fhir/data/FhirExecutionTestBase.java | 12 ++++++------ .../cql/engine/execution/CqlEngineTests.java | 8 ++++---- .../engine/execution/CqlExecutionTestBase.java | 17 +++++++---------- .../cql/engine/execution/CqlPerformanceIT.java | 4 ++-- .../cqf/cql/engine/execution/CqlTestSuite.java | 4 ++-- .../cql/engine/execution/TestLibraryLoader.java | 6 +++--- pom.xml | 2 +- 9 files changed, 33 insertions(+), 40 deletions(-) diff --git a/engine.fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java b/engine.fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java index d2e7cb692..a0d5d1c2d 100644 --- a/engine.fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java +++ b/engine.fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java @@ -21,11 +21,7 @@ import javax.xml.bind.JAXB; -import org.cqframework.cql.cql2elm.CqlTranslator; -import org.cqframework.cql.cql2elm.CqlTranslatorException; -import org.cqframework.cql.cql2elm.FhirLibrarySourceProvider; -import org.cqframework.cql.cql2elm.LibraryManager; -import org.cqframework.cql.cql2elm.ModelManager; +import org.cqframework.cql.cql2elm.*; import org.cqframework.cql.elm.execution.Library; import org.cqframework.cql.elm.tracking.TrackBack; import org.fhir.ucum.UcumEssenceService; @@ -182,16 +178,16 @@ private LibraryLoader getLibraryLoader() { } private Library translate(String cql) throws UcumException { - ArrayList options = new ArrayList<>(); - options.add(CqlTranslator.Options.EnableDateRangeOptimization); + ArrayList options = new ArrayList<>(); + options.add(CqlTranslatorOptions.Options.EnableDateRangeOptimization); UcumService ucumService = new UcumEssenceService( UcumEssenceService.class.getResourceAsStream("/ucum-essence.xml")); CqlTranslator translator = CqlTranslator.fromText(cql, getModelManager(), getLibraryManager(), ucumService, - options.toArray(new CqlTranslator.Options[options.size()])); + options.toArray(new CqlTranslatorOptions.Options[options.size()])); if (translator.getErrors().size() > 0) { ArrayList errors = new ArrayList<>(); - for (CqlTranslatorException error : translator.getErrors()) { + for (CqlCompilerException error : translator.getErrors()) { TrackBack tb = error.getLocator(); String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]", tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), diff --git a/engine.fhir/src/test/java/org/hl7/fhirpath/TestLibraryLoader.java b/engine.fhir/src/test/java/org/hl7/fhirpath/TestLibraryLoader.java index 28c457b27..7beff6c5c 100644 --- a/engine.fhir/src/test/java/org/hl7/fhirpath/TestLibraryLoader.java +++ b/engine.fhir/src/test/java/org/hl7/fhirpath/TestLibraryLoader.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; -import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.model.serialization.LibraryWrapper; @@ -59,13 +59,13 @@ private Library resolveLibrary(VersionedIdentifier libraryIdentifier) { } private Library loadLibrary(VersionedIdentifier libraryIdentifier) { - List errors = new ArrayList<>(); + List errors = new ArrayList<>(); org.hl7.elm.r1.VersionedIdentifier identifier = new org.hl7.elm.r1.VersionedIdentifier() .withId(libraryIdentifier.getId()) .withSystem(libraryIdentifier.getSystem()) .withVersion(libraryIdentifier.getVersion()); - org.cqframework.cql.cql2elm.model.TranslatedLibrary translatedLibrary = libraryManager.resolveLibrary(identifier, CqlTranslatorOptions.defaultOptions(), errors); + org.cqframework.cql.cql2elm.model.CompiledLibrary translatedLibrary = libraryManager.resolveLibrary(identifier, CqlTranslatorOptions.defaultOptions(), errors); LibraryWrapper wrapper = new LibraryWrapper(); wrapper.setLibrary(translatedLibrary.getLibrary()); diff --git a/engine.fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java b/engine.fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java index f41935350..f616accda 100644 --- a/engine.fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java +++ b/engine.fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java @@ -12,7 +12,7 @@ import javax.xml.bind.JAXBException; import org.cqframework.cql.cql2elm.*; -import org.cqframework.cql.cql2elm.model.TranslatedLibrary; +import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.elm.execution.Library; import org.cqframework.cql.elm.tracking.TrackBack; import org.fhir.ucum.UcumEssenceService; @@ -84,15 +84,15 @@ public void beforeEachTestMethod() throws JAXBException, IOException, UcumExcept try { File cqlFile = new File(URLDecoder.decode(this.getClass().getResource("fhir/" + fileName + ".cql").getFile(), "UTF-8")); - ArrayList options = new ArrayList<>(); - options.add(CqlTranslator.Options.EnableDateRangeOptimization); + ArrayList options = new ArrayList<>(); + options.add(CqlTranslatorOptions.Options.EnableDateRangeOptimization); - CqlTranslator translator = CqlTranslator.fromFile(cqlFile, modelManager, libraryManager, ucumService, options.toArray(new CqlTranslator.Options[options.size()])); + CqlTranslator translator = CqlTranslator.fromFile(cqlFile, modelManager, libraryManager, ucumService, options.toArray(new CqlTranslatorOptions.Options[options.size()])); if (translator.getErrors().size() > 0) { System.err.println("Translation failed due to errors:"); ArrayList errors = new ArrayList<>(); - for (CqlTranslatorException error : translator.getErrors()) { + for (CqlCompilerException error : translator.getErrors()) { TrackBack tb = error.getLocator(); String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]", tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar()); @@ -104,7 +104,7 @@ public void beforeEachTestMethod() throws JAXBException, IOException, UcumExcept assertThat(translator.getErrors().size(), is(0)); - for (Map.Entry entry : libraryManager.getTranslatedLibraries().entrySet()) { + for (Map.Entry entry : libraryManager.getCompiledLibraries().entrySet()) { String jsonContent = CqlTranslator.convertToJxson(entry.getValue().getLibrary()); StringReader sr = new StringReader(jsonContent); libraries.put(entry.getKey(), JsonCqlLibraryReader.read(sr)); diff --git a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTests.java b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTests.java index 1d82536dc..b4c2b70bb 100644 --- a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTests.java +++ b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTests.java @@ -15,10 +15,10 @@ import java.util.List; import java.util.Map; -import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; -import org.cqframework.cql.cql2elm.model.TranslatedLibrary; +import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.elm.execution.Library; import org.testng.annotations.Test; @@ -123,10 +123,10 @@ public void test_twoLibraries_expressionsForEach() throws IOException { LibraryManager libraryManager = this.toLibraryManager(libraries); - List errors = new ArrayList<>(); + List errors = new ArrayList<>(); List executableLibraries = new ArrayList<>(); for (org.hl7.elm.r1.VersionedIdentifier id : libraries.keySet()) { - TranslatedLibrary translated = libraryManager.resolveLibrary(id, CqlTranslatorOptions.defaultOptions(), errors); + CompiledLibrary translated = libraryManager.resolveLibrary(id, CqlTranslatorOptions.defaultOptions(), errors); String json = this.convertToJson(translated.getLibrary()); executableLibraries.add(this.readJson(json)); } diff --git a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExecutionTestBase.java b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExecutionTestBase.java index e6b4ad0a6..77d1e5a7e 100644 --- a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExecutionTestBase.java +++ b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExecutionTestBase.java @@ -11,10 +11,7 @@ import java.util.HashMap; import java.util.Map; -import org.cqframework.cql.cql2elm.CqlTranslator; -import org.cqframework.cql.cql2elm.CqlTranslatorException; -import org.cqframework.cql.cql2elm.LibraryManager; -import org.cqframework.cql.cql2elm.ModelManager; +import org.cqframework.cql.cql2elm.*; import org.cqframework.cql.elm.execution.Library; import org.cqframework.cql.elm.tracking.TrackBack; import org.fhir.ucum.UcumEssenceService; @@ -56,18 +53,18 @@ public void beforeEachTestMethod() throws IOException, UcumException { try { File cqlFile = new File(URLDecoder.decode(this.getClass().getResource(fileName + ".cql").getFile(), "UTF-8")); - ArrayList options = new ArrayList<>(); - options.add(CqlTranslator.Options.EnableDateRangeOptimization); - options.add(CqlTranslator.Options.EnableAnnotations); - options.add(CqlTranslator.Options.EnableLocators); + ArrayList options = new ArrayList<>(); + options.add(CqlTranslatorOptions.Options.EnableDateRangeOptimization); + options.add(CqlTranslatorOptions.Options.EnableAnnotations); + options.add(CqlTranslatorOptions.Options.EnableLocators); CqlTranslator translator = CqlTranslator.fromFile(cqlFile, getModelManager(), getLibraryManager(), ucumService, - options.toArray(new CqlTranslator.Options[options.size()])); + options.toArray(new CqlTranslatorOptions.Options[options.size()])); if (translator.getErrors().size() > 0) { System.err.println("Translation failed due to errors:"); ArrayList errors = new ArrayList<>(); - for (CqlTranslatorException error : translator.getErrors()) { + for (CqlCompilerException error : translator.getErrors()) { TrackBack tb = error.getLocator(); String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]", tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar()); diff --git a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java index 28428ff7f..f527006bf 100644 --- a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java +++ b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java @@ -14,7 +14,7 @@ import java.util.Collections; import org.cqframework.cql.cql2elm.CqlTranslator; -import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.cqframework.cql.elm.execution.Library; @@ -81,7 +81,7 @@ private Library translate(String file) throws UcumException, IOException { if (translator.getErrors().size() > 0) { System.err.println("Translation failed due to errors:"); ArrayList errors = new ArrayList<>(); - for (CqlTranslatorException error : translator.getErrors()) { + for (CqlCompilerException error : translator.getErrors()) { TrackBack tb = error.getLocator(); String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]", tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar()); diff --git a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestSuite.java b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestSuite.java index 0d8395a40..185a2857a 100644 --- a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestSuite.java +++ b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestSuite.java @@ -16,7 +16,7 @@ import java.util.TimeZone; import org.cqframework.cql.cql2elm.CqlTranslator; -import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.cqframework.cql.elm.execution.ExpressionDef; @@ -391,7 +391,7 @@ private Library translate(String file) throws UcumException, IOException { if (translator.getErrors().size() > 0) { System.err.println("Translation failed due to errors:"); ArrayList errors = new ArrayList<>(); - for (CqlTranslatorException error : translator.getErrors()) { + for (CqlCompilerException error : translator.getErrors()) { TrackBack tb = error.getLocator(); String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]", tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar()); diff --git a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestLibraryLoader.java b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestLibraryLoader.java index 91335b989..6a8d2988a 100644 --- a/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestLibraryLoader.java +++ b/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestLibraryLoader.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; -import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.model.serialization.LibraryWrapper; @@ -57,13 +57,13 @@ private Library resolveLibrary(VersionedIdentifier libraryIdentifier) { } private Library loadLibrary(VersionedIdentifier libraryIdentifier) { - List errors = new ArrayList<>(); + List errors = new ArrayList<>(); org.hl7.elm.r1.VersionedIdentifier identifier = new org.hl7.elm.r1.VersionedIdentifier() .withId(libraryIdentifier.getId()) .withSystem(libraryIdentifier.getSystem()) .withVersion(libraryIdentifier.getVersion()); - org.cqframework.cql.cql2elm.model.TranslatedLibrary translatedLibrary = libraryManager.resolveLibrary(identifier, CqlTranslatorOptions.defaultOptions(), errors); + org.cqframework.cql.cql2elm.model.CompiledLibrary translatedLibrary = libraryManager.resolveLibrary(identifier, CqlTranslatorOptions.defaultOptions(), errors); LibraryWrapper wrapper = new LibraryWrapper(); wrapper.setLibrary(translatedLibrary.getLibrary()); diff --git a/pom.xml b/pom.xml index 5752c6a89..dc159e05f 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ UTF-8 2.13.2 2.13.2.1 - 1.5.8 + 2.0.0-SNAPSHOT 5.6.3 1.7.29