ca.sqlpower.wabit
Class WabitWorkspace

java.lang.Object
  extended by ca.sqlpower.object.AbstractSPObject
      extended by ca.sqlpower.wabit.AbstractWabitObject
          extended by ca.sqlpower.wabit.WabitWorkspace
All Implemented Interfaces:
ca.sqlpower.object.SPObject, ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>, WabitObject

public class WabitWorkspace
extends AbstractWabitObject
implements ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

The WabitWorkspace is the root WabitObject of a WabitSession. It directly corresponds with the root workspace node in the XML representation of a Wabit workspace. It belongs to exactly one WabitSession.


Nested Class Summary
static class WabitWorkspace.WabitObjectOrder
          FIXME This enum defines the WabitObject child classes a WabitWorkspace 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.
 
Field Summary
static java.lang.String SYSTEM_WORKSPACE_UUID
          A workspace with this uuid is a system workspace.
 
Fields inherited from class ca.sqlpower.object.AbstractSPObject
uuid
 
Fields inherited from interface ca.sqlpower.sql.DataSourceCollection
DOS_CR_LF
 
Constructor Summary
WabitWorkspace()
          Creates a new Wabit workspace.
 
Method Summary
 void addChart(Chart chart)
           
 void addChart(Chart chart, int index)
           
protected  void addChildImpl(ca.sqlpower.object.SPObject child, int index)
           
 void addDatabaseListChangeListener(ca.sqlpower.sql.DatabaseListChangeListener l)
           
 void addDataSource(ca.sqlpower.sql.SPDataSource dbcs)
           
 void addDataSource(WabitDataSource ds)
           
 void addDataSource(WabitDataSource ds, int index)
           
 void addDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dataSourceType)
           
 void addGroup(ca.sqlpower.enterprise.client.Group g)
           
 void addGroup(ca.sqlpower.enterprise.client.Group g, int index)
           
 void addImage(WabitImage image)
           
 void addImage(WabitImage image, int index)
           
 void addOlapQuery(OlapQuery newQuery)
           
 void addOlapQuery(OlapQuery newQuery, int index)
           
 void addQuery(QueryCache query, WabitSession session)
           
 void addQuery(QueryCache query, WabitSession session, int index)
           
 void addReport(Report report)
           
 void addReport(Report report, int index)
           
 void addReportTask(ReportTask task)
           
 void addReportTask(ReportTask task, int index)
           
 void addTemplate(Template template)
           
 void addTemplate(Template template, int index)
           
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
           
 void addUser(ca.sqlpower.enterprise.client.User u)
           
 void addUser(ca.sqlpower.enterprise.client.User u, int index)
           
 boolean allowsChildren()
           
 int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
           
 boolean dsAlreadyAdded(ca.sqlpower.sql.SPDataSource dbcs)
           
<T extends ca.sqlpower.object.SPObject>
T
findByUuid(java.lang.String uuid, java.lang.Class<T> expectedType)
          Locates the WabitObject inside this workspace which has the given UUID, returning null if the item is not found.
 java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()
           
 java.util.List<Chart> getCharts()
           
 java.util.List<ca.sqlpower.object.SPObject> getChildren()
           
<T extends ca.sqlpower.object.SPObject>
java.util.List<T>
getChildren(java.lang.Class<T> type)
           
 java.util.List<ca.sqlpower.sql.SPDataSource> getConnections()
           
<C extends ca.sqlpower.sql.SPDataSource>
java.util.List<C>
getConnections(java.lang.Class<C> classType)
           
 ca.sqlpower.sql.SPDataSource getDataSource(java.lang.String name)
           
