private DaoFactory getDaoFactory() { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); } }
/** * 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(); }
public CvContext getCvContext() { return IntactContext.getCurrentInstance().getCvContext(); }
public BioSourceServiceImpl( TaxonomyService taxonomyService ) { // set default institution this( taxonomyService, IntactContext.getCurrentInstance().getInstitution() ); }
private static void createXref( Protein protein, XrefTag xrefTag, boolean identity ) throws IntactException { CvXrefQualifier qualifier = null; if ( identity ) { qualifier = ControlledVocabularyRepository.getIdentityQualifier(); } CvDatabase database = XrefChecker.getCvDatabase( xrefTag.getDb() ); if ( database == null ) { // failed to find the database, skip the Xref creation } else { InteractorXref xref = new InteractorXref( IntactContext.getCurrentInstance().getInstitution(), database, xrefTag.getId(), xrefTag.getSecondary(), xrefTag.getVersion(), qualifier ); protein.addXref( xref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( xref ); } }
chrono.start(); DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); BaseDao dao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao(); System.out.println( "Database: " + dao.getDbName() ); System.out.println( "Username: " + IntactContext.getCurrentInstance().getUserContext().getUserId() ); System.out.print( "Loading " + label + "..." ); System.out.flush(); experiments.addAll( IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getExperimentDao().getByShortLabelLike(label)); System.out.println( "done." ); IntactContext.getCurrentInstance().getDataContext().commitAllActiveTransactions();
/** * Checks if there is only one value, and then if this value is an accession returns true */ private static boolean isQuerySearchingOnlyOneAc( String[] values ) { if ( values.length > 1 || values.length == 0 ) { return false; } String value = values[0]; String institutionPrefix = IntactContext.getCurrentInstance().getConfig().getAcPrefix(); return ( value.toUpperCase().startsWith( institutionPrefix ) && !value.endsWith( "%" ) ); }
CvContext cvContext = IntactContext.getCurrentInstance().getCvContext(); cv = (CvObject) constructor.newInstance(IntactContext.getCurrentInstance().getInstitution(), shortlabel); IntactContext.getCurrentInstance().getDataContext().flushSession(); CvObjectXref xref = new CvObjectXref(IntactContext.getCurrentInstance().getInstitution(), psi, mi, null, null, identity);
public static MockDaoFactory configureMockDaoFactory() { if (!IntactContext.currentInstanceExists()) { MockIntactContext.initMockContext(); } return (MockDaoFactory) IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); }
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); } }
public boolean onPreInsert( PreInsertEvent preInsertEvent ) { if ( !( preInsertEvent.getEntity() instanceof Auditable ) ) { log.debug( "No auditable object: " + preInsertEvent.getId() ); return false; } log.debug( "Inserting audit info for: " + preInsertEvent.getId() ); Date now = new Date(); Auditable auditable = ( Auditable ) preInsertEvent.getEntity(); auditable.setCreated( now ); auditable.setUpdated( now ); String currentUser = IntactContext.getCurrentInstance().getUserContext().getUserId().toUpperCase(); auditable.setCreator( currentUser ); auditable.setUpdator( currentUser ); String[] names = preInsertEvent.getPersister().getPropertyNames(); Object[] values = preInsertEvent.getState(); for ( int i = 0; i < names.length; i++ ) { if ( names[i].equals( "created" ) || names[i].equals( "updated" ) ) { values[i] = now; continue; } if ( names[i].equals( "creator" ) || names[i].equals( "updator" ) ) { log.debug( "Current user " + currentUser ); values[i] = currentUser; } } return false; }
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 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(); }
@After public final void tearDown() throws Exception { getDataContext().commitTransaction(); if (IntactContext.currentInstanceExists()) { IntactContext.getCurrentInstance().close(); } }
public static DaoFactory getCurrentInstance( IntactContext context ) { return getCurrentInstance( context.getSession(), context.getConfig().getDefaultDataConfig() ); }
public Institution getInstitution() throws IntactException { return getConfig().getInstitution(); }
@Deprecated public CvDatabase createPsiMiCvDatabase(IntactContext intactContext) { return createPsiMiCvDatabase(intactContext.getInstitution()); }
private static void createXref( Protein protein, XrefTag xrefTag, boolean identity ) throws IntactException { CvXrefQualifier qualifier = null; if ( identity ) { qualifier = ControlledVocabularyRepository.getIdentityQualifier(); } CvDatabase database = XrefChecker.getCvDatabase( xrefTag.getDb() ); if ( database == null ) { // failed to find the database, skip the Xref creation } else { InteractorXref xref = new InteractorXref( IntactContext.getCurrentInstance().getInstitution(), database, xrefTag.getId(), xrefTag.getSecondary(), xrefTag.getVersion(), qualifier ); protein.addXref( xref ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao().persist( xref ); } }
chrono.start(); DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); BaseDao dao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getBaseDao(); System.out.println( "Database: " + dao.getDbName() ); System.out.println( "Username: " + IntactContext.getCurrentInstance().getUserContext().getUserId() ); System.out.print( "Loading " + label + "..." ); System.out.flush(); experiments.addAll( IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getExperimentDao().getByShortLabelLike(label)); System.out.println( "done." ); IntactContext.getCurrentInstance().getDataContext().commitAllActiveTransactions(); } catch (IntactTransactionException e) { e.printStackTrace();
/** * Checks if there is only one value, and then if this value is an accession returns true */ private static boolean isQuerySearchingOnlyOneAc(String[] values) { if (values.length > 1 || values.length == 0) { return false; } String value = values[0]; String institutionPrefix = IntactContext.getCurrentInstance().getConfig().getAcPrefix(); return (value.toUpperCase().startsWith(institutionPrefix) && !value.endsWith("%")); }