ca.sqlpower.wabit.dao
Class OpenWorkspaceXMLDAO

java.lang.Object
  extended by ca.sqlpower.wabit.dao.OpenWorkspaceXMLDAO
All Implemented Interfaces:
ca.sqlpower.util.Monitorable

public class OpenWorkspaceXMLDAO
extends java.lang.Object
implements ca.sqlpower.util.Monitorable

This DAO will load workspaces to a context from a given input stream. Each time a new input stream is to be loaded a new instance of this class should be created.


Field Summary
static long UNKNOWN_STREAM_LENGTH
          Constant specifying that the length of a workspace XML stream is unknown.
 
Constructor Summary
OpenWorkspaceXMLDAO(WabitSessionContext context, java.io.InputStream in, long bytesInStream)
          Creates a new XML DAO for Wabit workspaces.
 
Method Summary
 void addImportedWorkspaceContentToWorkspace(WabitSession session)
          Call this method to add the WabitObjects in the loaded workspaces to the given session .
 WabitSession addLoadedWorkspacesToContext()
          Call this method to register the loaded workspace with the context in this DAO.
 java.lang.Integer getJobSize()
           
 java.lang.String getMessage()
           
 int getProgress()
           
 boolean hasStarted()
           
 void importWorkspaces(WabitSession session)
          Calling this method will import all of the workspaces from the input stream into the session given.
 boolean isCancelled()
           
 boolean isFinished()
           
 void loadWorkspacesFromStream()
          Call this method to load the workspaces in the given stream into the saxHandler.
 WabitSession openWorkspaces()
          Calling this method will load the workspaces from the input stream into the context that was given to this class when its constructor was called.
 void setCancelled(boolean cancelled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_STREAM_LENGTH

public static final long UNKNOWN_STREAM_LENGTH
Constant specifying that the length of a workspace XML stream is unknown.

See Also:
Constant Field Values
Constructor Detail

OpenWorkspaceXMLDAO

public OpenWorkspaceXMLDAO(WabitSessionContext context,
                           java.io.InputStream in,
                           long bytesInStream)
Creates a new XML DAO for Wabit workspaces. This must be constructed on the foreground thread.

Parameters:
context - The session context to create new sessions in.
in - The input stream of the workspace's XML representation.
bytesInStream - The length of the stream in question. If not known, specify UNKNOWN_STREAM_LENGTH.
Method Detail

loadWorkspacesFromStream

public void loadWorkspacesFromStream()
Call this method to load the workspaces in the given stream into the saxHandler. This is the first step to loading or importing a file into Wabit. This needs to be done before any other parts of loading if it is being done in multiple parts.

If loading is done on multiple threads this operation can be done on a separate thread. This method should only be called once for each DAO.


addLoadedWorkspacesToContext

public WabitSession addLoadedWorkspacesToContext()
Call this method to register the loaded workspace with the context in this DAO. This is the last step to loading a file into Wabit.

If loading is done on multiple threads this operation must be done on the event dispatch thread. This should only be called once for each DAO or the same workspace will be added to the context multiple times.

Returns:
The session that contain the workspaces that have been added to Wabit. This may be null if the load was cancelled.

addImportedWorkspaceContentToWorkspace

public void addImportedWorkspaceContentToWorkspace(WabitSession session)
Call this method to add the WabitObjects in the loaded workspaces to the given session . This is the last step to importing a file into Wabit workspace.

If importing is done on multiple threads this operation must be done on the event dispatch thread. This should only be called once for each DAO or the same workspace will be added to the context multiple times.

Parameters:
session - The session that will have WabitObjects added to it. Null should not be passed into this method.

openWorkspaces

public WabitSession openWorkspaces()
Calling this method will load the workspaces from the input stream into the context that was given to this class when its constructor was called. This is a complete version of loading a file into Wabit. If this method is used no other methods need to be called.

Use this method to load a file into Wabit if there is no concerns about multi threading.


importWorkspaces

public void importWorkspaces(WabitSession session)
Calling this method will import all of the workspaces from the input stream into the session given. This is a complete version of importing a file into a workspace in Wabit. If this method is used no other methods need to be called.

Use this method to import a file into Wabit if there is no concerns about multi threading.

Parameters:
session - The session to import WabitObjects into. This should not be null.

getJobSize

public java.lang.Integer getJobSize()
Specified by:
getJobSize in interface ca.sqlpower.util.Monitorable

getMessage

public java.lang.String getMessage()
Specified by:
getMessage in interface ca.sqlpower.util.Monitorable

getProgress

public int getProgress()
Specified by:
getProgress in interface ca.sqlpower.util.Monitorable

hasStarted

public boolean hasStarted()
Specified by:
hasStarted in interface ca.sqlpower.util.Monitorable

isFinished

public boolean isFinished()
Specified by:
isFinished in interface ca.sqlpower.util.Monitorable

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface ca.sqlpower.util.Monitorable

setCancelled

public void setCancelled(boolean cancelled)
Specified by:
setCancelled in interface ca.sqlpower.util.Monitorable


Copyright © 2009. All Rights Reserved.