update generator after rebuilding R5
This commit is contained in:
parent
0425a2beff
commit
e9fbf47d37
|
@ -36,12 +36,12 @@
|
|||
public BundleLinkComponent getLinkOrCreate(String theRelation) {
|
||||
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
||||
for (BundleLinkComponent next : getLink()) {
|
||||
if (theRelation.equals(next.getRelation())) {
|
||||
if (theRelation.equals(next.getRelation().toCode())) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
BundleLinkComponent retVal = new BundleLinkComponent();
|
||||
retVal.setRelation(theRelation);
|
||||
retVal.setRelation(LinkRelationTypes.fromCode(theRelation));
|
||||
getLink().add(retVal);
|
||||
return retVal;
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
public BundleLinkComponent getLink(String theRelation) {
|
||||
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
||||
for (BundleLinkComponent next : getLink()) {
|
||||
if (theRelation.equals(next.getRelation())) {
|
||||
if (theRelation.equals(next.getRelation().toCode())) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
@ -36,12 +36,12 @@
|
|||
public BundleLinkComponent getLinkOrCreate(String theRelation) {
|
||||
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
||||
for (BundleLinkComponent next : getLink()) {
|
||||
if (theRelation.equals(next.getRelation())) {
|
||||
if (theRelation.equals(next.getRelation().toCode())) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
BundleLinkComponent retVal = new BundleLinkComponent();
|
||||
retVal.setRelation(theRelation);
|
||||
retVal.setRelation(LinkRelationTypes.fromCode(theRelation));
|
||||
getLink().add(retVal);
|
||||
return retVal;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
@Override
|
||||
public String toString() {
|
||||
return fhirType()+"["+getUrl()+"]";
|
||||
return fhirType()+"["+getUrl()+(hasVersion() ? "|"+getVersion(): "")+"]";
|
||||
}
|
||||
|
||||
public String present() {
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
public String getAttributeUri(String code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (AdditionalAttributeComponent aa : getAdditionalAttribute()) {
|
||||
if (code.equals(aa.getCode())) {
|
||||
return aa.hasUri() ? aa.getUri() : code;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public String registerAttribute(String uri) {
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
// determine a default code
|
||||
String t = tail(uri).replace("-", "");
|
||||
if (Utilities.noString(t))
|
||||
t = "code";
|
||||
String code = t;
|
||||
int i = 0;
|
||||
while (alreadyExistsAsCode(code)) {
|
||||
i++;
|
||||
code = t + i;
|
||||
}
|
||||
|
||||
for (AdditionalAttributeComponent aa : getAdditionalAttribute()) {
|
||||
if (uri.equals(aa.getUri())) {
|
||||
if (!aa.hasCode()) {
|
||||
aa.setCode(code);
|
||||
}
|
||||
return aa.getCode();
|
||||
}
|
||||
}
|
||||
addAdditionalAttribute().setUri(uri).setCode(code);
|
||||
return code;
|
||||
}
|
||||
|
||||
private boolean alreadyExistsAsCode(String code) {
|
||||
for (PropertyComponent prop : getProperty()) {
|
||||
if (code.equals(prop.getCode())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (AdditionalAttributeComponent prop : getAdditionalAttribute()) {
|
||||
if (code.equals(prop.getCode())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String tail(String uri) {
|
||||
return uri.contains("/") ? uri.substring(uri.lastIndexOf("/")+1) : uri;
|
||||
}
|
|
@ -12,7 +12,8 @@ public class Constants {
|
|||
public final static String NS_SYSTEM_TYPE = "http://hl7.org/fhirpath/System.";
|
||||
|
||||
public final static String VERSION = "{{version}}";
|
||||
public final static String VERSION_BASE = "{{version-base}}";
|
||||
public final static String VERSION_MM = "{{version-mm}}";
|
||||
public final static String DATE = "{{date}}";
|
||||
public final static String URI_REGEX = "((http|https)://([A-Za-z0-9\\\\\\.\\:\\%\\$]*\\/)*)?({{rt}})\\/[A-Za-z0-9\\-\\.]{1,64}(\\/_history\\/[A-Za-z0-9\\-\\.]{1,64})?";
|
||||
public final static String URI_REGEX = "((http|https):\\/\\/([A-Za-z0-9\\\\\\.\\:\\%\\$\\-]*\\/)*?)?({{rt}})\\/[A-Za-z0-9\\-\\.]{1,64}(\\/_history\\/[A-Za-z0-9\\-\\.]{1,64})?";
|
||||
}
|
|
@ -79,4 +79,13 @@ public void checkNoModifiers(String noun, String verb) throws FHIRException {
|
|||
}
|
||||
}
|
||||
return Collections.unmodifiableList(retVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public StandardsStatus getStandardsStatus() {
|
||||
return ToolingExtensions.getStandardsStatus(this);
|
||||
}
|
||||
|
||||
public void setStandardsStatus(StandardsStatus status) {
|
||||
ToolingExtensions.setStandardsStatus(this, status, null);
|
||||
}
|
||||
|
|
|
@ -124,3 +124,12 @@
|
|||
throw new FHIRException("Extension could not be converted to a string");
|
||||
return ext.get(0).getValue().primitiveValue();
|
||||
}
|
||||
|
||||
|
||||
public StandardsStatus getStandardsStatus() {
|
||||
return ToolingExtensions.getStandardsStatus(this);
|
||||
}
|
||||
|
||||
public void setStandardsStatus(StandardsStatus status) {
|
||||
ToolingExtensions.setStandardsStatus(this, status, null);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,10 @@
|
|||
public String getName() {
|
||||
return hasPath() ? getPath().contains(".") ? getPath().substring(getPath().lastIndexOf(".")+1) : getPath() : null;
|
||||
}
|
||||
|
||||
public String getNameBase() {
|
||||
return getName().replace("[x]", "");
|
||||
}
|
||||
|
||||
public boolean unbounded() {
|
||||
return getMax().equals("*") || Integer.parseInt(getMax()) > 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
public boolean supportsCopyright() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
public boolean supportsCopyright() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
public boolean supportsCopyright() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,91 +1,115 @@
|
|||
public Parameters addParameter(String name, boolean b) {
|
||||
addParameter().setName(name).setValue(new BooleanType(b));
|
||||
return this;
|
||||
}
|
||||
addParameter().setName(name).setValue(new BooleanType(b));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters addParameter(String name, String s) {
|
||||
if (s != null)
|
||||
addParameter().setName(name).setValue(new StringType(s));
|
||||
return this;
|
||||
}
|
||||
public Parameters addParameter(String name, String s) {
|
||||
if (s != null)
|
||||
addParameter().setName(name).setValue(new StringType(s));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters addParameter(String name, DataType v) {
|
||||
if (v != null)
|
||||
addParameter().setName(name).setValue(v);
|
||||
return this;
|
||||
}
|
||||
public Parameters addParameter(String name, DataType v) {
|
||||
if (v != null)
|
||||
addParameter().setName(name).setValue(v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters setParameter(String name, boolean b) {
|
||||
public Parameters setParameter(String name, boolean b) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name)) {
|
||||
p.setValue(new BooleanType(b));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
addParameter().setName(name).setValue(new BooleanType(b));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters setParameter(String name, String s) {
|
||||
if (s != null) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name)) {
|
||||
p.setValue(new BooleanType(b));
|
||||
p.setValue(new StringType(s));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
addParameter().setName(name).setValue(new BooleanType(b));
|
||||
return this;
|
||||
addParameter().setName(name).setValue(new StringType(s));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters setParameter(String name, String s) {
|
||||
if (s != null) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name)) {
|
||||
p.setValue(new StringType(s));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
addParameter().setName(name).setValue(new StringType(s));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Parameters setParameter(String name, DataType v) {
|
||||
if (v != null) {
|
||||
for (ParametersParameterComponent p : getParameter() ) {
|
||||
if (p.getName().equals(name)) {
|
||||
p.setValue(v);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
addParameter().setName(name).setValue(v);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasParameter(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DataType getParameter(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
return p.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<DataType> getParameters(String name) {
|
||||
List<DataType> res = new ArrayList<>();
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
res.add(p.getValue());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public boolean getParameterBool(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
public Parameters setParameter(String name, DataType v) {
|
||||
if (v != null) {
|
||||
for (ParametersParameterComponent p : getParameter() ) {
|
||||
if (p.getName().equals(name)) {
|
||||
if (p.getValue() instanceof BooleanType)
|
||||
return ((BooleanType) p.getValue()).booleanValue();
|
||||
boolean ok = Boolean.getBoolean(p.getValue().primitiveValue());
|
||||
return ok;
|
||||
p.setValue(v);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
addParameter().setName(name).setValue(v);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasParameterValue(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name) && p.hasValue())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasParameter(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DataType getParameterValue(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
return p.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParametersParameterComponent getParameter(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<DataType> getParameterValues(String name) {
|
||||
List<DataType> res = new ArrayList<>();
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
res.add(p.getValue());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<ParametersParameterComponent> getParameters(String name) {
|
||||
List<ParametersParameterComponent> res = new ArrayList<ParametersParameterComponent>();
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name))
|
||||
res.add(p);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean getParameterBool(String name) {
|
||||
for (ParametersParameterComponent p : getParameter()) {
|
||||
if (p.getName().equals(name)) {
|
||||
if (p.getValue() instanceof BooleanType)
|
||||
return ((BooleanType) p.getValue()).booleanValue();
|
||||
boolean ok = Boolean.getBoolean(p.getValue().primitiveValue());
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
public RequirementsStatementComponent findStatement(String key) {
|
||||
for (RequirementsStatementComponent t : getStatement()) {
|
||||
if (key.equals(t.getKey())) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -11,4 +11,30 @@
|
|||
|
||||
public String getLanguage(String defValue) {
|
||||
return hasLanguage() ? getLanguage() : defValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// when possible, the source package is considered when performing reference resolution.
|
||||
|
||||
private PackageInformation sourcePackage;
|
||||
|
||||
public boolean hasSourcePackage() {
|
||||
return sourcePackage != null;
|
||||
}
|
||||
|
||||
public PackageInformation getSourcePackage() {
|
||||
return sourcePackage;
|
||||
}
|
||||
|
||||
public void setSourcePackage(PackageInformation sourcePackage) {
|
||||
this.sourcePackage = sourcePackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the logical ID part of this resource's id
|
||||
* @see IdType#getIdPart()
|
||||
*/
|
||||
public String getIdPart() {
|
||||
return getIdElement().getIdPart();
|
||||
}
|
||||
|
|
@ -1,4 +1,14 @@
|
|||
public boolean supportsCopyright() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasBase(String value) {
|
||||
if (this.base == null)
|
||||
return false;
|
||||
for (Enumeration<VersionIndependentResourceTypesAll> v : this.base)
|
||||
if (v.getCode().equals(value)) // code
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -9,4 +9,37 @@ public String describeType() {
|
|||
default:
|
||||
return "Definition";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getTypeName() {
|
||||
String t = getType();
|
||||
return StructureDefinitionKind.LOGICAL.equals(getKind()) && t.contains("/") ? t.substring(t.lastIndexOf("/")+1) : t;
|
||||
}
|
||||
|
||||
public String getTypeTail() {
|
||||
if (getType().contains("/")) {
|
||||
return getType().substring(getType().lastIndexOf("/")+1);
|
||||
} else {
|
||||
return getType();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean generatedSnapshot;
|
||||
private boolean generatingSnapshot;
|
||||
|
||||
public boolean isGeneratedSnapshot() {
|
||||
return generatedSnapshot;
|
||||
}
|
||||
|
||||
public void setGeneratedSnapshot(boolean generatedSnapshot) {
|
||||
this.generatedSnapshot = generatedSnapshot;
|
||||
}
|
||||
|
||||
public boolean isGeneratingSnapshot() {
|
||||
return generatingSnapshot;
|
||||
}
|
||||
|
||||
public void setGeneratingSnapshot(boolean generatingSnapshot) {
|
||||
this.generatingSnapshot = generatingSnapshot;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
public ElementDefinition getElementByPath(String path) {
|
||||
for (ElementDefinition ed : getElement()) {
|
||||
if (path.equals(ed.getPath())) {
|
||||
return ed;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -21,11 +21,11 @@ Binary = extends BaseBinary implements IBaseBinary
|
|||
|
||||
[imports]
|
||||
Meta = org.hl7.fhir.instance.model.api.IBaseMetaType
|
||||
DomainResource = java.util.Collections, org.hl7.fhir.instance.model.api.IDomainResource, org.hl7.fhir.instance.model.api.IBaseDatatypeElement, org.hl7.fhir.instance.model.api.IBaseHasExtensions, org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions, org.hl7.fhir.instance.model.api.IBaseBackboneElement
|
||||
DomainResource = java.util.Collections, java.util.Set, org.hl7.fhir.instance.model.api.IDomainResource, org.hl7.fhir.instance.model.api.IBaseDatatypeElement, org.hl7.fhir.instance.model.api.IBaseHasExtensions, org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions, org.hl7.fhir.instance.model.api.IBaseBackboneElement, org.hl7.fhir.r5.utils.ToolingExtensions, org.hl7.fhir.utilities.StandardsStatus
|
||||
Parameters = org.hl7.fhir.instance.model.api.IBaseParameters, org.hl7.fhir.utilities.CommaSeparatedStringBuilder
|
||||
Bundle = org.hl7.fhir.instance.model.api.IBaseBundle
|
||||
Reference = org.hl7.fhir.instance.model.api.IAnyResource, org.hl7.fhir.instance.model.api.IBaseReference, org.hl7.fhir.instance.model.api.ICompositeType, org.hl7.fhir.instance.model.api.IIdType
|
||||
Element = org.hl7.fhir.instance.model.api.IBaseElement, org.hl7.fhir.instance.model.api.IBaseHasExtensions
|
||||
Element = org.hl7.fhir.instance.model.api.IBaseElement, org.hl7.fhir.instance.model.api.IBaseHasExtensions, org.hl7.fhir.r5.utils.ToolingExtensions, org.hl7.fhir.utilities.StandardsStatus
|
||||
Resource = org.hl7.fhir.instance.model.api.IAnyResource
|
||||
Period = ca.uhn.fhir.model.api.TemporalPrecisionEnum
|
||||
Extension = org.hl7.fhir.instance.model.api.IBaseExtension, org.hl7.fhir.instance.model.api.IBaseDatatype, org.hl7.fhir.instance.model.api.IBaseHasExtensions
|
||||
|
@ -39,6 +39,9 @@ DataType = org.hl7.fhir.instance.model.api.IBaseDatatype, ca.uhn.fhir.model.api.
|
|||
ElementDefinition = org.hl7.fhir.instance.model.api.ICompositeType, org.hl7.fhir.{{jid}}.model.Enumerations.BindingStrength, org.hl7.fhir.{{jid}}.model.Enumerations.BindingStrengthEnumFactory, org.hl7.fhir.{{jid}}.utils.ToolingExtensions, org.hl7.fhir.instance.model.api.IBaseDatatypeElement, org.hl7.fhir.utilities.CommaSeparatedStringBuilder
|
||||
Binary = org.hl7.fhir.instance.model.api.IBaseBinary
|
||||
ContactDetail = org.hl7.fhir.{{jid}}.model.ContactPoint.ContactPointSystem
|
||||
BodyStructure = org.hl7.fhir.utilities.Utilities
|
||||
RegulatedAuthorization = org.hl7.fhir.utilities.Utilities
|
||||
|
||||
|
||||
[shared]
|
||||
http://hl7.org/fhir/ValueSet/concept-map-relationship = true
|
||||
|
|
|
@ -10,7 +10,9 @@ import org.hl7.fhir.r5.model.CodeType;
|
|||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.Enumeration;
|
||||
import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
|
||||
import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
|
@ -307,8 +309,8 @@ public class Analyser {
|
|||
if (!Utilities.existsInList(name, "Resource")) {
|
||||
for (SearchParameter sp : definitions.getSearchParams().getList()) {
|
||||
boolean relevant = false;
|
||||
for (CodeType c : sp.getBase()) {
|
||||
if (c.getValue().equals(name)) {
|
||||
for (Enumeration<VersionIndependentResourceTypesAll> c : sp.getBase()) {
|
||||
if (c.getCode().equals(name)) {
|
||||
relevant = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ public class JavaBaseGenerator extends OutputStreamWriter {
|
|||
protected Definitions definitions;
|
||||
protected Configuration config;
|
||||
protected String version;
|
||||
protected Date genDate;
|
||||
protected String genDate;
|
||||
protected String jid;
|
||||
|
||||
public JavaBaseGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, Date genDate, String jid) throws UnsupportedEncodingException {
|
||||
public JavaBaseGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, String genDate, String jid) throws UnsupportedEncodingException {
|
||||
super(arg0, "UTF-8");
|
||||
this.definitions = definitions;
|
||||
this.config = config;
|
||||
|
@ -67,7 +67,7 @@ public class JavaBaseGenerator extends OutputStreamWriter {
|
|||
this.jid = jid;
|
||||
}
|
||||
|
||||
public void startMark(String version, Date genDate) throws IOException {
|
||||
public void startMark(String version, String genDate) throws IOException {
|
||||
write(startLicenseValue());
|
||||
write(startVMarkValue());
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class JavaBaseGenerator extends OutputStreamWriter {
|
|||
}
|
||||
|
||||
public String startVMarkValue() {
|
||||
return "// Generated on "+config.DATE_FORMAT().format(genDate)+" for FHIR v"+version+"\r\n\r\n";
|
||||
return "// Generated on "+genDate+" for FHIR v"+version+"\r\n\r\n";
|
||||
// return "// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0\r\n\r\n";
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ public class JavaBaseGenerator extends OutputStreamWriter {
|
|||
protected String makeConst(String cc) {
|
||||
if (cc.equals("*"))
|
||||
cc = "ASTERISK";
|
||||
if (Utilities.isOid(cc))
|
||||
if (Utilities.isOid(cc) && Utilities.charCount(cc, '.') > 2)
|
||||
cc = "OID_"+cc;
|
||||
if (cc.equals("%"))
|
||||
cc = "pct";
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.hl7.fhir.utilities.VersionUtilities;
|
|||
public class JavaConstantsGenerator extends JavaBaseGenerator {
|
||||
|
||||
|
||||
public JavaConstantsGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaConstantsGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,8 @@ public class JavaConstantsGenerator extends JavaBaseGenerator {
|
|||
template = template.replace("{{rt}}", rt.toString());
|
||||
template = template.replace("{{version}}", version);
|
||||
template = template.replace("{{version-mm}}", VersionUtilities.getMajMin(version));
|
||||
template = template.replace("{{date}}", config.DATE_FORMAT().format(genDate));
|
||||
template = template.replace("{{version-base}}", version.substring(0, version.indexOf("-")));
|
||||
template = template.replace("{{date}}", genDate);
|
||||
|
||||
write(template);
|
||||
flush();
|
||||
|
|
|
@ -53,7 +53,7 @@ changes for James
|
|||
*/
|
||||
public class JavaEnumerationsGenerator extends JavaBaseGenerator {
|
||||
|
||||
public JavaEnumerationsGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaEnumerationsGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
@ -216,19 +216,20 @@ public class JavaEnumerationsGenerator extends JavaBaseGenerator {
|
|||
}
|
||||
write(" throw new IllegalArgumentException(\"Unknown "+name+" code '\"+codeString+\"'\");\r\n");
|
||||
write(" }\r\n");
|
||||
write(" public Enumeration<"+name+"> fromType(Base code) throws FHIRException {\r\n");
|
||||
write("\r\n");
|
||||
write(" public Enumeration<"+name+"> fromType(PrimitiveType<?> code) throws FHIRException {\r\n");
|
||||
write(" if (code == null)\r\n");
|
||||
write(" return null;\r\n");
|
||||
write(" if (code.isEmpty())\r\n");
|
||||
write(" return new Enumeration<"+name+">(this);\r\n");
|
||||
write(" return new Enumeration<"+name+">(this, "+name+".NULL, code);\r\n");
|
||||
write(" String codeString = ((PrimitiveType) code).asStringValue();\r\n");
|
||||
write(" if (codeString == null || \"\".equals(codeString))\r\n");
|
||||
write(" return null;\r\n");
|
||||
write(" return new Enumeration<"+name+">(this, "+name+".NULL, code);\r\n");
|
||||
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
|
||||
String cc = Utilities.camelCase(c.getCode());
|
||||
cc = makeConst(cc);
|
||||
write(" if (\""+c.getCode()+"\".equals(codeString))\r\n");
|
||||
write(" return new Enumeration<"+name+">(this, "+name+"."+cc+");\r\n");
|
||||
write(" return new Enumeration<"+name+">(this, "+name+"."+cc+", code);\r\n");
|
||||
}
|
||||
write(" throw new FHIRException(\"Unknown "+name+" code '\"+codeString+\"'\");\r\n");
|
||||
write(" }\r\n");
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
|||
public class JavaFactoryGenerator extends JavaBaseGenerator {
|
||||
|
||||
|
||||
public JavaFactoryGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaFactoryGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class JavaParserJsonGenerator extends JavaBaseGenerator {
|
|||
private StringBuilder cregtp = new StringBuilder();
|
||||
private StringBuilder cregti = new StringBuilder();
|
||||
|
||||
public JavaParserJsonGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaParserJsonGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class JavaParserRdfGenerator extends JavaBaseGenerator {
|
|||
private StringBuilder reg = new StringBuilder();
|
||||
private StringBuilder regt = new StringBuilder();
|
||||
|
||||
public JavaParserRdfGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaParserRdfGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class JavaParserXmlGenerator extends JavaBaseGenerator {
|
|||
private StringBuilder cRN = new StringBuilder();
|
||||
private StringBuilder cType = new StringBuilder();
|
||||
|
||||
public JavaParserXmlGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaParserXmlGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@ import org.hl7.fhir.r5.model.CompartmentDefinition;
|
|||
import org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.Enumeration;
|
||||
import org.hl7.fhir.r5.model.Enumerations.SearchParamType;
|
||||
import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
@ -77,7 +79,7 @@ public class JavaResourceGenerator extends JavaBaseGenerator {
|
|||
private long hashSum;
|
||||
|
||||
|
||||
public JavaResourceGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaResourceGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
@ -543,8 +545,8 @@ public class JavaResourceGenerator extends JavaBaseGenerator {
|
|||
}
|
||||
|
||||
Set<String> targets = new TreeSet<>();
|
||||
for (CodeType c : sp.getTarget()) {
|
||||
targets.add(c.asStringValue());
|
||||
for (Enumeration<VersionIndependentResourceTypesAll> c : sp.getTarget()) {
|
||||
targets.add(c.getCode());
|
||||
}
|
||||
if (targets != null && !targets.isEmpty() && !targets.contains("Any")) {
|
||||
write(", target={");
|
||||
|
@ -1347,19 +1349,19 @@ private void generatePropertyMaker(Analysis analysis, TypeInfo ti, String indent
|
|||
}
|
||||
write(" throw new IllegalArgumentException(\"Unknown "+tns+" code '\"+codeString+\"'\");\r\n");
|
||||
write(" }\r\n");
|
||||
write(" public Enumeration<"+tns+"> fromType(Base code) throws FHIRException {\r\n");
|
||||
write(" public Enumeration<"+tns+"> fromType(PrimitiveType<?> code) throws FHIRException {\r\n");
|
||||
write(" if (code == null)\r\n");
|
||||
write(" return null;\r\n");
|
||||
write(" if (code.isEmpty())\r\n");
|
||||
write(" return new Enumeration<"+tns+">(this);\r\n");
|
||||
write(" return new Enumeration<"+tns+">(this, "+tns+".NULL, code);\r\n");
|
||||
write(" String codeString = ((PrimitiveType) code).asStringValue();\r\n");
|
||||
write(" if (codeString == null || \"\".equals(codeString))\r\n");
|
||||
write(" return null;\r\n");
|
||||
write(" return new Enumeration<"+tns+">(this, "+tns+".NULL, code);\r\n");
|
||||
for (ValueSetExpansionContainsComponent c : codes) {
|
||||
String cc = Utilities.camelCase(c.getCode());
|
||||
cc = makeConst(cc);
|
||||
write(" if (\""+c.getCode()+"\".equals(codeString))\r\n");
|
||||
write(" return new Enumeration<"+tns+">(this, "+tns+"."+cc+");\r\n");
|
||||
write(" return new Enumeration<"+tns+">(this, "+tns+"."+cc+", code);\r\n");
|
||||
}
|
||||
write(" throw new FHIRException(\"Unknown "+tns+" code '\"+codeString+\"'\");\r\n");
|
||||
write(" }\r\n");
|
||||
|
@ -2310,7 +2312,7 @@ private void generatePropertyMaker(Analysis analysis, TypeInfo ti, String indent
|
|||
}
|
||||
|
||||
private boolean isString(String tn) {
|
||||
return tn.equals("StringType") || tn.equals("CodeType") || tn.equals("IdType") || tn.equals("UriType") || tn.equals("OidType") || tn.equals("CanonicalType") || tn.equals("UrlType") || tn.equals("UuidType");
|
||||
return tn.equals("StringType") || tn.equals("CodeType") || tn.equals("IdType") || tn.equals("UriType") || tn.equals("OidType") || tn.equals("CanonicalType") || tn.equals("UrlType") || tn.equals("UuidType") || tn.equals("MarkdownType");
|
||||
}
|
||||
|
||||
public long getHashSum() {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
|||
public class JavaTypeGenerator extends JavaBaseGenerator {
|
||||
|
||||
|
||||
public JavaTypeGenerator(OutputStream out, Definitions definitions, Configuration configuration, Date genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
public JavaTypeGenerator(OutputStream out, Definitions definitions, Configuration configuration, String genDate, String version, String jid) throws UnsupportedEncodingException {
|
||||
super(out, definitions, configuration, version, genDate, jid);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.hl7.fhir.core.generator.engine.Definitions;
|
|||
|
||||
public class JavaConverterGenerator extends JavaBaseGenerator {
|
||||
|
||||
public JavaConverterGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, Date genDate, String jid)
|
||||
public JavaConverterGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, String genDate, String jid)
|
||||
throws UnsupportedEncodingException {
|
||||
super(arg0, definitions, config, version, genDate, jid);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
|
|
@ -17,7 +17,7 @@ changes for James
|
|||
*/
|
||||
public class JavaPatternImplGenerator extends JavaBaseGenerator {
|
||||
|
||||
public JavaPatternImplGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, Date genDate, String jid)
|
||||
public JavaPatternImplGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, String genDate, String jid)
|
||||
throws UnsupportedEncodingException {
|
||||
super(arg0, definitions, config, version, genDate, jid);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
|
|
@ -18,7 +18,7 @@ changes for James
|
|||
*/
|
||||
public class JavaPatternIntfGenerator extends JavaBaseGenerator {
|
||||
|
||||
public JavaPatternIntfGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, Date genDate, String jid)
|
||||
public JavaPatternIntfGenerator(OutputStream arg0, Definitions definitions, Configuration config, String version, String genDate, String jid)
|
||||
throws UnsupportedEncodingException {
|
||||
super(arg0, definitions, config, version, genDate, jid);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
|
|
@ -53,14 +53,14 @@ public class JavaCoreGenerator {
|
|||
|
||||
private void generate(String version, String src, String dest) throws Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
Date date = new Date();
|
||||
|
||||
String ap = Utilities.path(src);
|
||||
System.out.println("Load Configuration from "+ap);
|
||||
Configuration config = new Configuration(ap);
|
||||
String pid = VersionUtilities.isR4BVer(version) ? "r4b" : "r5";
|
||||
String jid = VersionUtilities.isR4BVer(version) ? "r4b" : "r5";
|
||||
|
||||
Date ddate = new Date();
|
||||
String date = config.DATE_FORMAT().format(ddate);
|
||||
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
System.out.println("Cache: "+pcm.getFolder());
|
||||
|
@ -147,7 +147,7 @@ public class JavaCoreGenerator {
|
|||
|
||||
}
|
||||
|
||||
public void genClass(String version, String dest, Date date, Configuration config, String jid, NpmPackage npm, Definitions master,
|
||||
public void genClass(String version, String dest, String date, Configuration config, String jid, NpmPackage npm, Definitions master,
|
||||
JavaParserJsonGenerator jgen, JavaParserXmlGenerator xgen, JavaParserRdfGenerator rgen, StructureDefinition sd)
|
||||
throws Exception, IOException, UnsupportedEncodingException, FileNotFoundException {
|
||||
String name = javaName(sd.getName());
|
||||
|
|
Loading…
Reference in New Issue