@Transactional(propagation = Propagation.REQUIRES_NEW) public void checkSchemaCompatibility() { if( ! configuration.isSkipSchemaCheck() ) { DbInfo dbInfoSchemaVersion = dbInfoDao.get(DbInfo.SCHEMA_VERSION); SchemaVersion schemaVersion; if (dbInfoSchemaVersion == null ) { if( ! autoPersist ) { throw new IntactInitializationError( "Could not find key "+ DbInfo.SCHEMA_VERSION +" in table IA_DB_INFO, please set IntactInitializer.autoPersist to true so it can be initialized at startup." ); } if ( log.isInfoEnabled() ) log.info( "Schema version does not exist. Will be created: " + requiredSchemaVersion); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredSchemaVersion.toString()); dbInfoDao.persist(dbInfo); } else { try { schemaVersion = SchemaVersion.parse(dbInfoSchemaVersion.getValue()); } catch ( Exception e) { throw new IntactInitializationError("Error parsing schema version", e); } if (!schemaVersion.isCompatibleWith(requiredSchemaVersion)) { throw new IntactInitializationError("Database schema version " + requiredSchemaVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion); } } } }
daof.getDbInfoDao().persist( newDbInfo ); } else {
@Transactional(propagation = Propagation.REQUIRES_NEW) public void checkSchemaCompatibility() { if( ! configuration.isSkipSchemaCheck() ) { DbInfo dbInfoSchemaVersion = dbInfoDao.get(DbInfo.SCHEMA_VERSION); SchemaVersion schemaVersion; if (dbInfoSchemaVersion == null ) { if( ! autoPersist ) { throw new IntactInitializationError( "Could not find key "+ DbInfo.SCHEMA_VERSION +" in table IA_DB_INFO, please set IntactInitializer.autoPersist to true so it can be initialized at startup." ); } if ( log.isInfoEnabled() ) log.info( "Schema version does not exist. Will be created: " + requiredSchemaVersion); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredSchemaVersion.toString()); dbInfoDao.persist(dbInfo); } else { try { schemaVersion = SchemaVersion.parse(dbInfoSchemaVersion.getValue()); } catch ( Exception e) { throw new IntactInitializationError("Error parsing schema version", e); } if (!schemaVersion.isCompatibleWith(requiredSchemaVersion)) { throw new IntactInitializationError("Database schema version " + requiredSchemaVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion); } } } }
daof.getDbInfoDao().persist( newDbInfo ); } else {
/** * Saves the last date the during which protein update was undertaken * * @param date goes to the value column * @throws DbInfoServiceException */ public void saveLastProteinUpdate( Date date ) throws DbInfoServiceException { if ( date == null ) { throw new NullPointerException( "You must give a non null date" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); Date lastUpdated = getLastProteinUpdate(); if ( lastUpdated == null ) { //create and persist DbInfo newDbInfo = new DbInfo( DbInfo.LAST_PROTEIN_UPDATE, formatDate( date ) ); daof.getDbInfoDao().persist( newDbInfo ); } else { //update DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "Updating ..." + dbinfo.toString() ); } dbinfo.setValue( formatDate( date ) ); }//end else }//end method
/** * Saves the last date the during which protein update was undertaken * * @param date goes to the value column * @throws DbInfoServiceException */ public void saveLastProteinUpdate( Date date ) throws DbInfoServiceException { if ( date == null ) { throw new NullPointerException( "You must give a non null date" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); Date lastUpdated = getLastProteinUpdate(); if ( lastUpdated == null ) { //create and persist DbInfo newDbInfo = new DbInfo( DbInfo.LAST_PROTEIN_UPDATE, formatDate( date ) ); daof.getDbInfoDao().persist( newDbInfo ); } else { //update DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "Updating ..." + dbinfo.toString() ); } dbinfo.setValue( formatDate( date ) ); }//end else }//end method