public Date getLastCvUpdate( String namespace ) throws DbInfoServiceException { Date date; DbInfo dbinfo = null; if ( namespace == null ) { throw new NullPointerException( "You must give a non null namespace" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); if ( namespace.equals( DbInfo.NAMESPACE_PSIMI ) ) { dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); } try { if ( dbinfo != null && dbinfo.getValue() != null ) { date = new SimpleDateFormat( "yyyy-MM-dd" ).parse( dbinfo.getValue() ); return date; } else { return null; } } catch ( ParseException pe ) { throw new DbInfoServiceException( pe ); } }
public Date getLastCvUpdate( String namespace ) throws DbInfoServiceException { Date date; DbInfo dbinfo = null; if ( namespace == null ) { throw new NullPointerException( "You must give a non null namespace" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); if ( namespace.equals( DbInfo.NAMESPACE_PSIMI ) ) { dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); } try { if ( dbinfo != null && dbinfo.getValue() != null ) { date = new SimpleDateFormat( "yyyy-MM-dd" ).parse( dbinfo.getValue() ); return date; } else { return null; } } catch ( ParseException pe ) { throw new DbInfoServiceException( pe ); } }
@Test public void saveLastProteinUpdateTest() throws Exception { String DATE_FORMAT = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat( DATE_FORMAT ); Date yesterday = sdf.parse( "2008-06-17" ); final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); //Updating first time with previous date DbInfoService service = new DbInfoServiceImpl(); service.saveLastProteinUpdate( yesterday ); DbInfo dbinfoBefore = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo Before : " + dbinfoBefore.toString() ); } Assert.assertEquals( sdf.format( yesterday ), dbinfoBefore.getValue() ); //Updating second time with later date Date today = sdf.parse( "2008-06-20" ); service.saveLastProteinUpdate( today ); DbInfo dbinfoAfter = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo After: " + dbinfoAfter.toString() ); } Assert.assertEquals( sdf.format( today ), dbinfoAfter.getValue() ); Date lastProteinUpdate = service.getLastProteinUpdate(); String formattedDate = new SimpleDateFormat( "yyyy-MM-dd" ).format( lastProteinUpdate ); Assert.assertEquals( sdf.format( today ), formattedDate ); }//end method
@Test public void saveLastCvUpdateTest() throws Exception { String DATE_FORMAT = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat( DATE_FORMAT ); Date yesterday = sdf.parse( "2008-06-17" ); final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); //Updating first time with previous date DbInfoService service = new DbInfoServiceImpl(); service.saveLastCvUpdate( yesterday, DbInfo.NAMESPACE_PSIMI ); DbInfo dbinfoBefore = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo Before updating CV : " + dbinfoBefore.toString() ); } Assert.assertEquals( sdf.format( yesterday ), dbinfoBefore.getValue() ); //Updating second time with later date Date today = sdf.parse( "2008-06-20" ); service.saveLastCvUpdate( today, DbInfo.NAMESPACE_PSIMI ); DbInfo dbinfoAfter = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo After updating CV : " + dbinfoAfter.toString() ); } Assert.assertEquals( sdf.format( today ), dbinfoAfter.getValue() ); Date lastCvUpdate = service.getLastCvUpdate( DbInfo.NAMESPACE_PSIMI ); String formattedDate = new SimpleDateFormat( "yyyy-MM-dd" ).format( lastCvUpdate ); Assert.assertEquals( sdf.format( today ), formattedDate ); }//end method
@Test public void saveLastCvUpdateTest() throws Exception { String DATE_FORMAT = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat( DATE_FORMAT ); Date yesterday = sdf.parse( "2008-06-17" ); final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); //Updating first time with previous date DbInfoService service = new DbInfoServiceImpl(); service.saveLastCvUpdate( yesterday, DbInfo.NAMESPACE_PSIMI ); DbInfo dbinfoBefore = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo Before updating CV : " + dbinfoBefore.toString() ); } Assert.assertEquals( sdf.format( yesterday ), dbinfoBefore.getValue() ); //Updating second time with later date Date today = sdf.parse( "2008-06-20" ); service.saveLastCvUpdate( today, DbInfo.NAMESPACE_PSIMI ); DbInfo dbinfoAfter = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo After updating CV : " + dbinfoAfter.toString() ); } Assert.assertEquals( sdf.format( today ), dbinfoAfter.getValue() ); Date lastCvUpdate = service.getLastCvUpdate( DbInfo.NAMESPACE_PSIMI ); String formattedDate = new SimpleDateFormat( "yyyy-MM-dd" ).format( lastCvUpdate ); Assert.assertEquals( sdf.format( today ), formattedDate ); }//end method
@Test public void saveLastProteinUpdateTest() throws Exception { String DATE_FORMAT = "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat( DATE_FORMAT ); Date yesterday = sdf.parse( "2008-06-17" ); final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); //Updating first time with previous date DbInfoService service = new DbInfoServiceImpl(); service.saveLastProteinUpdate( yesterday ); DbInfo dbinfoBefore = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo Before : " + dbinfoBefore.toString() ); } Assert.assertEquals( sdf.format( yesterday ), dbinfoBefore.getValue() ); //Updating second time with later date Date today = sdf.parse( "2008-06-20" ); service.saveLastProteinUpdate( today ); DbInfo dbinfoAfter = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); if ( log.isDebugEnabled() ) { log.debug( "DbInfo After: " + dbinfoAfter.toString() ); } Assert.assertEquals( sdf.format( today ), dbinfoAfter.getValue() ); Date lastProteinUpdate = service.getLastProteinUpdate(); String formattedDate = new SimpleDateFormat( "yyyy-MM-dd" ).format( lastProteinUpdate ); Assert.assertEquals( sdf.format( today ), formattedDate ); }//end method
public Date getLastProteinUpdate() throws DbInfoServiceException { Date date; final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); try { if ( dbinfo != null && dbinfo.getValue() != null ) { date = new SimpleDateFormat( "yyyy-MM-dd" ).parse( dbinfo.getValue() ); return date; } else { return null; } } catch ( ParseException pe ) { throw new DbInfoServiceException( pe ); } }
public Date getLastProteinUpdate() throws DbInfoServiceException { Date date; final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_PROTEIN_UPDATE ); try { if ( dbinfo != null && dbinfo.getValue() != null ) { date = new SimpleDateFormat( "yyyy-MM-dd" ).parse( dbinfo.getValue() ); return date; } else { return null; } } catch ( ParseException pe ) { throw new DbInfoServiceException( pe ); } }
daof.getDbInfoDao().persist( newDbInfo ); } else { DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "Updating ..." + dbinfo.toString() );
/** * 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
daof.getDbInfoDao().persist( newDbInfo ); } else { DbInfo dbinfo = daof.getDbInfoDao().get( DbInfo.LAST_CV_UPDATE_PSIMI ); if ( log.isDebugEnabled() ) { log.debug( "Updating ..." + dbinfo.toString() );
/** * 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