Merge pull request #1290 from hapifhir/gg-202206-cardinality-fixes
Gg 202206 cardinality fixes
This commit is contained in:
commit
a4f54f519f
|
@ -29,8 +29,9 @@ public class PackageMinifier {
|
|||
for (PackageResourceInformation pri : src.listIndexedResources()) {
|
||||
if (min.isMinified(pri.getResourceType())) {
|
||||
Resource res = new JsonParser().parse(src.load(pri));
|
||||
min.minify(res);
|
||||
tgt.addFile("package", res.fhirType()+"-"+res.getIdPart()+".json", new JsonParser().composeBytes(res), null);
|
||||
if (min.minify(res)) {
|
||||
tgt.addFile("package", res.fhirType()+"-"+res.getIdPart()+".json", new JsonParser().composeBytes(res), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
tgt.save(new FileOutputStream(target));
|
||||
|
|
|
@ -91,7 +91,9 @@ public class ResourceDependencyPackageBuilder {
|
|||
ResourceMinifier min = new ResourceMinifier();
|
||||
if (min.isMinified(resource.fhirType())) {
|
||||
resource = resource.copy();
|
||||
min.minify(resource);
|
||||
if (!min.minify(resource)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -123,16 +123,20 @@ public class R5ExtensionsLoader {
|
|||
if (Utilities.existsInList(lsd.info.getId(), types)) {
|
||||
StructureDefinition sd = lsd.getResource();
|
||||
count++;
|
||||
List<ElementDefinition> rl = new ArrayList<>();
|
||||
for (ElementDefinition ed : sd.getDifferential().getElement()) {
|
||||
if (!stripTypes(ed, sd, types)) {
|
||||
System.out.println("A problem...");
|
||||
rl.add(ed);
|
||||
}
|
||||
}
|
||||
sd.getDifferential().getElement().removeAll(rl);
|
||||
rl.clear();
|
||||
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (!stripTypes(ed, sd, types)) {
|
||||
System.out.println("A problem...");
|
||||
rl.add(ed);
|
||||
}
|
||||
}
|
||||
sd.getSnapshot().getElement().removeAll(rl);
|
||||
sd.setWebPath(Utilities.pathURL(lsd.source.getWebLocation(), sd.getId().toLowerCase()+".html"));
|
||||
registerTerminologies(sd);
|
||||
context.cacheResourceFromPackage(sd, new PackageInformation(lsd.source));
|
||||
|
|
|
@ -157,8 +157,7 @@ public class ProfilePathProcessor {
|
|||
* @throws DefinitionException, FHIRException
|
||||
* @throws Exception
|
||||
*/
|
||||
private ElementDefinition processPaths(
|
||||
final ProfilePathProcessorState cursors) throws FHIRException {
|
||||
private ElementDefinition processPaths(final ProfilePathProcessorState cursors) throws FHIRException {
|
||||
debugProcessPathsEntry(cursors);
|
||||
ElementDefinition res = null;
|
||||
List<TypeSlice> typeList = new ArrayList<>();
|
||||
|
@ -253,9 +252,8 @@ public class ProfilePathProcessor {
|
|||
.incrementDebugIndent()
|
||||
.withBaseLimit(newBaseLimit)
|
||||
.withDiffLimit(newDiffLimit)
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, 0)).withSlicing(new PathSlicingParams(true, null, null)).
|
||||
processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor,
|
||||
cursors.contextName, cursors.resultPathBase));
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, 0)).withSlicing(new PathSlicingParams(true, null, null))
|
||||
.processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
if (e == null)
|
||||
throw new FHIRException(profileUtilities.getContext().formatMessage(I18nConstants.DID_NOT_FIND_SINGLE_SLICE_, diffMatches.get(0).getPath()));
|
||||
e.setSlicing(diffMatches.get(0).getSlicing());
|
||||
|
@ -267,9 +265,10 @@ public class ProfilePathProcessor {
|
|||
outcome.setPath(profileUtilities.fixedPathDest(getContextPathTarget(), outcome.getPath(), getRedirector(), getContextPathSource()));
|
||||
profileUtilities.updateFromBase(outcome, currentBase, getSourceStructureDefinition().getUrl());
|
||||
|
||||
if (!diffMatches.get(0).hasSlicing())
|
||||
if (!diffMatches.get(0).hasSlicing()) {
|
||||
outcome.setSlicing(profileUtilities.makeExtensionSlicing());
|
||||
else {
|
||||
outcome.setUserData("auto-added-slicing", true);
|
||||
} else {
|
||||
outcome.setSlicing(diffMatches.get(0).getSlicing().copy());
|
||||
for (int i = 1; i < diffMatches.size(); i++) {
|
||||
if (diffMatches.get(i).hasSlicing()) {
|
||||
|
@ -348,7 +347,8 @@ public class ProfilePathProcessor {
|
|||
.withBaseLimit(newBaseLimit)
|
||||
.withDiffLimit(newDiffLimit)
|
||||
.withProfileName(getProfileName() + profileUtilities.pathTail(diffMatches, i))
|
||||
.withSlicing(new PathSlicingParams(true, slicerElement, null)).processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
.withSlicing(new PathSlicingParams(true, slicerElement, null))
|
||||
.processPaths(new ProfilePathProcessorState(cursors.base, cursors.baseCursor, newDiffCursor, cursors.contextName, cursors.resultPathBase));
|
||||
}
|
||||
// ok, done with that - next in the base list
|
||||
cursors.baseCursor = newBaseLimit + 1;
|
||||
|
|
|
@ -777,17 +777,21 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
int count = slice.checkMin();
|
||||
boolean repeats = !"1".equals(slice.getFocus().getBase().getMax()); // type slicing if repeats = 1
|
||||
if (count > -1 && repeats) {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a minimum of "+slice.getFocus().getMin()+" but the slices add up to a minimum of "+count;
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, forPublication ? ValidationMessage.IssueSeverity.ERROR : ValidationMessage.IssueSeverity.INFORMATION));
|
||||
if (slice.getFocus().hasUserData("auto-added-slicing")) {
|
||||
slice.getFocus().setMin(count);
|
||||
} else {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a minimum of "+slice.getFocus().getMin()+" but the slices add up to a minimum of "+count;
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, forPublication ? ValidationMessage.IssueSeverity.ERROR : ValidationMessage.IssueSeverity.INFORMATION));
|
||||
}
|
||||
}
|
||||
count = slice.checkMax();
|
||||
if (count > -1 && repeats) {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a maximum of "+slice.getFocus().getMax()+" but the slices add up to a maximum of "+count+". Check that this is what is intended";
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, ValidationMessage.IssueSeverity.INFORMATION));
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, ValidationMessage.IssueSeverity.INFORMATION));
|
||||
}
|
||||
if (!slice.checkMinMax()) {
|
||||
String msg = "The slice definition for "+slice.getFocus().getId()+" has a maximum of "+slice.getFocus().getMax()+" which is less than the minimum of "+slice.getFocus().getMin();
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+ed.getId(), msg, ValidationMessage.IssueSeverity.WARNING));
|
||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+slice.getFocus().getId(), msg, ValidationMessage.IssueSeverity.WARNING));
|
||||
}
|
||||
slices.remove(s);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.hl7.fhir.r5.context.IWorkerContext;
|
|||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent;
|
||||
import org.hl7.fhir.r5.model.DataType;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
|
@ -36,7 +38,7 @@ import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TranslationUnit;
|
|||
*/
|
||||
public class LanguageUtils {
|
||||
|
||||
public static final List<String> TRANSLATION_SUPPLEMENT_RESOURCE_TYPES = Arrays.asList("CodeSystem", "StructureDefinition");
|
||||
public static final List<String> TRANSLATION_SUPPLEMENT_RESOURCE_TYPES = Arrays.asList("CodeSystem", "StructureDefinition", "Questionnaire");
|
||||
|
||||
private static final String ORPHAN_TRANSLATIONS_NAME = "translations.orphans";
|
||||
|
||||
|
@ -64,7 +66,7 @@ public class LanguageUtils {
|
|||
if (translation == null) {
|
||||
translation = element.getTranslation(langSession.getTargetLang());
|
||||
}
|
||||
langSession.entry(new TextUnit(pathForElement(element), base, translation));
|
||||
langSession.entry(new TextUnit(pathForElement(element), contextForElement(element), base, translation));
|
||||
}
|
||||
}
|
||||
for (Element c: element.getChildren()) {
|
||||
|
@ -75,6 +77,10 @@ public class LanguageUtils {
|
|||
}
|
||||
|
||||
|
||||
private String contextForElement(Element element) {
|
||||
throw new Error("Not done yet");
|
||||
}
|
||||
|
||||
private String getSpecialTranslation(Element parent, Element element, String targetLang) {
|
||||
if (parent == null) {
|
||||
return null;
|
||||
|
@ -188,7 +194,7 @@ public class LanguageUtils {
|
|||
private Set<TranslationUnit> findTranslations(String path, String src, Set<TranslationUnit> translations) {
|
||||
Set<TranslationUnit> res = new HashSet<>();
|
||||
for (TranslationUnit translation : translations) {
|
||||
if (path.equals(translation.getContext()) && src.equals(translation.getSrcText())) {
|
||||
if (path.equals(translation.getId()) && src.equals(translation.getSrcText())) {
|
||||
res.add(translation);
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +208,7 @@ public class LanguageUtils {
|
|||
public static void fillSupplement(CodeSystem cs, List<TranslationUnit> list) {
|
||||
cs.setUserData(SUPPLEMENT_NAME, "true");
|
||||
for (TranslationUnit tu : list) {
|
||||
ConceptDefinitionComponent cd = CodeSystemUtilities.getCode(cs, tu.getContext());
|
||||
ConceptDefinitionComponent cd = CodeSystemUtilities.getCode(cs, tu.getId());
|
||||
if (cd != null && cd.hasDisplay() && cd.getDisplay().equals(tu.getSrcText())) {
|
||||
cd.addDesignation().setLanguage(tu.getLanguage()).setValue(tu.getTgtText());
|
||||
} else {
|
||||
|
@ -273,9 +279,18 @@ public class LanguageUtils {
|
|||
target = d.getValue();
|
||||
}
|
||||
}
|
||||
list.add(new TranslationUnit(lang, code, display, target));
|
||||
list.add(new TranslationUnit(lang, code, getDefinition(cd), display, target));
|
||||
for (ConceptDefinitionComponent cd1 : cd.getConcept()) {
|
||||
generateTranslations(list, cd1, lang);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getDefinition(ConceptDefinitionComponent cd) {
|
||||
ConceptPropertyComponent v = CodeSystemUtilities.getProperty(cd, "translation-context");
|
||||
if (v != null && v.hasValue()) {
|
||||
return v.getValue().primitiveValue();
|
||||
} else {
|
||||
return cd.getDefinition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public abstract class ParserBase {
|
|||
if (res == null) {
|
||||
throw new FHIRException("Parsing FHIR content failed: "+errors.get(0).summary());
|
||||
} else if (res.size() == 0) {
|
||||
throw new FHIRException("Parsing FHIR content returned no elements in a context where one element is required");
|
||||
throw new FHIRException("Parsing FHIR content returned no elements in a context where one element is required because: "+errors.get(0).summary());
|
||||
}
|
||||
if (res.size() != 1) {
|
||||
throw new FHIRException("Parsing FHIR content returned multiple elements in a context where only one element is allowed");
|
||||
|
|
|
@ -665,16 +665,16 @@ public class ValueSetValidator {
|
|||
if (code.getDisplay() == null) {
|
||||
return new ValidationResult(code.getSystem(), cs.getVersion(), cc, vc.getDisplay());
|
||||
}
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(", ", " or ");
|
||||
if (cc.hasDisplay() && isOkLanguage(cs.getLanguage())) {
|
||||
b.append(cc.getDisplay());
|
||||
b.append("'"+cc.getDisplay()+"'");
|
||||
if (code.getDisplay().equalsIgnoreCase(cc.getDisplay())) {
|
||||
return new ValidationResult(code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs));
|
||||
}
|
||||
}
|
||||
for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
|
||||
if (isOkLanguage(ds.getLanguage())) {
|
||||
b.append(ds.getValue());
|
||||
b.append("'"+ds.getValue()+"'");
|
||||
if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
|
||||
return new ValidationResult(code.getSystem(),cs.getVersion(), cc, getPreferredDisplay(cc, cs));
|
||||
}
|
||||
|
@ -685,14 +685,14 @@ public class ValueSetValidator {
|
|||
ConceptReferencePair vs = findValueSetRef(code.getSystem(), code.getCode());
|
||||
if (vs != null && (vs.getCc().hasDisplay() ||vs.getCc().hasDesignation())) {
|
||||
if (vs.getCc().hasDisplay() && isOkLanguage(vs.getValueset().getLanguage())) {
|
||||
b.append(vs.getCc().getDisplay());
|
||||
b.append("'"+vs.getCc().getDisplay()+"'");
|
||||
if (code.getDisplay().equalsIgnoreCase(vs.getCc().getDisplay())) {
|
||||
return new ValidationResult(code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs));
|
||||
}
|
||||
}
|
||||
for (ConceptReferenceDesignationComponent ds : vs.getCc().getDesignation()) {
|
||||
if (isOkLanguage(ds.getLanguage())) {
|
||||
b.append(ds.getValue());
|
||||
b.append("'"+ds.getValue()+"'");
|
||||
if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
|
||||
return new ValidationResult(code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs));
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ResourceLanguageFileBuilder {
|
|||
String ppath = path+"."+p.getName()+(p.isList() ? "["+i+"]" : "");
|
||||
i++;
|
||||
if (isTranslatable(p, b, pid)) {
|
||||
sess.entry(new TextUnit(ppath, b.primitiveValue(), getTranslation(b, target)));
|
||||
sess.entry(new TextUnit(ppath, getContext(), b.primitiveValue(), getTranslation(b, target)));
|
||||
}
|
||||
for (Property pp : b.children()) {
|
||||
process(sess, pp, pid, ppath);
|
||||
|
@ -86,6 +86,11 @@ public class ResourceLanguageFileBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private String getContext() {
|
||||
throw new Error("not done yet");
|
||||
}
|
||||
|
||||
|
||||
private boolean isTranslatable(Property p, Base b, String id) {
|
||||
if (new ContextUtilities(context).isPrimitiveDatatype(b.fhirType())) { // never any translations for non-primitives
|
||||
ElementDefinition ed = null;
|
||||
|
|
|
@ -32,7 +32,9 @@ import org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterCom
|
|||
import org.hl7.fhir.r5.model.Questionnaire;
|
||||
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
|
@ -46,33 +48,32 @@ public class ResourceMinifier {
|
|||
"ConceptMap", "NamingSystem", "OperationDefinition", "SearchParameter", "Questionnaire");
|
||||
}
|
||||
|
||||
public void minify(Resource res) {
|
||||
public boolean minify(Resource res) {
|
||||
if (res instanceof StructureDefinition) {
|
||||
minifySD((StructureDefinition) res);
|
||||
}
|
||||
if (res instanceof ValueSet) {
|
||||
return minifySD((StructureDefinition) res);
|
||||
} else if (res instanceof ValueSet) {
|
||||
minifyVS((ValueSet) res);
|
||||
}
|
||||
if (res instanceof CodeSystem) {
|
||||
} else if (res instanceof CodeSystem) {
|
||||
minifyCS((CodeSystem) res);
|
||||
}
|
||||
if (res instanceof CapabilityStatement) {
|
||||
} else if (res instanceof CapabilityStatement) {
|
||||
minifyCS((CapabilityStatement) res);
|
||||
}
|
||||
if (res instanceof ConceptMap) {
|
||||
} else if (res instanceof ConceptMap) {
|
||||
minifyCM((ConceptMap) res);
|
||||
}
|
||||
if (res instanceof NamingSystem) {
|
||||
} else if (res instanceof NamingSystem) {
|
||||
minifyNS((NamingSystem) res);
|
||||
}
|
||||
|
||||
if (res instanceof OperationDefinition) {
|
||||
} else if (res instanceof OperationDefinition) {
|
||||
minifyOD((OperationDefinition) res);
|
||||
}
|
||||
|
||||
if (res instanceof Questionnaire) {
|
||||
} else if (res instanceof Questionnaire) {
|
||||
minifyQ((Questionnaire) res);
|
||||
} else if (res instanceof SearchParameter) {
|
||||
minifySP((SearchParameter) res);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void minifySP(SearchParameter sp) {
|
||||
minCR(sp);
|
||||
// nothing
|
||||
}
|
||||
|
||||
private void minifyQ(Questionnaire q) {
|
||||
|
@ -242,14 +243,20 @@ public class ResourceMinifier {
|
|||
// can't remove anything else
|
||||
}
|
||||
|
||||
private void minifySD(StructureDefinition sd) {
|
||||
private boolean minifySD(StructureDefinition sd) {
|
||||
if (sd.getKind() == StructureDefinitionKind.LOGICAL) {
|
||||
return false;
|
||||
}
|
||||
minCR(sd);
|
||||
sd.setKeyword(null);
|
||||
sd.setMapping(null);
|
||||
sd.setSnapshot(null);
|
||||
sd.setMapping(null);
|
||||
if (sd.hasDifferential()) {
|
||||
sd.setSnapshot(null);
|
||||
}
|
||||
for (ElementDefinition ed : sd.getDifferential().getElement()) {
|
||||
minifyED(ed);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void minifyED(ElementDefinition ed) {
|
||||
|
@ -272,6 +279,7 @@ public class ResourceMinifier {
|
|||
abn.setShortDoco(null);
|
||||
}
|
||||
ed.setMapping(null);
|
||||
ed.setMustSupportElement(null);
|
||||
}
|
||||
|
||||
private void minCR(CanonicalResource cr) {
|
||||
|
|
|
@ -74,7 +74,10 @@ public class JsonLangFileProducer extends LanguageFileProducer {
|
|||
public void entry(TextUnit unit) {
|
||||
JsonObject entry = new JsonObject();
|
||||
json.forceArray("entries").add(entry);
|
||||
entry.add("context", unit.getContext());
|
||||
entry.add("id", unit.getId());
|
||||
if (unit.getContext1() != null) {
|
||||
entry.add("context", unit.getContext1());
|
||||
}
|
||||
entry.add("source", unit.getSrcText());
|
||||
entry.add("target", unit.getTgtText());
|
||||
}
|
||||
|
@ -88,7 +91,7 @@ public class JsonLangFileProducer extends LanguageFileProducer {
|
|||
JsonObject json = JsonParser.parseObject(source);
|
||||
for (JsonObject lang : json.forceArray("languages").asJsonObjects()) {
|
||||
for (JsonObject entry : lang.forceArray("entries").asJsonObjects()) {
|
||||
list.add(new TranslationUnit(lang.asString("targetLang"), entry.asString("context"), entry.asString("source"), entry.asString("target")));
|
||||
list.add(new TranslationUnit(lang.asString("targetLang"), entry.asString("id"), entry.asString("context"), entry.asString("source"), entry.asString("target")));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
@ -118,7 +121,10 @@ public class JsonLangFileProducer extends LanguageFileProducer {
|
|||
for (TranslationUnit tu : translations) {
|
||||
JsonObject entry = new JsonObject();
|
||||
lj.forceArray("entries").add(entry);
|
||||
entry.add("context", tu.getContext());
|
||||
entry.add("id", tu.getId());
|
||||
if (tu.getContext1() != null) {
|
||||
entry.add("context", tu.getContext1());
|
||||
}
|
||||
entry.add("source", tu.getSrcText());
|
||||
entry.add("target", tu.getTgtText());
|
||||
}
|
||||
|
|
|
@ -18,35 +18,59 @@ import java.util.HashMap;
|
|||
public abstract class LanguageFileProducer {
|
||||
|
||||
public static class TextUnit {
|
||||
protected String id;
|
||||
protected String context;
|
||||
protected String srcText;
|
||||
protected String tgtText;
|
||||
public TextUnit(String context, String srcText, String tgtText) {
|
||||
public TextUnit(String id, String context, String srcText, String tgtText) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.context = context;
|
||||
this.srcText = srcText;
|
||||
this.tgtText = tgtText;
|
||||
}
|
||||
|
||||
public String getContext() {
|
||||
/**
|
||||
* The identity of the item being translated
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional language that helps establish the context
|
||||
* @return
|
||||
*/
|
||||
public String getContext1() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* The language that's being translated from
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getSrcText() {
|
||||
return srcText;
|
||||
}
|
||||
|
||||
/**
|
||||
* The language that's being translated to
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTgtText() {
|
||||
return tgtText;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class TranslationUnit extends TextUnit {
|
||||
private String language;
|
||||
|
||||
public TranslationUnit(String language, String context, String srcText, String tgtText) {
|
||||
super(context, srcText, tgtText);
|
||||
public TranslationUnit(String language, String id, String context, String srcText, String tgtText) {
|
||||
super(id, context, srcText, tgtText);
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,10 @@ public class PoGetTextProducer extends LanguageFileProducer {
|
|||
|
||||
@Override
|
||||
public void entry(TextUnit unit) {
|
||||
ln("#: "+unit.getContext());
|
||||
// if (context != null) {
|
||||
// ln("#. "+context);
|
||||
// }
|
||||
ln("#: "+unit.getId());
|
||||
if (unit.getContext1() != null) {
|
||||
ln("#. "+unit.getContext1());
|
||||
}
|
||||
ln("msgid \""+unit.getSrcText()+"\"");
|
||||
ln("msgstr \""+(unit.getTgtText() == null ? "" : unit.getTgtText())+"\"");
|
||||
ln("");
|
||||
|
@ -117,7 +117,7 @@ public class PoGetTextProducer extends LanguageFileProducer {
|
|||
lang = p[1].trim();
|
||||
}
|
||||
} else if (s.startsWith("#:")) {
|
||||
tu = new TranslationUnit(lang, s.substring(2).trim(), null, null);
|
||||
tu = new TranslationUnit(lang, s.substring(2).trim(), null, null, null);
|
||||
} else {
|
||||
throw new IOException("Encountered unexpected line '"+s+"'");
|
||||
}
|
||||
|
@ -166,10 +166,10 @@ public class PoGetTextProducer extends LanguageFileProducer {
|
|||
ln(po, "# "+baseLang+" -> "+targetLang);
|
||||
ln(po, "");
|
||||
for (TranslationUnit tu : translations) {
|
||||
ln(po, "#: "+tu.getContext());
|
||||
// if (context != null) {
|
||||
// ln("#. "+context);
|
||||
// }
|
||||
ln(po, "#: "+tu.getId());
|
||||
if (tu.getContext1() != null) {
|
||||
ln(po, "#. "+tu.getContext1());
|
||||
}
|
||||
ln(po, "msgid \""+tu.getSrcText()+"\"");
|
||||
ln(po, "msgstr \""+(tu.getTgtText() == null ? "" : tu.getTgtText())+"\"");
|
||||
ln(po, "");
|
||||
|
|
|
@ -50,12 +50,12 @@ public class XLIFFProducer extends LanguageFileProducer {
|
|||
@Override
|
||||
public void entry(TextUnit unit) {
|
||||
i++;
|
||||
ln(" <trans-unit id=\""+id+"\" resname=\""+unit.getContext()+"\">");
|
||||
// if (context != null) {
|
||||
// ln(" <notes>");
|
||||
// ln(" <note id=\"n"+i+"\">"+Utilities.escapeXml(context)+"</note>");
|
||||
// ln(" </notes>");
|
||||
// }
|
||||
ln(" <trans-unit id=\""+id+"\" resname=\""+unit.getId()+"\">");
|
||||
if (unit.getContext1() != null) {
|
||||
ln(" <notes>");
|
||||
ln(" <note id=\"n"+i+"\">"+Utilities.escapeXml(unit.getContext1())+"</note>");
|
||||
ln(" </notes>");
|
||||
}
|
||||
ln(" <source>"+Utilities.escapeXml(unit.getSrcText())+"</source>");
|
||||
ln(" <target>"+Utilities.escapeXml(unit.getTgtText())+"</target>");
|
||||
ln(" </trans-unit>");
|
||||
|
@ -114,7 +114,9 @@ public class XLIFFProducer extends LanguageFileProducer {
|
|||
for (Element file : XMLUtil.getNamedChildren(xliff, "file")) {
|
||||
Element body = XMLUtil.getNamedChild(file, "body");
|
||||
for (Element transUnit : XMLUtil.getNamedChildren(body, "trans-unit")) {
|
||||
TranslationUnit tu = new TranslationUnit(file.getAttribute("target-language"), transUnit.getAttribute("id"),
|
||||
Element notes = XMLUtil.getNamedChild(transUnit, "notes");
|
||||
TranslationUnit tu = new TranslationUnit(file.getAttribute("target-language"), transUnit.getAttribute("id"),
|
||||
notes == null ? null : XMLUtil.getNamedChildText(notes, "note"),
|
||||
XMLUtil.getNamedChildText(transUnit, "source"), XMLUtil.getNamedChildText(transUnit, "target"));
|
||||
if (!Utilities.noString(tu.getSrcText()) && !Utilities.noString(tu.getTgtText())) {
|
||||
list.add(tu);
|
||||
|
@ -149,7 +151,14 @@ public class XLIFFProducer extends LanguageFileProducer {
|
|||
ln(xml, " <file source-language=\""+baseLang+"\" target-language=\""+targetLang+"\" id=\""+id+"\" original=\"Resource "+id+"\" datatype=\"KEYVALUEJSON\">");
|
||||
ln(xml, " <body>");
|
||||
for (TranslationUnit tu : translations) {
|
||||
ln(xml, " <trans-unit id=\""+id+"\" resname=\""+tu.getContext()+"\">");
|
||||
int i = 0;
|
||||
ln(xml, " <trans-unit id=\""+id+"\" resname=\""+tu.getId()+"\">");
|
||||
if (tu.getContext1() != null) {
|
||||
i++;
|
||||
ln(xml, " <notes>");
|
||||
ln(xml, " <note id=\"n"+i+"\">"+Utilities.escapeXml(tu.getContext1())+"</note>");
|
||||
ln(xml, " </notes>");
|
||||
}
|
||||
ln(xml, " <source>"+Utilities.escapeXml(tu.getSrcText())+"</source>");
|
||||
ln(xml, " <target>"+Utilities.escapeXml(tu.getTgtText())+"</target>");
|
||||
ln(xml, " </trans-unit>");
|
||||
|
|
|
@ -52,6 +52,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
|
@ -60,6 +61,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
|||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipParameters;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.SimpleHTTPClient;
|
||||
|
@ -946,7 +948,9 @@ public class NpmPackage {
|
|||
|
||||
OutputStream = new ByteArrayOutputStream();
|
||||
bufferedOutputStream = new BufferedOutputStream(OutputStream);
|
||||
gzipOutputStream = new GzipCompressorOutputStream(bufferedOutputStream);
|
||||
GzipParameters gp = new GzipParameters();
|
||||
gp.setCompressionLevel(Deflater.BEST_COMPRESSION);
|
||||
gzipOutputStream = new GzipCompressorOutputStream(stream, gp);
|
||||
tar = new TarArchiveOutputStream(gzipOutputStream);
|
||||
|
||||
|
||||
|
|
|
@ -463,8 +463,8 @@ Version_mismatch_The_context_has_version__loaded_and_the_new_content_being_loade
|
|||
Error_reading__from_package__ = Error reading {0} from package {1}#{2}: {3}
|
||||
Error_parsing_ = Error parsing {0}:{1}
|
||||
Unable_to_connect_to_terminology_server_Use_parameter_tx_na_tun_run_without_using_terminology_services_to_validate_LOINC_SNOMED_ICDX_etc_Error__ = Unable to connect to terminology server. Use parameter ''-tx n/a'' to run without using terminology services to validate LOINC, SNOMED, ICD-X etc. Error = {0}
|
||||
Display_Name_for__should_be_one_of__instead_of_one = Wrong Display Name ''{4}'' for {1}#{2} - should be ''{3}'' (for the language(s) ''{5}'')
|
||||
Display_Name_for__should_be_one_of__instead_of_other = Wrong Display Name ''{4}'' for {1}#{2} - should be one of {0} choices: ''{3}'' for the language(s) ''{5}''
|
||||
Display_Name_for__should_be_one_of__instead_of_one = Wrong Display Name ''{4}'' for {1}#{2} - should be {3} (for the language(s) ''{5}'')
|
||||
Display_Name_for__should_be_one_of__instead_of_other = Wrong Display Name ''{4}'' for {1}#{2} - should be one of {0} choices: {3} (for the language(s) ''{5}'')
|
||||
Unknown_Code__in_ = Unknown Code ''{0}'' in the system ''{1}''
|
||||
UNKNOWN_CODE__IN_FRAGMENT = Unknown Code ''{0}'' in the system ''{1}'' - note that the code system is labeled as a fragment, so the code may be valid in some other fragment
|
||||
Code_found_in_expansion_however_ = Code found in expansion, however: {0}
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -19,7 +19,7 @@
|
|||
|
||||
<properties>
|
||||
<hapi_fhir_version>6.4.1</hapi_fhir_version>
|
||||
<validator_test_case_version>1.3.8</validator_test_case_version>
|
||||
<validator_test_case_version>1.3.9-SNAPSHOT</validator_test_case_version>
|
||||
<jackson_version>2.14.0</jackson_version>
|
||||
<junit_jupiter_version>5.9.2</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
|
|
Loading…
Reference in New Issue