private DaoFactory getDaoFactory( DataConfig dataConfig ) { return DaoFactory.getCurrentInstance( session, dataConfig ); }
private DaoFactory getDaoFactory() { return DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() ); }
private static DaoFactory getDefaultDaoFactory(IntactContext context) { IntactSession session = context.getSession(); return DaoFactory.getCurrentInstance(session, RuntimeConfig.getCurrentInstance(session).getDefaultDataConfig()); }
public static DaoFactory getCurrentInstance( IntactContext context, String dataConfigName ) { return getCurrentInstance( context.getSession(), context.getConfig().getDataConfig( dataConfigName ) ); }
public static DaoFactory getCurrentInstance( IntactContext context ) { return getCurrentInstance( context.getSession(), context.getConfig().getDefaultDataConfig() ); }
public Session getSession() { RuntimeConfig config = RuntimeConfig.getCurrentInstance( intactSession ); DaoFactory daoFactory = DaoFactory.getCurrentInstance( intactSession, config.getDefaultDataConfig() ); if ( !daoFactory.isTransactionActive() ) { if ( config.isAutoBeginTransaction() ) { log.debug( "Auto starting transaction" ); daoFactory.beginTransaction(); // starts or uses an existing transaction } else { throw new AutoBeginTransactionException( "You must begin a transaction manually." ); } } // invoking the method from the session factory because if the session is closed it will automatically // open one return session.getSessionFactory().getCurrentSession(); }
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 checkSchemaCompatibility( DataConfig dataConfig, IntactSession session ) { SchemaVersion requiredVersion = dataConfig.getMinimumRequiredVersion(); DaoFactory daoFactory = DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() ); IntactTransaction tx = daoFactory.beginTransaction(); DbInfo dbInfoSchemaVersion = daoFactory.getDbInfoDao().get( DbInfo.SCHEMA_VERSION ); try { tx.commit(); } catch ( IntactTransactionException e ) { log.error( "Exception commiting " + e ); } SchemaVersion schemaVersion; if ( dbInfoSchemaVersion == null ) { log.warn( "Schema version does not exist. Will be created" ); setSchemaVersionToBePersisted( session ); return; } try { schemaVersion = SchemaVersion.parse( dbInfoSchemaVersion.getValue() ); } catch ( Exception e ) { throw new IntactInitializationError( "Error getting schema version", e ); } log.info( "Schema Version: " + schemaVersion ); if ( !schemaVersion.isCompatibleWith( requiredVersion ) ) { throw new IntactInitializationError( "Database schema version " + requiredVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion ); } }
if ( preloadCommonCvs ) { log.info( "Preloading common CvObjects" ); IntactTransaction tx = DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() ).beginTransaction(); CvContext.getCurrentInstance( session ).loadCommonCvObjects(); try {
biosources = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().getByTaxonId(taxid); CvObjectDao<CvTissue> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getCvObjectDao(CvTissue.class); bsTissue = cvObjectDao.getByShortLabel(tissue.getShortlabel()); CvObjectDao<CvCellType> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getCvObjectDao(CvCellType.class); bsCellType = cvObjectDao.getByShortLabel( cellType.getShortlabel() ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getBioSourceDao().persist( bs ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().update( bs );
biosources = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().getByTaxonId(taxid); CvObjectDao<CvTissue> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getCvObjectDao(CvTissue.class); bsTissue = cvObjectDao.getByShortLabel(tissue.getShortlabel()); CvObjectDao<CvCellType> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getCvObjectDao(CvCellType.class); bsCellType = cvObjectDao.getByShortLabel( cellType.getShortlabel() ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getBioSourceDao().persist( bs ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().update( bs );
biosources = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().getByTaxonId(taxid); CvObjectDao<CvTissue> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getCvObjectDao(CvTissue.class); bsTissue = cvObjectDao.getByShortLabel(tissue.getShortlabel()); CvObjectDao<CvCellType> cvObjectDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getCvObjectDao(CvCellType.class); bsCellType = cvObjectDao.getByShortLabel( cellType.getShortlabel() ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()).getBioSourceDao().persist( bs ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentInstance(IntactContext.getCurrentInstance()) .getBioSourceDao().update( bs );
DaoFactory daoFactory = DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() );