Skip to content

Commit

Permalink
Merge pull request #3352 from IBM/issue-3087
Browse files Browse the repository at this point in the history
Bulk Data 2.0.0 Export Response needs updates to PollingLocationResponse #3087
  • Loading branch information
lmsurpre authored Feb 16, 2022
2 parents 6a0e929 + 0115896 commit b7e4eda
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ public PollingLocationResponse status(String job) throws Exception {
result.setOutput(Collections.emptyList());
}

if (result.getDeleted() == null || result.getDeleted().isEmpty()) {
result.setDeleted(Collections.emptyList());
}

} catch (FHIROperationException fe) {
throw fe;
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2021
* (C) Copyright IBM Corp. 2019, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -51,6 +51,7 @@ public class PollingLocationResponse {
private Boolean requiresAccessToken;
private List<Output> output;
private List<Output> error;
private List<Output> deleted;
private JsonObject extension;

public String getTransactionTime() {
Expand Down Expand Up @@ -100,6 +101,14 @@ public void setError(List<Output> error) {
this.error = error;
}

public List<Output> getDeleted() {
return deleted;
}

public void setDeleted(List<Output> deleted) {
this.deleted = deleted;
}

public JsonObject getExtension() {
return extension;
}
Expand Down Expand Up @@ -259,6 +268,15 @@ public static String generate(PollingLocationResponse response) throws IOExcepti
generator.writeEnd();
}

if (response.getDeleted() != null) {
// outputs the output array.
generator.writeStartArray("deleted");
for (Output output : response.getDeleted()) {
Output.Writer.generate(generator, output);
}
generator.writeEnd();
}

if (response.getExtension() != null) {
generator.write("extension", response.getExtension());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2021
* (C) Copyright IBM Corp. 2019, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -292,6 +292,10 @@ public void testResponseMetadataJsonFullWithOutputAndError() throws IOException
errors.add(new Output("type3", "url3", "3000"));
errors.add(new Output("type4", "url4", "4000"));

List<Output> deleted = new ArrayList<>();
deleted.add(new Output("dtype3", "urld3", "13000"));
deleted.add(new Output("dtype4", "urld4", "44000"));

PollingLocationResponse metadata = new PollingLocationResponse();

metadata.setRequest("request");
Expand All @@ -300,23 +304,17 @@ public void testResponseMetadataJsonFullWithOutputAndError() throws IOException
String s = now.getValue().format(Instant.PARSER_FORMATTER).toString();
metadata.setTransactionTime(s);
assertNotNull(metadata.getTransactionTime());

// Set the output arrays
metadata.setError(errors);

metadata.setDeleted(deleted);
metadata.setOutput(outputs);

assertFalse(metadata.getOutput().isEmpty());
assertFalse(metadata.getError().isEmpty());
assertEquals(
PollingLocationResponse.Writer.generate(metadata)
.replaceFirst(s, ""),
"{\n" + " \"transactionTime\": \"\",\n"
+ " \"request\": \"request\",\n" + " \"requiresAccessToken\": false,\n"
+ " \"output\": [\n" + " {\n" + " \"type\": \"type\",\n"
+ " \"url\": \"url\",\n" + " \"count\": 1000\n" + " },\n"
+ " {\n" + " \"type\": \"type2\",\n" + " \"url\": \"url2\",\n"
+ " \"count\": 2000\n" + " }\n" + " ],\n" + " \"error\": [\n"
+ " {\n" + " \"type\": \"type3\",\n" + " \"url\": \"url3\",\n"
+ " \"count\": 3000\n" + " },\n" + " {\n"
+ " \"type\": \"type4\",\n" + " \"url\": \"url4\",\n"
+ " \"count\": 4000\n" + " }\n" + " ]\n" + "}");
"{\n \"transactionTime\": \"\",\n \"request\": \"request\",\n \"requiresAccessToken\": false,\n \"output\": [\n {\n \"type\": \"type\",\n \"url\": \"url\",\n \"count\": 1000\n },\n {\n \"type\": \"type2\",\n \"url\": \"url2\",\n \"count\": 2000\n }\n ],\n \"error\": [\n {\n \"type\": \"type3\",\n \"url\": \"url3\",\n \"count\": 3000\n },\n {\n \"type\": \"type4\",\n \"url\": \"url4\",\n \"count\": 4000\n }\n ],\n \"deleted\": [\n {\n \"type\": \"dtype3\",\n \"url\": \"urld3\",\n \"count\": 13000\n },\n {\n \"type\": \"dtype4\",\n \"url\": \"urld4\",\n \"count\": 44000\n }\n ]\n}");
}
}

0 comments on commit b7e4eda

Please sign in to comment.