private CvXrefQualifier getIdentity() throws IntactException { CvXrefQualifier identity = IntactContext.getCurrentInstance().getCvContext().getByMiRef( CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF ); if ( identity == null ) { throw new IllegalStateException( "Could not find the qualifier(identity) in the Database. Please update your controlled vocabularies." ); } return identity; }
private DaoFactory getDaoFactory() { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); } }
private Session getSession() { AbstractHibernateDataConfig abstractHibernateDataConfig = ( AbstractHibernateDataConfig ) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig(); SessionFactory factory = abstractHibernateDataConfig.getSessionFactory(); Session session = factory.getCurrentSession(); return session; }
private static Session getSession() { AbstractHibernateDataConfig dataConfig = (AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig(); return dataConfig.getSessionFactory().getCurrentSession(); } }
public IDataSet createDbUnitDataset(String tablePrefix) throws SQLException { Connection con = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().connection(); ResultSet tables = con.getMetaData().getTables(null, null, tablePrefix, new String[]{"TABLE"}); QueryDataSet allTablesDataSet = new QueryDataSet(getDatabaseConnection()); while (tables.next()) { String tableName = tables.getString(3); allTablesDataSet.addTable(tableName); } return allTablesDataSet; }
private void insertSearchItemForAnnotatedObject( AnnotatedObject<? extends Xref, ? extends Alias> ao, boolean includeAliases ) { if ( log.isDebugEnabled() ) { log.debug( "Inserting SearchItems for AnnotatedObject: " + ao.getShortLabel() + " (" + ao.getAc() + ")" ); } for ( SearchItem searchItem : searchItemsForAnnotatedObject( ao, includeAliases ) ) { if ( log.isDebugEnabled() ) { log.debug( "\t" + searchItem ); } IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getSearchItemDao().persist( searchItem ); } }
private Connection getConnection() { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory().connection(); } }
protected CvXrefQualifier getIdentity() { if ( identity == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); CvObjectDao<CvObject> cvdao = daoFactory.getCvObjectDao(); identity = cvdao.getByPrimaryId( CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF ); if ( identity == null ) { throw new IllegalStateException( "Could not find CvXrefQualifier( identity )." ); } } return identity; }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateDropSchemaDDL(String dialect) { Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); Properties props = new Properties(); props.put(Environment.DIALECT, dialect); return cfg.generateDropSchemaScript(Dialect.getDialect(props)); }
protected CvDatabase getIntact() { if ( intact == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); CvObjectDao<CvObject> cvdao = daoFactory.getCvObjectDao(); intact = cvdao.getByPrimaryId( CvDatabase.class, CvDatabase.INTACT_MI_REF ); if ( intact == null ) { throw new IllegalStateException( "Could not find CvDatabase( IntAct )." ); } } return intact; }
private void insertSearchItemForXref( Xref xref ) { if ( log.isDebugEnabled() ) { log.debug( "Inserting SearchItems for Xref: " + xref.getPrimaryId() + " (" + xref.getAc() + "); Parent AC: " + xref.getParentAc() ); } SearchItem searchItem = searchItemForXref( xref ); if ( log.isDebugEnabled() ) { log.debug( "\t" + searchItem ); } IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getSearchItemDao().persist( searchItem ); }
private void deleteSearchItemsForAnnotatedObject( AnnotatedObject<? extends Xref, ? extends Alias> ao ) { if ( log.isDebugEnabled() ) { log.debug( "Deleting SearchItems for AnnotatedObject: " + ao.getShortLabel() + " (" + ao.getAc() + ")" ); } IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getSearchItemDao().deleteByAc( ao.getAc() ); }
public static MockDaoFactory configureMockDaoFactory() { if (!IntactContext.currentInstanceExists()) { MockIntactContext.initMockContext(); } return (MockDaoFactory) IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); }
public static void saveOrUpdate(IntactEntry ... intactEntries) throws PersisterException { for (IntactEntry intactEntry : intactEntries) { boolean inTransaction = IntactContext.getCurrentInstance().getDataContext().isTransactionActive(); if (!inTransaction) IntactContext.getCurrentInstance().getDataContext().beginTransaction(); EntryPersister.getInstance().saveOrUpdate(intactEntry); EntryPersister.getInstance().commit(); if (!inTransaction) commitTransactionAndRollbackIfNecessary(); } }
private void deleteSearchItemForAlias( Alias alias ) { if ( log.isDebugEnabled() ) { log.debug( "Deleting SearchItems for Alias: " + alias.getName() + " (" + alias.getAc() + "); Parent AC: " + alias.getParentAc() ); } if ( !isAliasSearchable( alias ) ) { return; } SearchItem searchItem = searchItemForAlias( alias ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getSearchItemDao().delete( searchItem ); }
@After public final void tearDown() throws Exception { getDataContext().commitTransaction(); if (IntactContext.currentInstanceExists()) { IntactContext.getCurrentInstance().close(); } }
public IDatabaseConnection getDatabaseConnection() { IntactContext context = IntactContext.getCurrentInstance(); Connection con = context.getDataContext().getDaoFactory().connection(); IDatabaseConnection connection = new DatabaseConnection(con); DatabaseConfig config = connection.getConfig(); config.setProperty( DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory ); return connection; }
public static void checkCvInteractorType( ) { if ( false == interatorTypeChecked ) { // Load CvInteractorType( interaction / MI: ) cvProteinType = IntactContext.getCurrentInstance().getCvContext().getByMiRef(CvInteractorType.class, CvInteractorType.getInteractionMI()); if ( cvProteinType == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvInteractorType( interaction )." ) ); } interatorTypeChecked = true; } }
public static void checkCvInteractorType( ) { if ( false == interatorTypeChecked ) { // Load CvInteractorType( interaction / MI: ) cvInteractionType = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvInteractorType.class).getByXref(CvInteractorType.getInteractionMI()); if ( cvInteractionType == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvInteractorType( interaction )." ) ); } interatorTypeChecked = true; } }
private static void addStartAndEndPercentIfNecessary( QueryTerm term ) { if ( term.hasModifier( QueryModifier.PHRASE_DELIM ) ) { return; } String acPrefix = IntactContext.getCurrentInstance().getConfig().getAcPrefix(); if ( !term.startsWith( acPrefix ) && !term.hasModifier( QueryModifier.WILDCARD_START ) ) { term.addModifier( QueryModifier.WILDCARD_START ); } if ( !term.startsWith( acPrefix ) && !term.hasModifier( QueryModifier.WILDCARD_END ) ) { term.addModifier( QueryModifier.WILDCARD_END ); } }