public class DatabaseUpdater extends Object
| Modifier and Type | Class and Description | 
|---|---|
static interface  | 
DatabaseUpdater.ChangeSetExecutorCallback
Interface used for callbacks when updating the database. 
 | 
static class  | 
DatabaseUpdater.OpenMRSChangeSet
Represents each change in the liquibase-update-to-latest 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static String | 
DATABASE_UPDATES_LOG_FILE  | 
| Constructor and Description | 
|---|
DatabaseUpdater()  | 
| Modifier and Type | Method and Description | 
|---|---|
static Boolean | 
allowAutoUpdate()
Indicates whether automatic database updates are allowed by this server. 
 | 
static void | 
executeChangelog()
Convenience method to run the changesets using Liquibase to bring the database up to a
 version compatible with the code 
 | 
static void | 
executeChangelog(String changelog,
                Map<String,Object> userInput)
Run changesets on database using Liquibase to get the database up to the most recent version 
 | 
static List<String> | 
executeChangelog(String changelog,
                Map<String,Object> userInput,
                DatabaseUpdater.ChangeSetExecutorCallback callback)
Executes the given changelog file. 
 | 
static List<String> | 
executeChangelog(String changeLogFile,
                String contexts,
                Map<String,Object> userInput,
                DatabaseUpdater.ChangeSetExecutorCallback callback)
 | 
static List<String> | 
executeChangelog(String changeLogFile,
                String contexts,
                Map<String,Object> userInput,
                DatabaseUpdater.ChangeSetExecutorCallback callback,
                ClassLoader cl)
This code was borrowed from the liquibase jar so that we can call the given callback
 function. 
 | 
static Integer | 
getAuthenticatedUserId()  | 
static Connection | 
getConnection()
Gets a database connection for liquibase to do the updates 
 | 
static List<DatabaseUpdater.OpenMRSChangeSet> | 
getDatabaseChanges()
Looks at the current liquibase-update-to-latest.xml file and then checks the database to see
 if they have been run. 
 | 
static List<DatabaseUpdater.OpenMRSChangeSet> | 
getUnrunDatabaseChanges()
Looks at the current liquibase-update-to-latest.xml file returns all changesets in that file
 that have not been run on the database yet. 
 | 
static void | 
reportUpdateWarnings(List<String> warnings)
This method is called by an executing custom changeset to register warning messages. 
 | 
static void | 
setAuthenticatedUserId(Integer userId)  | 
static boolean | 
updatesRequired()
Ask Liquibase if it needs to do any updates 
 | 
static void | 
writeUpdateMessagesToFile(String text)
This method writes the given text to the database updates log file located in the application
 data directory. 
 | 
public static final String DATABASE_UPDATES_LOG_FILE
public static void executeChangelog()
                             throws DatabaseUpdateException,
                                    InputRequiredException
InputRequiredException - if the changelog file requirest some sort of user input. The
             error object will list of the user prompts and type of data for each promptDatabaseUpdateException#update(Map), 
executeChangelog(String, Map)public static void executeChangelog(String changelog, Map<String,Object> userInput) throws DatabaseUpdateException, InputRequiredException
changelog - the liquibase changelog file to use (or null to use the default file)userInput - nullable map from question to user answer. Used if a call to update(null)
            threw an InputRequiredExceptionDatabaseUpdateExceptionInputRequiredExceptionpublic static List<String> executeChangelog(String changelog, Map<String,Object> userInput, DatabaseUpdater.ChangeSetExecutorCallback callback) throws DatabaseUpdateException, InputRequiredException
CHANGE_LOG_FILE is ran.changelog - The string filename of a liquibase changelog xml file to runuserInput - nullable map from question to user answer. Used if a call to
            executeChangelog(InputRequiredExceptionInputRequiredException - if the changelog file requirest some sort of user input. The
             error object will list of the user prompts and type of data for each promptDatabaseUpdateException@Deprecated public static List<String> executeChangelog(String changeLogFile, String contexts, Map<String,Object> userInput, DatabaseUpdater.ChangeSetExecutorCallback callback) throws Exception
Exceptionpublic static List<String> executeChangelog(String changeLogFile, String contexts, Map<String,Object> userInput, DatabaseUpdater.ChangeSetExecutorCallback callback, ClassLoader cl) throws Exception
changeLogFile - the file to executecontexts - the liquibase changeset contextuserInput - answers given by the usercallback - the function to call after every changesetcl - ClassLoader to use to find the changeLogFile (or null to use
            OpenmrsClassLoader)Exceptionpublic static boolean updatesRequired()
                               throws Exception
Exceptionpublic static Boolean allowAutoUpdate()
public static Connection getConnection() throws Exception
Exception@Authorized(value="View Database Changes") public static List<DatabaseUpdater.OpenMRSChangeSet> getDatabaseChanges() throws Exception
Exception@Authorized(value="View Database Changes") public static List<DatabaseUpdater.OpenMRSChangeSet> getUnrunDatabaseChanges() throws Exception
Exceptionpublic static Integer getAuthenticatedUserId()
public static void setAuthenticatedUserId(Integer userId)
authenticatedUserId - the authenticatedUserId to setpublic static void reportUpdateWarnings(List<String> warnings)
warnings - list of warnings to append to the end of the current listpublic static void writeUpdateMessagesToFile(String text)
the - text to be written to the fileCopyright © 2018 OpenMRS LLC.. All Rights Reserved.