Skip to content

Commit

Permalink
limit (manual) indexing to only do Annotations with matchAgainst=true…
Browse files Browse the repository at this point in the history
… and acmId set
  • Loading branch information
naknomum committed Feb 6, 2025
1 parent 238fe75 commit 7c439bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/org/ecocean/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd
}
}

// TODO should this also be limited by matchAgainst and acmId?
@Override public String getAllVersionsSql() {
return "SELECT \"ID\", \"VERSION\" AS version FROM \"ANNOTATION\" ORDER BY version";
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/ecocean/Shepherd.java
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,26 @@ public Iterator getAllAnnotationsNoQuery() {
}
}

// note: where clause can also contain " ORDER BY xxx"
public Iterator getAnnotationsFilter(String jdoWhereClause) {
Query query = null;

try {
query = pm.newQuery("SELECT FROM org.ecocean.Annotation WHERE " + jdoWhereClause);
Collection c = (Collection)(query.execute());
List list = new ArrayList(c);
Iterator it = list.iterator();
query.closeAll();
return it;
} catch (Exception npe) {
System.out.println(
"Error encountered when trying to execute getAllAnnotationsFilter. Returning a null iterator.");
npe.printStackTrace();
if (query != null) query.closeAll();
return null;
}
}

public Iterator<Encounter> getAllAnnotations(String order) {
Extent extClass = pm.getExtent(Annotation.class, true);
Query q = pm.newQuery(extClass);
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/appadmin/opensearchSync.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if (endNum > 0) {
if (indexName.equals("encounter")) {
itr = myShepherd.getAllEncounters("catalogNumber");
} else if (indexName.equals("annotation")) {
itr = myShepherd.getAllAnnotations("id");
itr = myShepherd.getAnnotationsFilter("matchAgainst == true && acmId != null ORDER BY id");
} else if (indexName.equals("individual")) {
itr = myShepherd.getAllMarkedIndividuals();
}
Expand Down

0 comments on commit 7c439bc

Please sign in to comment.