Package com.redwood.scheduler.api.model
Interface APIResultSetCallback
- 
- All Known Subinterfaces:
- ReportDestination
 - All Known Implementing Classes:
- CollectionCallback,- ExistsCallback,- GetCountCallBack,- InternalToolResultSet,- LimitedUniqueIdListAPIResultSetCallback,- LongCallBack,- LongListCallback,- StringCallback,- UniqueIdListAPIResultSetCallback
 
 public interface APIResultSetCallbackThis interface is used to access the ResultSet of data model queries and is implemented in a number of classes listed above. You implement the interface as outlined in the following example: { //Get the job id and process server id for each job that has status Killed, Canceled, Error, or Unknown //This example is for illustration purposes only. //There are easier ways of storing these values in a Map usingexecuteObjectQuery, for example String query = "select j.JobId, j.ProcessServer from Job j where j.Status in ('K', 'A', 'E', 'U')"; final Map myMap = new HashMap<>(); jcsSession.executeQuery(query, null, new APIResultSetCallback() { public void start() { //This might be called multiple times in a row when database timeouts occur myMap.clear(); } public boolean callback(ResultSet rs, ObjectGetter objectGetter) throws SQLException { //ResultSet here stores only one row Long jobId = Long.valueOf(rs.getLong(1)); Long psId = Long.valueOf(rs.getLong(2)); myMap.put(jobId, psId); //Cool, we made it, return true return true; } public void finish() { // Do nothing } }); jcsOut.println(myMap.values().size()); }Important: The start may be called multiple times in case a query fails, in certain cases a retry is done. You have to make sure that you clear in start() or you may end up with undefined results (such as duplicates or invalid data). - See Also:
- executeObjectQuery,- executeQuery
 
- 
- 
Field SummaryFields Modifier and Type Field Description static APIResultSetCallbackNULL
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancallback(ResultSet rs, ObjectGetter objectGetter)Invoked for each result, provided that the previous invocation returnedtrue.default voidfinish()Invoked when all results have been processed.voidstart()Invoked before processing any results.
 
- 
- 
- 
Field Detail- 
NULLstatic final APIResultSetCallback NULL 
 
- 
 - 
Method Detail- 
startvoid start() throws InterruptedExceptionInvoked before processing any results.This is before any calls to callback(ResultSet, ObjectGetter)are made.Note that this may be invoked more than once under some circumstances. (Such circumstances include when the query is restarted due to underlying database errors.) - Throws:
- InterruptedException
 
 - 
callbackboolean callback(ResultSet rs, ObjectGetter objectGetter) throws SQLException, InterruptedException Invoked for each result, provided that the previous invocation returnedtrue.- Parameters:
- rs- the result-set to process
- objectGetter- an object-getter with can be used to convert the result-set into one (or more) objects.
- Returns:
- trueif this method should be invoked for the next result,- falseif subsequent results are to be discarded.
- Throws:
- SQLException- Exception thrown when a database-related error occurs
- InterruptedException
 
 - 
finishdefault void finish() throws InterruptedExceptionInvoked when all results have been processed. This is after all calls tocallback(ResultSet, ObjectGetter)have been made.- Throws:
- InterruptedException
 
 
- 
 
-