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
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.util.List;
import java.util.Locale;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
@ -69,6 +70,8 @@ public interface IResourceValidator {
Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException;
ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url);
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
void setLocale(Locale locale);
}
public enum BestPracticeWarningLevel {

View File

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

View File

@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
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("-recurse");
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(" Specify the edition of SNOMED CT to use. Valid Choices:");
System.out.println(" intl | us | uk | au | nl | ca | se | dk | es");
@ -399,6 +402,7 @@ public class Validator {
boolean anyExtensionsAllowed = true;
boolean hintAboutNonMustSupport = false;
boolean recursive = false;
Locale locale = null;
List<String> profiles = new ArrayList<String>();
EngineMode mode = EngineMode.VALIDATION;
String output = null;
@ -477,6 +481,12 @@ public class Validator {
throw new Error("Snomed edition '"+s+"' not known");
} else if (args[i].equals("-recurse")) {
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")) {
anyExtensionsAllowed = false;
} else if (args[i].equals("-hintAboutNonMustSupport")) {
@ -585,6 +595,7 @@ public class Validator {
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
validator.setLanguage(lang);
validator.setLocale(locale);
validator.setSnomedExtension(snomedCT);
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_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_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_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.

View File

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