|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.wabit.AbstractWabitObject
ca.sqlpower.wabit.QueryCache
public class QueryCache
This method will be able to execute and cache the results of a query. It also
delegates some of the methods to the QueryImpl contained in it.
| Nested Class Summary | |
|---|---|
static class |
QueryCache.WabitObjectOrder
FIXME This enum defines the WabitObject child classes a
QueryCache takes as well as the ordinal order of these child
classes such that the class going before does not depend on the class
that goes after. |
| Constructor Summary | |
|---|---|
QueryCache(QueryCache q)
This makes a copy of the given query cache. |
|
QueryCache(QueryCache q,
boolean connectListeners)
This makes a copy of the given query cache. |
|
QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping)
Creates a Query that caches the last set of results that were
returned when during the last execution. |
|
QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping,
boolean prepopulateConstants)
Creates a Query that caches the last set of results that were
returned when during the last execution. |
|
QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping,
boolean prepopulateConstants,
WabitConstantsContainer newConstantsContainer)
Creates a Query that caches the last set of results that were
returned when during the last execution. |
|
| Method Summary | |
|---|---|
protected void |
addChildImpl(WabitObject child,
int index)
This is the object specific implementation of #addChild(WabitObject). |
void |
addItem(ca.sqlpower.query.Item col)
|
void |
addJoin(ca.sqlpower.query.SQLJoin join)
|
void |
addQueryChangeListener(ca.sqlpower.query.QueryChangeListener l)
|
void |
addResultSetListener(ResultSetListener listener)
Adds the given listener to this result set producer's list of interested parties. |
void |
addTable(ca.sqlpower.query.Container container)
|
void |
addTable(ca.sqlpower.query.Container container,
int index)
|
boolean |
allowsChildren()
Returns true if this object may contain children. |
void |
cancel()
Cancels this query's execution if it is currently running. |
int |
childPositionOffset(java.lang.Class<? extends WabitObject> childType)
Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type. |
CleanupExceptions |
cleanup()
Default cleanup method that does nothing. |
boolean |
containsCrossJoins()
|
void |
endCompoundEdit()
|
java.util.concurrent.Future<ResultSetAndUpdateCountCollection> |
execute()
Executes the current query represented by this object, returning the results from the query's execution. |
boolean |
executeStatement()
Executes the current SQL query, returning a cached copy of the result set. |
boolean |
executeStatement(boolean fetchFullResults)
Executes the current SQL query, returning a cached copy of the result set that is either a subset of the full results, limited by the session's row limit, or the full result set. |
protected void |
fireCompoundEditEnded(ca.sqlpower.util.TransactionEvent evt)
|
protected void |
fireCompoundEditStarted(ca.sqlpower.util.TransactionEvent evt)
|
protected void |
fireContainerAdded(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
fireContainerRemoved(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
fireItemAdded(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
fireItemPropertyChangeEvent(java.beans.PropertyChangeEvent evt)
|
protected void |
fireItemRemoved(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
fireJoinAdded(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
fireJoinPropertyChangeEvent(java.beans.PropertyChangeEvent evt)
|
protected void |
fireJoinRemoved(ca.sqlpower.query.QueryChangeEvent evt)
|
protected void |
firePropertyChangeEvent(java.beans.PropertyChangeEvent evt)
|
void |
generateNewUUID()
Sets the UUID of this object to a newly generated UUID. |
java.lang.String |
generateQuery()
|
ca.sqlpower.sql.CachedRowSet |
getCachedRowSet()
|
java.util.List<? extends WabitObject> |
getChildren()
Returns an unmodifiable list of the children in this WabitObject. |
ca.sqlpower.query.Container |
getConstantsContainer()
|
ca.sqlpower.sqlobject.SQLDatabase |
getDatabase()
|
ca.sqlpower.sql.JDBCDataSource |
getDataSource()
|
ca.sqlpower.sqlobject.SQLDatabaseMapping |
getDBMapping()
|
java.util.List<WabitObject> |
getDependencies()
Returns a list of all WabitObjects that this Wabit object is
dependent on. |
boolean |
getExecuteQueriesWithCrossJoins()
|
java.util.List<ca.sqlpower.query.Container> |
getFromTableList()
|
java.lang.String |
getGlobalWhereClause()
|
java.util.Collection<ca.sqlpower.query.SQLJoin> |
getJoins()
|
boolean |
getMoreResults()
|
java.lang.String |
getName()
Returns the short name for this object. |
java.util.List<ca.sqlpower.query.Item> |
getOrderByList()
|
boolean |
getPromptForCrossJoins()
|
java.sql.ResultSet |
getResultSet()
|
protected java.util.List<ca.sqlpower.sql.CachedRowSet> |
getResultSets()
|
int |
getRowLimit()
|
java.util.List<ca.sqlpower.query.Item> |
getSelectedColumns()
|
java.lang.String |
getStatement()
|
int |
getStreamingRowLimit()
|
int |
getUpdateCount()
|
java.lang.String |
getUserModifiedQuery()
|
WabitConstantsContainer |
getWabitConstantsContainer()
|
WabitDataSource |
getWabitDataSource()
|
int |
getZoomLevel()
|
int |
indexOfSelectedItem(ca.sqlpower.query.Item item)
|
boolean |
isAutomaticallyExecuting()
|
boolean |
isGroupingEnabled()
|
boolean |
isPhantomQuery()
If this returns true then this query cache is a query that should not be hooked up to listeners. |
boolean |
isRunning()
Returns true if this Wabit object is doing something in the background. |
boolean |
isScriptModified()
|
boolean |
isStreaming()
|
void |
moveItem(ca.sqlpower.query.Item movedColumn,
int toIndex)
|
void |
moveOrderBy(ca.sqlpower.query.Item item,
int index)
|
void |
moveOrderByItemToEnd(ca.sqlpower.query.Item item)
|
void |
orderColumn(ca.sqlpower.query.Item item,
ca.sqlpower.query.QueryImpl.OrderByArgument ordering)
|
protected boolean |
removeChildImpl(WabitObject child)
This is the object specific implementation of removeChild. |
void |
removeDependency(WabitObject dependency)
Removes the given object as a dependency of this object. |
void |
removeItem(ca.sqlpower.query.Item col)
|
void |
removeJoin(ca.sqlpower.query.SQLJoin joinLine)
|
void |
removeQueryChangeListener(ca.sqlpower.query.QueryChangeListener l)
|
void |
removeResultSetListener(ResultSetListener listener)
Removes the given listener from the listener list. |
void |
removeTable(ca.sqlpower.query.Container table)
|
void |
removeUserModifications()
|
void |
reset()
|
void |
selectItem(ca.sqlpower.query.Item item)
|
void |
setAutomaticallyExecuting(boolean automaticallyExecute)
|
void |
setDataSource(ca.sqlpower.sql.JDBCDataSource ds)
|
boolean |
setDataSourceWithoutSideEffects(ca.sqlpower.sql.JDBCDataSource dataSource)
|
void |
setDBMapping(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping)
|
void |
setExecuteQueriesWithCrossJoins(boolean executeQueriesWithCrossJoins)
|
void |
setGlobalWhereClause(java.lang.String whereClause)
|
void |
setGroupingEnabled(boolean enabled)
|
void |
setName(java.lang.String string)
Sets the name for this object |
void |
setPromptForCrossJoins(boolean promptForCrossJoins)
|
void |
setRowLimit(int rowLimit)
This will set the row limit on the query. |
void |
setStreaming(boolean streaming)
|
void |
setStreamingRowLimit(int streamingRowLimit)
|
void |
setUserModifiedQuery(java.lang.String query)
|
void |
setUUID(java.lang.String uuid)
|
void |
setZoomLevel(int zoomLevel)
|
void |
startCompoundEdit(java.lang.String message)
|
java.lang.String |
toString()
|
void |
unselectItem(ca.sqlpower.query.Item item)
|
| Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject |
|---|
addChild, addWabitListener, begin, beginTransaction, commit, commitTransaction, equals, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, getChildren, getParent, getSession, getUUID, isForegroundThread, removeChild, removeWabitListener, rollback, rollbackTransaction, runInBackground, runInForeground, setParent |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ca.sqlpower.query.Query |
|---|
getUUID |
| Methods inherited from interface ca.sqlpower.wabit.WabitObject |
|---|
addChild, addWabitListener, begin, commit, getChildren, getParent, getUUID, removeChild, removeWabitListener, rollback, setParent |
| Constructor Detail |
|---|
public QueryCache(QueryCache q)
public QueryCache(QueryCache q,
boolean connectListeners)
public QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping)
Query that caches the last set of results that were
returned when during the last execution.
dbMapping - A mapping of SPDataSources to corresponding
SQLDatabases that allows getting the connection pool
in the SQLDatabase based on the connection defined by
the SPDataSource.
public QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping,
boolean prepopulateConstants)
Query that caches the last set of results that were
returned when during the last execution.
dbMapping - A mapping of SPDataSources to corresponding
SQLDatabases that allows getting the connection pool
in the SQLDatabase based on the connection defined by
the SPDataSource.prepopulateConstants - True if the constants table should be pre-populated with some
useful default constants, false otherwise.
public QueryCache(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping,
boolean prepopulateConstants,
WabitConstantsContainer newConstantsContainer)
Query that caches the last set of results that were
returned when during the last execution.
the query implementation constructor with the same args| Method Detail |
|---|
public boolean executeStatement()
throws java.sql.SQLException
executeStatement in interface ca.sqlpower.swingui.query.StatementExecutorjava.sql.SQLException - If the query fails to execute for any reason.
public boolean executeStatement(boolean fetchFullResults)
throws java.sql.SQLException
fullResultSet - If true the full result set will be retrieved. If false then a
limited result set will be retrieved based on the session's
row limit.
java.sql.SQLException - If the query fails to execute for any reason.public void cancel()
Statement.cancel().
cancel in interface WabitBackgroundWorkerpublic java.sql.ResultSet getResultSet()
getResultSet in interface ca.sqlpower.swingui.query.StatementExecutorpublic ca.sqlpower.sql.CachedRowSet getCachedRowSet()
protected java.util.List<ca.sqlpower.sql.CachedRowSet> getResultSets()
public int getUpdateCount()
getUpdateCount in interface ca.sqlpower.swingui.query.StatementExecutorpublic boolean getMoreResults()
getMoreResults in interface ca.sqlpower.swingui.query.StatementExecutorpublic CleanupExceptions cleanup()
AbstractWabitObject
cleanup in interface WabitObjectcleanup in class AbstractWabitObjectpublic WabitDataSource getWabitDataSource()
public boolean isRunning()
WabitBackgroundWorkerNote to implementers: this method is likely to be used for inter-thread communication. Be sure to use proper synchronization when passing the flag between threads!
isRunning in interface WabitBackgroundWorkerpublic boolean allowsChildren()
WabitObject
allowsChildren in interface WabitObjectWabitObject.childPositionOffset(Class)public int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
WabitObject
childPositionOffset in interface WabitObjectpublic java.util.List<? extends WabitObject> getChildren()
WabitObject
getChildren in interface WabitObjectpublic java.lang.String toString()
toString in interface ca.sqlpower.query.QuerytoString in class AbstractWabitObjectpublic java.util.List<WabitObject> getDependencies()
WabitObjectWabitObjects that this Wabit object is
dependent on. Children of a WabitObject are not dependencies and will not
be returned in this list. If there are no objects this Wabit object is
dependent on an empty list should be returned. These are only the
immediate dependencies of this object. If you want to find the
dependencies of this object's dependencies as well it may be useful to
look at WorkspaceGraphModel to make a full graph of all of the
dependencies.
getDependencies in interface WabitObjectpublic void removeDependency(WabitObject dependency)
WabitObject
removeDependency in interface WabitObjectpublic boolean isPhantomQuery()
public void setPromptForCrossJoins(boolean promptForCrossJoins)
public boolean getPromptForCrossJoins()
public void setExecuteQueriesWithCrossJoins(boolean executeQueriesWithCrossJoins)
public boolean getExecuteQueriesWithCrossJoins()
public void setAutomaticallyExecuting(boolean automaticallyExecute)
public boolean isAutomaticallyExecuting()
protected boolean removeChildImpl(WabitObject child)
AbstractWabitObject
removeChildImpl in class AbstractWabitObjectAbstractWabitObject.removeChild(WabitObject)
protected void addChildImpl(WabitObject child,
int index)
AbstractWabitObject#addChild(WabitObject). There are checks in the
#addChild(WabitObject) method to ensure that the object given
here is a valid child type of this object.
This method should be overwritten if children are allowed.
addChildImpl in class AbstractWabitObjectchild - The child to add to this object.index - The index to add the child at.public void addResultSetListener(ResultSetListener listener)
ResultSetProducer
addResultSetListener in interface ResultSetProducerlistener - The listener to add (must not be null).public void removeResultSetListener(ResultSetListener listener)
ResultSetProducer
removeResultSetListener in interface ResultSetProducerlistener - The listener to remove. Nulls are ignored.
public java.util.concurrent.Future<ResultSetAndUpdateCountCollection> execute()
throws ResultSetProducerException
ResultSetProducerEvery call to this method causes a ResultSetEvent to be fired, whether or not the call simply returns the same cached results as a previous invocation.
If the query is in a state where it can't be executed (because it is not sufficiently configured to issue a sensible query, or because the connection to the data source can't be established), the event will still be fired if it results in a state change from the previous execution attempt. In these cases, the event will deliver a null ResultSet to listeners.
Implementations of ResultSetProducer are allowed to fire the ResultSetEvent while the query is locked against concurrent and/or recursive execution, so it is vitally important that ResultSetListeners do not attempt to re-execute the query in response to any ResultSetEvent. Such behaviour by ResultSetListeners is unsafe in general, and may cause deadlock.
execute in interface ResultSetProducerResultSetProducerException - If there was any problem obtaining the result setpublic java.lang.String getStatement()
getStatement in interface ca.sqlpower.swingui.query.StatementExecutorpublic java.lang.String generateQuery()
generateQuery in interface ca.sqlpower.query.Querypublic boolean containsCrossJoins()
containsCrossJoins in interface ca.sqlpower.query.Querypublic boolean isScriptModified()
isScriptModified in interface ca.sqlpower.query.Querypublic void setDataSource(ca.sqlpower.sql.JDBCDataSource ds)
setDataSource in interface ca.sqlpower.query.Querypublic boolean setDataSourceWithoutSideEffects(ca.sqlpower.sql.JDBCDataSource dataSource)
setDataSourceWithoutSideEffects in interface ca.sqlpower.query.Querypublic ca.sqlpower.sql.JDBCDataSource getDataSource()
getDataSource in interface ca.sqlpower.query.Querypublic void setName(java.lang.String string)
WabitObject
setName in interface ca.sqlpower.query.QuerysetName in interface WabitObjectsetName in class AbstractWabitObjectpublic java.lang.String getName()
WabitObject
getName in interface ca.sqlpower.query.QuerygetName in interface WabitObjectgetName in class AbstractWabitObjectpublic void setDBMapping(ca.sqlpower.sqlobject.SQLDatabaseMapping dbMapping)
setDBMapping in interface ca.sqlpower.query.Querypublic int getStreamingRowLimit()
getStreamingRowLimit in interface ca.sqlpower.query.Querypublic void setStreamingRowLimit(int streamingRowLimit)
setStreamingRowLimit in interface ca.sqlpower.query.Querypublic boolean isStreaming()
isStreaming in interface ca.sqlpower.query.Querypublic void setRowLimit(int rowLimit)
setRowLimit in interface ca.sqlpower.query.Querypublic void addItem(ca.sqlpower.query.Item col)
addItem in interface ca.sqlpower.query.Querypublic void addJoin(ca.sqlpower.query.SQLJoin join)
addJoin in interface ca.sqlpower.query.Querypublic void addQueryChangeListener(ca.sqlpower.query.QueryChangeListener l)
addQueryChangeListener in interface ca.sqlpower.query.Querypublic void addTable(ca.sqlpower.query.Container container)
addTable in interface ca.sqlpower.query.Query
public void addTable(ca.sqlpower.query.Container container,
int index)
addTable in interface ca.sqlpower.query.Querypublic void setUserModifiedQuery(java.lang.String query)
setUserModifiedQuery in interface ca.sqlpower.query.Querypublic java.lang.String getUserModifiedQuery()
getUserModifiedQuery in interface ca.sqlpower.query.Querypublic void endCompoundEdit()
endCompoundEdit in interface ca.sqlpower.query.Querypublic ca.sqlpower.query.Container getConstantsContainer()
getConstantsContainer in interface ca.sqlpower.query.Querypublic ca.sqlpower.sqlobject.SQLDatabase getDatabase()
getDatabase in interface ca.sqlpower.query.Querypublic ca.sqlpower.sqlobject.SQLDatabaseMapping getDBMapping()
getDBMapping in interface ca.sqlpower.query.Querypublic java.util.List<ca.sqlpower.query.Container> getFromTableList()
getFromTableList in interface ca.sqlpower.query.Querypublic java.lang.String getGlobalWhereClause()
getGlobalWhereClause in interface ca.sqlpower.query.Querypublic java.util.Collection<ca.sqlpower.query.SQLJoin> getJoins()
getJoins in interface ca.sqlpower.query.Querypublic java.util.List<ca.sqlpower.query.Item> getOrderByList()
getOrderByList in interface ca.sqlpower.query.Querypublic int getRowLimit()
getRowLimit in interface ca.sqlpower.query.Querypublic java.util.List<ca.sqlpower.query.Item> getSelectedColumns()
getSelectedColumns in interface ca.sqlpower.query.Querypublic int getZoomLevel()
getZoomLevel in interface ca.sqlpower.query.Querypublic boolean isGroupingEnabled()
isGroupingEnabled in interface ca.sqlpower.query.Query
public void moveItem(ca.sqlpower.query.Item movedColumn,
int toIndex)
moveItem in interface ca.sqlpower.query.Query
public void moveOrderBy(ca.sqlpower.query.Item item,
int index)
moveOrderBy in interface ca.sqlpower.query.Querypublic void moveOrderByItemToEnd(ca.sqlpower.query.Item item)
moveOrderByItemToEnd in interface ca.sqlpower.query.Querypublic void removeItem(ca.sqlpower.query.Item col)
removeItem in interface ca.sqlpower.query.Querypublic void removeJoin(ca.sqlpower.query.SQLJoin joinLine)
removeJoin in interface ca.sqlpower.query.Querypublic void removeQueryChangeListener(ca.sqlpower.query.QueryChangeListener l)
removeQueryChangeListener in interface ca.sqlpower.query.Querypublic void removeTable(ca.sqlpower.query.Container table)
removeTable in interface ca.sqlpower.query.Querypublic void removeUserModifications()
removeUserModifications in interface ca.sqlpower.query.Querypublic void reset()
reset in interface ca.sqlpower.query.Querypublic void setGlobalWhereClause(java.lang.String whereClause)
setGlobalWhereClause in interface ca.sqlpower.query.Querypublic void setGroupingEnabled(boolean enabled)
setGroupingEnabled in interface ca.sqlpower.query.Querypublic void setStreaming(boolean streaming)
setStreaming in interface ca.sqlpower.query.Querypublic void setZoomLevel(int zoomLevel)
setZoomLevel in interface ca.sqlpower.query.Querypublic void startCompoundEdit(java.lang.String message)
startCompoundEdit in interface ca.sqlpower.query.Querypublic int indexOfSelectedItem(ca.sqlpower.query.Item item)
indexOfSelectedItem in interface ca.sqlpower.query.Querypublic void selectItem(ca.sqlpower.query.Item item)
selectItem in interface ca.sqlpower.query.Querypublic void unselectItem(ca.sqlpower.query.Item item)
unselectItem in interface ca.sqlpower.query.Query
public void orderColumn(ca.sqlpower.query.Item item,
ca.sqlpower.query.QueryImpl.OrderByArgument ordering)
orderColumn in interface ca.sqlpower.query.Queryprotected void fireJoinAdded(ca.sqlpower.query.QueryChangeEvent evt)
protected void fireJoinRemoved(ca.sqlpower.query.QueryChangeEvent evt)
protected void fireJoinPropertyChangeEvent(java.beans.PropertyChangeEvent evt)
protected void firePropertyChangeEvent(java.beans.PropertyChangeEvent evt)
protected void fireCompoundEditStarted(ca.sqlpower.util.TransactionEvent evt)
protected void fireCompoundEditEnded(ca.sqlpower.util.TransactionEvent evt)
protected void fireItemPropertyChangeEvent(java.beans.PropertyChangeEvent evt)
protected void fireItemAdded(ca.sqlpower.query.QueryChangeEvent evt)
protected void fireItemRemoved(ca.sqlpower.query.QueryChangeEvent evt)
protected void fireContainerRemoved(ca.sqlpower.query.QueryChangeEvent evt)
protected void fireContainerAdded(ca.sqlpower.query.QueryChangeEvent evt)
public WabitConstantsContainer getWabitConstantsContainer()
public void setUUID(java.lang.String uuid)
setUUID in interface WabitObjectsetUUID in class AbstractWabitObjectpublic void generateNewUUID()
WabitObject
generateNewUUID in interface WabitObjectgenerateNewUUID in class AbstractWabitObject
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||