|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.sqlpower.object.AbstractSPObject
ca.sqlpower.wabit.AbstractWabitObject
ca.sqlpower.wabit.rs.olap.OlapQuery
@ThreadSafe public class OlapQuery
This is the model of an OLAP query. This will store all values that need to be persisted in an OLAP query.
Instances of OlapQuery are thread safe: their state can me modified safely by multiple threads. To avoid thrashing the remote database, execution of the query is serialized so that only one MDX query evaluation at a time is in progress. However, while the query is executing, threads attempting to further modify the query's state are not blocked as long as they don't involve an attempt to execute the query.
Sometimes, you might want to perform a series of operations (such as adding or removing many members) atomically. You can do so by synchronizing on the OlapQuery instance, like this:
OlapQuery query = ...;
synchronized (query) {
for (Member member : membersToInclude) {
query.includeMember(member);
}
}
This will guarantee all the members in the list have been added to the query
with no intervening modifications to the query and no possibility that the
query would start executing on another thread when only half the members have
been added.
| Field Summary |
|---|
| Fields inherited from class ca.sqlpower.object.AbstractSPObject |
|---|
uuid |
| Constructor Summary | |
|---|---|
OlapQuery(OlapConnectionMapping olapMapping)
Creates a new, empty query with no set persistent object ID. |
|
OlapQuery(java.lang.String uuid,
OlapConnectionMapping olapMapping,
java.lang.String name,
java.lang.String queryName,
java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String cubeName)
Creates a new, empty query that will use the given persistent object ID when it's saved. |
|
| Method Summary | |
|---|---|
void |
addAxis(WabitOlapAxis axis)
Adds the given axis to the query. |
protected void |
addChildImpl(ca.sqlpower.object.SPObject child,
int index)
This method should only be used internally or in special cases such as an undo manager or synchronizing with a server. |
void |
addOlapQueryListener(OlapQueryListener listener)
|
void |
addResultSetListener(ResultSetListener listener)
Adds the given listener to this result set producer's list of interested parties. |
void |
addToAxis(int ordinal,
org.olap4j.metadata.Member member,
org.olap4j.Axis axis)
Adds the given member to the given axis. |
void |
addToAxis(int ordinal,
org.olap4j.metadata.Member member,
org.olap4j.query.Selection.Operator operator,
org.olap4j.Axis axis)
Adds the given member to the given axis with a defined operator. |
boolean |
allowsChildren()
OlapQuery has WabitOlapAxis as children, so this method returns true. |
void |
cancel()
If this worker is currently doing something in the background, calling this method requests the background processing be canceled. |
int |
childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
|
void |
clearExclusions(org.olap4j.metadata.Hierarchy hierarchy)
Takes the given Hierarchy and clears all exclusions from its Dimension. |
void |
clearSort(org.olap4j.Axis axis)
Removes the sort order on the given axis |
static OlapQuery |
copyOlapQuery(OlapQuery oldOlapQuery)
Creates a copy of the given OlapQuery. |
org.olap4j.OlapConnection |
createOlapConnection()
|
void |
drillReplace(org.olap4j.metadata.Member member)
Modifies this query's selection so that members equal to and descended from the given member remain selected as before, but other members are no longer selected. |
void |
drillUpTo(org.olap4j.metadata.Member fromMember,
org.olap4j.metadata.Member targetAncestor)
Modifies this query's selection so that targetAncestor, and every ancestor of fromMember in between will be included. |
void |
excludeMember(java.lang.String dimensionName,
org.olap4j.metadata.Member memberToExclude,
org.olap4j.query.Selection.Operator operator)
Adds the given Member or it's children (depending on the
Selection.Operator) as an exclusion to this query. |
java.util.concurrent.Future<ResultSetAndUpdateCountCollection> |
execute()
Executes the underlying MDX query, causing all the side effects described in executeOlapQuery(), then converts those results to an
OlapResultSet and notifies the ResultSetListeners with that
converted result. |
org.olap4j.CellSet |
executeOlapQuery()
Executes the current MDX query represented by this object, returning the cell set that results from the query's execution. |
org.olap4j.metadata.Member |
findMember(java.util.Map<java.lang.String,java.lang.String> attributes,
org.olap4j.metadata.Cube cube)
This method finds a member from a cube based on given attributes. |
java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> |
getAllowedChildTypes()
|
java.util.List<WabitOlapAxis> |
getAxes()
Returns the list of Axis wrappers stored by this query. |
java.lang.String |
getCatalogName()
|
java.util.List<? extends WabitObject> |
getChildren()
|
java.util.List<org.olap4j.metadata.Hierarchy> |
getColumnHierarchies()
|
java.lang.String |
getCubeName()
|
org.olap4j.metadata.Cube |
getCurrentCube()
|
java.util.List<WabitObject> |
getDependencies()
|
WabitOlapDimension |
getDimension(java.lang.String dimensionName)
Gets the wrapper around the Dimension with the given name. |
java.lang.String |
getMdxText()
Returns the current MDX text that this query object's state represents. |
ca.sqlpower.sql.Olap4jDataSource |
getOlapDataSource()
Returns the data source that this query obtains its connections from. |
java.lang.String |
getQueryName()
|
java.util.List<org.olap4j.metadata.Hierarchy> |
getRowHierarchies()
|
java.lang.String |
getSchemaName()
|
org.olap4j.metadata.Member |
getSlicerMember()
This method returns the single slicer member, since Olap4j does not track whether or not you have more than one member in your slicer and since mondrian does not support compound slicers we will use this variable to make sure that the user does not add more than one member to their slicer |
org.olap4j.query.SortOrder |
getSortOrder(org.olap4j.Axis axis)
Returns the SortOrder of the given Axis of the query. |
boolean |
hasCachedAttributes()
Tells if the connection was initialized. |
void |
includeMember(org.olap4j.metadata.Member member)
Includes the given member in the query, assuming its hierarchy is on a visible axis. |
boolean |
isIncluded(org.olap4j.metadata.Member member)
Checks if the given Member is already included in the given
QueryDimension. |
boolean |
isInitDone()
This method lets you know whether or not the OlapQuery has been initialized. |
boolean |
isNonEmpty()
Tells whether the ROWS axis of this query omits empty positions. |
boolean |
isRunning()
Returns true if this Wabit object is doing something in the background. |
protected boolean |
removeChildImpl(ca.sqlpower.object.SPObject child)
This method should only be used internally or in special cases such as an undo manager or synchronizing with a server. |
void |
removeDependency(ca.sqlpower.object.SPObject dependency)
|
void |
removeDimension(org.olap4j.metadata.Dimension dimension,
org.olap4j.Axis axis)
Removes the given Dimension from the given Axis in the
query |
boolean |
removeExcludedMember(org.olap4j.metadata.Member memberToExclude,
org.olap4j.query.Selection.Operator operator)
Removes the given member with the given operator from the list of members that are currently being excluded from the query. |
void |
removeHierarchy(org.olap4j.metadata.Hierarchy hierarchy,
org.olap4j.Axis axis)
Removes the given Hierarchy from the given Axis in the
query |
boolean |
removeIncludedMember(org.olap4j.metadata.Member member,
org.olap4j.query.Selection.Operator operator)
Removes the given member from the list of members included in this query. |
void |
removeOlapQueryListener(OlapQueryListener listener)
|
void |
removeResultSetListener(ResultSetListener listener)
Removes the given listener from the listener list. |
void |
reset()
This function is called by the 'Reset Query' button on the toolbar. |
void |
setCurrentCube(org.olap4j.metadata.Cube currentCube)
|
void |
setCurrentCube(org.olap4j.metadata.Cube currentCube,
boolean resetQuery)
|
void |
setNonEmpty(boolean nonEmpty)
Sets the ROWS axis of this query to omit empty positions. |
void |
setOlapDataSource(ca.sqlpower.sql.Olap4jDataSource olapDataSource)
Sets the data source that this query obtains its connections from, and fires a property change event. |
void |
sortBy(org.olap4j.Axis axis,
org.olap4j.query.SortOrder order,
org.olap4j.metadata.Measure measure)
Sorts the OLAP results on the given Axis by the given
Measure in the given SortOrder |
boolean |
toggleMember(org.olap4j.metadata.Member member)
If the member is currently "expanded" (its children are part of the MDX query), its children will be removed from the query. |
java.lang.String |
toString()
Returns the name of the string. |
void |
updateAttributes()
Updates the child references on all Olap wrapper classes owned by this query. |
| Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject |
|---|
cleanup, commit, equals, generateNewUUID, getParent, getSession, isForegroundThread, removeChild, rollback, runInBackground, runInForeground |
| Methods inherited from class ca.sqlpower.object.AbstractSPObject |
|---|
addChild, addSPListener, begin, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, getChildren, getName, getUUID, removeSPListener, setName, setParent, setUUID |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ca.sqlpower.wabit.WabitObject |
|---|
getParent |
| Methods inherited from interface ca.sqlpower.object.SPObject |
|---|
addChild, addSPListener, begin, cleanup, commit, generateNewUUID, getChildren, getName, getSession, getUUID, removeChild, removeSPListener, rollback, setName, setParent, setUUID |
| Constructor Detail |
|---|
public OlapQuery(OlapConnectionMapping olapMapping)
public OlapQuery(java.lang.String uuid,
OlapConnectionMapping olapMapping,
java.lang.String name,
java.lang.String queryName,
java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String cubeName)
| Method Detail |
|---|
public static OlapQuery copyOlapQuery(OlapQuery oldOlapQuery)
throws java.sql.SQLException,
QueryInitializationException
java.sql.SQLException
QueryInitializationException
public void setCurrentCube(org.olap4j.metadata.Cube currentCube)
throws java.sql.SQLException
java.sql.SQLException
public void setCurrentCube(org.olap4j.metadata.Cube currentCube,
boolean resetQuery)
throws java.sql.SQLException
java.sql.SQLExceptionpublic org.olap4j.metadata.Cube getCurrentCube()
public org.olap4j.CellSet executeOlapQuery()
throws QueryInitializationException,
java.lang.InterruptedException,
java.sql.SQLException
Every call to this method results in a CellSetEvent and a ResultSetProducerEvent being fired.
java.sql.SQLException - If the cell set cannot be iterated over or its values cannot
be retrieved to create a result set based off of the cell
set.
QueryInitializationException
java.lang.InterruptedExceptioninnerExecuteOlapQuery()
public void removeHierarchy(org.olap4j.metadata.Hierarchy hierarchy,
org.olap4j.Axis axis)
throws QueryInitializationException
Hierarchy from the given Axis in the
query
hierarchy - The Hierarchy to removeaxis - The Axis to remove the Hierarchy from
QueryInitializationException
public void removeDimension(org.olap4j.metadata.Dimension dimension,
org.olap4j.Axis axis)
throws QueryInitializationException
Dimension from the given Axis in the
query
dimension - The Dimension to removeaxis - The Axis to remove the Dimension from
QueryInitializationExceptionpublic boolean isInitDone()
public void reset()
throws java.sql.SQLException
java.sql.SQLException
public void excludeMember(java.lang.String dimensionName,
org.olap4j.metadata.Member memberToExclude,
org.olap4j.query.Selection.Operator operator)
throws QueryInitializationException
Member or it's children (depending on the
Selection.Operator) as an exclusion to this query.
dimensionName - The name of the Dimension to exclude Member from.memberToExclude - The Member to exclude from the query resultsoperator - If value is Selection.Operator.MEMBER, the given Member is
excluded. If the value is Selection.Operator.CHILDREN, then the
Member's children get excluded. Due to insufficient
documentation in the Olap4j API, I am not certain what the
other values of Selection.Operator will do.
QueryInitializationException
public boolean removeExcludedMember(org.olap4j.metadata.Member memberToExclude,
org.olap4j.query.Selection.Operator operator)
throws QueryInitializationException
memberToExclude - The member that was excluded that we now want to remove from
the list of exclusions.operator - The operator that the member is being excluded with.
QueryInitializationException
public org.olap4j.OlapConnection createOlapConnection()
throws java.sql.SQLException,
java.lang.ClassNotFoundException,
javax.naming.NamingException
java.sql.SQLException
java.lang.ClassNotFoundException
javax.naming.NamingExceptionpublic void setOlapDataSource(ca.sqlpower.sql.Olap4jDataSource olapDataSource)
public ca.sqlpower.sql.Olap4jDataSource getOlapDataSource()
public org.olap4j.metadata.Member getSlicerMember()
public boolean allowsChildren()
allowsChildren in interface ca.sqlpower.object.SPObjectpublic int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
childPositionOffset in interface ca.sqlpower.object.SPObjectpublic java.util.List<? extends WabitObject> getChildren()
getChildren in interface ca.sqlpower.object.SPObjectpublic java.lang.String toString()
toString in class AbstractWabitObjectpublic java.util.List<WabitObject> getDependencies()
getDependencies in interface ca.sqlpower.object.SPObjectpublic void removeDependency(ca.sqlpower.object.SPObject dependency)
removeDependency in interface ca.sqlpower.object.SPObjectpublic void updateAttributes()
public void addAxis(WabitOlapAxis axis)
public java.util.List<WabitOlapAxis> getAxes()
public WabitOlapDimension getDimension(java.lang.String dimensionName)
Dimension with the given name.
public org.olap4j.metadata.Member findMember(java.util.Map<java.lang.String,java.lang.String> attributes,
org.olap4j.metadata.Cube cube)
public boolean toggleMember(org.olap4j.metadata.Member member)
throws QueryInitializationException
member - The member whose drilldown state to toggle. Must not be null.
QueryInitializationException
org.olap4j.OlapException - if the list of child members can't be retrievedpublic boolean hasCachedAttributes()
public org.olap4j.query.SortOrder getSortOrder(org.olap4j.Axis axis)
throws QueryInitializationException
SortOrder of the given Axis of the query.
axis - The Axis for which you want to find the SortOrder for
SortOrder of the given Axis
QueryInitializationException - If there is an error initializing the query
public java.lang.String getMdxText()
throws QueryInitializationException
QueryInitializationException
public void addToAxis(int ordinal,
org.olap4j.metadata.Member member,
org.olap4j.Axis axis)
throws org.olap4j.OlapException,
QueryInitializationException
ordinal - If the given member's dimension is not already on the given
axis, the dimension will be added to the axis at the given
ordinal. Otherwise, this argument is ignored.member - The member to add. If the member's dimension is not already on
the given axis, it will be added to the axis automatically.axis - The axis to add the member to. Must be either Axis.ROWS or
Axis.COLUMNS.
org.olap4j.OlapException - If a database error occurs
QueryInitializationException
public void addToAxis(int ordinal,
org.olap4j.metadata.Member member,
org.olap4j.query.Selection.Operator operator,
org.olap4j.Axis axis)
throws org.olap4j.OlapException,
QueryInitializationException
ordinal - If the given member's dimension is not already on the given
axis, the dimension will be added to the axis at the given
ordinal. Otherwise, this argument is ignored.member - The member to add. If the member's dimension is not already on
the given axis, it will be added to the axis automatically.operator - The operator to add with the member to the axis.axis - The axis to add the member to. Must be either Axis.ROWS or
Axis.COLUMNS.
org.olap4j.OlapException - If a database error occurs
QueryInitializationException
public java.util.List<org.olap4j.metadata.Hierarchy> getRowHierarchies()
throws QueryInitializationException
QueryInitializationException
public java.util.List<org.olap4j.metadata.Hierarchy> getColumnHierarchies()
throws QueryInitializationException
QueryInitializationException
public void drillReplace(org.olap4j.metadata.Member member)
throws QueryInitializationException
member - The member to drill replace on. This member will be the new
root of the selection for its hierarchy.
QueryInitializationException
public void drillUpTo(org.olap4j.metadata.Member fromMember,
org.olap4j.metadata.Member targetAncestor)
throws QueryInitializationException
fromMember - The member whose ancestors will be added to the query
selectiontargetAncestor - The highest ancestor member that will be added to the query
selection
QueryInitializationException
public void sortBy(org.olap4j.Axis axis,
org.olap4j.query.SortOrder order,
org.olap4j.metadata.Measure measure)
throws QueryInitializationException
Axis by the given
Measure in the given SortOrder
QueryInitializationException
public void clearSort(org.olap4j.Axis axis)
throws QueryInitializationException
axis - The Axis from which to remove the sort order
QueryInitializationException
public boolean isIncluded(org.olap4j.metadata.Member member)
throws QueryInitializationException
Member is already included in the given
QueryDimension.
Note that this currently does not take into account the value of
Selection.getOperator()
member - The member to check if it's included in the given
QueryDimensiondimension - The QueryDimension to check for inclusion.
Selections in dimension's
inclusions. Otherwise false.
QueryInitializationException
public void includeMember(org.olap4j.metadata.Member member)
throws QueryInitializationException
member - The member to include in the query. If the member is already
included, this method has no effect.
QueryInitializationException
public boolean removeIncludedMember(org.olap4j.metadata.Member member,
org.olap4j.query.Selection.Operator operator)
throws QueryInitializationException
member - The member to remove.operator - The operator used in the inclusion.
QueryInitializationExceptionpublic void setNonEmpty(boolean nonEmpty)
nonEmpty - True means to omit empty positions; false means to include
them.public boolean isNonEmpty()
public void addOlapQueryListener(OlapQueryListener listener)
public void removeOlapQueryListener(OlapQueryListener listener)
public void clearExclusions(org.olap4j.metadata.Hierarchy hierarchy)
throws QueryInitializationException
hierarchy -
QueryInitializationExceptionprotected boolean removeChildImpl(ca.sqlpower.object.SPObject child)
removeChildImpl in class ca.sqlpower.object.AbstractSPObject
protected void addChildImpl(ca.sqlpower.object.SPObject child,
int index)
addChildImpl in class ca.sqlpower.object.AbstractSPObjectpublic java.lang.String getQueryName()
public java.lang.String getCatalogName()
public java.lang.String getSchemaName()
public java.lang.String getCubeName()
public void cancel()
WabitBackgroundWorker
cancel in interface WabitBackgroundWorkerpublic 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 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,
java.lang.InterruptedException
executeOlapQuery(), then converts those results to an
OlapResultSet and notifies the ResultSetListeners with that
converted result.
execute in interface ResultSetProducerResultSetProducerException - If there was any problem obtaining the result set
java.lang.InterruptedException - If the calling thread is interrupted while blocked waiting
for another call to execute() to complete.public java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||