@Override @Transactional public Institution convertFromString(String str) { if (str == null) return null; return IntactContext.getCurrentInstance().getDaoFactory().getInstitutionDao().getByShortLabel(str); }
@Override @Transactional public Institution convertFromString(String str) { if (str == null) return null; return IntactContext.getCurrentInstance().getDaoFactory().getInstitutionDao().getByShortLabel(str); }
public <T extends AnnotatedObject> AnnotatedObjectDao<T> getAnnotatedObjectDao( Class<T> entityType ) { if (entityType.isAssignableFrom(Institution.class)) { return (AnnotatedObjectDao<T>)getInstitutionDao(); } else if (Publication.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getPublicationDao(); } else if (CvObject.class.isAssignableFrom(entityType)) { return getCvObjectDao((Class)entityType); } else if (Experiment.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getExperimentDao(); } else if (Interaction.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getInteractionDao(); } else if (Interactor.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getInteractorDao(); } else if (BioSource.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getBioSourceDao(); } else if (Component.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getComponentDao(); } else if (Feature.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getFeatureDao(); } else { throw new IllegalArgumentException( "No Dao for entity type: "+entityType.getClass().getName()); } }
public <T extends AnnotatedObject> AnnotatedObjectDao<T> getAnnotatedObjectDao( Class<T> entityType ) { if (entityType.isAssignableFrom(Institution.class)) { return (AnnotatedObjectDao<T>)getInstitutionDao(); } else if (Publication.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getPublicationDao(); } else if (CvObject.class.isAssignableFrom(entityType)) { return getCvObjectDao((Class)entityType); } else if (Experiment.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getExperimentDao(); } else if (Interaction.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getInteractionDao(); } else if (Interactor.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getInteractorDao(); } else if (BioSource.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getBioSourceDao(); } else if (Component.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getComponentDao(); } else if (Feature.class.isAssignableFrom(entityType)) { return (AnnotatedObjectDao<T>)getFeatureDao(); } else { throw new IllegalArgumentException( "No Dao for entity type: "+entityType.getClass().getName()); } }
public static Institution getInstitution(IntactContext intactContext, User user) { Preference preference = user.getPreference(Preference.KEY_INSTITUTION_AC); if (preference != null) { String institutionAc = preference.getValue(); return intactContext.getDaoFactory().getInstitutionDao().getByAc(institutionAc); } return null; }
public static Institution getInstitution(IntactContext intactContext, User user) { Preference preference = user.getPreference(Preference.KEY_INSTITUTION_AC); if (preference != null) { String institutionAc = preference.getValue(); return intactContext.getDaoFactory().getInstitutionDao().getByAc(institutionAc); } return null; }
/** * Gets the institution from the RuntimeConfig object. In addition, tries to refresh * the instance from the database if it is detached. * * @return * @throws IntactException */ public Institution getInstitution() throws IntactException { Institution institution = config.getDefaultInstitution(); if (institution.getAc() != null && getDataContext().getDaoFactory().getInstitutionDao().isTransient(institution)) { institution = getDataContext().getDaoFactory().getInstitutionDao().getByAc(institution.getAc()); } return institution; }
/** * Gets the institution from the RuntimeConfig object. In addition, tries to refresh * the instance from the database if it is detached. * * @return * @throws IntactException */ public Institution getInstitution() throws IntactException { Institution institution = config.getDefaultInstitution(); if (institution.getAc() != null && getDataContext().getDaoFactory().getInstitutionDao().isTransient(institution)) { institution = getDataContext().getDaoFactory().getInstitutionDao().getByAc(institution.getAc()); } return institution; }
/** * Finds an institution based on its properties. * * @param institution the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForInstitution( Institution institution ) { String ac = null; // try to fetch it first using the xref. If not, use the shortlabel Xref institutionXref = XrefUtils.getPsiMiIdentityXref( institution ); if ( institutionXref != null ) { Query query = getEntityManager().createQuery( "select distinct institution.ac from Institution institution " + "left join institution.xrefs as xref " + "where xref.primaryId = :primaryId" ); query.setParameter( "primaryId", institutionXref.getPrimaryId() ); ac = getFirstAcForQuery( query, institution ); } if ( ac == null ) { Institution fetchedInstitution = getDaoFactory().getInstitutionDao().getByShortLabel( institution.getShortLabel() ); if ( fetchedInstitution != null ) { ac = fetchedInstitution.getAc(); } } return ac; }
/** * Finds an institution based on its properties. * * @param institution the object we are searching an AC for. * @return an AC or null if it couldn't be found. */ protected String findAcForInstitution( Institution institution ) { String ac = null; // try to fetch it first using the xref. If not, use the shortlabel Xref institutionXref = XrefUtils.getPsiMiIdentityXref( institution ); if ( institutionXref != null ) { Query query = getEntityManager().createQuery( "select distinct institution.ac from Institution institution " + "left join institution.xrefs as xref " + "where xref.primaryId = :primaryId" ); query.setParameter( "primaryId", institutionXref.getPrimaryId() ); ac = getFirstAcForQuery( query, institution ); } if ( ac == null ) { Institution fetchedInstitution = getDaoFactory().getInstitutionDao().getByShortLabel( institution.getShortLabel() ); if ( fetchedInstitution != null ) { ac = fetchedInstitution.getAc(); } } return ac; }
/** * Prints the most counts in the database. * @param ps The printStream to use * * @since 1.9.0 */ public static void printDatabaseCounts(PrintStream ps) { final DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ps.println("Publications: "+ daoFactory.getPublicationDao().countAll()); ps.println("\tXrefs: "+ daoFactory.getXrefDao(PublicationXref.class).countAll()); ps.println("\tAliases: "+ daoFactory.getAliasDao(PublicationAlias.class).countAll()); ps.println("Experiments: "+ daoFactory.getExperimentDao().countAll()); ps.println("\tXrefs: "+ daoFactory.getXrefDao(ExperimentXref.class).countAll()); ps.println("\tAliases: "+ daoFactory.getAliasDao(ExperimentAlias.class).countAll()); ps.println("Interactors: "+ daoFactory.getInteractorDao().countAll()); ps.println("\tInteractions: "+ daoFactory.getInteractionDao().countAll()); ps.println("\tPolymers: " + daoFactory.getPolymerDao().countAll()); ps.println("\t\tProteins: "+ daoFactory.getProteinDao().countAll()); ps.println("\t\tNucleic Acids: "+ daoFactory.getInteractorDao(NucleicAcidImpl.class).countAll()); ps.println("\tSmall molecules: " + daoFactory.getInteractorDao(SmallMoleculeImpl.class).countAll()); ps.println("\tInteractor Xrefs: "+ daoFactory.getXrefDao(InteractorXref.class).countAll()); ps.println("\tInteractor Aliases: "+ daoFactory.getAliasDao(InteractorAlias.class).countAll()); ps.println("Components: "+ daoFactory.getComponentDao().countAll()); ps.println("Features: "+ daoFactory.getFeatureDao().countAll()); ps.println("\tRanges: "+ daoFactory.getRangeDao().countAll()); ps.println("CvObjects: "+ daoFactory.getCvObjectDao().countAll()); ps.println("BioSources: "+ daoFactory.getBioSourceDao().countAll()); ps.println("Annotations: "+ daoFactory.getAnnotationDao().countAll()); ps.println("Institutions: "+ daoFactory.getInstitutionDao().countAll()); }
for (Institution sourceInstitution : sourceInstitutions) { if (!sourceInstitution.equals(destinationInstitution)) { intactContext.getDaoFactory().getInstitutionDao().deleteByAc(sourceInstitution.getAc());
for (Institution sourceInstitution : sourceInstitutions) { if (!sourceInstitution.equals(destinationInstitution)) { intactContext.getDaoFactory().getInstitutionDao().deleteByAc(sourceInstitution.getAc());
/** * Prints the most counts in the database. * @param ps The printStream to use * * @since 1.9.0 */ public static void printDatabaseCounts(PrintStream ps) { final DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ps.println("Publications: "+ daoFactory.getPublicationDao().countAll()); ps.println("\tXrefs: "+ daoFactory.getXrefDao(PublicationXref.class).countAll()); ps.println("\tAliases: "+ daoFactory.getAliasDao(PublicationAlias.class).countAll()); ps.println("Experiments: "+ daoFactory.getExperimentDao().countAll()); ps.println("\tXrefs: "+ daoFactory.getXrefDao(ExperimentXref.class).countAll()); ps.println("\tAliases: "+ daoFactory.getAliasDao(ExperimentAlias.class).countAll()); ps.println("Interactors: "+ daoFactory.getInteractorDao().countAll()); ps.println("\tInteractions: "+ daoFactory.getInteractionDao().countAll()); ps.println("\tPolymers: " + daoFactory.getPolymerDao().countAll()); ps.println("\t\tProteins: "+ daoFactory.getProteinDao().countAll()); ps.println("\t\tNucleic Acids: "+ daoFactory.getInteractorDao(NucleicAcidImpl.class).countAll()); ps.println("\tSmall molecules: " + daoFactory.getInteractorDao(SmallMoleculeImpl.class).countAll()); ps.println("\tInteractor Xrefs: "+ daoFactory.getXrefDao(InteractorXref.class).countAll()); ps.println("\tInteractor Aliases: "+ daoFactory.getAliasDao(InteractorAlias.class).countAll()); ps.println("Components: "+ daoFactory.getComponentDao().countAll()); ps.println("Features: "+ daoFactory.getFeatureDao().countAll()); ps.println("\tRanges: "+ daoFactory.getRangeDao().countAll()); ps.println("CvObjects: "+ daoFactory.getCvObjectDao().countAll()); ps.println("BioSources: "+ daoFactory.getBioSourceDao().countAll()); ps.println("Annotations: "+ daoFactory.getAnnotationDao().countAll()); ps.println("Institutions: "+ daoFactory.getInstitutionDao().countAll()); }
Institution owner = daoFactory.getInstitutionDao().getByAc( IntactContext.getCurrentInstance().getInstitution().getAc() );
Institution owner = daoFactory.getInstitutionDao().getByAc( IntactContext.getCurrentInstance().getInstitution().getAc() );