Skip to content

Commit

Permalink
Handle both json object and array response
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdailis committed Apr 1, 2023
1 parent f2caf57 commit cde58eb
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1166,10 +1166,18 @@ public void updateSimulatedActivityParentsAction(

final JsonObject response;
response = postRequest(req, arguments).get();
final var affected_rows = response.getJsonObject("data").getJsonObject("update_span_many").getInt("affected_rows");
if(affected_rows != updateCounter) {
throw new PlanServiceException("not the same size");
}
final var jsonValue = response.getJsonObject("data").get("update_span_many");
var affected_rows = 0;
if (jsonValue.getValueType() == JsonValue.ValueType.ARRAY) {
for (final var jsonObject : response.getJsonObject("data").getJsonArray("update_span_many").getValuesAs(JsonObject.class)) {
affected_rows += jsonObject.getInt("affected_rows");
}
} else {
affected_rows = response.getJsonObject("data").getJsonObject("update_span_many").getInt("affected_rows");
}
if(affected_rows != updateCounter) {
throw new PlanServiceException("not the same size");
}
}

private static SpanRecord simulatedActivityToRecord(final SimulatedActivity activity,
Expand Down

0 comments on commit cde58eb

Please sign in to comment.