@Transactional(propagation = Propagation.REQUIRES_NEW) /** * Delete hidden annotations for each cv given in the collection */ public void removeHiddenFrom(Collection<CvObject> cvs){ DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory(); AnnotationDao annDao = factory.getAnnotationDao(); for (CvObject cv : cvs){ cv = factory.getEntityManager().merge(cv); Collection<Annotation> annotations = new ArrayList<Annotation>(cv.getAnnotations()); for (Annotation annotation : annotations){ if (annotation.getCvTopic() != null && CvTopic.HIDDEN.equalsIgnoreCase(annotation.getCvTopic().getShortLabel())){ cv.removeAnnotation(annotation); annDao.delete(annotation); } } } }
/** * 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()); }
/** * Retrieves the annotations from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized annotations * @return The returned annotations are ensured to be initialized * @since 2.4.0 */ public static Collection<Annotation> ensureInitializedAnnotations(AnnotatedObject ao) { Collection<Annotation> annotations; if (IntactCore.isInitialized(ao.getAnnotations())) { annotations = ao.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(ao.getClass(), ao.getAc()); } return annotations; }
IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotationDao().persist( annotation ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotationDao().update( annotation ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotationDao().delete( annotation );
IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotationDao().update( annot ); containsAnnotation = true; break;
private Annotation synchronizeAnnotation( Annotation annotation, AnnotatedObject parent ) { if (annotation.getAc() != null) { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getAnnotationDao().getByAc(annotation.getAc()); } else { } annotation.setCvTopic( synchronize( annotation.getCvTopic() ) ); if (annotation.getAc() == null && parent.getAc() != null) { annotatedObjectsToPersist.put(keyBuilder.keyForAnnotation(annotation, parent), annotation); } return annotation; }
@Transactional(propagation = Propagation.REQUIRES_NEW) /** * Hide all the given cvs with the given message */ public void hideTerms(Collection<CvObject> cvs, String message){ DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory(); AnnotationDao annDao = factory.getAnnotationDao(); for (CvObject cv : cvs){ cv = factory.getEntityManager().merge(cv); boolean hasHidden = false; for (Annotation annotation : cv.getAnnotations()){ if (annotation.getCvTopic() != null && CvTopic.HIDDEN.equalsIgnoreCase(annotation.getCvTopic().getShortLabel())){ hasHidden = true; } } if (!hasHidden){ annDao.persist(CvUpdateUtils.hideTerm(cv, message)); } } }
private Annotation synchronizeAnnotation( Annotation annotation, AnnotatedObject parent ) { if (annotation.getAc() != null) { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getAnnotationDao().getByAc(annotation.getAc()); } else { } annotation.setCvTopic( synchronize( annotation.getCvTopic() ) ); if (annotation.getAc() == null && parent.getAc() != null) { annotatedObjectsToPersist.put(keyBuilder.keyForAnnotation(annotation, parent), annotation); } return annotation; }
if ( ! experiment.getAnnotations().contains( annotation ) ) { IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getAnnotationDao().persist( annotation ); experiment.addAnnotation( annotation ); IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getExperimentDao().update( experiment );
/** * Retrieves the annotations from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized annotations * @return The returned annotations are ensured to be initialized * @since 2.4.0 */ public static Collection<Annotation> ensureInitializedAnnotations(AnnotatedObject ao) { Collection<Annotation> annotations; if (IntactCore.isInitialized(ao.getAnnotations())) { annotations = ao.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(ao.getClass(), ao.getAc()); } return annotations; }
/** * 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()); }
private static Collection<Annotation> fetchAnnotations(Interaction interaction) { Collection<Annotation> annotations; if (IntactCore.isInitialized(interaction.getAnnotations())) { annotations = interaction.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(InteractionImpl.class, interaction.getAc()); } return annotations; }
private static Collection<Annotation> fetchAnnotations(Interaction interaction) { Collection<Annotation> annotations; if (IntactCore.isInitialized(interaction.getAnnotations())) { annotations = interaction.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(InteractionImpl.class, interaction.getAc()); } return annotations; }