Skip to content

Commit

Permalink
LOCAL: switch single Encounter submission to Encounter-based submissi…
Browse files Browse the repository at this point in the history
…ons, seems redundant but needed where encounters are cloned
  • Loading branch information
holmbergius committed Oct 29, 2024
1 parent c823098 commit 483d0bd
Showing 1 changed file with 55 additions and 9 deletions.
64 changes: 55 additions & 9 deletions src/main/java/org/ecocean/identity/IBEISIA.java
Original file line number Diff line number Diff line change
Expand Up @@ -2049,15 +2049,61 @@ public static JSONObject processCallback(String taskID, JSONObject resp, String
}
}
if (needIdentifying.size() > 0) {
Task task = IA.intakeAnnotations(myShepherd2, needIdentifying, parentTask, false);
// Here is a place we check downstream. IA.intakeAnnotations() will check the anns vs the identification classes in IA.properties,
// and return null if nobody was valid.
if (task != null) {
rtn.put("identificationTaskId", task.getId());
if (parentTask != null) parentTask.addChild(task);
myShepherd2.storeNewTask(task);
}
} else {

//split the results into encounters
HashMap<String,ArrayList<Annotation>> needIdentifyingMap = new HashMap<String,ArrayList<Annotation>>();
for(Annotation annot:needIdentifying) {
Encounter enc=annot.findEncounter(myShepherd2);
if(enc!=null) {
if(needIdentifyingMap.containsKey(enc.getCatalogNumber())) {
ArrayList<Annotation> annots = needIdentifyingMap.get(enc.getCatalogNumber());
annots.add(annot);
needIdentifyingMap.put(enc.getCatalogNumber(), annots);
}
else {
ArrayList<Annotation> annots = new ArrayList<Annotation>();
annots.add(annot);
needIdentifyingMap.put(enc.getCatalogNumber(), annots);
}
}
}

//check number of encounters
System.out.println("ZZZZ Sending "+needIdentifyingMap.keySet().size() +" encounters to ID.");

//send to ID by Encounter
for(String encUUID:needIdentifyingMap.keySet()) {

System.out.println("ZZZZ Sending enc "+encUUID+" to ID.");

ArrayList<Annotation> annots = needIdentifyingMap.get(encUUID);

JSONObject j = new JSONObject();
JSONObject taskParameters = j.optJSONObject("taskParameters");
if (taskParameters == null) taskParameters = new JSONObject();
JSONObject tp = new JSONObject();
JSONObject mf = new JSONObject();
taskParameters.put("matchingSetFilter", mf);

Task subParentTask = new Task();
subParentTask.setParameters(taskParameters);
myShepherd.storeNewTask(subParentTask);
myShepherd.updateDBTransaction();

Task task = IA.intakeAnnotations(myShepherd2, annots, subParentTask, false);
// Here is a place we check downstream. IA.intakeAnnotations() will check the anns vs the identification classes in IA.properties,
// and return null if nobody was valid.
if (task != null) {
rtn.put("identificationTaskId", task.getId());
if (subParentTask != null) subParentTask.addChild(task);
myShepherd2.storeNewTask(task);
}

}


}
else {
System.out.println(
"[INFO]: No annotations were suitable for identification. Check resulting identification class(es).");
myShepherd2.rollbackDBTransaction();
Expand Down

0 comments on commit 483d0bd

Please sign in to comment.