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 ); }
public static String createSyncLabelIfNecessary(String shortLabel, Class<? extends CvDagObject> termClass){ CvObjectDao cvDao = IntactContext.getCurrentInstance().getDaoFactory().getCvObjectDao(termClass); AnnotatedObject existingOriginalShortLabel = cvDao.getByShortLabel(shortLabel); List<String> existingLabels = cvDao.getShortLabelsLike(shortLabel + "-%");
cv = dao.getByShortLabel( shortlabel );
/** * 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); }
database = context.getDataContext().getDaoFactory().getCvObjectDao( CvDatabase.class ).getByShortLabel( name );
aliasType = context.getDataContext().getDaoFactory().getCvObjectDao( CvAliasType.class ).getByShortLabel( name );
String cvShortLabel = ( String ) term.getValue(); CvDagObject cvDagObject = ( CvDagObject ) IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getCvObjectDao(cvType).getByShortLabel( cvType, cvShortLabel );
String cvShortLabel = ( String ) term.getValue(); CvDagObject cvDagObject = ( CvDagObject ) IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getCvObjectDao(cvType).getByShortLabel( cvType, cvShortLabel );
CvTopic usedInClass = factory.getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.USED_IN_CLASS);
cv = dao.getByShortLabel(clazz, shortlabel);
cv = dao.getByShortLabel(clazz, shortlabel);
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; }
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; }
CvTopic topicFromDb = factory.getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.DEFINITION);
protected void updateCVsUsingAnnotationDataset(List<CvDagObject> allCvs, AnnotationInfoDataset annotationInfoDataset, CorePersister corePersister) { for ( CvDagObject cvObject : allCvs ) { final String identity = CvObjectUtils.getIdentity( cvObject ); if ( identity != null && annotationInfoDataset.containsCvAnnotation( identity ) ) { AnnotationInfo annotInfo = annotationInfoDataset.getCvAnnotation( identity ); // check if the topic has already been processed CvTopic topic = createdNonMiTopics.get(annotInfo.getTopicShortLabel()); // if not, try to get it from the database if (topic == null) { topic = IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getCvObjectDao(CvTopic.class).getByShortLabel(CvTopic.class, annotInfo.getTopicShortLabel()); // if it is not in the database, create it and persist it. if (topic == null) { topic = CvObjectUtils.createCvObject( IntactContext.getCurrentInstance().getInstitution(), CvTopic.class, null, annotInfo.getTopicShortLabel() ); corePersister.saveOrUpdate(topic); } // now it has been created createdNonMiTopics.put(annotInfo.getTopicShortLabel(), topic); } // create the corresponding annotation Annotation annotation = new Annotation( IntactContext.getCurrentInstance().getInstitution(), topic, annotInfo.getReason() ); addAnnotation( annotation, cvObject, annotInfo.isApplyToChildren() ); } } }