/** * 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; }
@Override @Transactional public Institution convertFromString(String str) { if (str == null) return null; return IntactContext.getCurrentInstance().getDaoFactory().getInstitutionDao().getByShortLabel(str); }
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; }
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()); }
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; }
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()); }
/** * 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; }
@Override @Transactional public Institution convertFromString(String str) { if (str == null) return null; return IntactContext.getCurrentInstance().getDaoFactory().getInstitutionDao().getByShortLabel(str); }
Institution owner = daoFactory.getInstitutionDao().getByAc( IntactContext.getCurrentInstance().getInstitution().getAc() );
/** * 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; }
Institution owner = daoFactory.getInstitutionDao().getByAc( IntactContext.getCurrentInstance().getInstitution().getAc() );
/** * 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; }
@Transactional(propagation = Propagation.REQUIRES_NEW) public void persistInstitution(Institution candidateInstitution, boolean isDefault) { Institution institution = institutionDao.getByShortLabel(candidateInstitution.getShortLabel()); CvDatabase intact = daoFactory.getCvObjectDao(CvDatabase.class).getByIdentifier(CvDatabase.INTACT_MI_REF); CvXrefQualifier identity = daoFactory.getCvObjectDao(CvXrefQualifier.class).getByIdentifier(CvXrefQualifier.IDENTITY_MI_REF); if (identity == null && isAutoPersist()){ createCvIfMissing(CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF, CvXrefQualifier.IDENTITY, null); } if (intact == null && isAutoPersist()){ createCvIfMissing(CvDatabase.class, CvDatabase.INTACT_MI_REF, CvDatabase.INTACT, null); } if (institution == null && isAutoPersist()) { if (log.isDebugEnabled()) log.debug("Persisting institution: "+candidateInstitution); corePersister.saveOrUpdate(candidateInstitution); } else if (isDefault) { if (institution == null) { institution = candidateInstitution; } configuration.setDefaultInstitution(institution); } }
@Transactional(propagation = Propagation.REQUIRES_NEW) public void persistInstitution(Institution candidateInstitution, boolean isDefault) { Institution institution = institutionDao.getByShortLabel(candidateInstitution.getShortLabel()); CvDatabase intact = daoFactory.getCvObjectDao(CvDatabase.class).getByIdentifier(CvDatabase.INTACT_MI_REF); CvXrefQualifier identity = daoFactory.getCvObjectDao(CvXrefQualifier.class).getByIdentifier(CvXrefQualifier.IDENTITY_MI_REF); if (identity == null && isAutoPersist()){ createCvIfMissing(CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF, CvXrefQualifier.IDENTITY, null); } if (intact == null && isAutoPersist()){ createCvIfMissing(CvDatabase.class, CvDatabase.INTACT_MI_REF, CvDatabase.INTACT, null); } if (institution == null && isAutoPersist()) { if (log.isDebugEnabled()) log.debug("Persisting institution: "+candidateInstitution); corePersister.saveOrUpdate(candidateInstitution); } else if (isDefault) { if (institution == null) { institution = candidateInstitution; } configuration.setDefaultInstitution(institution); } }