protected void commitTransaction() { try { getDataContext().commitTransaction(); } catch (IntactTransactionException e) { throw new IntactException(e); } }
protected void commitTransaction() { try { getDataContext().commitTransaction(); } catch (IntactTransactionException e) { throw new IntactException(e); } }
private static void persistBasicCvObjects(IntactContext context) { log.debug("Persisting necessary CvObjects"); DaoFactory daoFactory = getDefaultDaoFactory(context); daoFactory.beginTransaction(); CvPrimer cvPrimer = new EmptyCvPrimer(daoFactory); cvPrimer.createCVs(); try { context.getDataContext().commitTransaction(); } catch (IntactTransactionException e) { log.error(e); } }
private ArrayList getSpeciesTypes() throws SQLException, IntactTransactionException { ArrayList species = new ArrayList(); Statement stmt = null; IntactContext.getCurrentInstance().getDataContext().beginTransaction(); try { stmt = getConnection().createStatement(); ResultSet rs = stmt.executeQuery("SELECT distinct species " + "FROM ia_payg"); while (rs.next()) { species.add(rs.getString(1)); } } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { } } } IntactContext.getCurrentInstance().getDataContext().commitTransaction(); return species; }
public void commitTransaction() throws IntactTransactionException { try { commitTransaction( getDefaultDataConfig().getName() ); } catch ( Exception e ) { throw new IntactTransactionException( e ); } }
protected void commitTransaction() throws IntactTestException { if (getDataContext().isTransactionActive()) { try { getDataContext().commitTransaction(); } catch (IntactTransactionException e) { throw new IntactTestException(e); } } }
@After public final void tearDown() throws Exception { getDataContext().commitTransaction(); if (IntactContext.currentInstanceExists()) { IntactContext.getCurrentInstance().close(); } }
/** * Drops the current schema, emptying the database */ public static void dropSchema() throws IntactTransactionException { if (log.isDebugEnabled()) log.debug("Droping schema"); DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); if (dataContext.isTransactionActive()) { throw new IllegalStateException("To drop the schema, the transaction must NOT be active"); } dataContext.beginTransaction(); Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); SchemaExport se = new SchemaExport(cfg); se.drop(false, true); dataContext.commitTransaction(); }
private static void persistInstitution(IntactContext context) throws IntactTransactionException { Institution institution = context.getConfig().getInstitution(); if (institution == null) { throw new NullPointerException("Institution is null. Set an institution to the RuntimeConfig first"); } // remove ac, it should not have one at this point to be persisted correctly if (institution.getAc() != null) institution.setAc(null); log.debug("Persisting institution: " + institution.getShortLabel()); DaoFactory daoFactory = getDefaultDaoFactory(context); daoFactory.beginTransaction(); daoFactory.getInstitutionDao().persist(institution); context.getDataContext().commitTransaction(); }
/** * Creates a schema * @param initializeDatabase If false, do not initialize the database (e.g. don't create Institution) */ public static void createSchema(boolean initializeDatabase) throws IntactTransactionException { if (log.isDebugEnabled()) log.debug("Creating schema"); DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); if (dataContext.isTransactionActive()) { throw new IllegalStateException("To reset the schema, the transaction must NOT be active: "+dataContext.getDaoFactory().getCurrentTransaction()); } dataContext.beginTransaction(); Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); SchemaExport se = new SchemaExport(cfg); se.create(false, true); dataContext.commitTransaction(); dataContext.beginTransaction(); if (initializeDatabase) { if (log.isDebugEnabled()) log.debug("Initializing database"); IntactConfigurator.initializeDatabase(IntactContext.getCurrentInstance()); } dataContext.commitTransaction(); }
private void doPayAsYouGo(String species) throws SQLException, IntactTransactionException { IntactContext.getCurrentInstance().getDataContext().beginTransaction(); String nextbait = getNextNode(species); // while we have uncovered node for (int counter = 1; !nextbait.equals(""); counter++) { virtualPullOut(nextbait, counter, species); nextbait = getNextNode(species); } IntactContext.getCurrentInstance().getDataContext().commitTransaction(); }
IntactContext.getCurrentInstance().getDataContext().commitTransaction();
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " interaction(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractionDao idao = daoFactory.getInteractionDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<InteractionImpl> interactions = idao.getAll( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting interaction range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Interaction interaction : interactions ) { current++; exportEntry( interaction ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } }
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " interactor(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractorDao pdao = daoFactory.getInteractorDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<Interactor> interactors = pdao.getInteractorInvolvedInInteraction( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting interactor range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Interactor interactor : interactors ) { current++; exportEntry( interactor ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( "Error when closing transaction.", e ); } } }
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " experiment(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ExperimentDao edao = daoFactory.getExperimentDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<Experiment> experiments = edao.getAll( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting experiment range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Experiment experiment : experiments ) { current++; exportEntry( experiment ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } }
private static void persistSchemaVersion(IntactContext context) { IntactSession session = context.getSession(); SchemaVersion requiredVersion = context.getConfig().getDefaultDataConfig().getMinimumRequiredVersion(); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredVersion.toString()); if (log.isDebugEnabled()) log.debug("Persisting schema version: " + requiredVersion.toString()); DaoFactory daoFactory = DaoFactory.getCurrentInstance(session, RuntimeConfig.getCurrentInstance(session).getDefaultDataConfig()); context.getDataContext().beginTransaction(); daoFactory.getDbInfoDao().persist(dbInfo); try { context.getDataContext().commitTransaction(); } catch (IntactTransactionException e) { log.error(e); } }
private static void commitTransactionAndRollbackIfNecessary() throws PersisterException { try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch (IntactTransactionException e) { try { IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentTransaction().rollback(); } catch (IntactTransactionException e1) { throw new PersisterException(e1); } } } }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractorDao<InteractorImpl> interactorDao = daoFactory.getInteractorDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); count = interactorDao.countInteractorInvolvedInInteraction(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( "Error while closing transaction.", e ); } } return count; }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractionDao idao = daoFactory.getInteractionDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); // TODO do not take into account interactor that do not interact. count = idao.countAll(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } return count; } }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ExperimentDao edao = daoFactory.getExperimentDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); // TODO do not take into account interactor that do not interact. count = edao.countAll(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } return count; } }