support for -show-times in validator
This commit is contained in:
parent
fa7de3a308
commit
64d6f24d08
|
@ -267,6 +267,7 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
||||||
private boolean crumbTrails;
|
private boolean crumbTrails;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private List<ImplementationGuide> igs = new ArrayList<>();
|
private List<ImplementationGuide> igs = new ArrayList<>();
|
||||||
|
private boolean showTimes;
|
||||||
|
|
||||||
private class AsteriskFilter implements FilenameFilter {
|
private class AsteriskFilter implements FilenameFilter {
|
||||||
String dir;
|
String dir;
|
||||||
|
@ -329,6 +330,15 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
||||||
this.anyExtensionsAllowed = anyExtensionsAllowed;
|
this.anyExtensionsAllowed = anyExtensionsAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isShowTimes() {
|
||||||
|
return showTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowTimes(boolean showTimes) {
|
||||||
|
this.showTimes = showTimes;
|
||||||
|
}
|
||||||
|
|
||||||
public ValidationEngine(String src, String txsrvr, String txLog, FhirPublication version, boolean canRunWithoutTerminologyServer, String vString) throws Exception {
|
public ValidationEngine(String src, String txsrvr, String txLog, FhirPublication version, boolean canRunWithoutTerminologyServer, String vString) throws Exception {
|
||||||
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
loadCoreDefinitions(src, false);
|
loadCoreDefinitions(src, false);
|
||||||
|
@ -1114,6 +1124,9 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
||||||
}
|
}
|
||||||
InstanceValidator validator = getValidator();
|
InstanceValidator validator = getValidator();
|
||||||
validator.validate(null, messages, new ByteArrayInputStream(source), cntType, asSdList(profiles));
|
validator.validate(null, messages, new ByteArrayInputStream(source), cntType, asSdList(profiles));
|
||||||
|
if (showTimes) {
|
||||||
|
System.out.println(location+": "+validator.reportTimes());
|
||||||
|
}
|
||||||
return messagesToOutcome(messages);
|
return messagesToOutcome(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2114,4 +2127,12 @@ public class ValidationEngine implements IValidatorResourceFetcher {
|
||||||
return TextFile.streamToBytes(c.getInputStream());
|
return TextFile.streamToBytes(c.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doneLoading(long loadStart) {
|
||||||
|
if (showTimes) {
|
||||||
|
String s = String.format("Load Time (ms): %d", (System.nanoTime() - loadStart) / 1000000);
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -131,6 +131,7 @@ public class Validator {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
long loadStart = System.nanoTime();
|
||||||
System.out.println("FHIR Validation tool " + VersionUtil.getVersionString());
|
System.out.println("FHIR Validation tool " + VersionUtil.getVersionString());
|
||||||
System.out.println("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch") + " (" + System.getProperty("sun.arch.data.model") + "bit). " + toMB(Runtime.getRuntime().maxMemory()) + "MB available");
|
System.out.println("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch") + " (" + System.getProperty("sun.arch.data.model") + "bit). " + toMB(Runtime.getRuntime().maxMemory()) + "MB available");
|
||||||
String proxy = getNamedParam(args, Params.PROXY);
|
String proxy = getNamedParam(args, Params.PROXY);
|
||||||
|
@ -199,7 +200,7 @@ public class Validator {
|
||||||
if (cliContext.getMode() == EngineMode.SCAN) {
|
if (cliContext.getMode() == EngineMode.SCAN) {
|
||||||
ValidationService.validateScan(cliContext, validator);
|
ValidationService.validateScan(cliContext, validator);
|
||||||
} else {
|
} else {
|
||||||
ValidationService.validateSources(cliContext, validator);
|
ValidationService.validateSources(cliContext, validator, loadStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,9 @@ public class CliContext {
|
||||||
@JsonProperty("crumbTrails")
|
@JsonProperty("crumbTrails")
|
||||||
private boolean crumbTrails = false;
|
private boolean crumbTrails = false;
|
||||||
|
|
||||||
|
@JsonProperty("showTimes")
|
||||||
|
private boolean showTimes = false;
|
||||||
|
|
||||||
@JsonProperty("locale")
|
@JsonProperty("locale")
|
||||||
private String locale = Locale.ENGLISH.getDisplayLanguage();
|
private String locale = Locale.ENGLISH.getDisplayLanguage();
|
||||||
|
|
||||||
|
@ -436,6 +439,14 @@ public class CliContext {
|
||||||
this.crumbTrails = crumbTrails;
|
this.crumbTrails = crumbTrails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowTimes() {
|
||||||
|
return showTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowTimes(boolean showTimes) {
|
||||||
|
this.showTimes = showTimes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -464,6 +475,8 @@ public class CliContext {
|
||||||
Objects.equals(questionnaires, that.questionnaires) &&
|
Objects.equals(questionnaires, that.questionnaires) &&
|
||||||
Objects.equals(profiles, that.profiles) &&
|
Objects.equals(profiles, that.profiles) &&
|
||||||
Objects.equals(sources, that.sources) &&
|
Objects.equals(sources, that.sources) &&
|
||||||
|
Objects.equals(crumbTrails, that.crumbTrails) &&
|
||||||
|
Objects.equals(showTimes, that.showTimes) &&
|
||||||
mode == that.mode &&
|
mode == that.mode &&
|
||||||
Objects.equals(locale, that.locale) &&
|
Objects.equals(locale, that.locale) &&
|
||||||
Objects.equals(locations, that.locations);
|
Objects.equals(locations, that.locations);
|
||||||
|
@ -471,6 +484,6 @@ public class CliContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(doNative, anyExtensionsAllowed, hintAboutNonMustSupport, recursive, doDebug, assumeValidRestReferences, canDoNative, noInternalCaching, noExtensibleBindingMessages, map, output, txServer, sv, txLog, mapLog, lang, fhirpath, snomedCT, targetVer, igs, questionnaires, profiles, sources, mode, locale, locations);
|
return Objects.hash(doNative, anyExtensionsAllowed, hintAboutNonMustSupport, recursive, doDebug, assumeValidRestReferences, canDoNative, noInternalCaching, noExtensibleBindingMessages, map, output, txServer, sv, txLog, mapLog, lang, fhirpath, snomedCT, targetVer, igs, questionnaires, profiles, sources, mode, locale, locations, crumbTrails, showTimes);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,7 +44,8 @@ public class ValidationService {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validateSources(CliContext cliContext, ValidationEngine validator) throws Exception {
|
public static void validateSources(CliContext cliContext, ValidationEngine validator, long loadStart) throws Exception {
|
||||||
|
validator.doneLoading(loadStart);
|
||||||
if (cliContext.getProfiles().size() > 0) {
|
if (cliContext.getProfiles().size() > 0) {
|
||||||
System.out.println(" .. validate " + cliContext.getSources() + " against " + cliContext.getProfiles().toString());
|
System.out.println(" .. validate " + cliContext.getSources() + " against " + cliContext.getProfiles().toString());
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,6 +196,7 @@ public class ValidationService {
|
||||||
validator.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages());
|
validator.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages());
|
||||||
validator.setSecurityChecks(cliContext.isSecurityChecks());
|
validator.setSecurityChecks(cliContext.isSecurityChecks());
|
||||||
validator.setCrumbTrails(cliContext.isCrumbTrails());
|
validator.setCrumbTrails(cliContext.isCrumbTrails());
|
||||||
|
validator.setShowTimes(cliContext.isShowTimes());
|
||||||
TerminologyCache.setNoCaching(cliContext.isNoInternalCaching());
|
TerminologyCache.setNoCaching(cliContext.isNoInternalCaching());
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class Params {
|
||||||
public static final String NO_EXTENSIBLE_BINDING_WARNINGS = "-no-extensible-binding-warnings";
|
public static final String NO_EXTENSIBLE_BINDING_WARNINGS = "-no-extensible-binding-warnings";
|
||||||
public static final String SECURITY_CHECKS = "-security-checks";
|
public static final String SECURITY_CHECKS = "-security-checks";
|
||||||
public static final String CRUMB_TRAIL = "-crumb-trails";
|
public static final String CRUMB_TRAIL = "-crumb-trails";
|
||||||
|
public static final String SHOW_TIMES = "-show-times";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the list of passed in params to see if it contains the passed in param.
|
* Checks the list of passed in params to see if it contains the passed in param.
|
||||||
|
@ -157,6 +158,8 @@ public class Params {
|
||||||
cliContext.setSecurityChecks(true);
|
cliContext.setSecurityChecks(true);
|
||||||
} else if (args[i].equals(CRUMB_TRAIL)) {
|
} else if (args[i].equals(CRUMB_TRAIL)) {
|
||||||
cliContext.setCrumbTrails(true);
|
cliContext.setCrumbTrails(true);
|
||||||
|
} else if (args[i].equals(SHOW_TIMES)) {
|
||||||
|
cliContext.setShowTimes(true);
|
||||||
} else if (args[i].equals(SCAN)) {
|
} else if (args[i].equals(SCAN)) {
|
||||||
cliContext.setMode(Validator.EngineMode.SCAN);
|
cliContext.setMode(Validator.EngineMode.SCAN);
|
||||||
} else if (args[i].equals(TERMINOLOGY)) {
|
} else if (args[i].equals(TERMINOLOGY)) {
|
||||||
|
|
Loading…
Reference in New Issue