diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index 86ddbc22139b1..0bbd8325d30af 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -467,7 +467,7 @@ class BeamModulePlugin implements Plugin { google_api_services_clouddebugger : "com.google.apis:google-api-services-clouddebugger:v2-rev20200313-$google_clients_version", google_api_services_cloudresourcemanager : "com.google.apis:google-api-services-cloudresourcemanager:v1-rev20200311-$google_clients_version", google_api_services_dataflow : "com.google.apis:google-api-services-dataflow:v1b3-rev20200305-$google_clients_version", - google_api_services_healthcare : "com.google.apis:google-api-services-healthcare:v1beta1-rev20200307-$google_clients_version", + google_api_services_healthcare : "com.google.apis:google-api-services-healthcare:v1beta1-rev20200525-$google_clients_version", google_api_services_pubsub : "com.google.apis:google-api-services-pubsub:v1-rev20200312-$google_clients_version", google_api_services_storage : "com.google.apis:google-api-services-storage:v1-rev20200226-$google_clients_version", google_auth_library_credentials : "com.google.auth:google-auth-library-credentials:$google_auth_version", diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2Message.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2Message.java index 8e846db5b57db..00f2d37d2f6d7 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2Message.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2Message.java @@ -19,14 +19,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.api.services.healthcare.v1beta1.model.Message; +import com.google.api.services.healthcare.v1beta1.model.SchematizedData; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; /** The type HL7v2 message to wrap the {@link Message} model. */ public class HL7v2Message { - private static final String schematizedDataKey = "schematizedData"; - private static final String schematizedDataPrefix = "{data="; private final String name; private final String messageType; private final String sendTime; @@ -36,26 +35,6 @@ public class HL7v2Message { private String schematizedData; private final Map labels; - private static String extractDataJson(String schematizedData) { - String jsonData; - final ObjectMapper mapper = new ObjectMapper(); - if (schematizedData != null - && schematizedData.startsWith(schematizedDataPrefix) - && schematizedData.endsWith("}}")) { - jsonData = - schematizedData.substring(schematizedDataPrefix.length(), schematizedData.length() - 1); - } else { - jsonData = schematizedData; - } - try { - mapper.readTree(jsonData); - return jsonData; - } catch (IOException e) { - throw new IllegalArgumentException( - String.format("Could not validate inner schematizedData JSON: %s", e.getMessage())); - } - } - @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); @@ -73,12 +52,7 @@ public String toString() { * @return the hl7v2 message */ public static HL7v2Message fromModel(Message msg) { - final String schematizedData; - if (msg.get(schematizedDataKey) != null) { - schematizedData = extractDataJson(msg.get(schematizedDataKey).toString()); - } else { - schematizedData = null; - } + SchematizedData schematizedData = msg.getSchematizedData(); return new HL7v2Message( msg.getName(), msg.getMessageType(), @@ -86,28 +60,10 @@ public static HL7v2Message fromModel(Message msg) { msg.getCreateTime(), msg.getData(), msg.getSendFacility(), - schematizedData, + schematizedData != null ? schematizedData.getData() : null, msg.getLabels()); } - public static HL7v2Message fromMap(Map msg) { - final String schematizedData; - if (msg.get(schematizedDataKey) != null) { - schematizedData = extractDataJson(msg.get(schematizedDataKey).toString()); - } else { - schematizedData = null; - } - - return new HL7v2Message( - msg.get("name").toString(), - msg.get("messageType").toString(), - null, - msg.get("createTime").toString(), - msg.get("data").toString(), - msg.get("sendFacility").toString(), - schematizedData, - null); - } /** * To model message. * @@ -121,7 +77,7 @@ public Message toModel() { out.setCreateTime(this.getCreateTime()); out.setData(this.getData()); out.setSendFacility(this.getSendFacility()); - out.set(schematizedDataKey, this.getSchematizedData()); + out.setSchematizedData(new SchematizedData().setData(this.schematizedData)); out.setLabels(this.labels); return out; }