<C extends ca.sqlpower.sql.SPDataSource>
C
getDataSource(java.lang.String name, java.lang.Class<C> classType)
           
 java.util.List<WabitDataSource> getDataSources()
          Returns an unmodifiable view of the data sources in this workspace.
 java.util.List<ca.sqlpower.sql.JDBCDataSourceType> getDataSourceTypes()
           
 java.util.List<WabitObject> getDependencies()
           
 ca.sqlpower.object.SPObject getEditorPanelModel()
           
 java.util.List<ca.sqlpower.enterprise.client.Group> getGroups()
           
 java.util.List<WabitImage> getImages()
           
 java.net.URI getMondrianServerBaseURI()
           
 java.util.List<OlapQuery> getOlapQueries()
           
 WabitObject getParent()
          Returns the parent of this WabitObject.
 java.util.List<QueryCache> getQueries()
           
 Report getReportByName(java.lang.String name)
          Returns the first Report child having the given name, or null if no reports have the requested name.
 java.util.List<Report> getReports()
           
 java.util.List<ReportTask> getReportTasks()
           
 java.net.URI getServerBaseURI()
           
 WabitSession getSession()
          Helper method to find the session of a WabitObject.
 java.util.List<Template> getTemplates()
           
 java.util.List<ca.sqlpower.enterprise.client.User> getUsers()
           
 boolean isMagicDisabled()
           
 boolean isServerWorkspace()
           
 boolean isSystemWorkspace()
           
 void mergeDataSource(ca.sqlpower.sql.SPDataSource dbcs)
           
 void mergeDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dst)
           
 int mergeIntoWorkspace(WabitWorkspace workspace)
          This method will merge all of the objects in this workspace into the given workspace.
 void read(java.io.File location)
           
 void read(java.io.InputStream inStream)
           
protected  boolean removeChildImpl(ca.sqlpower.object.SPObject child)
           
 void removeDatabaseListChangeListener(ca.sqlpower.sql.DatabaseListChangeListener l)
           
 void removeDataSource(ca.sqlpower.sql.SPDataSource dbcs)
           
 boolean removeDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dataSourceType)
           
 void removeDependency(ca.sqlpower.object.SPObject dependency)
           
 boolean removeGroup(ca.sqlpower.enterprise.client.Group g)
           
 boolean removeReportTask(ReportTask task)
           
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
           
 boolean removeUser(ca.sqlpower.enterprise.client.User u)
           
 void reset()
          Resets the workspace by removing all of the children in the workspace and setting all of the values in the workspace to defaults.
 void setEditorPanelModel(ca.sqlpower.object.SPObject editorPanelModel)
           
 void setMagicDisabled(boolean magicDisabled)
           
 void setServerBaseURI(java.net.URI serverBaseURI)
           
 void setSession(WabitSession session)
          Sets the session which this workspace belongs to.
 void write()
          DataSourceCollection interface method which is currently not supported.
 void write(java.io.File location)
          DataSourceCollection interface method which is currently not supported.
 void write(java.io.OutputStream out)
          DataSourceCollection interface method which is currently not supported.
 
Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject
cleanup, commit, equals, generateNewUUID, isForegroundThread, removeChild, rollback, runInBackground, runInForeground, toString
 
Methods inherited from class ca.sqlpower.object.AbstractSPObject
addChild, addSPListener, begin, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, 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.sql.DataSourceCollection
toString
 
Methods inherited from interface ca.sqlpower.object.SPObject
addChild, addSPListener, begin, getName, getUUID, removeSPListener, setName, setParent, setUUID
 

Field Detail

SYSTEM_WORKSPACE_UUID

public static final java.lang.String SYSTEM_WORKSPACE_UUID
A workspace with this uuid is a system workspace.

See Also:
Constant Field Values
Constructor Detail

WabitWorkspace

public WabitWorkspace()
Creates a new Wabit workspace. This is normally done by the session it belongs to.

Method Detail

getChildren

public java.util.List<ca.sqlpower.object.SPObject> getChildren()
Specified by:
getChildren in interface ca.sqlpower.object.SPObject

getChildren

public <T extends ca.sqlpower.object.SPObject> java.util.List<T> getChildren(java.lang.Class<T> type)
Specified by:
getChildren in interface ca.sqlpower.object.SPObject
Overrides:
getChildren in class ca.sqlpower.object.AbstractSPObject

setSession

public void setSession(WabitSession session)
Sets the session which this workspace belongs to. This should normally only be called by that workspace. It's exposed as a publicly settable method so that "wrapper" sessions in other packages can claim ownership of this workspace from the "core" or "delegate" session they wrap.

This setter does not fire an event because it is not supposed to be called after the workspace has been initialized.

Parameters:
session - The session this workspace belongs to.

getSession

public WabitSession getSession()
Description copied from class: AbstractWabitObject
Helper method to find the session of a WabitObject. This will walk up the workspace tree to the WabitWorkspace and get its session. If the highest ancestor is not a WabitWorkspace or the workspace is not attached to a session this will throw a SessionNotFoundException.

Specified by:
getSession in interface ca.sqlpower.object.SPObject
Overrides:
getSession in class AbstractWabitObject

addDataSource

public void addDataSource(WabitDataSource ds)

addDataSource

public void addDataSource(WabitDataSource ds,
                          int index)

getDataSources

