Skip to content

Commit

Permalink
Breakout CqlTranslatorOptionsMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival committed Dec 16, 2024
1 parent 44f4bdf commit 3901bb9
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions Src/java/cql-to-elm-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ application {

dependencies {
implementation(project(":cql-to-elm"))
implementation(project(":cql-to-elm-jackson"))
implementation(project(":quick"))
implementation(project(":qdm"))
implementation(project(":model-jaxb"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
options.has(validateUnits),
options.has(disableDefaultModelInfoLoad),
signatureLevel,
options.has(compatibilityLevel) ? options.valueOf(compatibilityLevel) : null));
options.has(compatibilityLevel) ? options.valueOf(compatibilityLevel) : "1.5"));
}
}
}
8 changes: 8 additions & 0 deletions Src/java/cql-to-elm-jackson/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("cql.library-conventions")
}

dependencies {
implementation(project(":cql-to-elm"))
implementation("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${project.findProperty("jackson.version")}")
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
@file:Suppress("WildcardImport")

package org.cqframework.cql.cql2elm
package org.cqframework.cql.cq2elm

import com.fasterxml.jackson.databind.ObjectMapper
import java.io.*
import java.util.*
import org.cqframework.cql.cql2elm.CqlTranslatorOptions

object CqlTranslatorOptionsMapper {
private val om: ObjectMapper = ObjectMapper()
private val om: ObjectMapper =
ObjectMapper()
.setMixIns(
mapOf(CqlTranslatorOptions::class.java to CqlTranslatorOptionsMixin::class.java)
)

@JvmStatic
fun fromFile(fileName: String?): CqlTranslatorOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.cqframework.cql.cq2elm

import com.fasterxml.jackson.annotation.JsonUnwrapped
import org.cqframework.cql.cql2elm.CqlCompilerOptions

abstract class CqlTranslatorOptionsMixin {
@get:JsonUnwrapped @set:JsonUnwrapped abstract var cqlCompilerOptions: CqlCompilerOptions?
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import org.cqframework.cql.cq2elm.CqlTranslatorOptionsMapper;
import org.junit.jupiter.api.Test;

class OptionsTests {
Expand Down
6 changes: 0 additions & 6 deletions Src/java/cql-to-elm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ dependencies {
api(project(":cql"))
api(project(":model"))
api(project(":elm"))

// TODO: This dependencies are required due the the fact that the CqlTranslatorOptionsMapper lives
// in the cql-to-elm project. Ideally, we"d factor out all serialization dependencies into common
// libraries such that we could swap out jackson for something else. In the meantime, these are
// "implementation" dependencies so that they are not exported downstream.
implementation("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:${project.findProperty("jackson.version")}")
testImplementation(project(":elm-jackson"))
testImplementation(project(":model-jackson"))
testImplementation(project(":quick"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cqframework.cql.cql2elm

import com.fasterxml.jackson.annotation.JsonUnwrapped
import java.util.*

class CqlTranslatorOptions {
Expand All @@ -10,7 +9,7 @@ class CqlTranslatorOptions {
COFFEE
}

@JsonUnwrapped var cqlCompilerOptions: CqlCompilerOptions? = null
var cqlCompilerOptions: CqlCompilerOptions? = null
var formats: Set<Format>? = null

fun withCqlCompilerOptions(cqlCompilerOptions: CqlCompilerOptions?): CqlTranslatorOptions {
Expand Down
2 changes: 1 addition & 1 deletion Src/java/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ include(
"quick",
"cql-to-elm",
"cql-to-elm-cli",
"cql-to-elm-jackson",
"elm-fhir",
"ucum",
"tools:cql-formatter",
"tools:cql-parsetree",
"tools:xsd-to-modelinfo"
)
include("ucum")

0 comments on commit 3901bb9

Please sign in to comment.