cst.adminTool.persistenceLayer
Class ProductionAdminService

java.lang.Object
  extended by cst.common.persistenceLayer.AbstractProductionService
      extended by cst.adminTool.persistenceLayer.ProductionAdminService
All Implemented Interfaces:
AdminServiceAPI, CSTServiceAPI

public class ProductionAdminService
extends AbstractProductionService
implements AdminServiceAPI

The implementation of AdminServiceAPI that manages the data repository as a MySQL database. The class services business operations expected by the Administration Tool. This class is responsible for the following tasks:

Many methods follow the same sequence of steps:

  1. validating an administrator user
  2. allocating a database connection
  3. turning auto-commit off if the activity is supposed to update the database
  4. delegating SQL operations to ProductionAdminQueries.
  5. if the operation is successful, commit changes to the database
  6. if any errors were encountered, catch the error, perform rollback and recovery, then throw the error again to the client code

 Copyright 2010 Medical Research Council Unit for Lifelong Health and Ageing
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software 
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.  
 

Version:
1.0
Author:
Kevin Garwood (kgarwood@users.sourceforge.net)

Field Summary
 
Fields inherited from class cst.common.persistenceLayer.AbstractProductionService
activityChangesTableName, configurationManager, databaseName, log, productionServiceConnectionManager, sessionProperties, subjectTableName, trialSubjectModelFactory, userQueries, userTableName
 
Constructor Summary
ProductionAdminService()
           
 
Method Summary
 void addUser(User adminUser, User user)
          public void changeActivityName(User adminUser, String oldActivityDataStorageName, String newActivityDataStorageName) throws CSTException { validateAdministrator(adminUser); } public void addActivityStep(User adminUser, String activityDataStorageName, String activityStepDataStorageName) throws CSTException { validateAdministrator(adminUser); } public void changeActivityStepName(User adminUser, String oldActivityDataStorageName, String newActivityDataStorageName, String activityStepDataStorageName) throws CSTException { validateAdministrator(adminUser); }
 void changeAdministratorPassword(User candidateAdminUser, java.lang.String newPassword)
           
 void clearChanges(User adminUser)
          removes all records that describe changes made to activity data.
 void clearDatabase(User adminUser)
          produces an empty database.
 void clearUsers(User adminUser)
          removes all users from the list of registered users.
 void createDatabase(User admin)
          creates a database according to settings specified in the configuration file the end users choose when they start the Administration Tool.
 boolean databaseExists(User adminUser)
          determines whether the database described in the configuration file at startup exists or not.
 void deleteDatabase(User admin)
          deletes the database described in the configuration file end users choose when they start the Administration Tool.
 void deleteUser(User adminUser, User user)
          deletes a user from the registry of known users.
 java.util.ArrayList<User> getRegisteredUsers(User adminUser)
          returns a collection of registered users for the system.
 java.util.ArrayList<TrialSubjectModel> getSubjectAttributeData(User adminUser)
          Provides all the subject attribute data that is needed to uniquely identify and filter subjects.
 void importTrialSubjectModels(User adminUser, java.util.ArrayList<TrialSubjectModel> trialSubjectModels)
          imports a collection of trial subject model records into the data repository.
 void initialise(SessionProperties sessionProperties)
           
 void synchroniseRepository(User adminUser)
          ensures that every activity and activity step defined in the configuration file specied at startup has a corresponding entry in the data repository.
 void updateUser(User adminUser, User user)
          update the details of an existing user
 boolean userExists(User adminUser, java.lang.String userID)
          determines whether a given userID exists in the collection of registered users
 boolean validateAdministrator(User adminUser)
          determine whether a given user is the administrator or not
 
Methods inherited from class cst.common.persistenceLayer.AbstractProductionService
checkRepositoryIsSynchronised, closeStatements, commitDatabaseChanges, getTrialSubjectModel, initialiseConnection, rollBack, updateTrialActivity, validateUser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cst.common.businessLayer.CSTServiceAPI
checkRepositoryIsSynchronised, getTrialSubjectModel
 

Constructor Detail

ProductionAdminService

public ProductionAdminService()
Method Detail

createDatabase

public void createDatabase(User admin)
                    throws CSTException
Description copied from interface: AdminServiceAPI
creates a database according to settings specified in the configuration file the end users choose when they start the Administration Tool.

Specified by:
createDatabase in interface AdminServiceAPI
Throws:
CSTException

clearDatabase

public void clearDatabase(User adminUser)
                   throws CSTException
Description copied from interface: AdminServiceAPI
produces an empty database. This method exists mainly to service testing efforts

Specified by:
clearDatabase in interface AdminServiceAPI
Throws:
CSTException

deleteDatabase

public void deleteDatabase(User admin)
                    throws CSTException
Description copied from interface: AdminServiceAPI
deletes the database described in the configuration file end users choose when they start the Administration Tool.