public java.util.List<WabitDataSource> getDataSources()
Returns an unmodifiable view of the data sources in this workspace.

TODO change this to List<WabitDataSource> getDatabases()


addQuery

public void addQuery(QueryCache query,
                     WabitSession session)

addQuery

public void addQuery(QueryCache query,
                     WabitSession session,
                     int index)

addTemplate

public void addTemplate(Template template)

addTemplate

public void addTemplate(Template template,
                        int index)

addReport

public void addReport(Report report)

addReport

public void addReport(Report report,
                      int index)

addImage

public void addImage(WabitImage image)

addImage

public void addImage(WabitImage image,
                     int index)

getImages

public java.util.List<WabitImage> getImages()

addChart

public void addChart(Chart chart)

addChart

public void addChart(Chart chart,
                     int index)

getCharts

public java.util.List<Chart> getCharts()

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends ca.sqlpower.object.SPObject> childType)
Specified by:
childPositionOffset in interface ca.sqlpower.object.SPObject

getQueries

public java.util.List<QueryCache> getQueries()

getReports

public java.util.List<Report> getReports()

getTemplates

public java.util.List<Template> getTemplates()

getReportByName

public Report getReportByName(java.lang.String name)
Returns the first Report child having the given name, or null if no reports have the requested name.

Parameters:
name - The name to search. If null, null will be returned.

addUser

public void addUser(ca.sqlpower.enterprise.client.User u)

addUser

public void addUser(ca.sqlpower.enterprise.client.User u,
                    int index)

removeUser

public boolean removeUser(ca.sqlpower.enterprise.client.User u)

getUsers

public java.util.List<ca.sqlpower.enterprise.client.User> getUsers()

addGroup

public void addGroup(ca.sqlpower.enterprise.client.Group g)

addGroup

public void addGroup(ca.sqlpower.enterprise.client.Group g,
                     int index)

removeGroup

public boolean removeGroup(ca.sqlpower.enterprise.client.Group g)

getGroups

public java.util.List<ca.sqlpower.enterprise.client.Group> getGroups()

addReportTask

public void addReportTask(ReportTask task)

addReportTask

public void addReportTask(ReportTask task,
                          int index)

removeReportTask

public boolean removeReportTask(ReportTask task)

getReportTasks

public java.util.List<ReportTask> getReportTasks()

isSystemWorkspace

public boolean isSystemWorkspace()

getParent

public WabitObject getParent()
Description copied from interface: WabitObject
Returns the parent of this WabitObject. This will be null when the object is first created until it is added as a child to another object. If this object is never added as a child to another object this will remain null and the object may be treated as the root node of a WabitObject tree.

Specified by:
getParent in interface ca.sqlpower.object.SPObject
Specified by:
getParent in interface WabitObject
Overrides:
getParent in class AbstractWabitObject
Returns:
The parent of this object.

allowsChildren

public boolean allowsChildren()
Specified by:
allowsChildren in interface ca.sqlpower.object.SPObject

addDataSource

public void addDataSource(ca.sqlpower.sql.SPDataSource dbcs)
Specified by:
addDataSource in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

dsAlreadyAdded

public boolean dsAlreadyAdded(ca.sqlpower.sql.SPDataSource dbcs)

removeDataSource

public void removeDataSource(ca.sqlpower.sql.SPDataSource dbcs)
Specified by:
removeDataSource in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

addDataSourceType

public void addDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dataSourceType)
Specified by:
addDataSourceType in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

addDatabaseListChangeListener

public void addDatabaseListChangeListener(ca.sqlpower.sql.DatabaseListChangeListener l)
Specified by:
addDatabaseListChangeListener in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getConnections

public java.util.List<ca.sqlpower.sql.SPDataSource> getConnections()
Specified by:
getConnections in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getConnections

public <C extends ca.sqlpower.sql.SPDataSource> java.util.List<C> getConnections(java.lang.Class<C> classType)
Specified by:
getConnections in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getDataSource

public ca.sqlpower.sql.SPDataSource getDataSource(java.lang.String name)
Specified by:
getDataSource in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getDataSource

public <C extends ca.sqlpower.sql.SPDataSource> C getDataSource(java.lang.String name,
                                                                java.lang.Class<C> classType)
Specified by:
getDataSource in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getDataSourceTypes

public java.util.List<ca.sqlpower.sql.JDBCDataSourceType> getDataSourceTypes()
Specified by:
getDataSourceTypes in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

mergeDataSource

