This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.20.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit d67ca74fad3a7e0c326334ac2b2e9a9270a39438 Author: Claus Ibsen <[email protected]> AuthorDate: Fri Dec 30 20:55:37 2022 +0100 CAMEL-18850: camel-core-model - @XmlAttributes should be String or Enum type only --- .../fhir/FhirJsonDataFormatConfigurer.java | 2 + .../fhir/FhirXmlDataFormatConfigurer.java | 2 + .../org/apache/camel/component/fhir/fhirJson.json | 7 +- .../org/apache/camel/component/fhir/fhirXml.json | 7 +- .../camel/component/fhir/FhirDataFormat.java | 37 +++- .../spring/FhirDataformatConfigSpringTest.java | 2 +- .../fhir/FhirDataFormatConfigSpringTest.xml | 55 +----- .../apache/camel/model/dataformat/fhirJson.json | 7 +- .../org/apache/camel/model/dataformat/fhirXml.json | 7 +- .../camel/model/dataformat/FhirDataformat.java | 201 ++++++++++++++++++--- .../reifier/dataformat/FhirDataFormatReifier.java | 22 ++- .../java/org/apache/camel/xml/in/ModelParser.java | 7 +- .../dsl/yaml/deserializers/ModelDeserializers.java | 36 ++-- .../generated/resources/schema/camel-yaml-dsl.json | 36 ++-- .../generated/resources/schema/camelYamlDsl.json | 36 ++-- 15 files changed, 314 insertions(+), 150 deletions(-) diff --git a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirJsonDataFormatConfigurer.java b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirJsonDataFormatConfigurer.java index 53ef4c1b64e..dacbcc78395 100644 --- a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirJsonDataFormatConfigurer.java +++ b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirJsonDataFormatConfigurer.java @@ -26,6 +26,8 @@ public class FhirJsonDataFormatConfigurer extends PropertyConfigurerSupport impl case "serverBaseUrl": dataformat.setServerBaseUrl(property(camelContext, java.lang.String.class, value)); return true; case "prettyprint": case "prettyPrint": dataformat.setPrettyPrint(property(camelContext, boolean.class, value)); return true; + case "prefertypes": + case "preferTypes": dataformat.setPreferTypes(property(camelContext, java.util.List.class, value)); return true; case "omitresourceid": case "omitResourceId": dataformat.setOmitResourceId(property(camelContext, boolean.class, value)); return true; case "encodeelementsappliestochildresourcesonly": diff --git a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirXmlDataFormatConfigurer.java b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirXmlDataFormatConfigurer.java index 3f4d4cf554f..07a7135ee9b 100644 --- a/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirXmlDataFormatConfigurer.java +++ b/components/camel-fhir/camel-fhir-component/src/generated/java/org/apache/camel/component/fhir/FhirXmlDataFormatConfigurer.java @@ -26,6 +26,8 @@ public class FhirXmlDataFormatConfigurer extends PropertyConfigurerSupport imple case "serverBaseUrl": dataformat.setServerBaseUrl(property(camelContext, java.lang.String.class, value)); return true; case "prettyprint": case "prettyPrint": dataformat.setPrettyPrint(property(camelContext, boolean.class, value)); return true; + case "prefertypes": + case "preferTypes": dataformat.setPreferTypes(property(camelContext, java.util.List.class, value)); return true; case "omitresourceid": case "omitResourceId": dataformat.setOmitResourceId(property(camelContext, boolean.class, value)); return true; case "encodeelementsappliestochildresourcesonly": diff --git a/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirJson.json b/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirJson.json index 050556fc790..bb96834e253 100644 --- a/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirJson.json +++ b/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirJson.json @@ -18,16 +18,17 @@ "properties": { "fhirVersion": { "kind": "attribute", "displayName": "Fhir Version", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DSTU2", "DSTU2_HL7ORG", "DSTU2_1", "DSTU3", "R4", "R5" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "R4", "description": "The version of FHIR to use. Possible values are: DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5" }, "prettyPrint": { "kind": "attribute", "displayName": "Pretty Print", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets the pretty print flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible." }, + "preferTypes": { "kind": "attribute", "displayName": "Prefer Types", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set (FQN class names), when parsing resources the parser will try to use the given types when possible, in the order that they are provided (from highest to lowest priority). For example, if a custom type which declares to implement the Patient resourc [...] "serverBaseUrl": { "kind": "attribute", "displayName": "Server Base Url", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the server's base URL used by this parser. If a value is set, resource references will be turned into relative references if they are provided as absolute URLs but have a base matching the given base." }, "omitResourceId": { "kind": "attribute", "displayName": "Omit Resource Id", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) the ID of any resources being encoded will not be included in the output. Note that this does not apply to contained resources, only to root resources. In other words, if this is set to tru [...] "encodeElementsAppliesToChildResourcesOnly": { "kind": "attribute", "displayName": "Encode Elements Applies To Child Resources Only", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), the values supplied to setEncodeElements(Set) will not be applied to the root resource (typically a Bundle), but will be applied t [...] - "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for this field would include: Patient - Encode patient and all its children Patient.name - Encode only the patient's name Patien [...] - "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: Patient - Don't encode patient and all its children Patient.name - Don't encode the patient's name Patient.name.famil [...] + "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Encode patient and all its chi [...] + "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Don't encode patient and all its children Patient [...] "stripVersionsFromReferences": { "kind": "attribute", "displayName": "Strip Versions From References", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situati [...] "overrideResourceIdWithBundleEntryFullUrl": { "kind": "attribute", "displayName": "Override Resource Id With Bundle Entry Full Url", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens [...] "summaryMode": { "kind": "attribute", "displayName": "Summary Mode", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) only elements marked by the FHIR specification as being summary elements will be included." }, "suppressNarratives": { "kind": "attribute", "displayName": "Suppress Narratives", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), narratives will not be included in the encoded values." }, - "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "array", "javaType": "java.util.List<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. T [...] + "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has [...] "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } } diff --git a/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirXml.json b/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirXml.json index 2fb6629cb1e..30657b17cb7 100644 --- a/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirXml.json +++ b/components/camel-fhir/camel-fhir-component/src/generated/resources/org/apache/camel/component/fhir/fhirXml.json @@ -18,16 +18,17 @@ "properties": { "fhirVersion": { "kind": "attribute", "displayName": "Fhir Version", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DSTU2", "DSTU2_HL7ORG", "DSTU2_1", "DSTU3", "R4", "R5" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "R4", "description": "The version of FHIR to use. Possible values are: DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5" }, "prettyPrint": { "kind": "attribute", "displayName": "Pretty Print", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets the pretty print flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible." }, + "preferTypes": { "kind": "attribute", "displayName": "Prefer Types", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set (FQN class names), when parsing resources the parser will try to use the given types when possible, in the order that they are provided (from highest to lowest priority). For example, if a custom type which declares to implement the Patient resourc [...] "serverBaseUrl": { "kind": "attribute", "displayName": "Server Base Url", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the server's base URL used by this parser. If a value is set, resource references will be turned into relative references if they are provided as absolute URLs but have a base matching the given base." }, "omitResourceId": { "kind": "attribute", "displayName": "Omit Resource Id", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) the ID of any resources being encoded will not be included in the output. Note that this does not apply to contained resources, only to root resources. In other words, if this is set to tru [...] "encodeElementsAppliesToChildResourcesOnly": { "kind": "attribute", "displayName": "Encode Elements Applies To Child Resources Only", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), the values supplied to setEncodeElements(Set) will not be applied to the root resource (typically a Bundle), but will be applied t [...] - "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for this field would include: Patient - Encode patient and all its children Patient.name - Encode only the patient's name Patien [...] - "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: Patient - Don't encode patient and all its children Patient.name - Don't encode the patient's name Patient.name.famil [...] + "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Encode patient and all its chi [...] + "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Don't encode patient and all its children Patient [...] "stripVersionsFromReferences": { "kind": "attribute", "displayName": "Strip Versions From References", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situati [...] "overrideResourceIdWithBundleEntryFullUrl": { "kind": "attribute", "displayName": "Override Resource Id With Bundle Entry Full Url", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens [...] "summaryMode": { "kind": "attribute", "displayName": "Summary Mode", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) only elements marked by the FHIR specification as being summary elements will be included." }, "suppressNarratives": { "kind": "attribute", "displayName": "Suppress Narratives", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), narratives will not be included in the encoded values." }, - "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "array", "javaType": "java.util.List<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. T [...] + "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has [...] "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } } diff --git a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirDataFormat.java b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirDataFormat.java index b89af0bc518..0e769d157cf 100644 --- a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirDataFormat.java +++ b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirDataFormat.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.fhir; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -24,6 +25,8 @@ import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.ParserOptions; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParserErrorHandler; +import org.apache.camel.CamelContext; +import org.apache.camel.CamelContextAware; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.DataFormatContentTypeHeader; import org.apache.camel.spi.DataFormatName; @@ -32,7 +35,9 @@ import org.apache.camel.util.ObjectHelper; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -public abstract class FhirDataFormat extends ServiceSupport implements DataFormat, DataFormatName, DataFormatContentTypeHeader { +public abstract class FhirDataFormat extends ServiceSupport implements DataFormat, DataFormatName, DataFormatContentTypeHeader, CamelContextAware { + + private CamelContext camelContext; private FhirContext fhirContext; private String fhirVersion; @@ -42,6 +47,7 @@ public abstract class FhirDataFormat extends ServiceSupport implements DataForma private String serverBaseUrl; private boolean prettyPrint; private List<Class<? extends IBaseResource>> preferTypes; + private String preferTypesNames; private boolean omitResourceId; private IIdType forceResourceId; private boolean encodeElementsAppliesToChildResourcesOnly; @@ -53,6 +59,16 @@ public abstract class FhirDataFormat extends ServiceSupport implements DataForma private boolean suppressNarratives; private List<String> dontStripVersionsFromReferencesAtPaths; + @Override + public CamelContext getCamelContext() { + return camelContext; + } + + @Override + public void setCamelContext(CamelContext camelContext) { + this.camelContext = camelContext; + } + public FhirContext getFhirContext() { return fhirContext; } @@ -117,6 +133,14 @@ public abstract class FhirDataFormat extends ServiceSupport implements DataForma this.preferTypes = preferTypes; } + public String getPreferTypesNames() { + return preferTypesNames; + } + + public void setPreferTypesNames(String preferTypesNames) { + this.preferTypesNames = preferTypesNames; + } + public boolean isOmitResourceId() { return omitResourceId; } @@ -231,6 +255,17 @@ public abstract class FhirDataFormat extends ServiceSupport implements DataForma parser.setEncodeElementsAppliesToChildResourcesOnly(isEncodeElementsAppliesToChildResourcesOnly()); } + @Override + protected void doBuild() throws Exception { + if (preferTypes == null && preferTypesNames != null) { + preferTypes = new ArrayList<>(); + for (String name : preferTypesNames.split(",")) { + Class<IBaseResource> clazz = camelContext.getClassResolver().resolveMandatoryClass(name, IBaseResource.class); + preferTypes.add(clazz); + } + } + } + @Override protected void doStart() throws Exception { if (fhirContext == null && fhirVersion != null) { diff --git a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/dataformat/spring/FhirDataformatConfigSpringTest.java b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/dataformat/spring/FhirDataformatConfigSpringTest.java index 7405a70f7f2..650112f628a 100644 --- a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/dataformat/spring/FhirDataformatConfigSpringTest.java +++ b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/dataformat/spring/FhirDataformatConfigSpringTest.java @@ -68,7 +68,7 @@ public class FhirDataformatConfigSpringTest extends CamelSpringTestSupport { assertTrue(fhirJson.getForceResourceId().getClass().isAssignableFrom(IdType.class)); assertTrue(fhirJson.getParserErrorHandler().getClass().isAssignableFrom(LenientErrorHandler.class)); assertTrue(fhirJson.getParserOptions().getClass().isAssignableFrom(ParserOptions.class)); - assertNotNull(fhirJson.getPreferTypes()); + assertNotNull(fhirJson.getPreferTypesNames()); assertEquals("serverBaseUrl", fhirJson.getServerBaseUrl()); assertTrue(fhirJson.getOverrideResourceIdWithBundleEntryFullUrl()); assertTrue(fhirJson.getStripVersionsFromReferences()); diff --git a/components/camel-fhir/camel-fhir-component/src/test/resources/org/apache/camel/dataformat/fhir/FhirDataFormatConfigSpringTest.xml b/components/camel-fhir/camel-fhir-component/src/test/resources/org/apache/camel/dataformat/fhir/FhirDataFormatConfigSpringTest.xml index 788d4f01943..480cfd68616 100644 --- a/components/camel-fhir/camel-fhir-component/src/test/resources/org/apache/camel/dataformat/fhir/FhirDataFormatConfigSpringTest.xml +++ b/components/camel-fhir/camel-fhir-component/src/test/resources/org/apache/camel/dataformat/fhir/FhirDataFormatConfigSpringTest.xml @@ -49,29 +49,10 @@ <property name="overrideResourceIdWithBundleEntryFullUrl" value="TRUE" /> <property name="summaryMode" value="TRUE" /> <property name="suppressNarratives" value="TRUE" /> - <property name="dontStripVersionsFromReferencesAtPaths"> - <list> - <value>foo</value> - <value>bar</value> - </list> - </property> - <property name="preferTypes"> - <list> - <ref bean="patient"/> - </list> - </property> - <property name="encodeElements"> - <set> - <value>foo</value> - <value>bar</value> - </set> - </property> - <property name="dontEncodeElements"> - <set> - <value>foo</value> - <value>bar</value> - </set> - </property> + <property name="dontStripVersionsFromReferencesAtPaths" value="foo,bar"/> + <property name="preferTypes" value="org.hl7.fhir.r4.model.Patient"/> + <property name="encodeElements" value="foo,bar"/> + <property name="dontEncodeElements" value="foo,bar"/> </bean> <bean id="fhirJson" class="org.apache.camel.model.dataformat.FhirJsonDataFormat"> <property name="parserErrorHandler" ref="errorHandler" /> @@ -86,35 +67,15 @@ <property name="overrideResourceIdWithBundleEntryFullUrl" value="TRUE" /> <property name="summaryMode" value="TRUE" /> <property name="suppressNarratives" value="TRUE" /> - <property name="dontStripVersionsFromReferencesAtPaths"> - <list> - <value>foo</value> - <value>bar</value> - </list> - </property> - <property name="preferTypes"> - <list> - <ref bean="patient"/> - </list> - </property> - <property name="encodeElements"> - <set> - <value>foo</value> - <value>bar</value> - </set> - </property> - <property name="dontEncodeElements"> - <set> - <value>foo</value> - <value>bar</value> - </set> - </property> + <property name="dontStripVersionsFromReferencesAtPaths" value="foo,bar"/> + <property name="preferTypes" value="org.hl7.fhir.r4.model.Patient"/> + <property name="encodeElements" value="foo,bar"/> + <property name="dontEncodeElements" value="foo,bar"/> </bean> <bean id="fhirContext" class="ca.uhn.fhir.context.FhirContext" factory-method="forR4"/> <bean id ="errorHandler" class="ca.uhn.fhir.parser.LenientErrorHandler"/> <bean id="parserOptions" class="ca.uhn.fhir.context.ParserOptions" /> <bean id="forceResourceId" class="org.hl7.fhir.r4.model.IdType" /> - <bean id="patient" class="org.hl7.fhir.r4.model.Patient" /> </beans> diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirJson.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirJson.json index 2879d200ccf..d435188c236 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirJson.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirJson.json @@ -15,16 +15,17 @@ "properties": { "fhirVersion": { "kind": "attribute", "displayName": "Fhir Version", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DSTU2", "DSTU2_HL7ORG", "DSTU2_1", "DSTU3", "R4", "R5" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "R4", "description": "The version of FHIR to use. Possible values are: DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5" }, "prettyPrint": { "kind": "attribute", "displayName": "Pretty Print", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets the pretty print flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible." }, + "preferTypes": { "kind": "attribute", "displayName": "Prefer Types", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set (FQN class names), when parsing resources the parser will try to use the given types when possible, in the order that they are provided (from highest to lowest priority). For example, if a custom type which declares to implement the Patient resourc [...] "serverBaseUrl": { "kind": "attribute", "displayName": "Server Base Url", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the server's base URL used by this parser. If a value is set, resource references will be turned into relative references if they are provided as absolute URLs but have a base matching the given base." }, "omitResourceId": { "kind": "attribute", "displayName": "Omit Resource Id", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) the ID of any resources being encoded will not be included in the output. Note that this does not apply to contained resources, only to root resources. In other words, if this is set to tru [...] "encodeElementsAppliesToChildResourcesOnly": { "kind": "attribute", "displayName": "Encode Elements Applies To Child Resources Only", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), the values supplied to setEncodeElements(Set) will not be applied to the root resource (typically a Bundle), but will be applied t [...] - "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for this field would include: Patient - Encode patient and all its children Patient.name - Encode only the patient's name Patien [...] - "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: Patient - Don't encode patient and all its children Patient.name - Don't encode the patient's name Patient.name.famil [...] + "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Encode patient and all its chi [...] + "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Don't encode patient and all its children Patient [...] "stripVersionsFromReferences": { "kind": "attribute", "displayName": "Strip Versions From References", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situati [...] "overrideResourceIdWithBundleEntryFullUrl": { "kind": "attribute", "displayName": "Override Resource Id With Bundle Entry Full Url", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens [...] "summaryMode": { "kind": "attribute", "displayName": "Summary Mode", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) only elements marked by the FHIR specification as being summary elements will be included." }, "suppressNarratives": { "kind": "attribute", "displayName": "Suppress Narratives", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), narratives will not be included in the encoded values." }, - "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "array", "javaType": "java.util.List<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. T [...] + "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has [...] "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirXml.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirXml.json index 2214043baed..11e14cbf7f6 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirXml.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/fhirXml.json @@ -15,16 +15,17 @@ "properties": { "fhirVersion": { "kind": "attribute", "displayName": "Fhir Version", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DSTU2", "DSTU2_HL7ORG", "DSTU2_1", "DSTU3", "R4", "R5" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "R4", "description": "The version of FHIR to use. Possible values are: DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5" }, "prettyPrint": { "kind": "attribute", "displayName": "Pretty Print", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Sets the pretty print flag, meaning that the parser will encode resources with human-readable spacing and newlines between elements instead of condensing output as much as possible." }, + "preferTypes": { "kind": "attribute", "displayName": "Prefer Types", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set (FQN class names), when parsing resources the parser will try to use the given types when possible, in the order that they are provided (from highest to lowest priority). For example, if a custom type which declares to implement the Patient resourc [...] "serverBaseUrl": { "kind": "attribute", "displayName": "Server Base Url", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the server's base URL used by this parser. If a value is set, resource references will be turned into relative references if they are provided as absolute URLs but have a base matching the given base." }, "omitResourceId": { "kind": "attribute", "displayName": "Omit Resource Id", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) the ID of any resources being encoded will not be included in the output. Note that this does not apply to contained resources, only to root resources. In other words, if this is set to tru [...] "encodeElementsAppliesToChildResourcesOnly": { "kind": "attribute", "displayName": "Encode Elements Applies To Child Resources Only", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), the values supplied to setEncodeElements(Set) will not be applied to the root resource (typically a Bundle), but will be applied t [...] - "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for this field would include: Patient - Encode patient and all its children Patient.name - Encode only the patient's name Patien [...] - "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Set<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: Patient - Don't encode patient and all its children Patient.name - Don't encode the patient's name Patient.name.famil [...] + "encodeElements": { "kind": "attribute", "displayName": "Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should be encoded, to the exclusion of all others. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Encode patient and all its chi [...] + "dontEncodeElements": { "kind": "attribute", "displayName": "Dont Encode Elements", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If provided, specifies the elements which should NOT be encoded. Multiple elements can be separated by comma when using String parameter. Valid values for this field would include: Patient - Don't encode patient and all its children Patient [...] "stripVersionsFromReferences": { "kind": "attribute", "displayName": "Strip Versions From References", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), resource references containing a version will have the version removed when the resource is encoded. This is generally good behaviour because in most situati [...] "overrideResourceIdWithBundleEntryFullUrl": { "kind": "attribute", "displayName": "Override Resource Id With Bundle Entry Full Url", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's resource id if the fullUrl is defined. This behavior happens [...] "summaryMode": { "kind": "attribute", "displayName": "Summary Mode", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false) only elements marked by the FHIR specification as being summary elements will be included." }, "suppressNarratives": { "kind": "attribute", "displayName": "Suppress Narratives", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true (default is false), narratives will not be included in the encoded values." }, - "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "array", "javaType": "java.util.List<java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. T [...] + "dontStripVersionsFromReferencesAtPaths": { "kind": "attribute", "displayName": "Dont Strip Versions From References At Paths", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If supplied value(s), any resource references at the specified paths will have their resource versions encoded instead of being automatically stripped during the encoding process. This setting has [...] "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } } diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java index e317ab76cfe..0f16bec7a73 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/FhirDataformat.java @@ -42,9 +42,9 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con @XmlTransient @Metadata(label = "advanced") private Object parserOptions; - @XmlTransient + @XmlAttribute @Metadata(label = "advanced") - private Object preferTypes; + private String preferTypes; @XmlTransient @Metadata(label = "advanced") private Object forceResourceId; @@ -59,10 +59,10 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con private String encodeElementsAppliesToChildResourcesOnly; @XmlAttribute @Metadata(label = "advanced") - private Set<String> encodeElements; + private String encodeElements; @XmlAttribute @Metadata(label = "advanced") - private Set<String> dontEncodeElements; + private String dontEncodeElements; @XmlAttribute @Metadata(label = "advanced", javaType = "java.lang.Boolean") private String stripVersionsFromReferences; @@ -77,7 +77,7 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con private String suppressNarratives; @XmlAttribute @Metadata(label = "advanced") - private List<String> dontStripVersionsFromReferencesAtPaths; + private String dontStripVersionsFromReferencesAtPaths; @XmlAttribute @Metadata(javaType = "java.lang.Boolean", defaultValue = "true", description = "Whether the data format should set the Content-Type header with the type from the data format." @@ -173,19 +173,21 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con this.parserOptions = parserOptions; } - public Object getPreferTypes() { + public String getPreferTypes() { return preferTypes; } /** - * If set, when parsing resources the parser will try to use the given types when possible, in the order that they + * If set (FQN class names), when parsing resources the parser will try to use the given types when possible, in the order that they * are provided (from highest to lowest priority). For example, if a custom type which declares to implement the * Patient resource is passed in here, and the parser is parsing a Bundle containing a Patient resource, the parser * will use the given custom type. * + * Multiple class names can be separated by comma. + * * @param preferTypes The preferred types, or <code>null</code> */ - public void setPreferTypes(Object preferTypes) { + public void setPreferTypes(String preferTypes) { this.preferTypes = preferTypes; } @@ -243,13 +245,15 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con this.encodeElementsAppliesToChildResourcesOnly = encodeElementsAppliesToChildResourcesOnly; } - public Set<String> getEncodeElements() { + public String getEncodeElements() { return encodeElements; } /** - * If provided, specifies the elements which should be encoded, to the exclusion of all others. Valid values for - * this field would include: + * If provided, specifies the elements which should be encoded, to the exclusion of all others. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: * <ul> * <li><b>Patient</b> - Encode patient and all its children</li> * <li><b>Patient.name</b> - Encode only the patient's name</li> @@ -263,15 +267,39 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * @see #setDontEncodeElements(Set) */ public void setEncodeElements(Set<String> encodeElements) { + this.encodeElements = String.join(",", encodeElements); + } + + /** + * If provided, specifies the elements which should be encoded, to the exclusion of all others. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: + * <ul> + * <li><b>Patient</b> - Encode patient and all its children</li> + * <li><b>Patient.name</b> - Encode only the patient's name</li> + * <li><b>Patient.name.family</b> - Encode only the patient's family name</li> + * <li><b>*.text</b> - Encode the text element on any resource (only the very first position may contain a + * wildcard)</li> + * <li><b>*.(mandatory)</b> - This is a special case which causes any mandatory fields (min > 0) to be encoded</li> + * </ul> + * + * @param encodeElements The elements to encode + * @see #setDontEncodeElements(Set) + */ + public void setEncodeElements(String encodeElements) { this.encodeElements = encodeElements; } - public Set<String> getDontEncodeElements() { + public String getDontEncodeElements() { return dontEncodeElements; } /** - * If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: + * If provided, specifies the elements which should NOT be encoded. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: * <ul> * <li><b>Patient</b> - Don't encode patient and all its children</li> * <li><b>Patient.name</b> - Don't encode the patient's name</li> @@ -284,10 +312,34 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * values with subelements on meta such as <code>Patient.meta.lastUpdated</code> will only work in DSTU3+ mode. * </p> * - * @param dontEncodeElements The elements to encode + * @param dontEncodeElements The elements to NOT encode * @see #setEncodeElements(Set) */ public void setDontEncodeElements(Set<String> dontEncodeElements) { + this.dontEncodeElements = String.join(",", dontEncodeElements); + } + + /** + * If provided, specifies the elements which should NOT be encoded. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: + * <ul> + * <li><b>Patient</b> - Don't encode patient and all its children</li> + * <li><b>Patient.name</b> - Don't encode the patient's name</li> + * <li><b>Patient.name.family</b> - Don't encode the patient's family name</li> + * <li><b>*.text</b> - Don't encode the text element on any resource (only the very first position may contain a + * wildcard)</li> + * </ul> + * <p> + * DSTU2 note: Note that values including meta, such as <code>Patient.meta</code> will work for DSTU2 parsers, but + * values with subelements on meta such as <code>Patient.meta.lastUpdated</code> will only work in DSTU3+ mode. + * </p> + * + * @param dontEncodeElements The elements to NOT encode + * @see #setEncodeElements(Set) + */ + public void setDontEncodeElements(String dontEncodeElements) { this.dontEncodeElements = dontEncodeElements; } @@ -359,7 +411,7 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con this.suppressNarratives = suppressNarratives; } - public List<String> getDontStripVersionsFromReferencesAtPaths() { + public String getDontStripVersionsFromReferencesAtPaths() { return dontStripVersionsFromReferencesAtPaths; } @@ -367,6 +419,7 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * If supplied value(s), any resource references at the specified paths will have their resource versions encoded * instead of being automatically stripped during the encoding process. This setting has no effect on the parsing * process. + * Multiple elements can be separated by comma when using String parameter. * <p> * This method provides a finer-grained level of control than {@link #setStripVersionsFromReferences(String)} and * any paths specified by this method will be encoded even if {@link #setStripVersionsFromReferences(String)} has @@ -383,6 +436,30 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * @see #setStripVersionsFromReferences(String) */ public void setDontStripVersionsFromReferencesAtPaths(List<String> dontStripVersionsFromReferencesAtPaths) { + this.dontStripVersionsFromReferencesAtPaths = String.join(",", dontStripVersionsFromReferencesAtPaths); + } + + /** + * If supplied value(s), any resource references at the specified paths will have their resource versions encoded + * instead of being automatically stripped during the encoding process. This setting has no effect on the parsing + * process. + * Multiple elements can be separated by comma when using String parameter. + * <p> + * This method provides a finer-grained level of control than {@link #setStripVersionsFromReferences(String)} and + * any paths specified by this method will be encoded even if {@link #setStripVersionsFromReferences(String)} has + * been set to <code>true</code> (which is the default) + * </p> + * + * @param dontStripVersionsFromReferencesAtPaths A collection of paths for which the resource versions will not be + * removed automatically when serializing, e.g. + * "Patient.managingOrganization" or "AuditEvent.object.reference". + * Note that only resource name and field names with dots separating + * is allowed here (no repetition indicators, FluentPath expressions, + * etc.). Set to <code>null</code> to use the value set in the + * {@link #setParserOptions(Object)} + * @see #setStripVersionsFromReferences(String) + */ + public void setDontStripVersionsFromReferencesAtPaths(String dontStripVersionsFromReferencesAtPaths) { this.dontStripVersionsFromReferencesAtPaths = dontStripVersionsFromReferencesAtPaths; } @@ -407,18 +484,18 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con private String prettyPrint; private Object parserErrorHandler; private Object parserOptions; - private Object preferTypes; + private String preferTypes; private Object forceResourceId; private String serverBaseUrl; private String omitResourceId; private String encodeElementsAppliesToChildResourcesOnly; - private Set<String> encodeElements; - private Set<String> dontEncodeElements; + private String encodeElements; + private String dontEncodeElements; private String stripVersionsFromReferences; private String overrideResourceIdWithBundleEntryFullUrl; private String summaryMode; private String suppressNarratives; - private List<String> dontStripVersionsFromReferencesAtPaths; + private String dontStripVersionsFromReferencesAtPaths; private String contentTypeHeader; public T fhirContext(Object fhirContext) { @@ -484,7 +561,7 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * * @param preferTypes The preferred types, or <code>null</code> */ - public T preferTypes(Object preferTypes) { + public T preferTypes(String preferTypes) { this.preferTypes = preferTypes; return (T) this; } @@ -571,12 +648,39 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * @see #setDontEncodeElements(Set) */ public T encodeElements(Set<String> encodeElements) { + this.encodeElements = String.join(",", encodeElements); + return (T) this; + } + + /** + * If provided, specifies the elements which should be encoded, to the exclusion of all others. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: + * <ul> + * <li><b>Patient</b> - Encode patient and all its children</li> + * <li><b>Patient.name</b> - Encode only the patient's name</li> + * <li><b>Patient.name.family</b> - Encode only the patient's family name</li> + * <li><b>*.text</b> - Encode the text element on any resource (only the very first position may contain a + * wildcard)</li> + * <li><b>*.(mandatory)</b> - This is a special case which causes any mandatory fields (min > 0) to be + * encoded</li> + * </ul> + * Multiple elements can be separated by comma. + * + * @param encodeElements The elements to encode (multiple elements can be separated by comma) + * @see #setDontEncodeElements(Set) + */ + public T encodeElements(String encodeElements) { this.encodeElements = encodeElements; return (T) this; } /** - * If provided, specifies the elements which should NOT be encoded. Valid values for this field would include: + * If provided, specifies the elements which should NOT be encoded. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: * <ul> * <li><b>Patient</b> - Don't encode patient and all its children</li> * <li><b>Patient.name</b> - Don't encode the patient's name</li> @@ -590,10 +694,36 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * mode. * </p> * - * @param dontEncodeElements The elements to encode + * @param dontEncodeElements The elements to NOT encode (multiple elements can be separated by comma) * @see #setEncodeElements(Set) */ public T dontEncodeElements(Set<String> dontEncodeElements) { + this.dontEncodeElements = String.join(",", dontEncodeElements); + return (T) this; + } + + /** + * If provided, specifies the elements which should NOT be encoded. + * Multiple elements can be separated by comma when using String parameter. + * + * Valid values for this field would include: + * <ul> + * <li><b>Patient</b> - Don't encode patient and all its children</li> + * <li><b>Patient.name</b> - Don't encode the patient's name</li> + * <li><b>Patient.name.family</b> - Don't encode the patient's family name</li> + * <li><b>*.text</b> - Don't encode the text element on any resource (only the very first position may contain a + * wildcard)</li> + * </ul> + * <p> + * DSTU2 note: Note that values including meta, such as <code>Patient.meta</code> will work for DSTU2 parsers, + * but values with subelements on meta such as <code>Patient.meta.lastUpdated</code> will only work in DSTU3+ + * mode. + * </p> + * + * @param dontEncodeElements The elements to NOT encode + * @see #setEncodeElements(Set) + */ + public T dontEncodeElements(String dontEncodeElements) { this.dontEncodeElements = dontEncodeElements; return (T) this; } @@ -714,6 +844,7 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * If supplied value(s), any resource references at the specified paths will have their resource versions * encoded instead of being automatically stripped during the encoding process. This setting has no effect on * the parsing process. + * Multiple elements can be separated by comma when using String parameter. * <p> * This method provides a finer-grained level of control than {@link #setStripVersionsFromReferences(String)} * and any paths specified by this method will be encoded even if @@ -731,6 +862,32 @@ public abstract class FhirDataformat extends DataFormatDefinition implements Con * @see #setStripVersionsFromReferences(String) */ public T dontStripVersionsFromReferencesAtPaths(List<String> dontStripVersionsFromReferencesAtPaths) { + this.dontStripVersionsFromReferencesAtPaths = String.join(",", dontStripVersionsFromReferencesAtPaths); + return (T) this; + } + + /** + * If supplied value(s), any resource references at the specified paths will have their resource versions + * encoded instead of being automatically stripped during the encoding process. This setting has no effect on + * the parsing process. + * Multiple elements can be separated by comma when using String parameter. + * <p> + * This method provides a finer-grained level of control than {@link #setStripVersionsFromReferences(String)} + * and any paths specified by this method will be encoded even if + * {@link #setStripVersionsFromReferences(String)} has been set to <code>true</code> (which is the default) + * </p> + * + * @param dontStripVersionsFromReferencesAtPaths A collection of paths for which the resource versions will not + * be removed automatically when serializing, e.g. + * "Patient.managingOrganization" or + * "AuditEvent.object.reference". Note that only resource name and + * field names with dots separating is allowed here (no repetition + * indicators, FluentPath expressions, etc.). Set to + * <code>null</code> to use the value set in the + * {@link #setParserOptions(Object)} + * @see #setStripVersionsFromReferences(String) + */ + public T dontStripVersionsFromReferencesAtPaths(String dontStripVersionsFromReferencesAtPaths) { this.dontStripVersionsFromReferencesAtPaths = dontStripVersionsFromReferencesAtPaths; return (T) this; } diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/FhirDataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/FhirDataFormatReifier.java index d1917f7457b..12b239dde1a 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/FhirDataFormatReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/FhirDataFormatReifier.java @@ -16,7 +16,11 @@ */ package org.apache.camel.reifier.dataformat; +import java.util.Arrays; +import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.camel.CamelContext; import org.apache.camel.model.DataFormatDefinition; @@ -32,12 +36,9 @@ public class FhirDataFormatReifier<T extends FhirDataformat> extends DataFormatR protected void prepareDataFormatConfig(Map<String, Object> properties) { properties.put("fhirContext", definition.getFhirContext()); properties.put("fhirVersion", definition.getFhirVersion()); - properties.put("dontStripVersionsFromReferencesAtPaths", definition.getDontStripVersionsFromReferencesAtPaths()); - properties.put("dontEncodeElements", definition.getDontEncodeElements()); - properties.put("encodeElements", definition.getEncodeElements()); properties.put("serverBaseUrl", definition.getServerBaseUrl()); properties.put("forceResourceId", definition.getForceResourceId()); - properties.put("preferTypes", definition.getPreferTypes()); + properties.put("preferTypesNames", definition.getPreferTypes()); properties.put("parserOptions", definition.getParserOptions()); properties.put("parserErrorHandler", definition.getParserErrorHandler()); properties.put("encodeElementsAppliesToChildResourcesOnly", definition.getEncodeElementsAppliesToChildResourcesOnly()); @@ -47,6 +48,19 @@ public class FhirDataFormatReifier<T extends FhirDataformat> extends DataFormatR properties.put("summaryMode", definition.getSummaryMode()); properties.put("overrideResourceIdWithBundleEntryFullUrl", definition.getOverrideResourceIdWithBundleEntryFullUrl()); properties.put("stripVersionsFromReferences", definition.getStripVersionsFromReferences()); + // convert string to list/set for the following options + if (definition.getDontStripVersionsFromReferencesAtPaths() != null) { + List<String> list = Arrays.stream(definition.getDontStripVersionsFromReferencesAtPaths().split(",")).collect(Collectors.toList()); + properties.put("dontStripVersionsFromReferencesAtPaths", list); + } + if (definition.getDontEncodeElements() != null) { + Set<String> set = Arrays.stream(definition.getDontEncodeElements().split(",")).collect(Collectors.toSet()); + properties.put("dontEncodeElements", set); + } + if (definition.getEncodeElements() != null) { + Set<String> set = Arrays.stream(definition.getEncodeElements().split(",")).collect(Collectors.toSet()); + properties.put("encodeElements", set); + } } } diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java index 4b7bcbab39a..0e7873932a8 100644 --- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java +++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java @@ -2064,13 +2064,14 @@ public class ModelParser extends BaseParser { return (def, key, val) -> { switch (key) { case "contentTypeHeader": def.setContentTypeHeader(val); break; - case "dontEncodeElements": def.setDontEncodeElements(asStringSet(val)); break; - case "dontStripVersionsFromReferencesAtPaths": def.setDontStripVersionsFromReferencesAtPaths(asStringList(val)); break; - case "encodeElements": def.setEncodeElements(asStringSet(val)); break; + case "dontEncodeElements": def.setDontEncodeElements(val); break; + case "dontStripVersionsFromReferencesAtPaths": def.setDontStripVersionsFromReferencesAtPaths(val); break; + case "encodeElements": def.setEncodeElements(val); break; case "encodeElementsAppliesToChildResourcesOnly": def.setEncodeElementsAppliesToChildResourcesOnly(val); break; case "fhirVersion": def.setFhirVersion(val); break; case "omitResourceId": def.setOmitResourceId(val); break; case "overrideResourceIdWithBundleEntryFullUrl": def.setOverrideResourceIdWithBundleEntryFullUrl(val); break; + case "preferTypes": def.setPreferTypes(val); break; case "prettyPrint": def.setPrettyPrint(val); break; case "serverBaseUrl": def.setServerBaseUrl(val); break; case "stripVersionsFromReferences": def.setStripVersionsFromReferences(val); break; diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java index ad55601d3c8..84bf6079a13 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java @@ -5033,14 +5033,15 @@ public final class ModelDeserializers extends YamlDeserializerSupport { order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1, properties = { @YamlProperty(name = "content-type-header", type = "boolean"), - @YamlProperty(name = "dont-encode-elements", type = "array:string"), - @YamlProperty(name = "dont-strip-versions-from-references-at-paths", type = "array:string"), - @YamlProperty(name = "encode-elements", type = "array:string"), + @YamlProperty(name = "dont-encode-elements", type = "string"), + @YamlProperty(name = "dont-strip-versions-from-references-at-paths", type = "string"), + @YamlProperty(name = "encode-elements", type = "string"), @YamlProperty(name = "encode-elements-applies-to-child-resources-only", type = "boolean"), @YamlProperty(name = "fhir-version", type = "enum:DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5"), @YamlProperty(name = "id", type = "string"), @YamlProperty(name = "omit-resource-id", type = "boolean"), @YamlProperty(name = "override-resource-id-with-bundle-entry-full-url", type = "boolean"), + @YamlProperty(name = "prefer-types", type = "string"), @YamlProperty(name = "pretty-print", type = "boolean"), @YamlProperty(name = "server-base-url", type = "string"), @YamlProperty(name = "strip-versions-from-references", type = "boolean"), @@ -5068,17 +5069,17 @@ public final class ModelDeserializers extends YamlDeserializerSupport { break; } case "dont-encode-elements": { - java.util.Set<String> val = asStringSet(node); + String val = asText(node); target.setDontEncodeElements(val); break; } case "dont-strip-versions-from-references-at-paths": { - java.util.List<String> val = asStringList(node); + String val = asText(node); target.setDontStripVersionsFromReferencesAtPaths(val); break; } case "encode-elements": { - java.util.Set<String> val = asStringSet(node); + String val = asText(node); target.setEncodeElements(val); break; } @@ -5107,6 +5108,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport { target.setOverrideResourceIdWithBundleEntryFullUrl(val); break; } + case "prefer-types": { + String val = asText(node); + target.setPreferTypes(val); + break; + } case "pretty-print": { String val = asText(node); target.setPrettyPrint(val); @@ -5149,14 +5155,15 @@ public final class ModelDeserializers extends YamlDeserializerSupport { order = org.apache.camel.dsl.yaml.common.YamlDeserializerResolver.ORDER_LOWEST - 1, properties = { @YamlProperty(name = "content-type-header", type = "boolean"), - @YamlProperty(name = "dont-encode-elements", type = "array:string"), - @YamlProperty(name = "dont-strip-versions-from-references-at-paths", type = "array:string"), - @YamlProperty(name = "encode-elements", type = "array:string"), + @YamlProperty(name = "dont-encode-elements", type = "string"), + @YamlProperty(name = "dont-strip-versions-from-references-at-paths", type = "string"), + @YamlProperty(name = "encode-elements", type = "string"), @YamlProperty(name = "encode-elements-applies-to-child-resources-only", type = "boolean"), @YamlProperty(name = "fhir-version", type = "enum:DSTU2,DSTU2_HL7ORG,DSTU2_1,DSTU3,R4,R5"), @YamlProperty(name = "id", type = "string"), @YamlProperty(name = "omit-resource-id", type = "boolean"), @YamlProperty(name = "override-resource-id-with-bundle-entry-full-url", type = "boolean"), + @YamlProperty(name = "prefer-types", type = "string"), @YamlProperty(name = "pretty-print", type = "boolean"), @YamlProperty(name = "server-base-url", type = "string"), @YamlProperty(name = "strip-versions-from-references", type = "boolean"), @@ -5184,17 +5191,17 @@ public final class ModelDeserializers extends YamlDeserializerSupport { break; } case "dont-encode-elements": { - java.util.Set<String> val = asStringSet(node); + String val = asText(node); target.setDontEncodeElements(val); break; } case "dont-strip-versions-from-references-at-paths": { - java.util.List<String> val = asStringList(node); + String val = asText(node); target.setDontStripVersionsFromReferencesAtPaths(val); break; } case "encode-elements": { - java.util.Set<String> val = asStringSet(node); + String val = asText(node); target.setEncodeElements(val); break; } @@ -5223,6 +5230,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport { target.setOverrideResourceIdWithBundleEntryFullUrl(val); break; } + case "prefer-types": { + String val = asText(node); + target.setPreferTypes(val); + break; + } case "pretty-print": { String val = asText(node); target.setPrettyPrint(val); diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json index 80b7a75fac0..93ccc91186d 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json @@ -4893,22 +4893,13 @@ "type" : "boolean" }, "dont-encode-elements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "dont-strip-versions-from-references-at-paths" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encode-elements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encode-elements-applies-to-child-resources-only" : { "type" : "boolean" @@ -4926,6 +4917,9 @@ "override-resource-id-with-bundle-entry-full-url" : { "type" : "boolean" }, + "prefer-types" : { + "type" : "string" + }, "pretty-print" : { "type" : "boolean" }, @@ -4950,22 +4944,13 @@ "type" : "boolean" }, "dont-encode-elements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "dont-strip-versions-from-references-at-paths" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encode-elements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encode-elements-applies-to-child-resources-only" : { "type" : "boolean" @@ -4983,6 +4968,9 @@ "override-resource-id-with-bundle-entry-full-url" : { "type" : "boolean" }, + "prefer-types" : { + "type" : "string" + }, "pretty-print" : { "type" : "boolean" }, diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json index c65b2e838bd..a16324ccf44 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json @@ -4797,22 +4797,13 @@ "type" : "boolean" }, "dontEncodeElements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "dontStripVersionsFromReferencesAtPaths" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encodeElements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encodeElementsAppliesToChildResourcesOnly" : { "type" : "boolean" @@ -4830,6 +4821,9 @@ "overrideResourceIdWithBundleEntryFullUrl" : { "type" : "boolean" }, + "preferTypes" : { + "type" : "string" + }, "prettyPrint" : { "type" : "boolean" }, @@ -4854,22 +4848,13 @@ "type" : "boolean" }, "dontEncodeElements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "dontStripVersionsFromReferencesAtPaths" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encodeElements" : { - "type" : "array", - "items" : { - "type" : "string" - } + "type" : "string" }, "encodeElementsAppliesToChildResourcesOnly" : { "type" : "boolean" @@ -4887,6 +4872,9 @@ "overrideResourceIdWithBundleEntryFullUrl" : { "type" : "boolean" }, + "preferTypes" : { + "type" : "string" + }, "prettyPrint" : { "type" : "boolean" },
