Search in sources :

Example 1 with Empty

use of com.google.api.services.healthcare.v1.model.Empty in project beam by apache.

the class HL7V2MessagePagesTest method test_EmptyStoreEmptyIterator.

/**
 * Test empty store.
 */
@Test
public void test_EmptyStoreEmptyIterator() throws IOException {
    Mockito.doReturn(new ListMessagesResponse()).when(client).makeSendTimeBoundHL7v2ListRequest("foo", null, null, null, null, null);
    HL7v2MessagePages emptyPages = new HL7v2MessagePages(client, "foo", null, null);
    // In the case that the store is empty we should return a single empty list.
    assertFalse(emptyPages.iterator().hasNext());
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse) HL7v2MessagePages(org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages) Test(org.junit.Test)

Example 2 with Empty

use of com.google.api.services.healthcare.v1.model.Empty in project beam by apache.

the class HttpHealthcareApiClient method uploadToDicomStore.

@Override
public Empty uploadToDicomStore(String webPath, String filePath) throws IOException, URISyntaxException {
    byte[] dcmFile = Files.readAllBytes(Paths.get(filePath));
    ByteArrayEntity requestEntity = new ByteArrayEntity(dcmFile);
    String uri = String.format("%sv1/%s/dicomWeb/studies", client.getRootUrl(), webPath);
    URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", credentials.getAccessToken().getTokenValue());
    HttpUriRequest request = RequestBuilder.post(uriBuilder.build()).setEntity(requestEntity).addHeader("Content-Type", "application/dicom").build();
    httpClient.execute(request);
    return new Empty();
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) Empty(com.google.api.services.healthcare.v1.model.Empty) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 3 with Empty

use of com.google.api.services.healthcare.v1.model.Empty in project java-docs-samples by GoogleCloudPlatform.

the class BatchOperationSample method batchDeleteJobs.

// [END batch_job_update]
// [START batch_job_delete]
public static void batchDeleteJobs(List<Job> jobsToBeDeleted) throws IOException {
    BatchRequest batchDelete = talentSolutionClient.batch();
    for (Job job : jobsToBeDeleted) {
        talentSolutionClient.projects().jobs().delete(job.getName()).queue(batchDelete, new JsonBatchCallback<Empty>() {

            @Override
            public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
                System.out.println("Delete Error Message: " + e.getMessage());
            }

            @Override
            public void onSuccess(Empty empty, HttpHeaders responseHeaders) {
                System.out.println("Job deleted");
            }
        });
        batchDelete.execute();
    }
}
Also used : BatchRequest(com.google.api.client.googleapis.batch.BatchRequest) HttpHeaders(com.google.api.client.http.HttpHeaders) Empty(com.google.api.services.jobs.v3.model.Empty) GoogleJsonError(com.google.api.client.googleapis.json.GoogleJsonError) Job(com.google.api.services.jobs.v3.model.Job)

Example 4 with Empty

use of com.google.api.services.healthcare.v1.model.Empty in project jaxb-ri by eclipse-ee4j.

the class XmlSchemaBuilder method modelGroup.

@Override
public Leaf modelGroup(XSModelGroup mg) {
    XSParticle[] children = mg.getChildren();
    if (children.length == 0)
        return new Empty(mg.getLocator());
    Leaf l = particle(children[0]);
    for (int i = 1; i < children.length; i++) l.merge(particle(children[i]));
    return l;
}
Also used : Empty(com.sun.tools.txw2.model.Empty) XSParticle(com.sun.xml.xsom.XSParticle) Leaf(com.sun.tools.txw2.model.Leaf) XSIdentityConstraint(com.sun.xml.xsom.XSIdentityConstraint)

Example 5 with Empty

use of com.google.api.services.healthcare.v1.model.Empty in project beam by apache.

the class HttpHealthcareApiClient method getEarliestHL7v2SendTime.

@Override
public Instant getEarliestHL7v2SendTime(String hl7v2Store, @Nullable String filter) throws IOException {
    ListMessagesResponse response = client.projects().locations().datasets().hl7V2Stores().messages().list(hl7v2Store).setFilter(filter).set("view", // needed to retrieve the value for sendtime
    "full").setOrderBy(// default order is ascending
    "sendTime").setPageSize(// Only interested in the earliest sendTime
    1).execute();
    if (response.isEmpty()) {
        throw new IllegalArgumentException(String.format("Could not find earliest send time. The filter %s  matched no results on " + "HL7v2 Store: %s", filter, hl7v2Store));
    }
    String sendTime = response.getHl7V2Messages().get(0).getSendTime();
    if (Strings.isNullOrEmpty(sendTime)) {
        LOG.warn(String.format("Earliest message in %s has null or empty sendTime defaulting to Epoch.", hl7v2Store));
        return Instant.ofEpochMilli(0);
    }
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages#Message
    return Instant.parse(sendTime);
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse)

Aggregations

ListMessagesResponse (com.google.api.services.healthcare.v1.model.ListMessagesResponse)4 HL7v2MessagePages (org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages)2 Test (org.junit.Test)2 BatchRequest (com.google.api.client.googleapis.batch.BatchRequest)1 GoogleJsonError (com.google.api.client.googleapis.json.GoogleJsonError)1 HttpHeaders (com.google.api.client.http.HttpHeaders)1 Empty (com.google.api.services.healthcare.v1.model.Empty)1 Message (com.google.api.services.healthcare.v1.model.Message)1 Empty (com.google.api.services.jobs.v3.model.Empty)1 Job (com.google.api.services.jobs.v3.model.Job)1 Empty (com.sun.tools.txw2.model.Empty)1 Leaf (com.sun.tools.txw2.model.Leaf)1 XSIdentityConstraint (com.sun.xml.xsom.XSIdentityConstraint)1 XSParticle (com.sun.xml.xsom.XSParticle)1 List (java.util.List)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)1