From 9b0d702ba29cd30a6ba2ca87f6754e7e20f43aba Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 24 Apr 2019 06:14:26 +1000 Subject: [PATCH] updates for ongoing work in IG publisher + Implementation Guide relax codes on .definition.parameter.code --- compare updated code.bat | 4 +- .../conv40_50/ImplementationGuide.java | 4 +- .../hl7/fhir/r4/formats/FormatUtilities.java | 13 ++++++ .../org/hl7/fhir/r4/formats/JsonParser.java | 6 +-- .../org/hl7/fhir/r4/formats/RdfParser.java | 2 +- .../org/hl7/fhir/r4/formats/XmlParser.java | 4 +- .../fhir/r4/model/ImplementationGuide.java | 33 ++++++------- .../java/org/hl7/fhir/r4/utils/IGHelper.java | 6 +-- .../org/hl7/fhir/r5/formats/JsonParser.java | 6 +-- .../org/hl7/fhir/r5/formats/RdfParser.java | 2 +- .../org/hl7/fhir/r5/formats/XmlParser.java | 4 +- .../fhir/r5/model/ImplementationGuide.java | 33 ++++++------- .../java/org/hl7/fhir/r5/utils/IGHelper.java | 20 +++++--- .../fhir/r5/utils/NPMPackageGenerator.java | 38 +++++++++++++-- .../hl7/fhir/r5/utils/ToolingExtensions.java | 1 + .../java/org/hl7/fhir/utilities/TextFile.java | 4 ++ .../org/hl7/fhir/utilities/Utilities.java | 5 ++ .../hl7/fhir/utilities/cache/NpmPackage.java | 38 +++++++++++++++ .../utilities/cache/PackageCacheManager.java | 2 +- org.hl7.fhir.validation.cli/.project | 46 +++++++++++-------- 20 files changed, 187 insertions(+), 84 deletions(-) diff --git a/compare updated code.bat b/compare updated code.bat index e071c9b36..689568971 100644 --- a/compare updated code.bat +++ b/compare updated code.bat @@ -1,2 +1,2 @@ -"C:\Program Files (x86)\WinMerge\WinMergeU.exe" ..\..\temp\java\org.hl7.fhir.r4\src\org\hl7\fhir\r4\formats\ org.hl7.fhir.r4\src\org\hl7\fhir\r4\formats\ -"C:\Program Files (x86)\WinMerge\WinMergeU.exe" ..\..\temp\java\org.hl7.fhir.r4\src\org\hl7\fhir\r4\model\ org.hl7.fhir.r4\src\org\hl7\fhir\r4\model\ +"C:\Program Files (x86)\WinMerge\WinMergeU.exe" ..\build\temp\java\org.hl7.fhir.r5\src\org\hl7\fhir\r5\formats org.hl7.fhir.r5\src\main\java\org\hl7\fhir\r5\formats +"C:\Program Files (x86)\WinMerge\WinMergeU.exe" ..\build\temp\java\org.hl7.fhir.r5\src\org\hl7\fhir\r5\model org.hl7.fhir.r5\src\main\java\org\hl7\fhir\r5\model diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/ImplementationGuide.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/ImplementationGuide.java index b3e706fd7..fc206309e 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/ImplementationGuide.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/ImplementationGuide.java @@ -1057,7 +1057,7 @@ public class ImplementationGuide extends VersionConvertor_40_50 { org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent tgt = new org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent(); copyElement(src, tgt); if (src.hasCode()) - tgt.setCode(convertGuideParameterCode(src.getCode())); + tgt.setCodeElement(convertString(src.getCodeElement())); if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); return tgt; @@ -1069,7 +1069,7 @@ public class ImplementationGuide extends VersionConvertor_40_50 { org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent tgt = new org.hl7.fhir.r4.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent(); copyElement(src, tgt); if (src.hasCode()) - tgt.setCode(convertGuideParameterCode(src.getCode())); + tgt.setCodeElement(convertString(src.getCodeElement())); if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); return tgt; diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/FormatUtilities.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/FormatUtilities.java index d9fa008b6..684cf39e3 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/FormatUtilities.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/FormatUtilities.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r4.formats; +import java.io.FileNotFoundException; +import java.io.IOException; + /*- * #%L * org.hl7.fhir.r4 @@ -55,7 +58,10 @@ import java.net.URI; import org.apache.commons.codec.binary.Base64; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat; +import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.utilities.TextFile; public abstract class FormatUtilities { public static final String ID_REGEX = "[A-Za-z0-9\\-\\.]{1,64}"; @@ -146,5 +152,12 @@ public abstract class FormatUtilities { return Integer.MAX_VALUE; } + public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException { + byte[] src = TextFile.fileToBytes(path); + FhirFormat fmt = determineFormat(src); + ParserBase parser = makeParser(fmt); + return parser.parse(src); + } + } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/JsonParser.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/JsonParser.java index d6570069b..6ac2bd8f9 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/JsonParser.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/JsonParser.java @@ -14198,7 +14198,7 @@ public class JsonParser extends JsonParserBase { protected void parseImplementationGuideImplementationGuideDefinitionParameterComponentProperties(JsonObject json, ImplementationGuide owner, ImplementationGuide.ImplementationGuideDefinitionParameterComponent res) throws IOException, FHIRFormatError { parseBackboneElementProperties(json, res); if (json.has("code")) - res.setCodeElement(parseEnumeration(json.get("code").getAsString(), ImplementationGuide.GuideParameterCode.NULL, new ImplementationGuide.GuideParameterCodeEnumFactory())); + res.setCodeElement(parseString(json.get("code").getAsString())); if (json.has("_code")) parseElementProperties(json.getAsJsonObject("_code"), res.getCodeElement()); if (json.has("value")) @@ -43754,8 +43754,8 @@ public class JsonParser extends JsonParserBase { protected void composeImplementationGuideImplementationGuideDefinitionParameterComponentInner(ImplementationGuide.ImplementationGuideDefinitionParameterComponent element) throws IOException { composeBackbone(element); if (element.hasCodeElement()) { - composeEnumerationCore("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory(), false); - composeEnumerationExtras("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory(), false); + composeStringCore("code", element.getCodeElement(), false); + composeStringExtras("code", element.getCodeElement(), false); } if (element.hasValueElement()) { composeStringCore("value", element.getValueElement(), false); diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/RdfParser.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/RdfParser.java index f266fdba6..1dd7ddead 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/RdfParser.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/RdfParser.java @@ -9026,7 +9026,7 @@ public class RdfParser extends RdfParserBase { } composeBackboneElement(t, "parameter", name, element, index); if (element.hasCodeElement()) - composeEnum(t, "ImplementationGuide", "code", element.getCodeElement(), -1); + composeString(t, "ImplementationGuide", "code", element.getCodeElement(), -1); if (element.hasValueElement()) composeString(t, "ImplementationGuide", "value", element.getValueElement(), -1); } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParser.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParser.java index a9028044c..a587a1be2 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParser.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParser.java @@ -12134,7 +12134,7 @@ public class XmlParser extends XmlParserBase { protected boolean parseImplementationGuideImplementationGuideDefinitionParameterComponentContent(int eventType, XmlPullParser xpp, ImplementationGuide owner, ImplementationGuide.ImplementationGuideDefinitionParameterComponent res) throws XmlPullParserException, IOException, FHIRFormatError { if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("code")) { - res.setCodeElement(parseEnumeration(xpp, ImplementationGuide.GuideParameterCode.NULL, new ImplementationGuide.GuideParameterCodeEnumFactory())); + res.setCodeElement(parseString(xpp)); } else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("value")) { res.setValueElement(parseString(xpp)); } else if (!parseBackboneElementContent(eventType, xpp, res)) @@ -37756,7 +37756,7 @@ public class XmlParser extends XmlParserBase { protected void composeImplementationGuideImplementationGuideDefinitionParameterComponentElements(ImplementationGuide.ImplementationGuideDefinitionParameterComponent element) throws IOException { composeBackboneElementElements(element); if (element.hasCodeElement()) - composeEnumeration("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory()); + composeString("code", element.getCodeElement()); if (element.hasValueElement()) { composeString("value", element.getValueElement()); } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ImplementationGuide.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ImplementationGuide.java index e1b0d801c..5d9f2ef57 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ImplementationGuide.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/ImplementationGuide.java @@ -8276,10 +8276,9 @@ public class ImplementationGuide extends MetadataResource { /** * apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - @Child(name = "code", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false) + @Child(name = "code", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false) @Description(shortDefinition="apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template", formalDefinition="apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template." ) - @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/guide-parameter-code") - protected Enumeration code; + protected StringType code; /** * Value for named type. @@ -8300,7 +8299,7 @@ public class ImplementationGuide extends MetadataResource { /** * Constructor */ - public ImplementationGuideDefinitionParameterComponent(Enumeration code, StringType value) { + public ImplementationGuideDefinitionParameterComponent(StringType code, StringType value) { super(); this.code = code; this.value = value; @@ -8309,12 +8308,12 @@ public class ImplementationGuide extends MetadataResource { /** * @return {@link #code} (apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value */ - public Enumeration getCodeElement() { + public StringType getCodeElement() { if (this.code == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create ImplementationGuideDefinitionParameterComponent.code"); else if (Configuration.doAutoCreate()) - this.code = new Enumeration(new GuideParameterCodeEnumFactory()); // bb + this.code = new StringType(); // bb return this.code; } @@ -8329,7 +8328,7 @@ public class ImplementationGuide extends MetadataResource { /** * @param value {@link #code} (apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value */ - public ImplementationGuideDefinitionParameterComponent setCodeElement(Enumeration value) { + public ImplementationGuideDefinitionParameterComponent setCodeElement(StringType value) { this.code = value; return this; } @@ -8337,16 +8336,16 @@ public class ImplementationGuide extends MetadataResource { /** * @return apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - public GuideParameterCode getCode() { + public String getCode() { return this.code == null ? null : this.code.getValue(); } /** * @param value apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - public ImplementationGuideDefinitionParameterComponent setCode(GuideParameterCode value) { + public ImplementationGuideDefinitionParameterComponent setCode(String value) { if (this.code == null) - this.code = new Enumeration(new GuideParameterCodeEnumFactory()); + this.code = new StringType(); this.code.setValue(value); return this; } @@ -8398,14 +8397,14 @@ public class ImplementationGuide extends MetadataResource { protected void listChildren(List children) { super.listChildren(children); - children.add(new Property("code", "code", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code)); + children.add(new Property("code", "string", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code)); children.add(new Property("value", "string", "Value for named type.", 0, 1, value)); } @Override public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { switch (_hash) { - case 3059181: /*code*/ return new Property("code", "code", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code); + case 3059181: /*code*/ return new Property("code", "string", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code); case 111972721: /*value*/ return new Property("value", "string", "Value for named type.", 0, 1, value); default: return super.getNamedProperty(_hash, _name, _checkValid); } @@ -8415,7 +8414,7 @@ public class ImplementationGuide extends MetadataResource { @Override public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { switch (hash) { - case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration + case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // StringType case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType default: return super.getProperty(hash, name, checkValid); } @@ -8426,8 +8425,7 @@ public class ImplementationGuide extends MetadataResource { public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case 3059181: // code - value = new GuideParameterCodeEnumFactory().fromType(castToCode(value)); - this.code = (Enumeration) value; // Enumeration + this.code = castToString(value); // StringType return value; case 111972721: // value this.value = castToString(value); // StringType @@ -8440,8 +8438,7 @@ public class ImplementationGuide extends MetadataResource { @Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("code")) { - value = new GuideParameterCodeEnumFactory().fromType(castToCode(value)); - this.code = (Enumeration) value; // Enumeration + this.code = castToString(value); // StringType } else if (name.equals("value")) { this.value = castToString(value); // StringType } else @@ -8462,7 +8459,7 @@ public class ImplementationGuide extends MetadataResource { @Override public String[] getTypesForProperty(int hash, String name) throws FHIRException { switch (hash) { - case 3059181: /*code*/ return new String[] {"code"}; + case 3059181: /*code*/ return new String[] {"string"}; case 111972721: /*value*/ return new String[] {"string"}; default: return super.getTypesForProperty(hash, name); } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/IGHelper.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/IGHelper.java index 6223f8cda..60742a56b 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/IGHelper.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/IGHelper.java @@ -29,7 +29,7 @@ public class IGHelper { public static String readStringParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name) { for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { - if (name == p.getCode()) { + if (name.toCode().equals(p.getCode())) { return p.getValue(); } } @@ -43,13 +43,13 @@ public class IGHelper { public static void setParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name, String value) { for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { - if (name == p.getCode()) { + if (name.toCode().equals(p.getCode())) { p.setValue(value); return; } } ImplementationGuideDefinitionParameterComponent p = ig.addParameter(); - p.setCode(name); + p.setCode(name.toCode()); p.setValue(value); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java index e6b8ac07e..b2d8e6b9f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonParser.java @@ -14198,7 +14198,7 @@ public class JsonParser extends JsonParserBase { protected void parseImplementationGuideImplementationGuideDefinitionParameterComponentProperties(JsonObject json, ImplementationGuide owner, ImplementationGuide.ImplementationGuideDefinitionParameterComponent res) throws IOException, FHIRFormatError { parseBackboneElementProperties(json, res); if (json.has("code")) - res.setCodeElement(parseEnumeration(json.get("code").getAsString(), ImplementationGuide.GuideParameterCode.NULL, new ImplementationGuide.GuideParameterCodeEnumFactory())); + res.setCodeElement(parseString(json.get("code").getAsString())); if (json.has("_code")) parseElementProperties(json.getAsJsonObject("_code"), res.getCodeElement()); if (json.has("value")) @@ -43754,8 +43754,8 @@ public class JsonParser extends JsonParserBase { protected void composeImplementationGuideImplementationGuideDefinitionParameterComponentInner(ImplementationGuide.ImplementationGuideDefinitionParameterComponent element) throws IOException { composeBackbone(element); if (element.hasCodeElement()) { - composeEnumerationCore("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory(), false); - composeEnumerationExtras("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory(), false); + composeStringCore("code", element.getCodeElement(), false); + composeStringExtras("code", element.getCodeElement(), false); } if (element.hasValueElement()) { composeStringCore("value", element.getValueElement(), false); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/RdfParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/RdfParser.java index 469aae1f7..0fb6c2e68 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/RdfParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/RdfParser.java @@ -9026,7 +9026,7 @@ public class RdfParser extends RdfParserBase { } composeBackboneElement(t, "parameter", name, element, index); if (element.hasCodeElement()) - composeEnum(t, "ImplementationGuide", "code", element.getCodeElement(), -1); + composeString(t, "ImplementationGuide", "code", element.getCodeElement(), -1); if (element.hasValueElement()) composeString(t, "ImplementationGuide", "value", element.getValueElement(), -1); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParser.java index bebe8585a..20272d713 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/XmlParser.java @@ -12134,7 +12134,7 @@ public class XmlParser extends XmlParserBase { protected boolean parseImplementationGuideImplementationGuideDefinitionParameterComponentContent(int eventType, XmlPullParser xpp, ImplementationGuide owner, ImplementationGuide.ImplementationGuideDefinitionParameterComponent res) throws XmlPullParserException, IOException, FHIRFormatError { if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("code")) { - res.setCodeElement(parseEnumeration(xpp, ImplementationGuide.GuideParameterCode.NULL, new ImplementationGuide.GuideParameterCodeEnumFactory())); + res.setCodeElement(parseString(xpp)); } else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("value")) { res.setValueElement(parseString(xpp)); } else if (!parseBackboneElementContent(eventType, xpp, res)) @@ -37756,7 +37756,7 @@ public class XmlParser extends XmlParserBase { protected void composeImplementationGuideImplementationGuideDefinitionParameterComponentElements(ImplementationGuide.ImplementationGuideDefinitionParameterComponent element) throws IOException { composeBackboneElementElements(element); if (element.hasCodeElement()) - composeEnumeration("code", element.getCodeElement(), new ImplementationGuide.GuideParameterCodeEnumFactory()); + composeString("code", element.getCodeElement()); if (element.hasValueElement()) { composeString("value", element.getValueElement()); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ImplementationGuide.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ImplementationGuide.java index 0b0c1fd25..de1d86bc8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ImplementationGuide.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ImplementationGuide.java @@ -8276,10 +8276,9 @@ public class ImplementationGuide extends MetadataResource { /** * apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - @Child(name = "code", type = {CodeType.class}, order=1, min=1, max=1, modifier=false, summary=false) + @Child(name = "code", type = {StringType.class}, order=1, min=1, max=1, modifier=false, summary=false) @Description(shortDefinition="apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template", formalDefinition="apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template." ) - @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/guide-parameter-code") - protected Enumeration code; + protected StringType code; /** * Value for named type. @@ -8300,7 +8299,7 @@ public class ImplementationGuide extends MetadataResource { /** * Constructor */ - public ImplementationGuideDefinitionParameterComponent(Enumeration code, StringType value) { + public ImplementationGuideDefinitionParameterComponent(StringType code, StringType value) { super(); this.code = code; this.value = value; @@ -8309,12 +8308,12 @@ public class ImplementationGuide extends MetadataResource { /** * @return {@link #code} (apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value */ - public Enumeration getCodeElement() { + public StringType getCodeElement() { if (this.code == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create ImplementationGuideDefinitionParameterComponent.code"); else if (Configuration.doAutoCreate()) - this.code = new Enumeration(new GuideParameterCodeEnumFactory()); // bb + this.code = new StringType(); // bb return this.code; } @@ -8329,7 +8328,7 @@ public class ImplementationGuide extends MetadataResource { /** * @param value {@link #code} (apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value */ - public ImplementationGuideDefinitionParameterComponent setCodeElement(Enumeration value) { + public ImplementationGuideDefinitionParameterComponent setCodeElement(StringType value) { this.code = value; return this; } @@ -8337,16 +8336,16 @@ public class ImplementationGuide extends MetadataResource { /** * @return apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - public GuideParameterCode getCode() { + public String getCode() { return this.code == null ? null : this.code.getValue(); } /** * @param value apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template. */ - public ImplementationGuideDefinitionParameterComponent setCode(GuideParameterCode value) { + public ImplementationGuideDefinitionParameterComponent setCode(String value) { if (this.code == null) - this.code = new Enumeration(new GuideParameterCodeEnumFactory()); + this.code = new StringType(); this.code.setValue(value); return this; } @@ -8398,14 +8397,14 @@ public class ImplementationGuide extends MetadataResource { protected void listChildren(List children) { super.listChildren(children); - children.add(new Property("code", "code", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code)); + children.add(new Property("code", "string", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code)); children.add(new Property("value", "string", "Value for named type.", 0, 1, value)); } @Override public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { switch (_hash) { - case 3059181: /*code*/ return new Property("code", "code", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code); + case 3059181: /*code*/ return new Property("code", "string", "apply | path-resource | path-pages | path-tx-cache | expansion-parameter | rule-broken-links | generate-xml | generate-json | generate-turtle | html-template.", 0, 1, code); case 111972721: /*value*/ return new Property("value", "string", "Value for named type.", 0, 1, value); default: return super.getNamedProperty(_hash, _name, _checkValid); } @@ -8415,7 +8414,7 @@ public class ImplementationGuide extends MetadataResource { @Override public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { switch (hash) { - case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // Enumeration + case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // StringType case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType default: return super.getProperty(hash, name, checkValid); } @@ -8426,8 +8425,7 @@ public class ImplementationGuide extends MetadataResource { public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case 3059181: // code - value = new GuideParameterCodeEnumFactory().fromType(castToCode(value)); - this.code = (Enumeration) value; // Enumeration + this.code = castToString(value); // StringType return value; case 111972721: // value this.value = castToString(value); // StringType @@ -8440,8 +8438,7 @@ public class ImplementationGuide extends MetadataResource { @Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("code")) { - value = new GuideParameterCodeEnumFactory().fromType(castToCode(value)); - this.code = (Enumeration) value; // Enumeration + this.code = castToString(value); // StringType } else if (name.equals("value")) { this.value = castToString(value); // StringType } else @@ -8462,7 +8459,7 @@ public class ImplementationGuide extends MetadataResource { @Override public String[] getTypesForProperty(int hash, String name) throws FHIRException { switch (hash) { - case 3059181: /*code*/ return new String[] {"code"}; + case 3059181: /*code*/ return new String[] {"string"}; case 111972721: /*value*/ return new String[] {"string"}; default: return super.getTypesForProperty(hash, name); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IGHelper.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IGHelper.java index a213deb1e..954f64d8d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IGHelper.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IGHelper.java @@ -20,14 +20,16 @@ package org.hl7.fhir.r5.utils; * #L% */ - -import org.hl7.fhir.r5.model.ImplementationGuide.GuideParameterCode; import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionComponent; import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent; public class IGHelper { - public static String readStringParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name) { + + public static final String EXT_SPREADSHEET = ToolingExtensions.EXT_IGP_SPREADSHEET; + public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE; + + public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) { for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { if (name == p.getCode()) { return p.getValue(); @@ -36,12 +38,12 @@ public class IGHelper { return null; } - public static boolean getBooleanParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name, boolean defaultValue) { + public static boolean getBooleanParameter(ImplementationGuideDefinitionComponent ig, String name, boolean defaultValue) { String v = readStringParameter(ig, name); return v == null ? false : Boolean.parseBoolean(v); } - public static void setParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name, String value) { + public static void setParameter(ImplementationGuideDefinitionComponent ig, String name, String value) { for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { if (name == p.getCode()) { p.setValue(value); @@ -53,7 +55,13 @@ public class IGHelper { p.setValue(value); } - public static void setParameter(ImplementationGuideDefinitionComponent ig, GuideParameterCode name, boolean value) { + public static void addParameter(ImplementationGuideDefinitionComponent ig, String name, String value) { + ImplementationGuideDefinitionParameterComponent p = ig.addParameter(); + p.setCode(name); + p.setValue(value); + } + + public static void setParameter(ImplementationGuideDefinitionComponent ig, String name, boolean value) { setParameter(ig, name, Boolean.toString(value)); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java index d1a991c5c..fe84ae71e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java @@ -23,6 +23,7 @@ package org.hl7.fhir.r5.utils; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; @@ -46,6 +47,7 @@ import org.hl7.fhir.r5.model.ImplementationGuide; import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDependsOnComponent; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.cache.PackageGenerator.PackageType; import org.hl7.fhir.utilities.cache.ToolsVersion; @@ -57,7 +59,7 @@ import com.google.gson.JsonObject; public class NPMPackageGenerator { public enum Category { - RESOURCE, OPENAPI, SCHEMATRON, RDF, OTHER, TOOL; + RESOURCE, OPENAPI, SCHEMATRON, RDF, OTHER, TOOL, TEMPLATE, JEKYLL; private String getDirectory() { switch (this) { @@ -66,6 +68,8 @@ public class NPMPackageGenerator { case SCHEMATRON: return "/xml/"; case RDF: return "/rdf/"; case OTHER: return "/other/"; + case TEMPLATE: return "/other/"; + case JEKYLL: return "/jekyll/"; case TOOL: return "/bin/"; } return "/"; @@ -112,8 +116,7 @@ public class NPMPackageGenerator { } catch (UnsupportedEncodingException e) { } } - - + private void buildPackageJson(String canonical, PackageType kind, String web, String genDate, ImplementationGuide ig, List fhirVersion) throws FHIRException, IOException { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); if (!ig.hasPackageId()) @@ -245,4 +248,33 @@ public class NPMPackageGenerator { public String filename() { return destFile; } + + public void loadDir(String rootDir, String name) throws IOException { + loadFiles(rootDir, new File(Utilities.path(rootDir, name))); + } + + public void loadFiles(String root, File dir, String... noload) throws IOException { + for (File f : dir.listFiles()) { + if (!Utilities.existsInList(f.getName(), noload)) { + if (f.isDirectory()) { + loadFiles(root, f); + } else { + String path = f.getAbsolutePath().substring(root.length()+1); + byte[] content = TextFile.fileToBytes(f); + if (created.contains(path)) + System.out.println("Duplicate package file "+path); + else { + created.add(path); + TarArchiveEntry entry = new TarArchiveEntry(path); + entry.setSize(content.length); + tar.putArchiveEntry(entry); + tar.write(content); + tar.closeArchiveEntry(); + } + } + } + } + } + + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 8939f8134..7b041a4f1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -143,6 +143,7 @@ public class ToolingExtensions { public static final String EXT_IGP_PAGES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-pages"; public static final String EXT_IGP_SPREADSHEET = "http://hl7.org/fhir/StructureDefinition/igpublisher-spreadsheet"; public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle"; + public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion"; public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"; public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"; public static final String EXT_PROFILE_ELEMENT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element"; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java index 5d5c42f50..47ae8bb59 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java @@ -192,6 +192,10 @@ public class TextFile { return streamToBytes(new FileInputStream(new CSFile(srcFile))); } + public static byte[] fileToBytes(File file) throws FileNotFoundException, IOException { + return streamToBytes(new FileInputStream(file)); + } + public static String bytesToString(byte[] bs) throws IOException { return streamToString(new ByteArrayInputStream(bs)); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index a7f09f6b4..cdef0cfba 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -832,6 +832,10 @@ public class Utilities { } + public static String makeUuidLC() { + return UUID.randomUUID().toString().toLowerCase(); + } + public static String makeUuidUrn() { return "urn:uuid:"+UUID.randomUUID().toString().toLowerCase(); } @@ -1167,4 +1171,5 @@ public class Utilities { } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 79d32b08c..e8fc923e5 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -26,6 +26,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -41,6 +42,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.hl7.fhir.utilities.IniFile; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; @@ -348,5 +350,41 @@ import com.google.gson.JsonObject; return content; } + public static NpmPackage fromFolder(String folder) throws IOException { + return fromFolder(folder, null); + } + + public static NpmPackage fromFolder(String folder, PackageType defType) throws IOException { + NpmPackage res = new NpmPackage(null); + loadFiles(res, folder, new File(folder)); + if (!res.content.containsKey("package/package.json") && defType != null) + res.content.put("package/package.json", TextFile.stringToBytes("{ \"type\" : \""+defType.getCode()+"\"}", false)); + res.npm = (JsonObject) new com.google.gson.JsonParser().parse(new String(res.content.get("package/package.json"))); + return res; + } + private static void loadFiles(NpmPackage res, String base, File folder) throws FileNotFoundException, IOException { + for (File f : folder.listFiles()) { + if (!f.getName().equals(".git")) { + if (f.isDirectory()) + loadFiles(res, base, f); + else { + String name = f.getAbsolutePath().substring(base.length()+1).replace("\\", "/"); + byte[] cnt = TextFile.fileToBytes(f); + res.content.put(name, cnt); + } + } + } + } + + public void unPack(String dir) throws IOException { + for (String s : content.keySet()) { + String fn = Utilities.path(dir, s); + String dn = Utilities.getDirectoryForFile(fn); + Utilities.createDirectory(dn); + TextFile.bytesToFile(content.get(s), fn); + } + if (path != null) + FileUtils.copyDirectory(new File(path), new File(dir)); + } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index 7c17082d2..bfecbf027 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -388,7 +388,7 @@ public class PackageCacheManager { Map canonicals = new HashMap(); if ("hl7.fhir.core".equals(npm.get("name").getAsString())) analysePackage(packRoot, npm.get("version").getAsString(), profiles, canonicals); - else + else if (npm.has("dependencies")) // templates do not analysePackage(packRoot, npm.getAsJsonObject("dependencies").get("hl7.fhir.core").getAsString(), profiles, canonicals); IniFile ini = new IniFile(Utilities.path(packRoot, "cache.ini")); ini.setTimeStampFormat("dd/MM/yyyy h:mm:ss a"); diff --git a/org.hl7.fhir.validation.cli/.project b/org.hl7.fhir.validation.cli/.project index aa11a1a25..7a413b3a5 100644 --- a/org.hl7.fhir.validation.cli/.project +++ b/org.hl7.fhir.validation.cli/.project @@ -1,21 +1,29 @@ - org.hl7.fhir.validation - An open-source implementation of the FHIR specification in Java. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - org.hl7.fhir.utilities - org.hl7.fhir.convertors - org.hl7.fhir.dstu2 - org.hl7.fhir.dstu2016may - org.hl7.fhir.dstu3 - org.hl7.fhir.r4 - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file + org.hl7.fhir.validation + An open-source implementation of the FHIR specification in Java. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.hl7.fhir.utilities + org.hl7.fhir.convertors + org.hl7.fhir.dstu2 + org.hl7.fhir.dstu2016may + org.hl7.fhir.dstu3 + org.hl7.fhir.r4 + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + +