Skip to content

Commit 1bd2631

Browse files
authored
Merge branch 'main' into all_filters_encounter_search
2 parents 2fb2e7a + aae82a2 commit 1bd2631

File tree

11 files changed

+334
-15
lines changed

11 files changed

+334
-15
lines changed

src/main/java/org/ecocean/Annotation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public long setVersion() {
134134

135135
public JSONObject opensearchMapping() {
136136
JSONObject map = super.opensearchMapping();
137-
JSONObject keywordType = new org.json.JSONObject("{\"type\": \"keyword\"}");
137+
JSONObject keywordType = new JSONObject("{\"type\": \"keyword\"}");
138138

139139
/*
140140
JSONObject keywordNormalType = new org.json.JSONObject(
@@ -1373,7 +1373,7 @@ public static Base createFromApi(JSONObject payload, List<File> files, Shepherd
13731373
public static Object validateFieldValue(String fieldName, JSONObject data)
13741374
throws ApiException {
13751375
if (data == null) throw new ApiException("empty payload");
1376-
org.json.JSONObject error = new org.json.JSONObject();
1376+
JSONObject error = new JSONObject();
13771377
error.put("fieldName", fieldName);
13781378
String exMessage = "invalid value for " + fieldName;
13791379
Object returnValue = null;

src/main/java/org/ecocean/Encounter.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,6 +4350,51 @@ public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd
43504350
}
43514351
}
43524352

4353+
public void opensearchIndexDeep()
4354+
throws IOException {
4355+
this.opensearchIndex();
4356+
4357+
final String encId = this.getId();
4358+
ExecutorService executor = Executors.newFixedThreadPool(4);
4359+
Runnable rn = new Runnable() {
4360+
public void run() {
4361+
Shepherd bgShepherd = new Shepherd("context0");
4362+
bgShepherd.setAction("Encounter.opensearchIndexDeep_" + encId);
4363+
bgShepherd.beginDBTransaction();
4364+
try {
4365+
Encounter enc = bgShepherd.getEncounter(encId);
4366+
if ((enc == null) || !enc.hasMarkedIndividual()) {
4367+
// bgShepherd.rollbackAndClose();
4368+
executor.shutdown();
4369+
return;
4370+
}
4371+
MarkedIndividual indiv = enc.getIndividual();
4372+
System.out.println("opensearchIndexDeep() background indexing indiv " +
4373+
indiv.getId() + " via enc " + encId);
4374+
try {
4375+
indiv.opensearchIndex();
4376+
} catch (Exception ex) {
4377+
System.out.println("opensearchIndexDeep() background indexing " +
4378+
indiv.getId() + " FAILED: " + ex.toString());
4379+
ex.printStackTrace();
4380+
}
4381+
} catch (Exception e) {
4382+
System.out.println("opensearchIndexDeep() backgrounding Encounter " + encId +
4383+
" hit an exception.");
4384+
e.printStackTrace();
4385+
} finally {
4386+
bgShepherd.rollbackAndClose();
4387+
}
4388+
System.out.println("opensearchIndexDeep() backgrounding Encounter " + encId +
4389+
" finished.");
4390+
executor.shutdown();
4391+
}
4392+
};
4393+
System.out.println("opensearchIndexDeep() begin backgrounding indiv for " + this);
4394+
executor.execute(rn);
4395+
System.out.println("opensearchIndexDeep() [foreground] finished for Encounter " + encId);
4396+
}
4397+
43534398
// given a doc from opensearch, can user access it?
43544399
public static boolean opensearchAccess(org.json.JSONObject doc, User user,
43554400
Shepherd myShepherd) {

0 commit comments

Comments
 (0)