/** * Imports an IntactEntry into intact * * @param entry the intact entry to import * * @return report of the import * * @throws PersisterException thrown if there are problems persisting the data in the intact-model database */ public void importIntoIntact(IntactEntry entry) throws PersisterException { corePersister.saveOrUpdate(entry); }
@Transactional(propagation = Propagation.REQUIRES_NEW) public PersisterStatistics importIntoIntact(Interaction interaction) { return corePersister.saveOrUpdate(interaction); }
private void addUsedInClass(CvObject cv, CvTopic usedInClass, String classes) { final Annotation hiddenAnnotation = new Annotation(usedInClass, classes); cv.addAnnotation(hiddenAnnotation); corePersister.saveOrUpdate(cv); }
private void markAsHidden(CvObject cv, CvTopic hidden) { final Annotation hiddenAnnotation = new Annotation(hidden, null); cv.addAnnotation(hiddenAnnotation); corePersister.saveOrUpdate(cv); }
private void addUsedInClass(CvObject cv, CvTopic usedInClass, String classes) { final Annotation hiddenAnnotation = new Annotation(usedInClass, classes); cv.addAnnotation(hiddenAnnotation); corePersister.saveOrUpdate(cv); }
private void markAsHidden(CvObject cv, CvTopic hidden) { final Annotation hiddenAnnotation = new Annotation(hidden, null); cv.addAnnotation(hiddenAnnotation); corePersister.saveOrUpdate(cv); }
@Transactional @IntactFlushMode(FlushModeType.COMMIT) @Deprecated public PersisterStatistics save( AnnotatedObject... annotatedObjects ) throws PersisterException { CorePersister corePersister = getCorePersister(); corePersister.getStatistics().reset(); corePersister.saveOrUpdate(annotatedObjects); return corePersister.getStatistics(); }
@Transactional @IntactFlushMode(FlushModeType.COMMIT) @Deprecated public PersisterStatistics save( AnnotatedObject... annotatedObjects ) throws PersisterException { CorePersister corePersister = getCorePersister(); corePersister.getStatistics().reset(); corePersister.saveOrUpdate(annotatedObjects); return corePersister.getStatistics(); }
@Transactional(propagation = Propagation.REQUIRED) public void updateChildrenHavingMissingParent(String child, String parent) { CvObjectDao<CvDagObject> cvDao = IntactContext.getCurrentInstance().getDaoFactory().getCvObjectDao(CvDagObject.class); CvDagObject reloadedChild = cvDao.getByAc(child); CvDagObject reloadedParent = cvDao.getByAc(parent); if (reloadedChild != null){ reloadedChild.addParent(reloadedParent); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(reloadedChild); } else { log.warn("Cv object " + child + " cannot be updated because does not exist anymore"); } }
private <T extends CvObject> T createCvIfMissing( Class<T> clazz, String cvId, String cvName, CvDagObject parent ) { T cv = daoFactory.getCvObjectDao(clazz).getByIdentifier(cvId); if ( cv == null) { cv = CvObjectUtils.createCvObject(configuration.getDefaultInstitution(), clazz, cvId, cvName ); corePersister.saveOrUpdate(cv); if( parent != null && cv instanceof CvDagObject ) { CvDagObject cvDag = (CvDagObject) cv; cvDag.addParent( parent ); } } return cv; }
private <T extends CvObject> T createIntactCvIfMissing( Class<T> clazz, String cvId, String cvName, CvDagObject parent ) { T cv = daoFactory.getCvObjectDao(clazz).getByIdentifier(cvId); if ( cv == null) { cv = CvObjectUtils.createIntactCvObject(configuration.getDefaultInstitution(), clazz, cvId, cvName ); corePersister.saveOrUpdate(cv); if( parent != null && cv instanceof CvDagObject ) { CvDagObject cvDag = (CvDagObject) cv; cvDag.addParent( parent ); } } return cv; }
private <T extends CvObject> T createCvIfMissing( Class<T> clazz, String cvId, String cvName, CvDagObject parent ) { T cv = daoFactory.getCvObjectDao(clazz).getByIdentifier(cvId); if ( cv == null) { cv = CvObjectUtils.createCvObject(configuration.getDefaultInstitution(), clazz, cvId, cvName ); corePersister.saveOrUpdate(cv); if( parent != null && cv instanceof CvDagObject ) { CvDagObject cvDag = (CvDagObject) cv; cvDag.addParent( parent ); } } return cv; }
private <T extends CvObject> T createIntactCvIfMissing( Class<T> clazz, String cvId, String cvName, CvDagObject parent ) { T cv = daoFactory.getCvObjectDao(clazz).getByIdentifier(cvId); if ( cv == null) { cv = CvObjectUtils.createIntactCvObject(configuration.getDefaultInstitution(), clazz, cvId, cvName ); corePersister.saveOrUpdate(cv); if( parent != null && cv instanceof CvDagObject ) { CvDagObject cvDag = (CvDagObject) cv; cvDag.addParent( parent ); } } return cv; }
/** * Add the dataset annotation for each experiment in the list * @param publications : the publications */ private void addDatasetToExperimentsAndPublication(List<Publication> publications) throws IOException, DatasetException { for (Publication p : publications){ if (!processedPublications.contains(p.getAc()) && isPublicationEligibleForDataset(p)){ processedPublications.add(p.getAc()); String pubId = p.getShortLabel(); // if publication has not been processed, we add the dataset to the publication if (this.listOfpublicationUpdated.add(pubId)){ Annotation annotation = createNewDataset(); log.info("Add dataset to " + p.getAc() + ": " + p.getShortLabel()); p.addAnnotation(annotation); for (Experiment exp : p.getExperiments()){ Annotation annotation2 = createNewDataset(); log.info("Add dataset to " + exp.getAc() + ": " + exp.getShortLabel()); exp.addAnnotation(annotation2); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(exp); } IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(p); } } } }
@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); } }
public static CvObjectXref createSecondaryXref(CvDagObject term, String database, String identifier) { DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory(); CvObjectXref cvXref; CvXrefQualifier secondary = factory.getCvObjectDao(CvXrefQualifier.class).getByPsiMiRef(CvXrefQualifier.SECONDARY_AC_MI_REF); CvDatabase db = factory.getCvObjectDao(CvDatabase.class).getByPsiMiRef(database); if (secondary == null){ secondary = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvXrefQualifier.class, CvXrefQualifier.SECONDARY_AC_MI_REF, CvXrefQualifier.SECONDARY_AC); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(secondary); } if (db == null){ db = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvDatabase.class, database, database); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(db); } // create identity xref cvXref = XrefUtils.createIdentityXref(term, identifier, secondary, db); term.addXref(cvXref); return cvXref; }
public static CvObjectXref createIdentityXref(CvDagObject term, String database, String identifier) { DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory(); CvObjectXref cvXref; CvXrefQualifier identity = factory.getCvObjectDao(CvXrefQualifier.class).getByPsiMiRef(CvXrefQualifier.IDENTITY_MI_REF); CvDatabase db = factory.getCvObjectDao(CvDatabase.class).getByPsiMiRef(database); if (identity == null){ identity = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF, CvXrefQualifier.IDENTITY); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(identity); } if (db == null){ db = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvDatabase.class, database, database); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(db); } // create identity xref cvXref = XrefUtils.createIdentityXref(term, identifier, identity, db); term.addXref(cvXref); return cvXref; }
public static Annotation hideTerm(CvObject c, String message){ DaoFactory factory = IntactContext.getCurrentInstance().getDaoFactory(); CvTopic topicFromDb = factory.getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.HIDDEN); if (topicFromDb == null){ topicFromDb = CvObjectUtils.createCvObject(IntactContext.getCurrentInstance().getInstitution(), CvTopic.class, null, CvTopic.HIDDEN); IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(topicFromDb); } Annotation newAnnotation = new Annotation(topicFromDb, message); c.addAnnotation(newAnnotation); return newAnnotation; }
@Transactional(propagation = Propagation.SUPPORTS) public CvDagObject createCvObjectFrom(IntactOntologyTermI ontologyTerm, IntactOntologyAccess ontologyAccess, Class<? extends CvDagObject> termClass, boolean hideParents, CvUpdateContext updateContext) throws IllegalAccessException, InstantiationException, CvUpdateException { String accession = ontologyTerm.getTermAccession(); CvDagObject cvObject = termClass.newInstance(); importUpdateContext.clear(); importUpdateContext.setCvTerm(cvObject); importUpdateContext.setIdentifier(accession); importUpdateContext.setOntologyAccess(ontologyAccess); importUpdateContext.setOntologyTerm(ontologyTerm); cvUpdater.updateTerm(importUpdateContext); // parents should not be obsolete. An obsolete term does not have parents children anymore if (hideParents){ CvUpdateUtils.hideTerm(cvObject, "term not used"); } // fire evt CvUpdateManager manager = updateContext.getManager(); CreatedTermEvent evt = new CreatedTermEvent(this, ontologyTerm.getTermAccession(), cvObject.getShortLabel(), cvObject.getAc(), hideParents, "Created child term"); manager.fireOnCreatedTerm(evt); // create object IntactContext.getCurrentInstance().getCorePersister().saveOrUpdate(cvObject); return cvObject; }