use of org.apereo.portal.jpa.BasePortalJpaDao.PortalTransactional in project uPortal by Jasig.
the class VersionedDataUpdaterImpl method postUpdateDatabase.
@Override
@PortalTransactional
public void postUpdateDatabase(String product) {
//This happens first because even if there are no updaters we need to make sure the attempted update is valid
final Version dbVersion = getAndVerifyDatabaseVersionForUpdate(product);
final SortedSet<IVersionedDatabaseUpdateHelper> updateHelpers = this.databaseUpdateHelpers.get(product);
if (updateHelpers == null || updateHelpers.isEmpty()) {
logger.info("No IVersionedDatabaseUpdateHelpers configured for database {}, nothing will be done in postUpdate", product);
} else {
//updateHelpers is sorted oldest to newest by version so iterate through and run the updaters that apply
for (final IVersionedDatabaseUpdateHelper updateHelper : updateHelpers) {
final Version updateVersion = updateHelper.getVersion();
if (dbVersion.equals(updateVersion) || dbVersion.isBefore(updateVersion)) {
logger.info("PostUpdate {} from {} to {}", product, dbVersion, updateVersion);
updateHelper.postUpdate();
logger.info("PostUpdate {} from {} to {} complete", product, dbVersion, updateVersion);
}
}
}
//Update the db version number
final Version codeVersion = this.requiredProductVersions.get(product);
logger.info("PostUpdate - Set {} version to {}", product, codeVersion);
this.versionDao.setVersion(product, codeVersion);
}
use of org.apereo.portal.jpa.BasePortalJpaDao.PortalTransactional in project uPortal by Jasig.
the class VersionedDataUpdaterImpl method postInitDatabase.
@Override
@PortalTransactional
public void postInitDatabase(String product) {
final Version version = this.requiredProductVersions.get(product);
if (version == null) {
throw new IllegalArgumentException("No Version is configured for: " + product);
}
logger.info("PostInit - Set {} version to {}", product, version);
this.versionDao.setVersion(product, version);
}
Aggregations