From 3e3723ed8f860eaab59084021c2a37b66ffb03da Mon Sep 17 00:00:00 2001 From: "A. Anil Sinaci" Date: Tue, 14 Jan 2025 10:05:38 +0300 Subject: [PATCH 1/3] :sparkles: Feat. Add heap size configuration as an environment variable to docker run. Advance embedded mongo version to fix the ubuntu build. --- docker/docker-entrypoint.sh | 9 ++++++++- .../main/scala/io/onfhir/path/FhirPathAggFunctions.scala | 2 +- pom.xml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 60fa41b8..f191c746 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -JAVA_CMD="java -Xms256m -Xmx3g -jar " +# Set default Java options +DEFAULT_JAVA_OPTIONS="-Xms256m -Xmx3g" + +# Use environment variable if provided, otherwise use default value +JAVA_OPTIONS="${JAVA_OPTIONS:-$DEFAULT_JAVA_OPTIONS}" + +# Construct JAVA_CMD with Java options +JAVA_CMD="java $JAVA_OPTIONS -jar " # Configure application.conf path if [ ! -z "$APP_CONF_FILE" ]; then diff --git a/onfhir-path/src/main/scala/io/onfhir/path/FhirPathAggFunctions.scala b/onfhir-path/src/main/scala/io/onfhir/path/FhirPathAggFunctions.scala index 2440fe04..f39970a5 100644 --- a/onfhir-path/src/main/scala/io/onfhir/path/FhirPathAggFunctions.scala +++ b/onfhir-path/src/main/scala/io/onfhir/path/FhirPathAggFunctions.scala @@ -142,7 +142,7 @@ class FhirPathAggFunctions(context:FhirPathEnvironment, current:Seq[FhirPathResu .flatMap(c => { val result = new FhirPathExpressionEvaluator(context, Seq(c)).visit(expr) if (result.length > 1) - throw new FhirPathException(s"Invalid function call 'min', the expression ${expr.getText} does not return a single value or Nil!") + throw new FhirPathException(s"Invalid function call 'max', the expression ${expr.getText} does not return a single value or Nil!") result.headOption }) diff --git a/pom.xml b/pom.xml index 77765bf7..0733af46 100644 --- a/pom.xml +++ b/pom.xml @@ -113,7 +113,7 @@ 2.8.5 5.1.3 - 4.12.0 + 4.18.1 3.7.0-M11 2.2.0 1.4.14 From c0796a39b4894a1bfab4647a68108f821d63af3f Mon Sep 17 00:00:00 2001 From: "A. Anil Sinaci" Date: Tue, 14 Jan 2025 14:12:37 +0300 Subject: [PATCH 2/3] :green_heart: Advance Apache commons versions to fix the build on Ubuntu. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0733af46..66fadcfa 100644 --- a/pom.xml +++ b/pom.xml @@ -122,9 +122,9 @@ 4.20.4 9.37.3 11.9.1 - 3.14.0 - 2.15.1 - 1.11.0 + 3.17.0 + 2.18.0 + 1.13.0 0.10.2 From a79e5f4e698f79024da9a154f9f6538e8724d044 Mon Sep 17 00:00:00 2001 From: "A. Anil Sinaci" Date: Wed, 15 Jan 2025 22:38:44 +0300 Subject: [PATCH 3/3] :art: Ignore hidden files starting with . while reading infrastructure resources at the beginning. --- .../scala/io/onfhir/api/util/IOUtil.scala | 47 +++++++++++++------ .../onfhir/config/BaseFhirConfigurator.scala | 2 +- .../src/main/scala/io/onfhir/Onfhir.scala | 2 +- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/onfhir-common/src/main/scala/io/onfhir/api/util/IOUtil.scala b/onfhir-common/src/main/scala/io/onfhir/api/util/IOUtil.scala index 718ce6c6..f3932a6f 100644 --- a/onfhir-common/src/main/scala/io/onfhir/api/util/IOUtil.scala +++ b/onfhir-common/src/main/scala/io/onfhir/api/util/IOUtil.scala @@ -20,9 +20,10 @@ object IOUtil { /** * Read a FHIR resource from given path or default path (within project resources) - * @param resourcePath Given file path - * @param defaultPath Default resource path (within project resources) - * @param rtype Resource type + * + * @param resourcePath Given file path + * @param defaultPath Default resource path (within project resources) + * @param rtype Resource type * @return */ def readResource(resourcePath: Option[String], defaultPath: String, rtype: String): Resource = { @@ -43,7 +44,8 @@ object IOUtil { /** * Read a FHIR resource from given File path - * @param filePath File path + * + * @param filePath File path * @return */ def readResource(filePath: String): Resource = { @@ -52,7 +54,8 @@ object IOUtil { /** * Read a FHIR resource from project resources with a path - * @param resourcePath Resource path + * + * @param resourcePath Resource path * @return */ def readInnerResource(resourcePath: String): Resource = { @@ -93,7 +96,7 @@ object IOUtil { if (!givenFile.isDirectory) throw new InitializationException(s"Given path '$path' is not a folder or zip file ...") //Given as folder - getFilesFromFolder(folder = givenFile, withExtension = None, recursively = Some(true)) + getFilesFromFolder(folder = givenFile, recursively = true, ignoreHidden = true, withExtension = None) .map(file => { try { parseResource(new InputStreamReader(BOMInputStream.builder.setInputStream(new FileInputStream(file)).get()), file.getAbsolutePath) @@ -120,19 +123,30 @@ object IOUtil { * Get the list of files from the given folder. * * @param folder The folder to retrieve the files from. + * @param recursively If true, the folder will be searched recursively to retrieve all files within. + * @param ignoreHidden If true, hidden files and directories will be excluded from the result. * @param withExtension An optional extension (e.g., .json) if the files need to be filtered. - * @param recursively If exists and true, the folder will be searched recursively to retrieve all files within. - * @return + * @return A sequence of files matching the criteria. */ - def getFilesFromFolder(folder: File, withExtension: Option[String], recursively: Option[Boolean]): Seq[File] = { + def getFilesFromFolder( + folder: File, + recursively: Boolean, + ignoreHidden: Boolean, + withExtension: Option[String] + ): Seq[File] = { if (folder.exists && folder.isDirectory) { val files = folder.listFiles().toSeq // List all available files in the given folder + + // Filter hidden files if ignoreHidden is true + val nonHiddenFiles = if (ignoreHidden) files.filterNot(f => f.isHidden || f.getName.startsWith(".")) else files + val filteredFiles = withExtension - .map(ext => files.filter(_.getName.endsWith(ext))).getOrElse(files) + .map(ext => nonHiddenFiles.filter(_.getName.endsWith(ext))).getOrElse(nonHiddenFiles) .filterNot(_.isDirectory) - if (recursively.contains(true)) { - val subFolders = files.filter(_.isDirectory) - filteredFiles ++ subFolders.flatMap(f => getFilesFromFolder(f, withExtension, recursively)) + + if (recursively) { + val subFolders = nonHiddenFiles.filter(_.isDirectory) + filteredFiles ++ subFolders.flatMap(f => getFilesFromFolder(f, recursively, ignoreHidden, withExtension)) } else { filteredFiles } @@ -141,8 +155,10 @@ object IOUtil { } } + /** * Given a filename, removes its extension if an extension exists (e.g., admissions.json -> admissions) + * * @param fileName * @return */ @@ -254,8 +270,9 @@ object IOUtil { /** * Parse a JSON resource - * @param reader Reader - * @param path File path it is read from + * + * @param reader Reader + * @param path File path it is read from * @return */ private def parseResource(reader: Reader, path: String): Resource = { diff --git a/onfhir-config/src/main/scala/io/onfhir/config/BaseFhirConfigurator.scala b/onfhir-config/src/main/scala/io/onfhir/config/BaseFhirConfigurator.scala index ff0a6de8..4ae0dd07 100644 --- a/onfhir-config/src/main/scala/io/onfhir/config/BaseFhirConfigurator.scala +++ b/onfhir-config/src/main/scala/io/onfhir/config/BaseFhirConfigurator.scala @@ -54,7 +54,7 @@ abstract class BaseFhirConfigurator extends IFhirVersionConfigurator { //Get the parser for parsing FHIR foundation resources val foundationResourceParser = getFoundationResourceParser(fhirConfig.FHIR_COMPLEX_TYPES, fhirConfig.FHIR_PRIMITIVE_TYPES) - logger.info("Reading FHIR foundation resources to start configuration of onFhir server ...") + logger.info("Reading FHIR foundation resources to start configuration of onFHIR server ...") //Read the StructureDefinitions for all supported profiles val profileResources = configReader.getInfrastructureResources(FHIR_STRUCTURE_DEFINITION) //Read the ValueSet definitions to be used in this server (within the profiles) diff --git a/onfhir-core/src/main/scala/io/onfhir/Onfhir.scala b/onfhir-core/src/main/scala/io/onfhir/Onfhir.scala index 2a3a6c58..ebd125ca 100644 --- a/onfhir-core/src/main/scala/io/onfhir/Onfhir.scala +++ b/onfhir-core/src/main/scala/io/onfhir/Onfhir.scala @@ -136,7 +136,7 @@ class Onfhir( logger.info("OnFhir server is gracefully terminated...") case Failure(exception) => logger.error("Problem while gracefully terminating OnFhir server!", exception) } - logger.info("OnFhir FHIR server started on host {} and port {}", OnfhirConfig.serverHost, OnfhirConfig.serverPort) + logger.info("onFHIR FHIR server started on host {} and port {}", OnfhirConfig.serverHost, OnfhirConfig.serverPort) //Wait for a shutdown signal Await.ready(waitForShutdownSignal(), Duration.Inf) fhirServerBinding.terminate(FiniteDuration.apply(60L, TimeUnit.SECONDS))