Specified by:
deleteDatabase in interface AdminServiceAPI
Throws:
CSTException

getRegisteredUsers

public java.util.ArrayList<User> getRegisteredUsers(User adminUser)
                                             throws CSTException
Description copied from interface: AdminServiceAPI
returns a collection of registered users for the system.

Specified by:
getRegisteredUsers in interface AdminServiceAPI
Returns:
Throws:
CSTException

userExists

public boolean userExists(User adminUser,
                          java.lang.String userID)
                   throws CSTException
Description copied from interface: AdminServiceAPI
determines whether a given userID exists in the collection of registered users

Specified by:
userExists in interface AdminServiceAPI
Returns:
Throws:
CSTException

validateAdministrator

public boolean validateAdministrator(User adminUser)
                              throws CSTException
Description copied from interface: AdminServiceAPI
determine whether a given user is the administrator or not

Specified by:
validateAdministrator in interface AdminServiceAPI
Returns:
Throws:
CSTException

changeAdministratorPassword

public void changeAdministratorPassword(User candidateAdminUser,
                                        java.lang.String newPassword)
                                 throws CSTException
Throws:
CSTException

initialise

public void initialise(SessionProperties sessionProperties)
                throws CSTException
Specified by:
initialise in interface CSTServiceAPI
Overrides:
initialise in class AbstractProductionService
Throws:
CSTException

getSubjectAttributeData

public java.util.ArrayList<TrialSubjectModel> getSubjectAttributeData(User adminUser)
                                                               throws CSTException
Description copied from interface: AdminServiceAPI
Provides all the subject attribute data that is needed to uniquely identify and filter subjects. Subject attribute data are stored in the system to support filtering operations found in the LoggingTool. For example, values for "Location", "Gender", "Strain", "Age Group" are subject attributes which are used to filter subjects but which are not actively maintained and edited by data curators.

Specified by:
getSubjectAttributeData in interface AdminServiceAPI
Returns:
Throws:
CSTException

importTrialSubjectModels

public void importTrialSubjectModels(User adminUser,
                                     java.util.ArrayList<TrialSubjectModel> trialSubjectModels)
                              throws CSTException
Description copied from interface: AdminServiceAPI
imports a collection of trial subject model records into the data repository. When a record is imported, an entry is made for both the subject attribute data and blank entries for each activity associated with it. Subject records each have a unique identifier. Imported subject records may overwrite existing records.

Specified by:
importTrialSubjectModels in interface AdminServiceAPI
Throws:
CSTException

addUser

public void addUser(User adminUser,
                    User user)
             throws CSTException
public void changeActivityName(User adminUser, String oldActivityDataStorageName, String newActivityDataStorageName) throws CSTException { validateAdministrator(adminUser); } public void addActivityStep(User adminUser, String activityDataStorageName, String activityStepDataStorageName) throws CSTException { validateAdministrator(adminUser); } public void changeActivityStepName(User adminUser, String oldActivityDataStorageName, String newActivityDataStorageName, String activityStepDataStorageName) throws CSTException { validateAdministrator(adminUser); }

Specified by:
addUser in interface AdminServiceAPI
Throws:
CSTException

updateUser

public void updateUser(User adminUser,
                       User user)
                throws CSTException
Description copied from interface: AdminServiceAPI
update the details of an existing user

Specified by:
updateUser in interface AdminServiceAPI
Throws:
CSTException

deleteUser

public void deleteUser(User adminUser,
                       User user)
                throws CSTException
Description copied from interface: AdminServiceAPI
deletes a user from the registry of known users.

Specified by:
deleteUser in interface AdminServiceAPI
Throws:
CSTException

clearUsers

public void clearUsers(User adminUser)
                throws CSTException
Description copied from interface: AdminServiceAPI
removes all users from the list of registered users.

Specified by:
clearUsers in interface AdminServiceAPI
Throws:
CSTException

databaseExists

public boolean databaseExists(User adminUser)
                       throws CSTException
Description copied from interface: AdminServiceAPI
determines whether the database described in the configuration file at startup exists or not.

Specified by:
databaseExists in interface AdminServiceAPI
Returns:
Throws:
CSTException

clearChanges

public void clearChanges(User adminUser)
                  throws CSTException
Description copied from interface: AdminServiceAPI
removes all records that describe changes made to activity data.

Specified by:
clearChanges in interface AdminServiceAPI
Throws:
CSTException

synchroniseRepository

public void synchroniseRepository(User adminUser)
                           throws CSTException
Description copied from interface: AdminServiceAPI
ensures that every activity and activity step defined in the configuration file specied at startup has a corresponding entry in the data repository. Although this method is supported by both Demonstration and Production versions of the service, its main use is to ensure that elements in the configuration file match elements in the MySQL database.

Specified by:
synchroniseRepository in interface AdminServiceAPI
Throws:
CSTException