updates for ongoing work in IG publisher + Implementation Guide relax codes on .definition.parameter.code

This commit is contained in:
Grahame Grieve 2019-04-24 06:14:26 +10:00
parent ed22a46775
commit 9b0d702ba2
20 changed files with 187 additions and 84 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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<GuideParameterCode> code;
protected StringType code;
/**
* Value for named type.
@ -8300,7 +8299,7 @@ public class ImplementationGuide extends MetadataResource {
/**
* Constructor
*/
public ImplementationGuideDefinitionParameterComponent(Enumeration<GuideParameterCode> 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<GuideParameterCode> 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<GuideParameterCode>(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<GuideParameterCode> 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<GuideParameterCode>(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<Property> 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<GuideParameterCode>
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<GuideParameterCode>
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<GuideParameterCode>
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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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<GuideParameterCode> code;
protected StringType code;
/**
* Value for named type.
@ -8300,7 +8299,7 @@ public class ImplementationGuide extends MetadataResource {
/**
* Constructor
*/
public ImplementationGuideDefinitionParameterComponent(Enumeration<GuideParameterCode> 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<GuideParameterCode> 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<GuideParameterCode>(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<GuideParameterCode> 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<GuideParameterCode>(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<Property> 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<GuideParameterCode>
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<GuideParameterCode>
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<GuideParameterCode>
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);
}

View File

@ -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));
}

View File

@ -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<String> 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();
}
}
}
}
}
}

View File

@ -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";

View File

@ -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));
}

View File

@ -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 {
}
}

View File

@ -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));
}
}

View File

@ -388,7 +388,7 @@ public class PackageCacheManager {
Map<String, String> canonicals = new HashMap<String, String>();
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");

View File

@ -1,21 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.hl7.fhir.validation</name>
<comment>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.</comment>
<projects>
<project>org.hl7.fhir.utilities</project>
<project>org.hl7.fhir.convertors</project>
<project>org.hl7.fhir.dstu2</project>
<project>org.hl7.fhir.dstu2016may</project>
<project>org.hl7.fhir.dstu3</project>
<project>org.hl7.fhir.r4</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<name>org.hl7.fhir.validation</name>
<comment>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.</comment>
<projects>
<project>org.hl7.fhir.utilities</project>
<project>org.hl7.fhir.convertors</project>
<project>org.hl7.fhir.dstu2</project>
<project>org.hl7.fhir.dstu2016may</project>
<project>org.hl7.fhir.dstu3</project>
<project>org.hl7.fhir.r4</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>