Skip to content

Commit

Permalink
Search facility exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
remarq committed Dec 29, 2021
1 parent 054bb56 commit 913968b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion doc/release.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Release 8.68.2
Exception handling refinement in specimen upload.
Exception handling refinement in specimen upload and search facility.
New profileQuery system.
manager class reload tuning.

Expand Down
6 changes: 3 additions & 3 deletions src/org/calacademy/antweb/search/AdvancedSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class AdvancedSearch extends GenericSearch implements Serializable {

public static String s_query = null;

protected ArrayList<ResultItem> createInitialResults() throws SearchException {
protected ArrayList<ResultItem> createInitialResults() throws SearchException, SQLException {

int sufficientCriteria = 3;
// We expect to receive status and family so have 2 already by default. If family
Expand Down Expand Up @@ -391,7 +391,7 @@ protected ArrayList<ResultItem> createInitialResults() throws SearchException {
} catch (SQLException e) {
s_log.error("createInitialResults() e:" + e + " query:" + theQuery);
//AntwebUtil.logShortStackTrace(e, 18);
return null;
throw e;
}
}

Expand All @@ -408,7 +408,7 @@ public static String getQuery() {
add status to specimen
*/

public void setResults() throws SearchException {
public void setResults() throws SearchException, SQLException {
// first do a big search getting images, types, and the validity
// then for the invalid ones - do another search to get the valid names
// put all of these in an array
Expand Down
8 changes: 4 additions & 4 deletions src/org/calacademy/antweb/search/AdvancedSearchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void addToSearch(StringBuffer sb, String field, String value, String sea
}

// This is a method called by ObjectMapDb. Used on geolocale pages.
public Map getGoogleMap(String country, String adm1, String resultRank, String output, Connection connection) {
public Map getGoogleMap(String country, String adm1, String resultRank, String output, Connection connection) throws SQLException {
//A.log("getGoogleMapFunction() country:" + country + " adm1:" + adm1 + " resultRank:" + resultRank + " output:" + output);
SearchParameters searchParameters = new SearchParameters();
searchParameters.setFamily(Family.FORMICIDAE);
Expand Down Expand Up @@ -130,7 +130,7 @@ public Map getGoogleMap(String country, String adm1, String resultRank, String o
}

// This is a method called by ObjectMapDb. Used on museum pages.
public Map getGoogleMap(Museum museum, String resultRank, String output, Connection connection) {
public Map getGoogleMap(Museum museum, String resultRank, String output, Connection connection) throws SQLException {
String museumCode = museum.getCode();
//A.log("getGoogleMapFunction() country:" + country + " adm1:" + adm1 + " resultRank:" + resultRank + " output:" + output);
SearchParameters searchParameters = new SearchParameters();
Expand Down Expand Up @@ -161,7 +161,7 @@ public Map getGoogleMap(Museum museum, String resultRank, String output, Connect
}

// This is a method called by ObjectMapDb. Used on group pages.
public Map getGoogleMap(Group group, String resultRank, String output, Connection connection) {
public Map getGoogleMap(Group group, String resultRank, String output, Connection connection) throws SQLException {
int groupId = group.getId();
//A.log("getGoogleMap() groupId:" + groupId + " resultRank:" + resultRank + " output:" + output);
SearchParameters searchParameters = new SearchParameters();
Expand Down Expand Up @@ -226,7 +226,7 @@ public ArrayList<ResultItem> getSearchResults(HttpServletRequest request,

// This version is used internally, for instance to create the geolocale maps. (Object_Maps table)
public ArrayList<ResultItem> getSearchResults(Connection connection, SearchParameters searchParameters)
throws IOException, ServletException, SearchException {
throws IOException, ServletException, SearchException, SQLException {
// s_log.warn("getSearchResults()");

AdvancedSearchResults results = new AdvancedSearchResults();
Expand Down
25 changes: 14 additions & 11 deletions src/org/calacademy/antweb/search/GenericSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class GenericSearch implements Serializable {
protected ArrayList<ResultItem> results;
protected Pattern inQuotes = Pattern.compile("(\".*?\")");

public ArrayList<ResultItem> getResults() throws SearchException {
public ArrayList<ResultItem> getResults() throws SearchException, SQLException {

if (results == null) {
setResults();
Expand All @@ -46,7 +46,7 @@ public ArrayList<ResultItem> getResults() throws SearchException {
return results;
}

public void setResults() throws SearchException {
public void setResults() throws SearchException, SQLException {
//A.log("GenericSearch.setResults()");
// first do a big search getting images, types, and the validity
// then for the invalid ones - do another search to get the valid names
Expand Down Expand Up @@ -85,7 +85,7 @@ public void setResults() throws SearchException {

}

protected ArrayList<ResultItem> filterByProject(ArrayList<ResultItem> currentList, String project) {
protected ArrayList<ResultItem> filterByProject(ArrayList<ResultItem> currentList, String project) throws SQLException {
//A.log("GenericSearch.filterByProject() project:" + project);
if ((project == null)
|| (project.length() <= 0)
Expand Down Expand Up @@ -149,7 +149,7 @@ protected ArrayList<ResultItem> filterByProject(ArrayList<ResultItem> currentLis
return theList;
} catch (SQLException e) {
s_log.error("filterByProject() query:" + theQuery + " " + e);
return null;
throw e;
} finally {
DBUtil.close(stmt, rset, this, "filterByProject()");
}
Expand All @@ -162,7 +162,7 @@ protected ArrayList<ResultItem> filterByProject(ArrayList<ResultItem> currentLis
// The second pass deals with cases where we don't have the specimen
// code. For these, we'll execute a prepared statement
//
protected ArrayList<SearchItem> setResultTypes(ArrayList<SearchItem> currentList, String project) {
protected ArrayList<SearchItem> setResultTypes(ArrayList<SearchItem> currentList, String project) throws SQLException {
//A.log("GenericSearch.setResultTypes() project:" + project);

if ((currentList == null) || (currentList.size() == 0)) {
Expand Down Expand Up @@ -239,6 +239,7 @@ protected ArrayList<SearchItem> setResultTypes(ArrayList<SearchItem> currentList
} catch (SQLException e) {
s_log.error("setResultTypes() 1 theQuery:" + theQuery + " e:" + e);
org.calacademy.antweb.util.AntwebUtil.logStackTrace(e);
throw e;
} finally {
DBUtil.close(prepStmt, rset, this, "setResultTypes() 1");
}
Expand Down Expand Up @@ -289,7 +290,8 @@ protected ArrayList<SearchItem> setResultTypes(ArrayList<SearchItem> currentList
}
} catch (SQLException e) {
s_log.error("setResultTypes() 2 theQuery:" + theQuery + " e:" + e);
org.calacademy.antweb.util.AntwebUtil.logStackTrace(e);
org.calacademy.antweb.util.AntwebUtil.logShortStackTrace(e);
throw e;
} finally {
DBUtil.close(stmt, rset, this, "setResultTypes() 2");
}
Expand Down Expand Up @@ -318,7 +320,7 @@ protected ArrayList<SearchItem> setResultTypes(ArrayList<SearchItem> currentList
return currentList;
}

protected ArrayList<ResultItem> createInitialResults() throws SearchException {
protected ArrayList<ResultItem> createInitialResults() throws SearchException, SQLException {
//A.log("GenericSearch.createInitialResults()");

// Need Subspecies logic?!
Expand Down Expand Up @@ -368,13 +370,13 @@ protected ArrayList<ResultItem> createInitialResults() throws SearchException {
return getListFromRset(GENERIC, rset, null, theQuery);
} catch (SQLException e) {
s_log.error("createInitialResults() query:" + theQuery + " e:" + e);
throw new SearchException(e.toString());
throw e;
} finally {
DBUtil.close(stmt, rset, this, "createInitialResults()");
}
}

protected ArrayList<ResultItem> getListFromRset(ResultSet rset, SearchItem synonymousItem, String theQuery, int numToShow) {
protected ArrayList<ResultItem> getListFromRset(ResultSet rset, SearchItem synonymousItem, String theQuery, int numToShow) throws SQLException {
//A.log("GenericSearch.getListFromRset(rset..)");
ArrayList<ResultItem> bigList = getListFromRset(GENERIC, rset, synonymousItem, theQuery);
ArrayList<ResultItem> smallList = new ArrayList<>();
Expand All @@ -395,7 +397,7 @@ protected ArrayList<ResultItem> getListFromRset(ResultSet rset, SearchItem synon
public static int DESC_EDIT = 5;
public static int SEARCH = 6;

protected ArrayList<ResultItem> getListFromRset(int searchType, ResultSet rset, SearchItem synonymousItem, String theQuery) {
protected ArrayList<ResultItem> getListFromRset(int searchType, ResultSet rset, SearchItem synonymousItem, String theQuery) throws SQLException {
//A.log("GenericSearch.getListFromRset(searchType...)");
ArrayList<ResultItem> theList = new ArrayList<>();
String family = null;
Expand Down Expand Up @@ -636,7 +638,8 @@ protected ArrayList<ResultItem> getListFromRset(int searchType, ResultSet rset,
}
} catch (SQLException e) {
s_log.error("getListFromRset() e:" + e + " query:" + theQuery);
AntwebUtil.logStackTrace(e);
AntwebUtil.logShortStackTrace(e);
throw e;
}

// AntwebUtil.logStackTrace();
Expand Down
31 changes: 21 additions & 10 deletions src/org/calacademy/antweb/util/UtilDataAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,17 +483,28 @@ private OperationDetails doAction(String action, UtilForm form, Login accessLogi
}

if (action.equals("regenerateAllAntweb")) {
ProjTaxonDb projTaxonDb = (new ProjTaxonDb(connection));
projTaxonDb.regenerateAllAntweb(); // Proj_taxon records
message = "All Antweb regenerated";

/* moved into regen
(new ProjTaxonCountDb(connection)).countCrawl("allantwebants"); // Proj_taxon counts
projTaxonDb.finishRegenerateAllAntweb();
(new ProjectDb(connection)).updateCounts("allantwebants"); // Project counts
*/
}
ProjTaxonDb projTaxonDb = (new ProjTaxonDb(connection));
projTaxonDb.regenerateAllAntweb(); // Proj_taxon records
message = "All Antweb regenerated";
}

/*
if (action.equals("runCountCrawls")) {
ProjTaxonCountDb projTaxonCountDb = (new ProjTaxonCountDb(connection));
projTaxonCountDb.countCrawl("allantwebants"); // Proj_taxon counts
//projTaxonDb.finishRegenerateAllAntweb();
//projTaxonDb.updateCounts("allantwebants"); // Project counts
BioregionTaxonCountDb bioregionTaxonCountDb = (new BioregionTaxonCountDb(connection));
bioregionTaxonCountDb.childrenCountCrawl();
GeolocaleTaxonCountDb geolocaleTaxonCountDb = (new GeolocaleTaxonCountDb(connection));
geolocaleTaxonCountDb.childrenCountCrawl(num);
MuseumTaxonCountDb museumTaxonCountDb = (new MuseumTaxonCountDb(connection));
museumTaxonCountDb.childrenCountCrawl();
}
*/
// ---------- Count Crawls -------------------------
// https://antweb-stg/utilData.do?action=geolocaleTaxonCountCrawl&num=392
if (action.equals("geolocaleTaxonCountCrawl")) {
Expand Down

0 comments on commit 913968b

Please sign in to comment.