|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd.api.db.control.TLptsRowSetEvent
public class TLptsRowSetEvent
Class Description : The rowset event used in the TLptsRowSetFactoryListener.
Nested Class Summary | |
---|---|
static class |
TLptsRowSetEvent.EVENT_TYPE
|
Constructor Summary | |
---|---|
TLptsRowSetEvent(TLptsStatement statement,
TLptsRowSet rowSet,
TLptsRowSetEvent.EVENT_TYPE eventType,
java.lang.String primaryStatementId,
java.lang.Integer rows,
java.lang.Integer objects,
java.util.List<java.lang.String> rowSetsNotFinished)
Default Constructor for a Row Set Event. |
Method Summary | |
---|---|
TLptsRowSetEvent.EVENT_TYPE |
getEventType()
Gets the type of the event. |
java.lang.String |
getId()
Gets the unique id for this event. |
java.lang.Integer |
getObjects()
Gets the number of objects affected by an INSERT, UPDATE or DELETE statement execution. |
java.lang.String |
getPrimaryStatementId()
Getσ the Id from the Primary statement to this rowset (another rowset that feeds this rowset). |
java.lang.Integer |
getRows()
Gets the number of rows affected by an INSERT, UPDATE or DELETE statement execution. |
TLptsRowSet |
getRowSet()
Gets the actual RowSet from this event. |
java.util.List<java.lang.String> |
getRowSetsNotFinished()
Gets the list of sources that did not complete for an INSERT, UPDATE or DELETE statement execution. |
TLptsStatement |
getStatement()
Gets the executed statement for this rowset operation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TLptsRowSetEvent(TLptsStatement statement, TLptsRowSet rowSet, TLptsRowSetEvent.EVENT_TYPE eventType, java.lang.String primaryStatementId, java.lang.Integer rows, java.lang.Integer objects, java.util.List<java.lang.String> rowSetsNotFinished)
Default Constructor for a Row Set Event.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N/A
Notes :
This constructor is initiated with status data from SELECT, INSERT, DELETE and UPDATE operations. It is received
by the application through the listener for the row set factory ILptsFactoryRowSetListener.processNewRowSetRows(TLptsRowSetEvent)
.
The operations for INSERT, DELETE and UPDATE do not utilise the rowEvent, so that means that a false return from ILptsFactoryRowSetListener.processNewRowSetRows(TLptsRowSetEvent)
is implied, and therefore the return from the application is ignored. Actually, those operations only send a status at the end of processing.
All post operation functionality for INSERT, DELETE and UPDATE needs to be inserted in the processNewRowSetRows (normally some GUI feedback on the status of the operation).
Example :
... public class ProcessData implements ILptsFactoryRowSetListener { ... public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET) { while (rowSetEvent.getRowSet().nextWE()) // nextWE is a convenience function { } } return false; // we have processed the rowset here and do not want TLptsFactoryRowSet to get the rows. } public void rowEvent(TLptsRowEvent rowEvent) { } }
statement
- The executed statement that created this rowsetrowSet
- The row set occurred from statement executioneventType
- is the type of the event (NEW_SELECT_RESULTSET, INSERT_COMPLETE, UPDATE_COMPLETE, DELETE_COMPLETE, ERROR_OCCURRED)primaryStatementId
- is the id from the Primary statement in a dynamic executionrows
- This is the number of rows affected by an INSERT, DELETE or UPDATE.objects
- This is the number of objects affected by an INSERT or UPDATE.rowSetsNotFinished
- This is a list of all the source strings, on which the operation was not complete.
In other words there was a mismatch in the size(s) of the data set(s) from the source to the target or an INSERT, DELETE or UPDATE.Method Detail |
---|
public TLptsRowSetEvent.EVENT_TYPE getEventType()
Gets the type of the event.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N/A
Notes :
The types of events are as follows:
NEW_SELECT_RESULTSET - a new SELECT statement rowset has been generated. At this point we can decide whether to process this ourselves or let TLptsFactoryRowSet process it.
INSERT_COMPLETE - The insert operation is complete. The number of inserted rows is reported in getRows()
. getRowSetsNotFinished()
contains the mismatched sets.
UPDATE_COMPLETE - The update operation is complete. The number of updated rows is reported in getRows()
. getRowSetsNotFinished()
contains the mismatched sets.
DELETE_COMPLETE - The delete operation is complete. The number of deleted rows is reported in getRows()
. getRowSetsNotFinished()
contains the mismatched sets.
ERROR_OCCURRED - This is provided by the SELECT statement execution and indicates that we have no results or there was an error in the processing. TLptsLogger
contains the error.
Example :
public class ProcessData implements ILptsFactoryRowSetListener { public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.UPDATE_COMPLETE) { System.out.println("The UPDATE has completed, with " + rowSetEvent.getRows() + " rows and " + rowSetEvent.getObjects() +" objects updated."); if (!rowSetEvent.getRowSetsNotFinished().isEmpty()) { System.out.println("NOTE: The following source sets were larger than this rowset and the excess records were not included for update: "); for (String sourceName : rowSetEvent.getRowSetsNotFinished()) System.out.println(sourceName); } } return false; // This is an update so it makes no difference what we return here. rowEvent will not be called. } public void rowEvent(TLptsRowEvent rowEvent) { } }
public java.lang.String getId()
Gets the unique id for this event.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Yes.
Notes :
public java.lang.Integer getObjects()
Gets the number of objects affected by an INSERT, UPDATE or DELETE statement execution.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N/A
Notes :
Example :
public class ProcessData implements ILptsFactoryRowSetListener { public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.INSERT_COMPLETE) { System.out.println("The INSERT has completed, with " + rowSetEvent.getRows() + " rows and " + rowSetEvent.getObjects() +" objects inserted."); if (!rowSetEvent.getRowSetsNotFinished().isEmpty()) { System.out.println("NOTE: The following source sets were larger than this rowset and the excess records were not included for insert: "); for (String sourceName : rowSetEvent.getRowSetsNotFinished()) System.out.println(sourceName); } } return false; // This is an insert so it makes no difference what we return here. rowEvent will not be called. } public void rowEvent(TLptsRowEvent rowEvent) { } }
public java.lang.String getPrimaryStatementId()
Getσ the Id from the Primary statement to this rowset (another rowset that feeds this rowset).
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Yes, in case of error or full rowset without dynamic.
Notes :
Example :
public class ProcessData implements ILptsFactoryRowSetListener
{
public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
{
if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET)
{
System.out.println("New rowset is available.");
if (!rowSetEvent.getStatement().hasPrimaryStatement() && !rowSetEvent.getStatement().hasDynamicSubStatement())
{
// this is not a primary set and it does not have a primary (is not dynamic)
while (rowSetEvent.getRowSet().nextWE())
{
// process the row in here
}
return false; // TLptsFactoryRowSet should not process this rowset.
}
}
if (rowSetEvent.getPrimaryStatementId()!=null)
System.out.println("The primary statement ID for this rowset is " + rowSetEvent.getPrimaryStatementId());
return true; // This is part of a dynamic primary relationship. Let TLptsFactoryRowSet process the rows and send the the rowEvents below.
}
public void rowEvent(TLptsRowEvent rowEvent)
{
// Here were have the row events. See TLptsRowEvent
for more details.
}
}
public java.lang.Integer getRows()
Gets the number of rows affected by an INSERT, UPDATE or DELETE statement execution.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N/A
Notes :
Example :
public class ProcessData implements ILptsFactoryRowSetListener { public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.INSERT_COMPLETE) { System.out.println("The INSERT has completed, with " + rowSetEvent.getRows() + " rows and " + rowSetEvent.getObjects() +" objects inserted."); if (!rowSetEvent.getRowSetsNotFinished().isEmpty()) { System.out.println("NOTE: The following source sets were larger than this rowset and the excess records were not included for insert: "); for (String sourceName : rowSetEvent.getRowSetsNotFinished()) System.out.println(sourceName); } } return false; // This is an insert so it makes no difference what we return here. rowEvent will not be called. } public void rowEvent(TLptsRowEvent rowEvent) { } }
public TLptsRowSet getRowSet()
Gets the actual RowSet from this event.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : N/A
Notes :
Example :
public class ProcessData implements ILptsFactoryRowSetListener { ... public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET) { while (rowSetEvent.getRowSet().nextWE()) // nextWE is a convenience function { } } return false; // we have processed the rowset here and do not want TLptsFactoryRowSet to get the rows. } public void rowEvent(TLptsRowEvent rowEvent) { } }
public java.util.List<java.lang.String> getRowSetsNotFinished()
Gets the list of sources that did not complete for an INSERT, UPDATE or DELETE statement execution.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never. An empty list is returned in the worst (or shall we say best) case.
Notes :
This list contains all the source strings that had sets smaller or larger than this rowset.
The ideal situation after an update is that this list be empty.
Example :
public class ProcessData implements ILptsFactoryRowSetListener { public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.INSERT_COMPLETE) { System.out.println("The INSERT has completed, with " + rowSetEvent.getRows() + " rows and " + rowSetEvent.getObjects() +" objects inserted."); if (!rowSetEvent.getRowSetsNotFinished().isEmpty()) { System.out.println("NOTE: The following source sets were larger than this rowset and the excess records were not included for insert: "); for (String sourceName : rowSetEvent.getRowSetsNotFinished()) System.out.println(sourceName); } } return false; // This is an insert so it makes no difference what we return here. rowEvent will not be called. } public void rowEvent(TLptsRowEvent rowEvent) { } }
public TLptsStatement getStatement()
Gets the executed statement for this rowset operation.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Yes, if there was an error. TLptsLogger
contains the error.
Notes :
Example :
public class ProcessData implements ILptsFactoryRowSetListener { public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent) { if(rowSetEvent.getEventType()==TLptsRowSetEvent.EVENT_TYPE.NEW_SELECT_RESULTSET) { System.out.println("The SQL string that executed this rowset is : " + rowSetEvent.getStatement().getSqlStatementFormatted()); } return false; } public void rowEvent(TLptsRowEvent rowEvent) { } }
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |