/** * Returns a String for a CvObject with this format: <code>MI:XXXX(cvLabel)</code>. * @param cvObject The CvObject to convert to simple string * @return The output String */ public static String cvObjectToSimpleString(CvObject cvObject) { if (cvObject == null) return null; return cvObject.getIdentifier()+"("+cvObject.getShortLabel()+")"; }
public CrossReference toCrossReference( O cvObject ) { if ( cvObject == null ) { throw new IllegalArgumentException( "CvObject must not be null. " ); } // name of the cv is the fullname String text = cvObject.getFullName()!= null ? cvObject.getFullName() : cvObject.getShortLabel(); String identity = cvObject.getIdentifier(); if(identity == null ) { throw new NullPointerException( cvObject.getClass().getSimpleName() + "("+ text +") didn't have an identity" ); } final CvObjectXref idXref = findMatchingIdentityXref(cvObject.getXrefs(), identity); //XrefUtils.getIdentityXref(cvObject, CvDatabase.PSI_MI_MI_REF); if (idXref != null){ try { CrossReference ref = crossRefConverter.createCrossReference(idXref, false); ref.setText(text); return ref; } catch ( Exception e ) { throw new RuntimeException( "An exception occured while building a cv object : " + text, e ); } } else { CrossReference ref = new CrossReferenceImpl(CrossReferenceConverter.DATABASE_UNKNOWN, identity, text); return ref; } }
private boolean areSameCvObject(CvObject cv1, CvObject cv2) { if (cv1.getIdentifier() != null && cv2.getIdentifier() != null) { return cv1.equals(cv2); } return cv1.getShortLabel().equals(cv2.getShortLabel()); }
@Override protected void saveOrUpdateAttributes( CvObject intactObject ) throws PersisterException { if ( intactObject.getXrefs().isEmpty() ) { log.warn( "CvObject without Xrefs: " + intactObject.getShortLabel() ); //throw new PersisterException("Cannot save or update a CvObject without Xrefs"); } super.saveOrUpdateAttributes( intactObject ); }
cv.setFullName(defaultFullName); cv.addXref(xref); log.debug("Created missing CV Term: " + clazz.getSimpleName() + "( " + cv.getShortLabel() + " - " + cv.getFullName() + " ).");
String identifier = cvObject.getIdentifier(); if (log.isDebugEnabled()) log.debug("Populating identifier for: "+cvObject.getShortLabel()); if (log.isDebugEnabled()) log.debug("New identifier will be generated for: "+cvObject.getShortLabel()); try { identifier = nextLocalIdentifier(); CvObjectXref xref = new CvObjectXref(cvObject.getOwner(), intact, identifier, identity); cvObject.addXref(xref); cvObject.setIdentifier(identifier);
if (cvObject.getIdentifier() != null){ identifiersToTest.add(cvObject.getIdentifier()); if (cvObject.getXrefs() != null && !cvObject.getXrefs().isEmpty()){ Collection<CvObjectXref> ref = cvObject.getXrefs(); throw new FinderException(" The CV object " + cvObject.getIdentifier() + ":" + cvObject.getShortLabel() + " has an identifier" + " which can't match any CV object identifiers of type " + cvClass +" but the shortlabel is matching one CVObject in the database : "+ valueForShortLabel + ". The CV object can't be duplicated with a different identifier, you should change the identifier.");
public String toString() { final StringBuffer sb = new StringBuffer(); sb.append( "Cv2Source" ); sb.append( "{cvObject=" ).append( cvObject.getShortLabel() ); sb.append( " Type=" ).append( cvObject.getClass() ); sb.append( ", parentNodeName='" ).append( parentNodeName ).append( '\'' ); sb.append( '}' ); return sb.toString(); } }
public static String getPsiReference( CvObject cv ) { if ( cv == null ) { throw new IllegalArgumentException( "the given CvObject must not be null." ); } for ( Iterator iterator = cv.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next(); if ( CvDatabase.PSI_MI.equals( xref.getCvDatabase().getShortLabel() ) ) { return xref.getPrimaryId(); } } return null; } }
public static <T extends CvObject> T createCvObject(Institution institution, Class<T> cvClass, String miIdentifier, String shortLabel) { T cv = ClassUtils.newInstance(cvClass); cv.setOwner(institution); cv.setShortLabel(shortLabel); cv.setIdentifier(miIdentifier); if (miIdentifier != null) { CvObjectXref idXref = XrefUtils.createIdentityXrefPsiMi(cv, miIdentifier); cv.addXref(idXref); idXref.prepareParentMi(); } return cv; }
if ( toCvObject != null && ! toCvObject.equals( cv ) ) { String msg = "NOTE: '" + cv.getShortLabel() + "' remapped to '" + toCvObject.getShortLabel() + "'."; session.addMessage( msg ); cv = toCvObject;
existingCvs = cvObjectDao.getByShortLabelLike( orphan.getShortLabel() ); boolean alreadyContainsObsolete = false; for ( Annotation annot : existingCv.getAnnotations() ) { if ( CvTopic.OBSOLETE_MI_REF.equals( CvObjectUtils.getIdentity( annot.getCvTopic() ) ) ) { alreadyContainsObsolete = true; for ( Annotation annot : orphan.getAnnotations() ) { if ( CvTopic.OBSOLETE_MI_REF.equals( CvObjectUtils.getIdentity( annot.getCvTopic() ) ) ) { annotatedText = annot.getAnnotationText(); final Annotation annotation = new Annotation( existingCv.getOwner(), obsoleteTopic, annotatedText ); existingCv.addAnnotation( annotation ); stats.addUpdatedCv( existingCv );
|| after.before( annotation.getCreated() ) ) { AnnotationInfo ai = new AnnotationInfo( cvObject.getShortLabel(), cvObject.getFullName(), CgLibUtil.getRealClassName( cvObject ).getName(), cvObject.getIdentifier(), annotation.getCvTopic().getShortLabel(), annotation.getAnnotationText(),
protected void writeCvTerm( Writer out, CvObject cv, String indent ) throws IOException { String title = cvtype2name.get( CgLibUtil.removeCglibEnhanced( cv.getClass() ) ); if ( title == null ) { throw new IllegalStateException( "No title has been assigned to CV type: " + cv.getClass().getName() ); } String sl = cv.getShortLabel(); String fn = escapeXml( cv.getFullName() ); writeField( out, title, sl, indent ); // write fullname only if different from shortlabel and not null. if ( !sl.equals( fn ) ) { if ( fn != null && fn.length() > 0 ) { writeField( out, title, fn, indent ); } } String mi = getMiReference( cv ); if ( mi != null ) { writeField( out, title, mi, indent ); } }
private void putCv( CvObject cv ) { cachedByAc.put( cv.getAc(), cv ); cachedByLabel.put( new LabelKey( cv.getShortLabel(), cv.getClass() ), cv ); }
cvObject.addXref( createIdentityXref( cvObject, oboObj.getID() ) ); cvObject.setIdentifier(oboObj.getID()); cvObject.setFullName( oboObj.getName() ); xref = toXref( cvObject, cvtermXref.getId(), cvtermXref.getQualifier(), cvtermXref.getDatabase() ); if ( xref != null ) { cvObject.addXref( xref ); cvObject.addAnnotation( annot ); cvObject.addAnnotation( new Annotation( institution, definitionTopicDef, prefixString ) ); cvObject.addAnnotation( annot ); cvObject.addAnnotation( new Annotation( institution, definitionTopicDef, prefixString ) ); cvObject.addAnnotation( new Annotation( institution, definitionTopic, oboObj.getDefinition() ) ); cvObject.addAnnotation( new Annotation( institution, definitionTopic, oboObj.getDefinition() ) ); Annotation annot = toAnnotation( CvTopic.XREF_VALIDATION_REGEXP, annotationText ); if ( annot != null ) { cvObject.addAnnotation( annot ); cvObject.addAnnotation( annot ); cvObject.addAnnotation( annot ); String aliasName = aSyn.getText();
protected String elementKey(C intactObject) { return intactObject.getIdentifier() + "_" + intactObject.getClass(); }
public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof Cv2Source ) ) { return false; } final Cv2Source cvClass2Source = (Cv2Source) o; if ( !cvObject.equals( cvClass2Source.cvObject ) ) { return false; } if ( parentNodeName != null ? !parentNodeName.equals( cvClass2Source.parentNodeName ) : cvClass2Source.parentNodeName != null ) { return false; } return true; }
public static <T extends CvObject> T createCvObject(Institution institution, Class<T> cvClass, String primaryId, String shortLabel) { T cv = ClassUtils.newInstance(cvClass); cv.setOwner(institution); cv.setShortLabel(shortLabel); CvObjectXref idXref = XrefUtils.createIdentityXrefPsiMi(cv, primaryId); cv.addXref(idXref); return cv; } }
/** * Equality for CvObject is currently based on equality for primary id of Xref having the qualifier of identity and * short label if there is xref of identity. We need to equals method to avoid circular references when invoking * equals methods * * @param obj The object to check * * @return true if given object has an identity xref and its primary id matches to this' object's primary id or * short label if there is no identity xref. * * @see Xref */ @Override public boolean equals( Object obj ) { if ( !( obj instanceof CvObject ) ) { return false; } final CvObject other = ( CvObject ) obj; if (!getObjClass().equals(other.getObjClass())) { return false; } if (( identifier != null && !identifier.equals(other.getIdentifier()))) { return false; } return super.equals(other); }