public void mergeDataSource(ca.sqlpower.sql.SPDataSource dbcs)
Specified by:
mergeDataSource in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

mergeDataSourceType

public void mergeDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dst)
Specified by:
mergeDataSourceType in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

read

public void read(java.io.File location)
          throws java.io.IOException
Specified by:
read in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>
Throws:
java.io.IOException

read

public void read(java.io.InputStream inStream)
          throws java.io.IOException
Specified by:
read in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>
Throws:
java.io.IOException

removeDataSourceType

public boolean removeDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dataSourceType)
Specified by:
removeDataSourceType in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getServerBaseURI

public java.net.URI getServerBaseURI()
Specified by:
getServerBaseURI in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

getMondrianServerBaseURI

public java.net.URI getMondrianServerBaseURI()
Specified by:
getMondrianServerBaseURI in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

setServerBaseURI

public void setServerBaseURI(java.net.URI serverBaseURI)

removeDatabaseListChangeListener

public void removeDatabaseListChangeListener(ca.sqlpower.sql.DatabaseListChangeListener l)
Specified by:
removeDatabaseListChangeListener in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

write

public void write()
           throws java.io.IOException
DataSourceCollection interface method which is currently not supported.

Specified by:
write in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>
Throws:
java.io.IOException

write

public void write(java.io.File location)
           throws java.io.IOException
DataSourceCollection interface method which is currently not supported.

Specified by:
write in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>
Throws:
java.io.IOException

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
DataSourceCollection interface method which is currently not supported.

Specified by:
write in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>
Throws:
java.io.IOException

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Specified by:
addUndoableEditListener in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Specified by:
removeUndoableEditListener in interface ca.sqlpower.sql.DataSourceCollection<ca.sqlpower.sql.SPDataSource>

setEditorPanelModel

public void setEditorPanelModel(ca.sqlpower.object.SPObject editorPanelModel)

getEditorPanelModel

public ca.sqlpower.object.SPObject getEditorPanelModel()

addOlapQuery

public void addOlapQuery(OlapQuery newQuery)

addOlapQuery

public void addOlapQuery(OlapQuery newQuery,
                         int index)

getOlapQueries

public java.util.List<OlapQuery> getOlapQueries()

removeDependency

public void removeDependency(ca.sqlpower.object.SPObject dependency)
Specified by:
removeDependency in interface ca.sqlpower.object.SPObject

getDependencies

public java.util.List<WabitObject> getDependencies()
Specified by:
getDependencies in interface ca.sqlpower.object.SPObject

findByUuid

public <T extends ca.sqlpower.object.SPObject> T findByUuid(java.lang.String uuid,
                                                            java.lang.Class<T> expectedType)
Locates the WabitObject inside this workspace which has the given UUID, returning null if the item is not found. Throws ClassCastException if in item is found, but it is not of the expected type.

Type Parameters:
T - The expected type of the item
Parameters:
uuid - The UUID of the item
expectedType - The type of the item with the given UUID. If you are uncertain what type of object it is, or you do not want a ClassCastException in case the item is of the wrong type, use WabitObject.class for this parameter.
Returns:
The item, or null if no item with the given UUID exists in this workspace.

removeChildImpl

protected boolean removeChildImpl(ca.sqlpower.object.SPObject child)
Specified by:
removeChildImpl in class ca.sqlpower.object.AbstractSPObject

addChildImpl

protected void addChildImpl(ca.sqlpower.object.SPObject child,
                            int index)
Overrides:
addChildImpl in class ca.sqlpower.object.AbstractSPObject

mergeIntoWorkspace

public int mergeIntoWorkspace(WabitWorkspace workspace)
This method will merge all of the objects in this workspace into the given workspace. Once this workspace has been merged in this workspace can be thrown away as it will have no children and will just be a leftover husk of what it once was.

Parameters:
workspace - The workspace to move all of the current workspace's children into.
Returns:
The number of objects imported into the given workspace.

isServerWorkspace

public boolean isServerWorkspace()

isMagicDisabled

public boolean isMagicDisabled()

setMagicDisabled

public void setMagicDisabled(boolean magicDisabled)

reset

public void reset()
Resets the workspace by removing all of the children in the workspace and setting all of the values in the workspace to defaults. Child removed events and other events will be thrown as children of the workspace are removed and cleaned up.


getAllowedChildTypes

public java.util.List<java.lang.Class<? extends ca.sqlpower.object.SPObject>> getAllowedChildTypes()


Copyright © 2009. All Rights Reserved.