Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added 'success' item to each results node of a job object #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import gov.nih.ncats.common.util.CachedSupplier;
Expand Down Expand Up @@ -259,6 +260,7 @@ public JsonNode handleActionsAsync(StagingAreaService stagingAreaService,
ArrayNode[] returnFromInnerLambda = new ArrayNode[1];
executor.execute(()-> {
ArrayNode returnNodes = JsonNodeFactory.instance.arrayNode();
BooleanNode successNode= JsonNodeFactory.instance.booleanNode(true);
for (int r = 0; r < configSet.getStagingAreaRecords().size(); r++) {
String stagingAreaId = configSet.getStagingAreaRecords().get(r).getId();
String databaseRecordId = configSet.getStagingAreaRecords().get(r).getMatchingID();
Expand All @@ -270,12 +272,18 @@ public JsonNode handleActionsAsync(StagingAreaService stagingAreaService,
log.trace("about to call runnable to call processOneRecord");
adminService.runAs(auth, runnable);
log.trace("got back singleReturn {}", singleReturn[0].toPrettyString());
if(singleReturn[0].get("message")!=null && singleReturn[0].get("message").textValue().startsWith("Error:")) {
singleReturn[0].put("success", false);
}else {
singleReturn[0].put("success", true);
}
} catch (Exception e) {
log.error("error during import processing: ", e);
singleReturn[0] = JsonNodeFactory.instance.objectNode();
singleReturn[0].put("id", stagingAreaId);
singleReturn[0].put("status", "INTERNAL_SERVER_ERROR");
singleReturn[0].put("message", "error: " + e.getMessage());
singleReturn[0].put("success", false);
}
int finalishRecord = r+1;
TransactionTemplate transactionTemplateUpdateCount = new TransactionTemplate(transactionManager);
Expand All @@ -285,6 +293,7 @@ public JsonNode handleActionsAsync(StagingAreaService stagingAreaService,
log.trace("appending node to returnNodes");
}
returnFromInnerLambda[0] =returnNodes;

//now synchronize all records -- tidy up relationships and other entity-entity links
if(needToSave(configSet.getProcessingActions())){
log.trace("going to synchronize entities");
Expand Down