cst.adminTool.persistenceLayer
Class DataRepositorySynchronisationUtility

java.lang.Object
  extended by cst.adminTool.persistenceLayer.DataRepositorySynchronisationUtility

public class DataRepositorySynchronisationUtility
extends java.lang.Object

A utility class designed to detect differences between activity properties specified in the configuration file and corresponding properties in the Production (MySQL) data repository. The class is also capable of automatically creating new activities and fields as necessary.

Note that synchronisation never deletes or renames tables and fields from the database. It will simply add new tables and fields if none exist in the database. We do not feel at this point that deleting or renaming tables will be a big issue for clinical study activities where the duration of the study is for a limited time and when projects are encouraged to retain all information they generate throughout the course of their study.


 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
protected  java.lang.String activityChangesTableName
           
protected  java.lang.String databaseName
           
protected  java.lang.String subjectTableName
           
protected  TrialSubjectModelFactory trialSubjectModelFactory
           
protected  java.lang.String userTableName
           
 
Constructor Summary
DataRepositorySynchronisationUtility(SessionProperties sessionProperties)
           
 
Method Summary
 void checkRepositoryIsSynchronised(java.sql.Connection connection)
           
protected  java.util.ArrayList<CSTError> checkTableFieldsExist(java.sql.Connection connection, java.lang.String tableName, java.util.ArrayList<java.lang.String> fieldNames)
           
 void synchroniseRepository(java.sql.Connection connection)
           
protected  boolean tableExists(java.sql.Connection connection, java.lang.String tableName)
           
protected  boolean tableFieldExists(java.sql.Connection connection, java.lang.String tableName, java.lang.String fieldName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trialSubjectModelFactory

protected TrialSubjectModelFactory trialSubjectModelFactory

databaseName

protected java.lang.String databaseName

userTableName

protected java.lang.String userTableName

subjectTableName

protected java.lang.String subjectTableName

activityChangesTableName

protected java.lang.String activityChangesTableName
Constructor Detail

DataRepositorySynchronisationUtility

public DataRepositorySynchronisationUtility(SessionProperties sessionProperties)
Method Detail

synchroniseRepository

public void synchroniseRepository(java.sql.Connection connection)
                           throws CSTException
Throws:
CSTException

checkRepositoryIsSynchronised

public void checkRepositoryIsSynchronised(java.sql.Connection connection)
                                   throws CSTException
Throws:
CSTException

tableExists

protected boolean tableExists(java.sql.Connection connection,
                              java.lang.String tableName)
                       throws java.lang.Exception
Throws:
java.lang.Exception

tableFieldExists

protected boolean tableFieldExists(java.sql.Connection connection,
                                   java.lang.String tableName,
                                   java.lang.String fieldName)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

checkTableFieldsExist

protected java.util.ArrayList<CSTError> checkTableFieldsExist(java.sql.Connection connection,
                                                              java.lang.String tableName,
                                                              java.util.ArrayList<java.lang.String> fieldNames)
                                                       throws java.lang.Exception
Throws:
java.lang.Exception