public CvObject getByAc( String ac, boolean forceReload ) { if ( !forceReload && cachedByAc.containsKey( ac ) ) { return cachedByAc.get( ac ); } CvObject cvObject = getDaoFactory().getCvObjectDao().getByAc( ac ); if ( cvObject == null ) { return null; } putCv( cvObject ); return cvObject; }
public <T extends CvObject> T getByLabel( Class<T> cvType, String label, boolean forceReload ) { if ( cvType == null ) { throw new NullPointerException( "To get a CV using its label, you need the CV type" ); } LabelKey labelKey = new LabelKey( label, cvType ); if ( !forceReload && cachedByLabel.containsKey( labelKey ) ) { if (log.isDebugEnabled()) log.debug("Getting by label: "+label+" ("+cvType.getSimpleName()+") - Hit"); return ( T ) cachedByLabel.get( labelKey ); } T cvObject = null; try { cvObject = getDaoFactory().getCvObjectDao( cvType ).getByShortLabel( cvType, label ); } catch (Exception e) { e.printStackTrace(); throw new IntactException("Exception getting cvType "+cvType.getSimpleName()+" with label: "+label, e); } if ( cvObject == null ) { if (log.isDebugEnabled()) log.debug("Getting by label: "+label+" ("+cvType.getSimpleName()+") - Missed"); return null; } if (log.isDebugEnabled()) log.debug("Getting by label: "+label+" ("+cvType.getSimpleName()+") - DB Hit"); putCv( cvObject ); return cvObject; }
public <T extends CvObject> T getByMiRef( Class<T> cvType, String miRef, boolean forceReload ) { if ( miRef == null ) { throw new NullPointerException( "miRef" ); } MiRefKey key = new MiRefKey( miRef, cvType ); if ( !forceReload && cachedByMiRef.containsKey( key ) ) { if (log.isDebugEnabled()) log.debug("Getting by miRef: "+miRef+" - Hit"); return ( T ) cachedByMiRef.get( key ); } T cvObject = null; try { cvObject = getDaoFactory().getCvObjectDao().getByPrimaryId( cvType, miRef ); } catch (Exception e) { throw new IntactException("Exception getting cvType "+cvType.getSimpleName()+" with miRef: "+miRef); } if ( cvObject == null ) { if (log.isDebugEnabled()) log.debug("Getting by miRef: "+miRef+" - Missed"); return null; } if (log.isDebugEnabled()) log.debug("Getting by miRef: "+miRef+" - DB Hit"); putCv( cvObject ); putCvInMiRef( miRef, cvObject ); return cvObject; }
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; }
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; }
protected CvDatabase getPsi() { if ( psi == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); CvObjectDao<CvObject> cvdao = daoFactory.getCvObjectDao(); psi = cvdao.getByPrimaryId( CvDatabase.class, CvDatabase.PSI_MI_MI_REF ); if ( psi == null ) { throw new IllegalStateException( "Could not find CvDatabase( IntAct )." ); } } return psi; }
/** * Determines the root node of that class and inserts the whole DAG as a tree into the database. Takes a class which * should inherit from the CvDagObject. * * @param cvClass Cv class to be inserted into the database. * * @throws IntactException if an error occur. */ public void insertCVs( Class<? extends CvObject> cvClass ) throws IntactException { if ( !CvDagObject.class.isAssignableFrom( cvClass ) ) { throw new IntactException( "invalid class!" ); } Collection cvDagObjects = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao( cvClass ).getAll(); // take any object out of the list to get the root CvDagObject aDagObject = ( CvDagObject ) cvDagObjects.iterator().next(); // get the root of the specified class CvDagObject root = aDagObject.getRoot(); // build the bounds of the root and all its children and insert them into the database this.buildBounds( root, 1 ); }
System.out.println( "Database: " + daoFactory.getBaseDao().getDbName() ); System.out.println( "User: " + daoFactory.getBaseDao().getDbUserName() ); CvTopic topic = daoFactory.getCvObjectDao( CvTopic.class ).getByShortLabel( "author-confidence" ); IntactContext.getCurrentInstance().getDataContext().commitTransaction();
/** * TODO: attempt identityXref(mi first and ia next)-cvType and then label-cvType */ @Override protected CvObject fetchFromDataSource( CvObject intactObject ) { // First search by psi-mi identifier CvObjectXref identityXref = CvObjectUtils.getPsiMiIdentityXref(intactObject); if (identityXref != null) { String mi = identityXref.getPrimaryId(); CvObject cvObject = getIntactContext().getDataContext().getDaoFactory() .getCvObjectDao(intactObject.getClass()).getByPsiMiRef(mi); if (cvObject != null) { return cvObject; } } // Failed by MI, try by shortlabel return getIntactContext().getDataContext().getDaoFactory() .getCvObjectDao().getByShortLabel( intactObject.getClass(), intactObject.getShortLabel() ); } }
/** * Loads all CvTopics that should not be shown on the public interface. */ private AnnotationFilter() { logger.debug( "Initializing which CvTopic should be filtered out." ); // search for the CvTopic no-export CvTopic noExport = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotatedObjectDao( CvTopic.class ).getByShortLabel( CvTopic.NO_EXPORT ); if ( noExport != null ) { // load all CvTopics Collection<CvTopic> cvTopics = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao( CvTopic.class ).getAll(); // select those that have an Annotation( no-export ) for ( CvTopic cvTopic : cvTopics ) { for ( Annotation annotation : cvTopic.getAnnotations() ) { if ( noExport.equals( annotation.getCvTopic() ) ) { if ( filteredTopics == null ) { filteredTopics = new HashSet<CvTopic>( 8 ); } logger.debug( "CvTopic( " + cvTopic.getShortLabel() + " )" ); filteredTopics.add( cvTopic ); } } } } if ( filteredTopics == null ) { filteredTopics = Collections.EMPTY_SET; } logger.debug( filteredTopics.size() + " CvTopic" + ( filteredTopics.size() > 1 ? "s" : "" ) + " filtered." ); }
private static void initialise( ) { if ( initialisationDone == false ) { // load CVs by shortlabel CvObjectDao<CvTopic> cvTopicDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvTopic.class); authorConfidenceTopic = cvTopicDao.getByShortLabel(CvTopic.AUTHOR_CONFIDENCE); noUniprotUpdate = cvTopicDao.getByShortLabel(CvTopic.NON_UNIPROT); // load CVs by MI reference CvObjectDao<CvXrefQualifier> cvXrefQualifierDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvXrefQualifier.class); primaryReferenceXrefQualifier = cvXrefQualifierDao.getByXref( CvXrefQualifier.PRIMARY_REFERENCE_MI_REF ); seeAlsoXrefQualifier = cvXrefQualifierDao.getByXref( CvXrefQualifier.SEE_ALSO_MI_REF ); identityXrefQualifier = cvXrefQualifierDao.getByXref( CvXrefQualifier.IDENTITY_MI_REF ); geneName = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvAliasType.class).getByXref( CvAliasType.GENE_NAME_MI_REF ); initialisationDone = true; } } // init
public UpdateTargetSpecies() { if (getDataContext().isTransactionActive()) { throw new IntactException("Transaction must NOT be active when instantiating UpdateTargetSpecies"); } beginTransaction(); CvObjectDao cvObjectDao = getDataContext().getDaoFactory().getCvObjectDao(); newt = (CvDatabase) cvObjectDao.getByPsiMiRef( CvDatabase.NEWT_MI_REF ); if (newt == null) { throw new IllegalStateException("Cv is null: "+ CvDatabase.NEWT + "("+ CvDatabase.NEWT_MI_REF + ")"); } targetSpeciesQualifier = (CvXrefQualifier) cvObjectDao.getByShortLabel( CvXrefQualifier.class, CvXrefQualifier.TARGET_SPECIES ); if (targetSpeciesQualifier == null) { throw new IllegalStateException("Cv is null: "+ CvXrefQualifier.TARGET_SPECIES); } commitTransaction(); }
public static void check( final XrefTag xref ) { final String db = xref.getDb(); if ( !cache.keySet().contains( db ) ) { CvDatabase cvDatabase = null; try { cvDatabase = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvDatabase.class).getByShortLabel( db ); if ( cvDatabase != null ) { System.out.println( "Found CvDatabase with shortlabel: " + db ); } else { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvDatabase " + "by shortlabel: " + db ) ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching " + "for CvDatabase " + "having the shortlabel: " + db ) ); e.printStackTrace(); } cache.put( db, cvDatabase ); } } }
public static void check( final ParticipantDetectionTag participantDetection ) { final XrefTag psiDef = participantDetection.getPsiDefinition(); XrefChecker.check( psiDef ); final String id = psiDef.getId(); if ( !cache.keySet().contains( id ) ) { CvIdentification cvIdentification = null; try { cvIdentification = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvIdentification.class).getByXref(id); if ( cvIdentification == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvIdentification for the PSI definition: " + id ) ); } else { System.out.println( "Found ParticipantDetection " + id + " as " + cvIdentification.getShortLabel() ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching for CvInteraction " + "having the PSI definition: " + id ) ); e.printStackTrace(); } cache.put( id, cvIdentification ); } } }
public static void check( final InteractionDetectionTag interactionDetection ) { final XrefTag psiDef = interactionDetection.getPsiDefinition(); XrefChecker.check( psiDef ); final String id = psiDef.getId(); if ( !cache.keySet().contains( id ) ) { CvInteraction cvInteraction = null; try { cvInteraction = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvInteraction.class).getByXref(id); if ( cvInteraction == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvInteraction by PSI definition: " + id ) ); } else { System.out.println( "Found CvInteraction " + id + " as " + cvInteraction.getShortLabel() ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching for CvInteraction " + "having the PSI definition: " + id ) ); e.printStackTrace(); } cache.put( id, cvInteraction ); } } }
public static void check( final InteractionTypeTag interactionType ) { final XrefTag psiDef = interactionType.getPsiDefinition(); XrefChecker.check( psiDef ); final String id = psiDef.getId(); if ( !cache.keySet().contains( id ) ) { CvInteractionType cvInteractionType = null; try { cvInteractionType = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvInteractionType.class).getByXref(id); if ( cvInteractionType == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvInteractionType " + "for the PSI definition: " + id ) ); } else { System.out.println( "Found InteractionType " + id + " as " + cvInteractionType.getShortLabel() ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching for CvInteractionType " + "having the PSI definition: " + id ) ); e.printStackTrace(); } cache.put( id, cvInteractionType ); } } }
private static void checkCvFeatureIdentification( FeatureTag feature ) { final XrefTag psiDef = feature.getFeatureDetection().getPsiDefinition(); XrefChecker.check( psiDef ); final String id = psiDef.getId(); if ( !featureIdentificationCache.keySet().contains( id ) ) { CvFeatureIdentification cvFeatureIdentification = null; try { cvFeatureIdentification = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvFeatureIdentification.class).getByXref(id); if ( cvFeatureIdentification == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvFeatureIdentification by PSI definition: " + id ) ); } else { System.out.println( "Found CvFeatureIdentification " + id + " as " + cvFeatureIdentification.getShortLabel() ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching for CvFeatureIdentification " + "having the PSI definition: " + id ) ); e.printStackTrace(); } featureIdentificationCache.put( id, cvFeatureIdentification ); } } }
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 checkCvTypeIdentification( FeatureTag feature ) { XrefTag psiDef = feature.getFeatureType().getPsiDefinition(); XrefChecker.check( psiDef ); final String id = psiDef.getId(); if ( !featureTypeCache.keySet().contains( id ) ) { CvFeatureType featureType = null; try { featureType = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvFeatureType.class).getByXref(id); if ( featureType == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvFeatureType by PSI definition: " + id ) ); } else { System.out.println( "Found CvFeatureType " + id + " as " + featureType.getShortLabel() ); } } catch ( IntactException e ) { MessageHolder.getInstance().addCheckerMessage( new Message( "An error occured while searching for CvFeatureType " + "having the PSI definition: " + id ) ); e.printStackTrace(); } featureTypeCache.put( id, featureType ); } }
public static void checkCvInteractorType( ) { if ( false == interatorTypeChecked ) { // Load CvInteractorType( interaction / MI: ) cvProteinType = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao(CvInteractorType.class).getByXref(CvInteractorType.getInteractionMI()); if ( cvProteinType == null ) { MessageHolder.getInstance().addCheckerMessage( new Message( "Could not find CvInteractorType( interaction )." ) ); } interatorTypeChecked = true; } }