ca.sqlpower.wabit
Class WabitWorkspace

java.lang.Object
  extended by ca.sqlpower.wabit.AbstractWabitObject
      extended by ca.sqlpower.wabit.WabitWorkspace
All Implemented Interfaces:
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 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(WabitObject child, int index)
          This is the object specific implementation of #addChild(WabitObject).
 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(Group g)
           
 void addGroup(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(User u)
           
 void addUser(User u, int index)
           
 boolean allowsChildren()
          Returns true if this object may contain children.
 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.
 boolean dsAlreadyAdded(ca.sqlpower.sql.SPDataSource dbcs)
           
<T extends WabitObject>
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<Chart> getCharts()
           
 java.util.List<WabitObject> getChildren()
          Returns an unmodifiable list of the children in this WabitObject.
 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()
          Returns a list of all WabitObjects that this Wabit object is dependent on.
 WabitObject getEditorPanelModel()
           
 java.util.List<Group> getGroups()
           
 java.util.List<WabitImage> getImages()
           
 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<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(WabitObject child)
          This is the object specific implementation of removeChild.
 void removeDatabaseListChangeListener(ca.sqlpower.sql.DatabaseListChangeListener l)
           
 void removeDataSource(ca.sqlpower.sql.SPDataSource dbcs)
           
 boolean removeDataSourceType(ca.sqlpower.sql.JDBCDataSourceType dataSourceType)
           
 void removeDependency(WabitObject dependency)
          Removes the given object as a dependency of this object.
 boolean removeGroup(Group g)
           
 boolean removeReportTask(ReportTask task)
           
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
           
 boolean removeUser(User u)
           
 void setEditorPanelModel(WabitObject 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
addChild, addWabitListener, begin, beginTransaction, cleanup, commit, commitTransaction, equals, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, generateNewUUID, getChildren, getName, getUUID, isForegroundThread, removeChild, removeWabitListener, rollback, rollbackTransaction, runInBackground, runInForeground, setName, setParent, setUUID, toString
 
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
 

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<WabitObject> getChildren()
Description copied from interface: WabitObject
Returns an unmodifiable list of the children in this WabitObject. If there are no children in this WabitObject an empty list should be returned.

Specified by:
getChildren in interface WabitObject

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.

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 WabitObject> childType)
Description copied from interface: WabitObject
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.

Specified by:
childPositionOffset in interface WabitObject

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(User u)

addUser

public void addUser(User u,
                    int index)

removeUser

public boolean removeUser(User u)

getUsers

public java.util.List<User> getUsers()

addGroup

public void addGroup(Group g)

addGroup

public void addGroup(Group g,
                     int index)

removeGroup

public boolean removeGroup(Group g)

getGroups

public java.util.List<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 WabitObject
Overrides:
getParent in class AbstractWabitObject
Returns:
The parent of this object.

allowsChildren

public boolean allowsChildren()
Description copied from interface: WabitObject
Returns true if this object may contain children. Not all types of WabitObjects can be a child to any WabitObject.

Specified by:
allowsChildren in interface WabitObject
See Also:
WabitObject.childPositionOffset(Class)

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>

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(WabitObject editorPanelModel)

getEditorPanelModel

public WabitObject 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(WabitObject dependency)
Description copied from interface: WabitObject
Removes the given object as a dependency of this object. For this object to no longer be dependent on the given dependency all of its children must also not be dependent on the given dependency when this method returns. This may remove this object from its parent if necessary.

Specified by:
removeDependency in interface WabitObject

getDependencies

public java.util.List<WabitObject> getDependencies()
Description copied from interface: WabitObject
Returns a list of all WabitObjects 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.

Specified by:
getDependencies in interface WabitObject

findByUuid

public <T extends WabitObject> 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(WabitObject child)
Description copied from class: AbstractWabitObject
This is the object specific implementation of removeChild. There are checks in the removeChild method to ensure the child being removed has no dependencies and is a child of this object.

Specified by:
removeChildImpl in class AbstractWabitObject
See Also:
AbstractWabitObject.removeChild(WabitObject)

addChildImpl

protected void addChildImpl(WabitObject child,
                            int index)
Description copied from class: AbstractWabitObject
This is the object specific implementation of #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.

Overrides:
addChildImpl in class AbstractWabitObject
Parameters:
child - The child to add to this object.
index - The index to add the child at.

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)


Copyright © 2009. All Rights Reserved.