Merge pull request #154 from hapifhir/locale_cli

Locale cli
This commit is contained in:
Grahame Grieve 2020-03-12 10:47:46 +11:00 committed by GitHub
commit 6d3095c314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 4 deletions

View File

@ -1311,6 +1311,6 @@ public abstract class BaseWorkerContext implements IWorkerContext {
@Override @Override
public void setValidationMessageLanguage(Locale locale) { public void setValidationMessageLanguage(Locale locale) {
i18Nmessages = ResourceBundle.getBundle("Messages", locale ); i18Nmessages = ResourceBundle.getBundle("Messages", locale);
} }
} }

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
@ -68,7 +69,9 @@ public interface IResourceValidator {
Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException; Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException;
ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url); ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url);
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException; boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
void setLocale(Locale locale);
} }
public enum BestPracticeWarningLevel { public enum BestPracticeWarningLevel {

View File

@ -139,6 +139,8 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
public class ValidationEngine implements IValidatorResourceFetcher { public class ValidationEngine implements IValidatorResourceFetcher {
public class ScanOutputItem { public class ScanOutputItem {
private String ref; private String ref;
private ImplementationGuide ig; private ImplementationGuide ig;
@ -240,6 +242,7 @@ public class ValidationEngine implements IValidatorResourceFetcher {
private Set<String> loadedIgs = new HashSet<>(); private Set<String> loadedIgs = new HashSet<>();
private IValidatorResourceFetcher fetcher; private IValidatorResourceFetcher fetcher;
private boolean assumeValidRestReferences; private boolean assumeValidRestReferences;
private Locale locale;
private class AsteriskFilter implements FilenameFilter { private class AsteriskFilter implements FilenameFilter {
String dir; String dir;
@ -1269,6 +1272,7 @@ public class ValidationEngine implements IValidatorResourceFetcher {
validator.setNoInvariantChecks(isNoInvariantChecks()); validator.setNoInvariantChecks(isNoInvariantChecks());
validator.setValidationLanguage(language); validator.setValidationLanguage(language);
validator.setAssumeValidRestReferences(assumeValidRestReferences); validator.setAssumeValidRestReferences(assumeValidRestReferences);
validator.getContext().setLocale(locale);
validator.setFetcher(this); validator.setFetcher(this);
return validator; return validator;
} }
@ -1592,6 +1596,11 @@ public class ValidationEngine implements IValidatorResourceFetcher {
return false; return false;
} }
@Override
public void setLocale(Locale locale) {
this.locale = locale;
}
public void handleOutput(Resource r, String output, String version) throws Exception { public void handleOutput(Resource r, String output, String version) throws Exception {
if (output.startsWith("http://") || output.startsWith("http://")) { if (output.startsWith("http://") || output.startsWith("http://")) {
ByteArrayOutputStream bs = new ByteArrayOutputStream(); ByteArrayOutputStream bs = new ByteArrayOutputStream();

View File

@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -195,6 +196,8 @@ public class Validator {
System.out.println(" Produce additional information about the loading/validation process"); System.out.println(" Produce additional information about the loading/validation process");
System.out.println("-recurse"); System.out.println("-recurse");
System.out.println(" Look in subfolders when -ig refers to a folder"); System.out.println(" Look in subfolders when -ig refers to a folder");
System.out.println("-locale");
System.out.println(" Specifies the locale/language of the validation result messages (eg.: de-DE");
System.out.println("-sct"); System.out.println("-sct");
System.out.println(" Specify the edition of SNOMED CT to use. Valid Choices:"); System.out.println(" Specify the edition of SNOMED CT to use. Valid Choices:");
System.out.println(" intl | us | uk | au | nl | ca | se | dk | es"); System.out.println(" intl | us | uk | au | nl | ca | se | dk | es");
@ -399,6 +402,7 @@ public class Validator {
boolean anyExtensionsAllowed = true; boolean anyExtensionsAllowed = true;
boolean hintAboutNonMustSupport = false; boolean hintAboutNonMustSupport = false;
boolean recursive = false; boolean recursive = false;
Locale locale = null;
List<String> profiles = new ArrayList<String>(); List<String> profiles = new ArrayList<String>();
EngineMode mode = EngineMode.VALIDATION; EngineMode mode = EngineMode.VALIDATION;
String output = null; String output = null;
@ -477,6 +481,12 @@ public class Validator {
throw new Error("Snomed edition '"+s+"' not known"); throw new Error("Snomed edition '"+s+"' not known");
} else if (args[i].equals("-recurse")) { } else if (args[i].equals("-recurse")) {
recursive = true; recursive = true;
} else if (args[i].equals("-locale")) {
if (i+1 == args.length) {
throw new Error("Specified -locale without indicating locale");
} else {
locale = new Locale(args[++i]);
}
} else if (args[i].equals("-strictExtensions")) { } else if (args[i].equals("-strictExtensions")) {
anyExtensionsAllowed = false; anyExtensionsAllowed = false;
} else if (args[i].equals("-hintAboutNonMustSupport")) { } else if (args[i].equals("-hintAboutNonMustSupport")) {
@ -585,6 +595,7 @@ public class Validator {
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport); validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
validator.setAnyExtensionsAllowed(anyExtensionsAllowed); validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
validator.setLanguage(lang); validator.setLanguage(lang);
validator.setLocale(locale);
validator.setSnomedExtension(snomedCT); validator.setSnomedExtension(snomedCT);
validator.setAssumeValidRestReferences(assumeValidRestReferences); validator.setAssumeValidRestReferences(assumeValidRestReferences);

View File

@ -10,8 +10,7 @@ Bundle_BUNDLE_Entry_NoProfile=Kein Profil für die contained Ressource vom Typ "
Bundle_BUNDLE_Entry_NotFound="{0}" konnte nicht in bundle ({1}) gefunden werden Bundle_BUNDLE_Entry_NotFound="{0}" konnte nicht in bundle ({1}) gefunden werden
Bundle_BUNDLE_Entry_Orphan=Entry {0} ist nicht durch Traversierung, vom ersten Bundle-Entry ausgehend, erreichbar Bundle_BUNDLE_Entry_Orphan=Entry {0} ist nicht durch Traversierung, vom ersten Bundle-Entry ausgehend, erreichbar
Bundle_BUNDLE_Entry_Type=Der type "{0}" ist nicht gültig - hier sind keine Ressourcen erlaubt Bundle_BUNDLE_Entry_Type=Der type "{0}" ist nicht gültig - hier sind keine Ressourcen erlaubt
Bundle_BUNDLE_Entry_Type2=Der type "{0}" ist nicht gültig - muss {1} sein\ Bundle_BUNDLE_Entry_Type2=Der type "{0}" ist nicht gültig - muss {1} sein
Bundle_BUNDLE_Entry_Type3=Der type "{0}" ist nicht gültig - muss einer von {1} sein Bundle_BUNDLE_Entry_Type3=Der type "{0}" ist nicht gültig - muss einer von {1} sein
Bundle_BUNDLE_FullUrl_Missing=Es besteht eine relative Reference innerhalb des Bundle, dessen Eintrag eine fullUrl fehlt Bundle_BUNDLE_FullUrl_Missing=Es besteht eine relative Reference innerhalb des Bundle, dessen Eintrag eine fullUrl fehlt
Bundle_BUNDLE_FullUrl_NeedVersion=Einträge, die mit fullURL {0} übereinstimmen, sollten meta/versionId deklarieren, da versionsspezifische Referenzen vorhanden sind. Bundle_BUNDLE_FullUrl_NeedVersion=Einträge, die mit fullURL {0} übereinstimmen, sollten meta/versionId deklarieren, da versionsspezifische Referenzen vorhanden sind.

View File

@ -427,6 +427,11 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
return !url.contains("example.org"); return !url.contains("example.org");
} }
@Override
public void setLocale(Locale locale) {
//do nothing
}
@Override @Override
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
IResourceValidator val = TestingUtilities.context(version).newValidator(); IResourceValidator val = TestingUtilities.context(version).newValidator();