added i18N handling to all BaseWorkerContexts
This commit is contained in:
parent
41e9b0e9fa
commit
7443eb3f59
|
@ -23,11 +23,15 @@ package org.hl7.fhir.dstu2.utils;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
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.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.dstu2.model.BooleanType;
|
||||
|
@ -73,6 +77,8 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
// private ValueSetExpansionCache expansionCache; //
|
||||
|
||||
protected FHIRToolingClient txServer;
|
||||
private Locale locale;
|
||||
private ResourceBundle i18Nmessages;
|
||||
|
||||
@Override
|
||||
public ValueSet fetchCodeSystem(String system) {
|
||||
|
@ -402,4 +408,37 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message;
|
||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
} else {
|
||||
message = theMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package org.hl7.fhir.dstu2.utils;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.hl7.fhir.dstu2.formats.IParser;
|
||||
import org.hl7.fhir.dstu2.formats.ParserType;
|
||||
import org.hl7.fhir.dstu2.model.CodeableConcept;
|
||||
|
@ -208,7 +209,15 @@ public interface IWorkerContext {
|
|||
* @return
|
||||
*/
|
||||
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc);
|
||||
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
void setLocale(Locale locale);
|
||||
|
||||
String formatMessage(String theMessage, Object... theMessageArguments);
|
||||
|
||||
void setValidationMessageLanguage(Locale locale);
|
||||
|
||||
public class ValidationResult {
|
||||
private ConceptDefinitionComponent definition;
|
||||
private IssueSeverity severity;
|
||||
|
|
|
@ -23,11 +23,15 @@ package org.hl7.fhir.dstu2016may.utils;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
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.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.model.BooleanType;
|
||||
|
@ -75,6 +79,8 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
|
||||
protected FHIRToolingClient txServer;
|
||||
private Bundle bndCodeSystems;
|
||||
private Locale locale;
|
||||
private ResourceBundle i18Nmessages;
|
||||
|
||||
@Override
|
||||
public CodeSystem fetchCodeSystem(String system) {
|
||||
|
@ -441,5 +447,37 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message;
|
||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
} else {
|
||||
message = theMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.hl7.fhir.dstu2016may.utils;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.formats.IParser;
|
||||
|
@ -204,7 +205,15 @@ public interface IWorkerContext {
|
|||
* @return
|
||||
*/
|
||||
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc);
|
||||
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
void setLocale(Locale locale);
|
||||
|
||||
String formatMessage(String theMessage, Object... theMessageArguments);
|
||||
|
||||
void setValidationMessageLanguage(Locale locale);
|
||||
|
||||
public class ValidationResult {
|
||||
private ConceptDefinitionComponent definition;
|
||||
private IssueSeverity severity;
|
||||
|
|
|
@ -27,11 +27,15 @@ import java.io.FileInputStream;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
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.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
@ -122,6 +126,8 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
private int expandCodesLimit = 1000;
|
||||
protected ILoggingService logger;
|
||||
protected ExpansionProfile expProfile;
|
||||
private Locale locale;
|
||||
private ResourceBundle i18Nmessages;
|
||||
|
||||
public Map<String, CodeSystem> getCodeSystems() {
|
||||
return codeSystems;
|
||||
|
@ -991,5 +997,37 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message;
|
||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
} else {
|
||||
message = theMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.hl7.fhir.dstu3.context;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.dstu3.formats.IParser;
|
||||
|
@ -236,7 +237,15 @@ public interface IWorkerContext {
|
|||
* @throws FHIRException
|
||||
*/
|
||||
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc, boolean heiarchical) throws TerminologyServiceException;
|
||||
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
void setLocale(Locale locale);
|
||||
|
||||
String formatMessage(String theMessage, Object... theMessageArguments);
|
||||
|
||||
void setValidationMessageLanguage(Locale locale);
|
||||
|
||||
public class ValidationResult {
|
||||
private ConceptDefinitionComponent definition;
|
||||
private IssueSeverity severity;
|
||||
|
|
|
@ -21,6 +21,10 @@ package org.hl7.fhir.r4.context;
|
|||
*/
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.fhir.ucum.UcumService;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
|
@ -99,7 +103,9 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
protected TerminologyCache txCache;
|
||||
|
||||
private boolean tlogging = true;
|
||||
|
||||
private Locale locale;
|
||||
private ResourceBundle i18Nmessages;
|
||||
|
||||
public BaseWorkerContext() throws FileNotFoundException, IOException, FHIRException {
|
||||
super();
|
||||
txCache = new TerminologyCache(lock, null);
|
||||
|
@ -1174,5 +1180,37 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message;
|
||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
} else {
|
||||
message = theMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.hl7.fhir.r4.context;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -283,7 +284,15 @@ public interface IWorkerContext {
|
|||
* @throws FHIRException
|
||||
*/
|
||||
public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean heirarchical) throws TerminologyServiceException;
|
||||
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
void setLocale(Locale locale);
|
||||
|
||||
String formatMessage(String theMessage, Object... theMessageArguments);
|
||||
|
||||
void setValidationMessageLanguage(Locale locale);
|
||||
|
||||
public class ValidationResult {
|
||||
private ConceptDefinitionComponent definition;
|
||||
private IssueSeverity severity;
|
||||
|
|
|
@ -425,19 +425,6 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
this.expandCodesLimit = expandCodesLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
@Override
|
||||
public ValueSetExpansionOutcome expandVS(ElementDefinitionBindingComponent binding, boolean cacheOk, boolean heirarchical) throws FHIRException {
|
||||
ValueSet vs = null;
|
||||
|
@ -1293,6 +1280,21 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return binaries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message;
|
||||
|
@ -1306,6 +1308,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
|
|
@ -334,6 +334,8 @@ public interface IWorkerContext {
|
|||
|
||||
String formatMessage(String theMessage, Object... theMessageArguments);
|
||||
|
||||
void setValidationMessageLanguage(Locale locale);
|
||||
|
||||
class ValidationResult {
|
||||
private ConceptDefinitionComponent definition;
|
||||
private IssueSeverity severity;
|
||||
|
|
Loading…
Reference in New Issue