Skip to content

Commit

Permalink
Merge pull request #835 from NASA-AMMOS/fix/scheduling-sim-results-ch…
Browse files Browse the repository at this point in the history
…ild-activities

Use simulated id rather than directive id as key for simulatedActivityRecords
  • Loading branch information
mattdailis authored Apr 3, 2023
2 parents cc591d1 + cde58eb commit dd87466
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1116,11 +1116,11 @@ private void postActivities(
{
final var simulatedActivityRecords = simulatedActivities.entrySet().stream()
.collect(Collectors.toMap(
e -> simulationActivityDirectiveIdToMerlinActivityDirectiveId.get(e.getValue().directiveId().get()).id(),
e -> e.getKey().id(),
e -> simulatedActivityToRecord(e.getValue(), simulationActivityDirectiveIdToMerlinActivityDirectiveId)));
final var allActivityRecords = unfinishedActivities.entrySet().stream()
.collect(Collectors.toMap(
e -> simulationActivityDirectiveIdToMerlinActivityDirectiveId.get(e.getValue().directiveId().get()).id(),
e -> e.getKey().id(),
e -> unfinishedActivityToRecord(e.getValue(), simulationActivityDirectiveIdToMerlinActivityDirectiveId)));
allActivityRecords.putAll(simulatedActivityRecords);
final var simIdToPgId = postSpans(
Expand Down 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 dd87466

Please sign in to comment.