public CvObjectDao<CvObject> getCvObjectDao() { return getCvObjectDao(CvObject.class); }
public CvObjectDao<CvObject> getCvObjectDao() { return getCvObjectDao(CvObject.class); }
protected <T extends CvObject> T getCvObjectByLabel( Class<T> cvObjectClass, String label ) { if ( label == null ) { throw new NullPointerException( "label is null" ); } if ( log.isTraceEnabled() ) log.trace( "Processed values size: " + processed.size() ); for ( CvObject cvObject : processed.values() ) { if ( cvObjectClass.isAssignableFrom( cvObject.getClass() ) && label.equals( cvObject.getShortLabel() ) ) { return ( T ) cvObject; } } return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getCvObjectDao( cvObjectClass ).getByShortLabel( cvObjectClass, label ); }
protected Map<String, Class> getMapOfExistingCvs() { Map<String, Class> existingMi2Class = new HashMap<String, Class>(); List<CvObject> allExistingCvs = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao().getAll(); for ( CvObject cvObject : allExistingCvs ) { existingMi2Class.put( CvObjectUtils.getIdentity( cvObject ), cvObject.getClass() ); } return existingMi2Class; }
/** * Adds the 'on-hold' to a publication. * * @param intactContext The IntactContext as accessing data is necessary * @param publication the publication to hold * @param reason the reason for the 'on-hold' status * @since 2.5.0 */ public static void markAsOnHold(IntactContext intactContext, Publication publication, String reason) { CvTopic onholdTopic = intactContext.getDaoFactory().getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.ON_HOLD); if (onholdTopic == null) throw new IllegalStateException("CvTopic on-hold was not found in the database"); Annotation annotation = new Annotation(onholdTopic, reason); publication.addAnnotation(annotation); }
/** * Adds the 'on-hold' to a publication. * * @param intactContext The IntactContext as accessing data is necessary * @param publication the publication to hold * @param reason the reason for the 'on-hold' status * @since 2.5.0 */ public static void markAsOnHold(IntactContext intactContext, Publication publication, String reason) { CvTopic onholdTopic = intactContext.getDaoFactory().getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.ON_HOLD); if (onholdTopic == null) throw new IllegalStateException("CvTopic on-hold was not found in the database"); Annotation annotation = new Annotation(onholdTopic, reason); publication.addAnnotation(annotation); }
public Collection<String> getNucleicAcidMIs() { final CvObjectDao<CvInteractorType> itdao = IntactContext.getCurrentInstance().getDataContext() .getDaoFactory().getCvObjectDao( CvInteractorType.class); // 1. load the root term CvInteractorType root = itdao.getByPsiMiRef( CvInteractorType.NUCLEIC_ACID_MI_REF ); Collection<String> collectedMIs = new ArrayList<String>( ); if( root != null ) { // 2. traverse children and collect their MIs CvObjectUtils.getChildrenMIs( root, collectedMIs ); } return collectedMIs; }
public Collection<String> getNucleicAcidMIs() { final CvObjectDao<CvInteractorType> itdao = IntactContext.getCurrentInstance().getDataContext() .getDaoFactory().getCvObjectDao( CvInteractorType.class); // 1. load the root term CvInteractorType root = itdao.getByPsiMiRef( CvInteractorType.NUCLEIC_ACID_MI_REF ); Collection<String> collectedMIs = new ArrayList<String>( ); if( root != null ) { // 2. traverse children and collect their MIs CvObjectUtils.getChildrenMIs( root, collectedMIs ); } return collectedMIs; }
protected void changeStatus(Publication publication, String cvPublicationStatusIdentifier) { IntactContext intactContext = IntactContext.getCurrentInstance(); final CvObjectDao<CvPublicationStatus> cvObjectDao = intactContext.getDaoFactory().getCvObjectDao( CvPublicationStatus.class ); CvPublicationStatus publicationStatus = cvObjectDao.getByIdentifier( cvPublicationStatusIdentifier ); publication.setStatus(publicationStatus); }
protected void changeStatus(Publication publication, String cvPublicationStatusIdentifier) { IntactContext intactContext = IntactContext.getCurrentInstance(); final CvObjectDao<CvPublicationStatus> cvObjectDao = intactContext.getDaoFactory().getCvObjectDao( CvPublicationStatus.class ); CvPublicationStatus publicationStatus = cvObjectDao.getByIdentifier( cvPublicationStatusIdentifier ); publication.setStatus(publicationStatus); }
private CvFuzzyType findCvFuzzyTypeInDatabase(CvFuzzyType type){ if(type == null){ return null; } CvFuzzyType status = null; if (type.getIdentifier() != null){ status = intactContext.getDaoFactory().getCvObjectDao(CvFuzzyType.class).getByIdentifier(type.getIdentifier()); } else if (type.getShortLabel() != null){ status = intactContext.getDaoFactory().getCvObjectDao(CvFuzzyType.class).getByShortLabel(type.getShortLabel()); } return status; }
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; }
@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 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; }
protected void addLifecycleEvent(Publication publication, String cvLifecycleEventIdentifier, String comment) { IntactContext intactContext = IntactContext.getCurrentInstance(); final CvObjectDao<CvLifecycleEvent> cvObjectDao = intactContext.getDaoFactory().getCvObjectDao( CvLifecycleEvent.class ); CvLifecycleEvent lifecycleEvent = cvObjectDao.getByIdentifier( cvLifecycleEventIdentifier ); publication.addLifecycleEvent(new LifecycleEvent(lifecycleEvent, intactContext.getUserContext().getUser(), comment)); }
protected void addLifecycleEvent(Publication publication, String cvLifecycleEventIdentifier, String comment) { IntactContext intactContext = IntactContext.getCurrentInstance(); final CvObjectDao<CvLifecycleEvent> cvObjectDao = intactContext.getDaoFactory().getCvObjectDao( CvLifecycleEvent.class ); CvLifecycleEvent lifecycleEvent = cvObjectDao.getByIdentifier( cvLifecycleEventIdentifier ); publication.addLifecycleEvent(new LifecycleEvent(lifecycleEvent, intactContext.getUserContext().getUser(), comment)); }
/** * * @return a new Dataset annotation with the dataset value contained in the DatasetSelector of this object */ private Annotation createNewDataset() throws DatasetException { CvTopic dataset = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCvObjectDao( CvTopic.class ).getByPsiMiRef( CvTopic.DATASET_MI_REF ); if (dataset == null){ throw new DatasetException("The CVTopic " + CvTopic.DATASET_MI_REF + " : " + CvTopic.DATASET + "doesn't exist in the database."); } Annotation annotation = new Annotation(dataset, this.selector.getDatasetValueToAdd()); return annotation; }
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; }