au.gov.naa.digipres.dpr.core
Class DPRClient
java.lang.Object
  extended by au.gov.naa.digipres.dpr.core.DPRClient

public class DPRClient
extends java.lang.Object

This class represents a client to the DPR Model and Task management system. An application wishing to use DPR (be it through a UI, CLI, Web Browser, or Unit Test) should instantiate this class to connect to the data store. On instantiation, the data access manager is null; if the data access manager is not set before a connection is attempted then a default data access manager, using Hibernate, will be instantiated and used. This class provides information such as the current user that is logged in, access to system preferences, the logging package, and so on.


Constructor Summary
DPRClient()
          Create a new instance of a DPR Client.
DPRClient(boolean debugMode)
          Create a new instance of a DPR Client, with the debug mode set by the given flag.
 
Method Summary
 void connectToDataStore(java.util.Map<java.lang.String,java.lang.String> connectionProperties)
          Connect to the data store - this call is passed to the connection exception.
 void disconnectFromDataStore()
          Disconnect from the data store.
 java.util.Map<java.lang.String,java.lang.String> getConnectionProperties()
          Return the connection properties for the current data access manager.
 Facility getCurrentFacility()
          Return the current facility
 DataAccessManager getDataAccessManager()
          Return the data access manager.
 boolean getGenerateDummyAips()
           
 DPRPreferences getPreferences()
           
 Task getTaskByName(User user, java.lang.String taskName)
          Get the specified task by name.
 boolean isLoggedOn()
          Return true if a user has logged on to this DPR Client.
 boolean isTaskEnabled(User user, java.lang.String taskName)
           
 void logOff(User user)
           
 User logOn(java.lang.String userName, java.lang.String password, DataAccessManager.LogOnHandler logOnHandler)
          Connect to the persistance layer, and log the user on.
 void setDataAccessManager(DataAccessManager dataAccessManager)
          Set the data access manager to use.
 void setGenerateDummyAips(boolean generateDummyAips)
           
 void setPreferences(DPRPreferences preferences)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DPRClient

public DPRClient()
Create a new instance of a DPR Client. By default, debug mode is set to true, to produce verbose output.


DPRClient

public DPRClient(boolean debugMode)
Create a new instance of a DPR Client, with the debug mode set by the given flag.

Parameters:
debugMode -
Method Detail

setDataAccessManager


public void setDataAccessManager(DataAccessManager dataAccessManager)
Set the data access manager to use. If the data access manager is NOT null, (ie it has already been set) then throw an illegal state exception.

Parameters:
dataAccessManager -

getDataAccessManager

public DataAccessManager getDataAccessManager()
Return the data access manager. If the data access manager has not been instantiated, then we create an instance of the default data access manager (the hibernate one!)

Returns:
The data access manager

getConnectionProperties

public java.util.Map<java.lang.String,java.lang.String> getConnectionProperties()
Return the connection properties for the current data access manager.

See Also:
DataAccessManager#getConnectionProperties()

connectToDataStore

public void connectToDataStore(java.util.Map<java.lang.String,java.lang.String> connectionProperties)
                        throws ConnectionException
Connect to the data store - this call is passed to the connection exception.

Parameters:
connectionProperties -
Throws:
ConnectionException - in the case of an error
See Also:
DataAccessManager#connectToDataStore(Map)

disconnectFromDataStore

public void disconnectFromDataStore()
                             throws ConnectionException
Disconnect from the data store.

Throws:
ConnectionException

logOn

public User logOn(java.lang.String userName,
                  java.lang.String password,
                  DataAccessManager.LogOnHandler logOnHandler)
           throws ConnectionException,
                  AccessDeniedException
Connect to the persistance layer, and log the user on.

Throws:
ConnectionException
AccessDeniedException

logOff

public void logOff(User user)

getTaskByName


public Task getTaskByName(User user,
                          java.lang.String taskName)
                   throws AccessRestrictedException
Get the specified task by name. This will invoke the constructor for the object, and if the current user has insufficient privileges the task will return false from Task#isEnabled() and attempts to do work on the task will throw run time exceptions.
This method will throw illegal state exceptions if the data store is not connected to the back end or we are not currently logged in.

Parameters:
taskName - The name of the task to retrieve
Returns:
The task given by the name, null if that task is not available on this facility.
Throws:
AccessRestrictedException

isTaskEnabled

public boolean isTaskEnabled(User user,
                             java.lang.String taskName)

isLoggedOn

public boolean isLoggedOn()
Return true if a user has logged on to this DPR Client.

Returns:
true if a user has logged on to this DPR Client.

getCurrentFacility

public Facility getCurrentFacility()
Return the current facility

Returns:

getGenerateDummyAips

public boolean getGenerateDummyAips()
Returns:
the generateDummyAips

setGenerateDummyAips

public void setGenerateDummyAips(boolean generateDummyAips)
Parameters:
generateDummyAips - the generateDummyAips to set

getPreferences

public DPRPreferences getPreferences()

setPreferences

public void setPreferences(DPRPreferences preferences)