Skip to content

Commit

Permalink
sprint start
Browse files Browse the repository at this point in the history
  • Loading branch information
redmitry committed Feb 1, 2024
1 parent f84e8cf commit defbc6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>es.bsc.inb.ga4gh</groupId>
<artifactId>beacon-network-v2</artifactId>
<version>0.0.10</version>
<version>0.0.11-SNAPSHOT</version>
<packaging>war</packaging>

<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Response build(
BeaconRequestQuery query,
List<CompletableFuture<HttpResponse<AbstractBeaconResponse>>> invocations) {

AbstractBeaconResponse aggregated = null;
AbstractBeaconResponse aggregated;

final List<AbstractBeaconResponse> beacons_responses = getResultsets(invocations);

Expand All @@ -101,25 +101,19 @@ public Response build(
aggregated = response;
} else {
final BeaconResultsetsResponse response = new BeaconResultsetsResponse();
final BeaconResultsets resultsets = new BeaconResultsets();

response.setResponse(resultsets);
response.setMeta(new BeaconResponseMeta());
response.setResponseSummary(new BeaconResponseSummary(false));

for (AbstractBeaconResponse beacon_response : beacons_responses) {
if (beacon_response instanceof BeaconResultsetsResponse res) {
mergeMeta(response, res);
mergeResultsets(response, res);
mergeSummary(response, res);
}
}
aggregated = response;
}

if (aggregated instanceof BeaconResultsetsResponse resultsets) {
BeaconResultsets results = resultsets.getResponse();

for (AbstractBeaconResponse beacon_response : beacons_responses) {
if (beacon_response instanceof BeaconErrorResponse err) {
BeaconResultset empty = new BeaconResultset();
} else if (beacon_response instanceof BeaconErrorResponse err) {
final BeaconResultset empty = new BeaconResultset();
empty.setExists(false);
BeaconError error = err.getBeaconError();
if (error != null) {
Expand All @@ -133,16 +127,20 @@ public Response build(
empty.setInfo(Json.createObjectBuilder().add("error", b).build());
}

BeaconResponseMeta err_meta = err.getMeta();
final BeaconResponseMeta err_meta = err.getMeta();
if (err_meta != null) {
empty.setBeaconId(err_meta.getBeaconId());
}

List<BeaconResultset> list = resultsets.getResultSets();
if (list == null) {
resultsets.setResultSets(list = new ArrayList());
}

results.getResultSets().add(empty);
list.add(empty);
}
}
} else {
aggregated = new BeaconErrorResponse(); // todo
aggregated = response;
}

final BeaconResponseMeta beacon_network_response_meta = this.getMeta(meta, query);
Expand Down Expand Up @@ -184,9 +182,6 @@ private void mergeResultsets(BeaconResultsetsResponse target, BeaconResultsetsRe
: source.getMeta().getBeaconId();

BeaconResultsets target_response = target.getResponse();
if (target_response == null) {
target.setResponse(target_response = new BeaconResultsets());
}

List<BeaconResultset> target_resultsets = target_response.getResultSets();
if (target_resultsets == null) {
Expand All @@ -208,7 +203,7 @@ private void mergeResultsets(BeaconResultsetsResponse target, BeaconResultsetsRe

// emulate a resultset for boolean or count responses
BeaconResultset result_set = new BeaconResultset();
result_set.setId(beacon_id);
result_set.setBeaconId(beacon_id);
result_set.setInfo(source.getInfo());
result_set.setResultsHandovers(source.getBeaconHandovers());
BeaconResponseSummary summary = source.getResponseSummary();
Expand Down

0 comments on commit defbc6d

Please sign in to comment.