Merge branch 'master' into do-reintroduce-saxon-dependency
This commit is contained in:
commit
0fd3c4af42
|
@ -1,7 +1,6 @@
|
|||
## Validator Changes
|
||||
|
||||
* Add support for fhir_comments in R2/R2B
|
||||
* Add validator checking around versions in extension URLs
|
||||
* no changes
|
||||
|
||||
## Other code changes
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ import org.hl7.fhir.r5.model.Resource;
|
|||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent;
|
||||
|
@ -2523,109 +2524,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return !p.contains(".");
|
||||
}
|
||||
|
||||
// public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker, RenderingContext rc) throws IOException, FHIRException {
|
||||
// HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
// gen.setTranslator(getTranslator());
|
||||
// TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true);
|
||||
//
|
||||
// boolean deep = false;
|
||||
// String m = "";
|
||||
// boolean vdeep = false;
|
||||
// if (ed.getSnapshot().getElementFirstRep().getIsModifier())
|
||||
// m = "modifier_";
|
||||
// for (ElementDefinition eld : ed.getSnapshot().getElement()) {
|
||||
// deep = deep || eld.getPath().contains("Extension.extension.");
|
||||
// vdeep = vdeep || eld.getPath().contains("Extension.extension.extension.");
|
||||
// }
|
||||
// Row r = gen.new Row();
|
||||
// model.getRows().add(r);
|
||||
// String en;
|
||||
// if (!full)
|
||||
// en = ed.getName();
|
||||
// else if (ed.getSnapshot().getElement().get(0).getIsModifier())
|
||||
// en = "modifierExtension";
|
||||
// else
|
||||
// en = "extension";
|
||||
//
|
||||
// r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#extension."+ed.getName(), en, null, null));
|
||||
// r.getCells().add(gen.new Cell());
|
||||
// r.getCells().add(gen.new Cell(null, null, describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null));
|
||||
//
|
||||
// ElementDefinition ved = null;
|
||||
// if (full || vdeep) {
|
||||
// r.getCells().add(gen.new Cell("", "", "Extension", null, null));
|
||||
//
|
||||
// r.setIcon(deep ? "icon_"+m+"extension_complex.png" : "icon_extension_simple.png", deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX : HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
// List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0));
|
||||
// for (ElementDefinition child : children)
|
||||
// if (!child.getPath().endsWith(".id")) {
|
||||
// List<StructureDefinition> sdl = new ArrayList<>();
|
||||
// sdl.add(ed);
|
||||
// genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), sdl, true, defFile, true, full, corePath, imagePath, true, false, false, false, null, false, rc, "", ed);
|
||||
// }
|
||||
// } else if (deep) {
|
||||
// List<ElementDefinition> children = new ArrayList<ElementDefinition>();
|
||||
// for (ElementDefinition ted : ed.getSnapshot().getElement()) {
|
||||
// if (ted.getPath().equals("Extension.extension"))
|
||||
// children.add(ted);
|
||||
// }
|
||||
//
|
||||
// r.getCells().add(gen.new Cell("", "", "Extension", null, null));
|
||||
// r.setIcon("icon_"+m+"extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
|
||||
//
|
||||
// for (ElementDefinition c : children) {
|
||||
// ved = getValueFor(ed, c);
|
||||
// ElementDefinition ued = getUrlFor(ed, c);
|
||||
// if (ved != null && ued != null) {
|
||||
// Row r1 = gen.new Row();
|
||||
// r.getSubRows().add(r1);
|
||||
// r1.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#"+ed.getId()+"."+c.getId(), ((UriType) ued.getFixed()).getValue(), null, null));
|
||||
// r1.getCells().add(gen.new Cell());
|
||||
// r1.getCells().add(gen.new Cell(null, null, describeCardinality(c, null, new UnusedTracker()), null, null));
|
||||
// genTypes(gen, r1, ved, defFile, ed, corePath, imagePath, false, false);
|
||||
// r1.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
// generateDescription(gen, r1, c, null, true, corePath, corePath, ed, corePath, imagePath, false, false, false, ved, false, false, false, rc);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// for (ElementDefinition ted : ed.getSnapshot().getElement()) {
|
||||
// if (ted.getPath().startsWith("Extension.value"))
|
||||
// ved = ted;
|
||||
// }
|
||||
//
|
||||
// genTypes(gen, r, ved, defFile, ed, corePath, imagePath, false, false);
|
||||
//
|
||||
// r.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
// }
|
||||
// Cell c = gen.new Cell("", "", "URL = "+ed.getUrl(), null, null);
|
||||
// Piece cc = gen.new Piece(null, ed.getName()+": ", null);
|
||||
// c.addPiece(gen.new Piece("br")).addPiece(cc);
|
||||
// c.addMarkdown(ed.getDescription());
|
||||
//
|
||||
// if (!full && !(deep || vdeep) && ved != null && ved.hasBinding()) {
|
||||
// c.addPiece(gen.new Piece("br"));
|
||||
// BindingResolution br = pkp.resolveBinding(ed, ved.getBinding(), ved.getPath());
|
||||
// c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, translate("sd.table", "Binding")+": ", null).addStyle("font-weight:bold")));
|
||||
// c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null)));
|
||||
// if (ved.getBinding().hasStrength()) {
|
||||
// c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, " (", null)));
|
||||
// c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(corePath+"terminologies.html#"+ved.getBinding().getStrength().toCode(), egt(ved.getBinding().getStrengthElement()), ved.getBinding().getStrength().getDefinition())));
|
||||
// c.getPieces().add(gen.new Piece(null, ")", null));
|
||||
// }
|
||||
// if (ved.getBinding().hasDescription() && MarkDownProcessor.isSimpleMarkdown(ved.getBinding().getDescription())) {
|
||||
// c.getPieces().add(gen.new Piece(null, ": ", null));
|
||||
// c.addMarkdownNoPara(PublicationHacker.fixBindingDescriptions(context, ved.getBinding().getDescriptionElement()).asStringValue());
|
||||
// }
|
||||
// }
|
||||
// c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, describeExtensionContext(ed), null));
|
||||
// r.getCells().add(c);
|
||||
//
|
||||
// try {
|
||||
// return gen.generate(model, corePath, 0, outputTracker);
|
||||
// } catch (org.hl7.fhir.exceptions.FHIRException e) {
|
||||
// throw new FHIRException(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
|
||||
int i = ed.getSnapshot().getElement().indexOf(c) + 1;
|
||||
|
@ -2636,17 +2535,6 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
//
|
||||
// private ElementDefinition getValueFor(StructureDefinition ed, ElementDefinition c) {
|
||||
// int i = ed.getSnapshot().getElement().indexOf(c) + 1;
|
||||
// while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) {
|
||||
// if (ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".value"))
|
||||
// return ed.getSnapshot().getElement().get(i);
|
||||
// i++;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2668,31 +2556,31 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// public static String describeExtensionContext(StructureDefinition ext) {
|
||||
// StringBuilder b = new StringBuilder();
|
||||
// b.append("Use on ");
|
||||
// for (int i = 0; i < ext.getContext().size(); i++) {
|
||||
// StructureDefinitionContextComponent ec = ext.getContext().get(i);
|
||||
// if (i > 0)
|
||||
// b.append(i < ext.getContext().size() - 1 ? ", " : " or ");
|
||||
// b.append(ec.getType().getDisplay());
|
||||
// b.append(" ");
|
||||
// b.append(ec.getExpression());
|
||||
// }
|
||||
// if (ext.hasContextInvariant()) {
|
||||
// b.append(", with <a href=\"structuredefinition-definitions.html#StructureDefinition.contextInvariant\">Context Invariant</a> = ");
|
||||
// boolean first = true;
|
||||
// for (StringType s : ext.getContextInvariant()) {
|
||||
// if (first)
|
||||
// first = false;
|
||||
// else
|
||||
// b.append(", ");
|
||||
// b.append("<code>"+s.getValue()+"</code>");
|
||||
// }
|
||||
// }
|
||||
// return b.toString();
|
||||
// }
|
||||
|
||||
public static String describeExtensionContext(StructureDefinition ext) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("Use on ");
|
||||
for (int i = 0; i < ext.getContext().size(); i++) {
|
||||
StructureDefinitionContextComponent ec = ext.getContext().get(i);
|
||||
if (i > 0)
|
||||
b.append(i < ext.getContext().size() - 1 ? ", " : " or ");
|
||||
b.append(ec.getType().getDisplay());
|
||||
b.append(" ");
|
||||
b.append(ec.getExpression());
|
||||
}
|
||||
if (ext.hasContextInvariant()) {
|
||||
b.append(", with <a href=\"structuredefinition-definitions.html#StructureDefinition.contextInvariant\">Context Invariant</a> = ");
|
||||
boolean first = true;
|
||||
for (StringType s : ext.getContextInvariant()) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
b.append(", ");
|
||||
b.append("<code>"+s.getValue()+"</code>");
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
|||
}
|
||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Code", getContext().getLang()));
|
||||
if (hasURI) {
|
||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "URL", getContext().getLang()));
|
||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "URI", getContext().getLang()));
|
||||
}
|
||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Type", getContext().getLang()));
|
||||
if (hasDescription) {
|
||||
|
|
|
@ -2661,4 +2661,149 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker, RenderingContext rc) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true);
|
||||
|
||||
boolean deep = false;
|
||||
String m = "";
|
||||
boolean vdeep = false;
|
||||
if (ed.getSnapshot().getElementFirstRep().getIsModifier())
|
||||
m = "modifier_";
|
||||
for (ElementDefinition eld : ed.getSnapshot().getElement()) {
|
||||
deep = deep || eld.getPath().contains("Extension.extension.");
|
||||
vdeep = vdeep || eld.getPath().contains("Extension.extension.extension.");
|
||||
}
|
||||
Row r = gen.new Row();
|
||||
model.getRows().add(r);
|
||||
String en;
|
||||
if (!full)
|
||||
en = ed.getName();
|
||||
else if (ed.getSnapshot().getElement().get(0).getIsModifier())
|
||||
en = "modifierExtension";
|
||||
else
|
||||
en = "extension";
|
||||
|
||||
r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#extension."+ed.getName(), en, null, null));
|
||||
r.getCells().add(gen.new Cell());
|
||||
r.getCells().add(gen.new Cell(null, null, describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null));
|
||||
|
||||
ElementDefinition ved = null;
|
||||
if (full || vdeep) {
|
||||
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
|
||||
|
||||
r.setIcon(deep ? "icon_"+m+"extension_complex.png" : "icon_extension_simple.png", deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX : HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0));
|
||||
for (ElementDefinition child : children)
|
||||
if (!child.getPath().endsWith(".id")) {
|
||||
List<StructureDefinition> sdl = new ArrayList<>();
|
||||
sdl.add(ed);
|
||||
genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), sdl, true, defFile, true, full, corePath, imagePath, true, false, false, false, null, false, rc, "", ed, null);
|
||||
}
|
||||
} else if (deep) {
|
||||
List<ElementDefinition> children = new ArrayList<ElementDefinition>();
|
||||
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
|
||||
if (ted.getPath().equals("Extension.extension"))
|
||||
children.add(ted);
|
||||
}
|
||||
|
||||
r.getCells().add(gen.new Cell("", "", "Extension", null, null));
|
||||
r.setIcon("icon_"+m+"extension_complex.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
|
||||
|
||||
for (ElementDefinition c : children) {
|
||||
ved = getValueFor(ed, c);
|
||||
ElementDefinition ued = getUrlFor(ed, c);
|
||||
if (ved != null && ued != null) {
|
||||
Row r1 = gen.new Row();
|
||||
r.getSubRows().add(r1);
|
||||
r1.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#"+ed.getId()+"."+c.getId(), ((UriType) ued.getFixed()).getValue(), null, null));
|
||||
r1.getCells().add(gen.new Cell());
|
||||
r1.getCells().add(gen.new Cell(null, null, describeCardinality(c, null, new UnusedTracker()), null, null));
|
||||
genTypes(gen, r1, ved, defFile, ed, corePath, imagePath, false, false);
|
||||
r1.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
generateDescription(gen, r1, c, null, true, corePath, corePath, ed, corePath, imagePath, false, false, false, ved, false, false, false, rc);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (ElementDefinition ted : ed.getSnapshot().getElement()) {
|
||||
if (ted.getPath().startsWith("Extension.value"))
|
||||
ved = ted;
|
||||
}
|
||||
|
||||
genTypes(gen, r, ved, defFile, ed, corePath, imagePath, false, false);
|
||||
|
||||
r.setIcon("icon_"+m+"extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
|
||||
}
|
||||
Cell c = gen.new Cell("", "", "URL = "+ed.getUrl(), null, null);
|
||||
Piece cc = gen.new Piece(null, ed.getName()+": ", null);
|
||||
c.addPiece(gen.new Piece("br")).addPiece(cc);
|
||||
c.addMarkdown(ed.getDescription());
|
||||
|
||||
if (!full && !(deep || vdeep) && ved != null && ved.hasBinding()) {
|
||||
c.addPiece(gen.new Piece("br"));
|
||||
BindingResolution br = context.getPkp().resolveBinding(ed, ved.getBinding(), ved.getPath());
|
||||
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, translate("sd.table", "Binding")+": ", null).addStyle("font-weight:bold")));
|
||||
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !context.getPkp().prependLinks() ? br.url : corePath+br.url, br.display, null)));
|
||||
if (ved.getBinding().hasStrength()) {
|
||||
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(null, " (", null)));
|
||||
c.getPieces().add(checkForNoChange(ved.getBinding(), gen.new Piece(corePath+"terminologies.html#"+ved.getBinding().getStrength().toCode(), egt(ved.getBinding().getStrengthElement()), ved.getBinding().getStrength().getDefinition())));
|
||||
c.getPieces().add(gen.new Piece(null, ")", null));
|
||||
}
|
||||
if (ved.getBinding().hasDescription() && MarkDownProcessor.isSimpleMarkdown(ved.getBinding().getDescription())) {
|
||||
c.getPieces().add(gen.new Piece(null, ": ", null));
|
||||
c.addMarkdownNoPara(PublicationHacker.fixBindingDescriptions(context.getWorker(), ved.getBinding().getDescriptionElement()).asStringValue());
|
||||
}
|
||||
}
|
||||
c.addPiece(gen.new Piece("br")).addPiece(gen.new Piece(null, ProfileUtilities.describeExtensionContext(ed), null));
|
||||
r.getCells().add(c);
|
||||
|
||||
try {
|
||||
return gen.generate(model, corePath, 0, outputTracker);
|
||||
} catch (org.hl7.fhir.exceptions.FHIRException e) {
|
||||
throw new FHIRException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String describeCardinality(ElementDefinition definition, ElementDefinition fallback, UnusedTracker tracker) {
|
||||
IntegerType min = definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
|
||||
StringType max = definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
|
||||
if (min.isEmpty() && fallback != null)
|
||||
min = fallback.getMinElement();
|
||||
if (max.isEmpty() && fallback != null)
|
||||
max = fallback.getMaxElement();
|
||||
|
||||
tracker.used = !max.isEmpty() && !max.getValue().equals("0");
|
||||
|
||||
if (min.isEmpty() && max.isEmpty())
|
||||
return null;
|
||||
else
|
||||
return (!min.hasValue() ? "" : Integer.toString(min.getValue())) + ".." + (!max.hasValue() ? "" : max.getValue());
|
||||
}
|
||||
|
||||
|
||||
private ElementDefinition getValueFor(StructureDefinition ed, ElementDefinition c) {
|
||||
int i = ed.getSnapshot().getElement().indexOf(c) + 1;
|
||||
while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) {
|
||||
if (ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".value"))
|
||||
return ed.getSnapshot().getElement().get(i);
|
||||
i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
|
||||
int i = ed.getSnapshot().getElement().indexOf(c) + 1;
|
||||
while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) {
|
||||
if (ed.getSnapshot().getElement().get(i).getPath().equals(c.getPath()+".url"))
|
||||
return ed.getSnapshot().getElement().get(i);
|
||||
i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
public class FTPClient {
|
||||
|
||||
/**
|
||||
* Connect to an FTP server
|
||||
* @param server - the server to connect to (uusally just an IP address). It's up to the system to figure out access (VPN etc)
|
||||
* @param path - the path on the FTP server to treat all the operations as relative to
|
||||
* @param user - username for the FTP server
|
||||
* @param password - password for the FTP server
|
||||
*/
|
||||
public FTPClient(String server, String path, String user, String password) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the server, throw an exception if it fails
|
||||
*/
|
||||
public void connect() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file on the FTP server
|
||||
*
|
||||
* @param path - relative to the path provided in the constructor
|
||||
*/
|
||||
public void delete(String path) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file from the local system to the FTP Server
|
||||
* @param source - absolute path on local system
|
||||
* @param path - relative to the path provided in the constructor
|
||||
*/
|
||||
public void upload(String source, String path) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1469,6 +1469,10 @@ public class Utilities {
|
|||
return byteArrays;
|
||||
}
|
||||
|
||||
public static void unzip(InputStream zip, String target) throws IOException {
|
||||
unzip(zip, Path.of(target));
|
||||
}
|
||||
|
||||
public static void unzip(InputStream zip, Path target) throws IOException {
|
||||
try (ZipInputStream zis = new ZipInputStream(zip)) {
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
|
@ -1494,7 +1498,7 @@ public class Utilities {
|
|||
}
|
||||
}
|
||||
|
||||
private static Path zipSlipProtect(ZipEntry zipEntry, Path targetDir)
|
||||
public static Path zipSlipProtect(ZipEntry zipEntry, Path targetDir)
|
||||
throws IOException {
|
||||
|
||||
// test zip slip vulnerability
|
||||
|
@ -1815,4 +1819,47 @@ public class Utilities {
|
|||
}
|
||||
return baseText + "\r\n" + derivedText.substring(3);
|
||||
}
|
||||
|
||||
public static void deleteEmptyFolders(File df) {
|
||||
for (File f : df.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
deleteEmptyFolders(f);
|
||||
}
|
||||
}
|
||||
boolean empty = true;
|
||||
for (File f : df.listFiles()) {
|
||||
empty = false;
|
||||
break;
|
||||
}
|
||||
if (empty) {
|
||||
df.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRelativePath(String root, String path) {
|
||||
String res = path.substring(root.length());
|
||||
if (res.startsWith(File.separator)) {
|
||||
res = res.substring(1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<String> listAllFiles(String path, List<String> ignoreList) {
|
||||
List<String> res = new ArrayList<>();
|
||||
addAllFiles(res, path, new File(path), ignoreList);
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void addAllFiles(List<String> res, String root, File dir, List<String> ignoreList) {
|
||||
for (File f : dir.listFiles()) {
|
||||
if (ignoreList == null || !ignoreList.contains(f.getAbsolutePath())) {
|
||||
if (f.isDirectory()) {
|
||||
addAllFiles(res, root, f, ignoreList);
|
||||
} else {
|
||||
res.add(getRelativePath(root, f.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package org.hl7.fhir.utilities.json.model;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -49,7 +53,7 @@ public class JsonObject extends JsonElement {
|
|||
|
||||
public JsonObject add(String name, String value) throws JsonException {
|
||||
check(name != null, "Name is null");
|
||||
return add(name, new JsonString(value));
|
||||
return add(name, value == null ? new JsonNull() : new JsonString(value));
|
||||
}
|
||||
|
||||
public JsonObject add(String name, boolean value) throws JsonException {
|
||||
|
@ -74,14 +78,20 @@ public class JsonObject extends JsonElement {
|
|||
}
|
||||
}
|
||||
|
||||
public JsonObject set(String name, Instant value) throws JsonException {
|
||||
String v = value == null ? null : value.toString();
|
||||
return set(name, v);
|
||||
}
|
||||
|
||||
|
||||
public JsonObject set(String name, String value) throws JsonException {
|
||||
check(name != null, "Name is null");
|
||||
JsonProperty p = propMap.get(name);
|
||||
if (p != null) {
|
||||
p.setValue(new JsonString(value));
|
||||
p.setValue(value == null ? new JsonNull() : new JsonString(value));
|
||||
return this;
|
||||
} else {
|
||||
return add(name, new JsonString(value));
|
||||
return add(name, value == null ? new JsonNull() : new JsonString(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,6 +266,19 @@ public class JsonObject extends JsonElement {
|
|||
}
|
||||
}
|
||||
|
||||
public Instant asInstant(String name) throws ParseException {
|
||||
String source = asString(name);
|
||||
if (Utilities.noString(source) || "null".equals(source)) {
|
||||
return null;
|
||||
} else if (source.length() <= 10) {
|
||||
Date d = new SimpleDateFormat("yyyy-mm-dd").parse(source);
|
||||
return d.toInstant();
|
||||
} else {
|
||||
OffsetDateTime odt = OffsetDateTime.parse(source);
|
||||
return odt.toInstant();
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject forceObject(String name) throws JsonException {
|
||||
if (has(name) && !hasObject(name)) {
|
||||
remove(name);
|
||||
|
|
|
@ -181,7 +181,7 @@ public class JsonParser {
|
|||
}
|
||||
|
||||
public static byte[] composeBytes(JsonElement element, boolean pretty) {
|
||||
String s = compose(element);
|
||||
String s = compose(element, pretty);
|
||||
return s.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.hl7.fhir.utilities.npm;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,6 +47,8 @@ public class PackageList {
|
|||
}
|
||||
|
||||
public String fhirVersion() {
|
||||
if (json.has("fhir-version")) // legacy
|
||||
return json.asString("fhir-version");
|
||||
return json.asString("fhirversion");
|
||||
}
|
||||
|
||||
|
@ -114,6 +118,14 @@ public class PackageList {
|
|||
json.set("changes", changes);
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject json() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public Instant instant() throws ParseException {
|
||||
return json.asInstant("date");
|
||||
}
|
||||
}
|
||||
|
||||
private String source;
|
||||
|
@ -251,4 +263,21 @@ public class PackageList {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String title() {
|
||||
return json.asString("title");
|
||||
}
|
||||
|
||||
public PackageListEntry current() {
|
||||
for (PackageListEntry e : list) {
|
||||
if (e.current() && !"ci-build".equals(e.status())) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String intro() {
|
||||
return json.asString("introduction");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package org.hl7.fhir.utilities.json;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JsonObjectTests {
|
||||
|
||||
@Test
|
||||
void test1() throws ParseException {
|
||||
JsonObject json = new JsonObject();
|
||||
json.set("date", "2022-10-12");
|
||||
System.out.println(json.asString("date"));
|
||||
Assertions.assertNotNull(json.asInstant("date"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test2() throws ParseException {
|
||||
Instant instant = Instant.now();
|
||||
JsonObject json = new JsonObject();
|
||||
json.set("date", instant);
|
||||
System.out.println(json.asString("date"));
|
||||
Assertions.assertEquals(instant, json.asInstant("date"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test3() {
|
||||
Instant instant = Instant.now();
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("MMM-yyyy").withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault());
|
||||
System.out.println(df.format(instant));
|
||||
df = DateTimeFormatter.ofPattern("yyyy-MM-dd").withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault());
|
||||
System.out.println(df.format(instant));
|
||||
Assertions.assertNotEquals(instant, Instant.now());
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -14,12 +14,12 @@
|
|||
HAPI FHIR
|
||||
-->
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>5.6.89-SNAPSHOT</version>
|
||||
<version>5.6.90-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<hapi_fhir_version>6.2.1</hapi_fhir_version>
|
||||
<validator_test_case_version>1.2.5-SNAPSHOT</validator_test_case_version>
|
||||
<validator_test_case_version>1.2.6</validator_test_case_version>
|
||||
<junit_jupiter_version>5.7.1</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
<maven_surefire_version>3.0.0-M5</maven_surefire_version>
|
||||
|
|
Loading…
Reference in New Issue