From 50e8d990a8e2abc7c17a6d4800679b10d7955927 Mon Sep 17 00:00:00 2001 From: dotasek Date: Tue, 27 Jun 2023 10:49:55 -0400 Subject: [PATCH 1/2] Fix help placeholders --- .../org/hl7/fhir/validation/cli/tasks/ValidateTask.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java index 4a486d2c6..68b49cbcc 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java @@ -1,9 +1,11 @@ package org.hl7.fhir.validation.cli.tasks; +import ca.uhn.fhir.context.FhirVersionEnum; import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.r5.model.ImplementationGuide; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.utilities.TimeTracker; +import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.validation.ValidationEngine; import org.hl7.fhir.validation.cli.model.CliContext; import org.hl7.fhir.validation.cli.services.ValidationService; @@ -15,9 +17,13 @@ import java.io.PrintStream; public class ValidateTask extends ValidationEngineTask { final static String[][] PLACEHOLDERS = { - { "XML_AND_JSON_FHIR_VERSIONS", "1.0, 1.4, 3.0, 4.0, " + Constants.VERSION_MM }, + { "XML_AND_JSON_FHIR_VERSIONS", "1.0, 1.4, 3.0, 4.0, " + Constants.VERSION_MM + ", 6.0" }, { "TURTLE_FHIR_VERSIONS", "3.0, 4.0, " + Constants.VERSION_MM }, + { "FHIR_MAJOR_VERSIONS", "1.0, 1.4, 3.0, 4.0, " + Constants.VERSION_MM, "6.0"}, + { "FHIR_MINOR_VERSIONS", "1.0.2, 1.4.0, 3.0.2, 4.0.1, 4.1.0, 4.3.0, 5.0.0, 6.0.0" }, + { "FHIR_CURRENT_VERSION", Constants.VERSION_MM} }; + @Override public String getName() { return "validate"; From a114d751db50341c5511580ab429367831ee2507 Mon Sep 17 00:00:00 2001 From: dotasek Date: Tue, 27 Jun 2023 11:29:24 -0400 Subject: [PATCH 2/2] Refactor version utility code --- .../hl7/fhir/utilities/VersionUtilities.java | 24 ++++++++++++++----- .../validation/cli/tasks/ValidateTask.java | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java index 4a967c6bc..6dd7e178b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java @@ -1,9 +1,6 @@ package org.hl7.fhir.utilities; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.HashSet; +import java.util.*; import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.exceptions.FHIRException; @@ -41,6 +38,9 @@ import org.hl7.fhir.exceptions.FHIRException; public class VersionUtilities { + public static final String[] SUPPORTED_MAJOR_VERSIONS = {"1.0", "1.4", "3.0", "4.0", "5.0", "6.0"}; + public static final String[] SUPPORTED_VERSIONS = {"1.0.2", "1.4.0", "3.0.2", "4.0.1", "4.1.0", "4.3.0", "5.0.0", "6.0.0"}; + public static class VersionURLInfo { private String version; private String url; @@ -138,11 +138,23 @@ public class VersionUtilities { if (version.contains("-")) { version = version.substring(0, version.indexOf("-")); } - return Utilities.existsInList(version, "1.0.2", "1.4.0", "3.0.2", "4.0.1", "4.1.0", "4.3.0", "5.0.0", "6.0.0"); + return Utilities.existsInList(version, SUPPORTED_VERSIONS); } public static String listSupportedVersions() { - return "1.0.2, 1.4.0, 3.0.2, 4.0.1, 4.1.0, 4.3.0, 5.0, 6.0"; + return listVersions(SUPPORTED_VERSIONS); + } + + public static String listSupportedMajorVersions() { + return listVersions(SUPPORTED_MAJOR_VERSIONS); + } + + private static String listVersions(String[] versions) { + StringJoiner stringJoiner = new StringJoiner(", "); + for (String supportedVersion : versions) { + stringJoiner.add(supportedVersion); + } + return stringJoiner.toString(); } public static boolean isR6Ver(String ver) { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java index 68b49cbcc..5ee5547c5 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/tasks/ValidateTask.java @@ -19,8 +19,8 @@ public class ValidateTask extends ValidationEngineTask { final static String[][] PLACEHOLDERS = { { "XML_AND_JSON_FHIR_VERSIONS", "1.0, 1.4, 3.0, 4.0, " + Constants.VERSION_MM + ", 6.0" }, { "TURTLE_FHIR_VERSIONS", "3.0, 4.0, " + Constants.VERSION_MM }, - { "FHIR_MAJOR_VERSIONS", "1.0, 1.4, 3.0, 4.0, " + Constants.VERSION_MM, "6.0"}, - { "FHIR_MINOR_VERSIONS", "1.0.2, 1.4.0, 3.0.2, 4.0.1, 4.1.0, 4.3.0, 5.0.0, 6.0.0" }, + { "FHIR_MAJOR_VERSIONS", VersionUtilities.listSupportedMajorVersions()}, + { "FHIR_MINOR_VERSIONS", VersionUtilities.listSupportedVersions() }, { "FHIR_CURRENT_VERSION", Constants.VERSION_MM} };