@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 ); }
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 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 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; } }
/** * Retreive (if any) the PSI ID (MI:xxxx) of a Controlled Vocabulary item. * * @param cv the CV we want to get the PSI ID from. * * @return a PSI ID or null if none is found. */ public static String getPsiID( CvObject cv ) { if ( cv == null ) { throw new IllegalArgumentException( "You must give a non null argument." ); } if ( cv.getXrefs() == null ) { return null; } for ( Iterator iterator = cv.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next(); // TODO shouldn't they be CvXrefQualifier = identity ? if ( CvDatabase.PSI_MI.equals( xref.getCvDatabase().getShortLabel() ) ) { return xref.getPrimaryId(); } } return null; }
/** * Retreive (if any) the PSI ID (MI:xxxx) of a Controlled Vocabulary item. * * @param cv the CV we want to get the PSI ID from. * * @return a PSI ID or null if none is found. */ public static String getPsiID( CvObject cv ) { if ( cv == null ) { throw new IllegalArgumentException( "You must give a non null argument." ); } if ( cv.getXrefs() == null ) { return null; } for ( Iterator iterator = cv.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next(); // TODO shouldn't they be CvXrefQualifier = identity ? if ( CvDatabase.PSI_MI.equals( xref.getCvDatabase().getShortLabel() ) ) { return xref.getPrimaryId(); } } return null; }
/** * Retreive (if any) the PSI ID (MI:xxxx) of a Controlled Vocabulary item. * * @param cv the CV we want to get the PSI ID from. * * @return a PSI ID or null if none is found. */ public static String getPsiID( CvObject cv ) { if ( cv == null ) { throw new IllegalArgumentException( "You must give a non null argument." ); } if ( cv.getXrefs() == null ) { return null; } for ( Iterator iterator = cv.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next(); // TODO shouldn't they be CvXrefQualifier = identity ? if ( CvDatabase.PSI_MI.equals( xref.getCvDatabase().getShortLabel() ) ) { return xref.getPrimaryId(); } } return null; }
private boolean hasAnIdentityCrossReference(CvObject cvObject){ if (cvObject.getXrefs() != null){ if (!cvObject.getXrefs().isEmpty()){ for (Xref ref : cvObject.getXrefs()){ CvXrefQualifier qualifier = ref.getCvXrefQualifier(); if (qualifier.getAc() != null){ if (qualifier.getAc().equals("MI:0356")){ return true; } } else { if (qualifier.getShortLabel().equals("identity") || qualifier.getFullName().equals("identical object")){ return true; } } } } } return false; }
private boolean hasAnIdentityCrossReference(CvObject cvObject){ if (cvObject.getXrefs() != null){ if (!cvObject.getXrefs().isEmpty()){ for (Xref ref : cvObject.getXrefs()){ CvXrefQualifier qualifier = ref.getCvXrefQualifier(); if (qualifier.getAc() != null){ if (qualifier.getAc().equals("MI:0356")){ return true; } } else { if (qualifier.getShortLabel().equals("identity") || qualifier.getFullName().equals("identical object")){ return true; } } } } } return false; }
/** * Returns the Identity xref. * This method does not take into account that a cvObject can have several identity xref, therefore it will be * deprecated and will disappear from version 1.7 use instead : getPsiMiIdentityXref from the * uk.ac.ebi.intact.model.util.CvObjectUtils method. * It will throw an IllegalStateException if one CvObject is found 2 identity xref. * * @return the Identity xref or null if there is no Identity xref found. */ @Transient @Deprecated public Xref getIdentityXref() { List<Xref> xrefs = new ArrayList<Xref>(); for ( Xref xref : getXrefs() ) { CvXrefQualifier xq = xref.getCvXrefQualifier(); if ( ( xq != null ) && CvXrefQualifier.IDENTITY.equals( xq.getShortLabel() ) ) { xrefs.add( xref ); } if ( xrefs.size() > 1 ) { throw new IllegalStateException( "This cv has 2 xref identities. Can not decide on witch one to return" ); } } return xrefs.get( 0 ); } } // end CvObject
/** * Extract from the given CV term its PSI-MI id (if any). * * @param cv the CV term. * * @return a psi id or the shortlabel of the CV if not found. */ private 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 cv.getShortLabel(); }
/** * Extract from the given CV term its PSI-MI id (if any). * * @param cv the CV term. * * @return a psi id or the shortlabel of the CV if not found. */ private 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 cv.getShortLabel(); }
/** * Extract from the given CV term its PSI-MI id (if any). * * @param cv the CV term. * * @return a psi id or the shortlabel of the CV if not found. */ private 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 cv.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 String getMiReference( CvObject cv ) { for ( Xref xref : cv.getXrefs() ) { if ( getPsi().equals( xref.getCvDatabase() ) ) { if ( getIdentity().equals( xref.getCvXrefQualifier() ) ) { return xref.getPrimaryId(); } } } return null; }