use of org.apereo.portal.version.om.Version 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 {
// 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.version.om.Version in project uPortal by Jasig.
the class JpaVersionDaoTest method testVersionLifecycle.
@Test
public void testVersionLifecycle() {
final String productName = "TEST_VERSION";
// Doesn't exist
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final Version version = versionDao.getVersion(productName);
assertNull(version);
}
});
// Create
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
Version version = versionDao.getVersion(productName);
assertNull(version);
version = versionDao.setVersion(productName, 1, 2, 3, null);
assertNotNull(version);
assertEquals(1, version.getMajor());
assertEquals(2, version.getMinor());
assertEquals(3, version.getPatch());
assertNull(version.getLocal());
}
});
// Update
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
Version version = versionDao.getVersion(productName);
assertNotNull(version);
assertEquals(1, version.getMajor());
assertEquals(2, version.getMinor());
assertEquals(3, version.getPatch());
assertNull(version.getLocal());
version = versionDao.setVersion(productName, 4, 5, 6, null);
assertNotNull(version);
assertEquals(4, version.getMajor());
assertEquals(5, version.getMinor());
assertEquals(6, version.getPatch());
assertNull(version.getLocal());
}
});
// verify
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
Version version = versionDao.getVersion(productName);
assertNotNull(version);
assertEquals(4, version.getMajor());
assertEquals(5, version.getMinor());
assertEquals(6, version.getPatch());
assertNull(version.getLocal());
}
});
}
Aggregations