/** * 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); }
/** * 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); }
/** * @param exclusionList list of cv classes that are to be excluded eg: uk.ac.ebi.intact.model.CvCellType * @return List of Cvs with No MiIdentifiers */ public static List<CvObject> getCvsInIntactNotInPsi(Collection<String> exclusionList) { if(exclusionList==null || exclusionList.size()==0) { //create a default exclusionList exclusionList = new ArrayList<String>(); exclusionList.add( "uk.ac.ebi.intact.model.CvCellType" ); exclusionList.add( "uk.ac.ebi.intact.model.CvTissue" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); List<CvObject> allCvs = daof.getCvObjectDao().getAll(); List<CvObject> cvsNotInPsi = new ArrayList<CvObject>(); for ( CvObject cv : allCvs ) { if ( cv.getIdentifier() != null && cv.getIdentifier().startsWith( "IA:" )) { if(!exclusionList.contains( cv.getObjClass() )){ cvsNotInPsi.add( cv ); } } } return cvsNotInPsi; }
/** * Gets the CVs from the database created after a given date. * @param date cutoff date * @param exclusionList list of cv classes that are to be excluded eg: uk.ac.ebi.intact.model.CvCellType * @return List of cvs added after the given date excluding the date */ public static List<CvObject> getCvsAddedAfter( Date date, Collection<String> exclusionList ) { if ( date == null ) { throw new NullPointerException( "You must give a non null date" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); List<CvObject> allCvs = daof.getCvObjectDao().getAll(); List<CvObject> cvsAddedAfter = new ArrayList<CvObject>(); for ( CvObject cv : allCvs ) { if ( cv.getCreated() != null && cv.getCreated().after( date ) ) { if ( exclusionList == null || exclusionList.size() == 0 ) { cvsAddedAfter.add( cv ); } else { if ( !exclusionList.contains( cv.getObjClass() ) ) cvsAddedAfter.add( cv ); } } } return cvsAddedAfter; }
/** * Gets the CVs from the database created before a given date. * @param date cutoff date * @param exclusionList list of cv classes that are to be excluded eg: uk.ac.ebi.intact.model.CvCellType * @return List of cvs added before the given date excluding the date */ public static List<CvObject> getCVsAddedBefore( Date date, Collection<String> exclusionList ) { if ( date == null ) { throw new NullPointerException( "You must give a non null date" ); } final DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); DaoFactory daof = dataContext.getDaoFactory(); List<CvObject> allCvs = daof.getCvObjectDao().getAll(); List<CvObject> cvsAddedBefore = new ArrayList<CvObject>(); for ( CvObject cv : allCvs ) { if ( cv.getCreated() != null && cv.getCreated().before( date ) ) { if ( exclusionList == null || exclusionList.size() == 0 ) { cvsAddedBefore.add( cv ); } else { if ( !exclusionList.contains( cv.getObjClass() ) ) cvsAddedBefore.add( cv ); } } } return cvsAddedBefore; }
clone.setObjClass(cvObject.getObjClass());
clone.setObjClass(cvObject.getObjClass());