Cleanup
This commit is contained in:
parent
0e45efb766
commit
7affad01fc
|
@ -54,7 +54,7 @@ import org.hl7.fhir.r5.model.ImplementationGuide;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.validation.cliutils.*;
|
||||
import org.hl7.fhir.validation.cli.*;
|
||||
|
||||
/**
|
||||
* A executable class that will validate one or more FHIR resources against
|
||||
|
@ -114,9 +114,9 @@ public class Validator {
|
|||
System.out.println("Specified destination (-dest parameter) is not valid: \"" + dest + "\")");
|
||||
else {
|
||||
// first, prepare the context
|
||||
String txLog = Common.getTerminologyServerLog(args);
|
||||
String txLog = Params.getTerminologyServerLog(args);
|
||||
ValidationEngine validator = Common.getValidationEngine(args, txLog);
|
||||
Common.checkIGFileReferences(args);
|
||||
Params.checkIGFileReferences(args);
|
||||
Comparison.doLeftRightComparison(args, dest, validator);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.validation.Validator;
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.r5.model.Constants;
|
||||
import org.hl7.fhir.r5.model.FhirPublication;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.validation.ValidationEngine;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Common {
|
||||
|
||||
public static String getVersion(String[] args) {
|
||||
|
@ -77,15 +75,6 @@ public class Common {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getTerminologyServerLog(String[] args) {
|
||||
String txLog = null;
|
||||
if (Params.hasParam(args, "-txLog")) {
|
||||
txLog = Params.getParam(args, "-txLog");
|
||||
new File(txLog).delete();
|
||||
}
|
||||
return txLog;
|
||||
}
|
||||
|
||||
public static ValidationEngine getValidationEngine(String[] args, String txLog) throws Exception {
|
||||
String v = Common.getVersion(args);
|
||||
String definitions = VersionUtilities.packageForVersion(v) + "#" + v;
|
||||
|
@ -93,18 +82,4 @@ public class Common {
|
|||
return new ValidationEngine(definitions, "http://tx.fhir.org", txLog, FhirPublication.fromCode(v), v);
|
||||
}
|
||||
|
||||
public static void checkIGFileReferences(String[] args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if ("-ig".equals(args[i])) {
|
||||
if (i + 1 == args.length)
|
||||
throw new Error("Specified -ig without indicating ig file");
|
||||
else {
|
||||
String s = args[++i];
|
||||
if (!s.startsWith("hl7.fhir.core-")) {
|
||||
System.out.println("Load Package: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.r5.conformance.CapabilityStatementUtilities;
|
||||
import org.hl7.fhir.r5.conformance.ProfileComparer;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.r5.model.Constants;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
|
@ -7,6 +7,11 @@ import org.hl7.fhir.utilities.cache.ToolsVersion;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Class for displaying output to the cli user.
|
||||
*
|
||||
* TODO - Clean this up for localization
|
||||
*/
|
||||
public class Display {
|
||||
|
||||
public static void printCliArgumentsAndInfo(String[] args) throws IOException {
|
|
@ -1,8 +1,9 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.validation.Validator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class Params {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fetches the vlaue for the passed in param from the provided list of params.
|
||||
* Fetches the value for the passed in param from the provided list of params.
|
||||
*
|
||||
* @param args Array of params to search.
|
||||
* @param param {@link String} param keyword to search for.
|
||||
|
@ -71,11 +72,7 @@ public class Params {
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO Don't do this all in one for loop.
|
||||
*
|
||||
* @param args
|
||||
* @return
|
||||
* @throws Exception
|
||||
* TODO Don't do this all in one for loop. Use the above methods.
|
||||
*/
|
||||
public static CliContext loadCliContext(String[] args) throws Exception {
|
||||
CliContext cliContext = new CliContext();
|
||||
|
@ -207,4 +204,28 @@ public class Params {
|
|||
throw new Exception("Must provide at least one source file");
|
||||
return cliContext;
|
||||
}
|
||||
|
||||
public static String getTerminologyServerLog(String[] args) {
|
||||
String txLog = null;
|
||||
if (hasParam(args, "-txLog")) {
|
||||
txLog = getParam(args, "-txLog");
|
||||
new File(txLog).delete();
|
||||
}
|
||||
return txLog;
|
||||
}
|
||||
|
||||
public static void checkIGFileReferences(String[] args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (IMPLEMENTATION_GUIDE.equals(args[i])) {
|
||||
if (i + 1 == args.length)
|
||||
throw new Error("Specified -ig without indicating ig file");
|
||||
else {
|
||||
String s = args[++i];
|
||||
if (!s.startsWith("hl7.fhir.core-")) {
|
||||
System.out.println("Load Package: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hl7.fhir.validation.cliutils;
|
||||
package org.hl7.fhir.validation.cli;
|
||||
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class ValidationUtils {
|
||||
|
||||
public static void validateSources(CliContext cliContext, ValidationEngine validator) throws Exception {
|
||||
if (cliContext.getProfiles().size() > 0)
|
||||
System.out.println(" .. validate " + cliContext.getSources() + " against " + cliContext.getProfiles().toString());
|
Loading…
Reference in New Issue