Search in sources :

Example 1 with PortalTransactional

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);
}
Also used : Version(org.apereo.portal.version.om.Version) PortalTransactional(org.apereo.portal.jpa.BasePortalJpaDao.PortalTransactional)

Example 2 with PortalTransactional

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);
}
Also used : Version(org.apereo.portal.version.om.Version) PortalTransactional(org.apereo.portal.jpa.BasePortalJpaDao.PortalTransactional)

Aggregations

PortalTransactional (org.apereo.portal.jpa.BasePortalJpaDao.PortalTransactional)2 Version (org.apereo.portal.version.om.Version)2