|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openmrs.util.DatabaseUpdater
public class DatabaseUpdater
This class uses Liquibase to update the database.
See /metadata/model/liquibase-update-to-latest.xml for the changes. This class will also run
arbitrary liquibase xml files on the associated database as well. Details for the database are
taken from the openmrs runtime properties.
| Nested Class Summary | |
|---|---|
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 |
| Field Summary | |
|---|---|
static java.lang.String |
DATABASE_UPDATES_LOG_FILE
|
| Constructor Summary | |
|---|---|
DatabaseUpdater()
|
|
| Method Summary | |
|---|---|
static java.lang.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(java.lang.String changelog,
java.util.Map<java.lang.String,java.lang.Object> userInput)
Run changesets on database using Liquibase to get the database up to the most recent version |
static java.util.List<java.lang.String> |
executeChangelog(java.lang.String changelog,
java.util.Map<java.lang.String,java.lang.Object> userInput,
DatabaseUpdater.ChangeSetExecutorCallback callback)
Executes the given changelog file. |
static java.util.List<java.lang.String> |
executeChangelog(java.lang.String changeLogFile,
java.lang.String contexts,
java.util.Map<java.lang.String,java.lang.Object> userInput,
DatabaseUpdater.ChangeSetExecutorCallback callback)
Deprecated. use executeChangelog(String, String, Map, ChangeSetExecutorCallback, ClassLoader) |
static java.util.List<java.lang.String> |
executeChangelog(java.lang.String changeLogFile,
java.lang.String contexts,
java.util.Map<java.lang.String,java.lang.Object> userInput,
DatabaseUpdater.ChangeSetExecutorCallback callback,
java.lang.ClassLoader cl)
This code was borrowed from the liquibase jar so that we can call the given callback function. |
static java.lang.Integer |
getAuthenticatedUserId()
|
static java.sql.Connection |
getConnection()
Gets a database connection for liquibase to do the updates |
static java.util.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 java.util.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(java.util.List<java.lang.String> warnings)
This method is called by an executing custom changeset to register warning messages. |
static void |
setAuthenticatedUserId(java.lang.Integer userId)
|
static boolean |
updatesRequired()
Ask Liquibase if it needs to do any updates |
static void |
writeUpdateMessagesToFile(java.lang.String text)
This method writes the given text to the database updates log file located in the application data directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DATABASE_UPDATES_LOG_FILE
| Constructor Detail |
|---|
public DatabaseUpdater()
| Method Detail |
|---|
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 prompt
DatabaseUpdateException#update(Map),
executeChangelog(String, Map)
public static void executeChangelog(java.lang.String changelog,
java.util.Map<java.lang.String,java.lang.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 InputRequiredException
DatabaseUpdateException
InputRequiredException
public static java.util.List<java.lang.String> executeChangelog(java.lang.String changelog,
java.util.Map<java.lang.String,java.lang.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(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 prompt
DatabaseUpdateException
@Deprecated
public static java.util.List<java.lang.String> executeChangelog(java.lang.String changeLogFile,
java.lang.String contexts,
java.util.Map<java.lang.String,java.lang.Object> userInput,
DatabaseUpdater.ChangeSetExecutorCallback callback)
throws java.lang.Exception
executeChangelog(String, String, Map, ChangeSetExecutorCallback, ClassLoader)
java.lang.Exception
public static java.util.List<java.lang.String> executeChangelog(java.lang.String changeLogFile,
java.lang.String contexts,
java.util.Map<java.lang.String,java.lang.Object> userInput,
DatabaseUpdater.ChangeSetExecutorCallback callback,
java.lang.ClassLoader cl)
throws java.lang.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)
java.lang.Exception
public static boolean updatesRequired()
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.Boolean allowAutoUpdate()
public static java.sql.Connection getConnection()
throws java.lang.Exception
java.lang.Exception
@Authorized(value="View Database Changes")
public static java.util.List<DatabaseUpdater.OpenMRSChangeSet> getDatabaseChanges()
throws java.lang.Exception
java.lang.Exception
@Authorized(value="View Database Changes")
public static java.util.List<DatabaseUpdater.OpenMRSChangeSet> getUnrunDatabaseChanges()
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.Integer getAuthenticatedUserId()
public static void setAuthenticatedUserId(java.lang.Integer userId)
authenticatedUserId - the authenticatedUserId to setpublic static void reportUpdateWarnings(java.util.List<java.lang.String> warnings)
warnings - list of warnings to append to the end of the current listpublic static void writeUpdateMessagesToFile(java.lang.String text)
the - text to be written to the file
|
OpenMRS-1.7.x | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||