/** * Collect a non redundant list of all children psi-mi identity identifier including the given root term's. * * @param root term from which we start traversing children. * @return a non null collection of MIs. */ public static Set<String> getChildrenMIs(CvDagObject root) { Set<String> collectedMIs = new HashSet<String>(); getChildrenMIs(root, collectedMIs); return collectedMIs; }
/** * Collect a non redundant list of all children psi-mi identity identifier including the given root term's. * * @param root term from which we start traversing children. * @return a non null collection of MIs. */ public static Set<String> getChildrenMIs(CvDagObject root) { Set<String> collectedMIs = new HashSet<String>(); getChildrenMIs(root, collectedMIs); return collectedMIs; }
private Query createGetByInteractorTypeQuery(String cvIdentifer, boolean includeChildren, boolean isCount) { List<String> cvIdentifiers = new ArrayList<String>(); cvIdentifiers.add(cvIdentifer); if (includeChildren) { CvObjectDao<CvInteractorType> cvObjectDao = IntactContext.getCurrentInstance().getDaoFactory() .getCvObjectDao(CvInteractorType.class); CvDagObject cvInteractorType = cvObjectDao.getByPsiMiRef(cvIdentifer); if (cvInteractorType != null) { final Set<String> childrenMIs = CvObjectUtils.getChildrenMIs(cvInteractorType); cvIdentifiers.addAll(childrenMIs); } else { if (log.isDebugEnabled()) log.debug("CvInteractorType with this identifier was not found in the database: "+cvIdentifer); } } String sqlQuery = (isCount? "select count(*) " : "") + "from " + getEntityClass().getName() + " i where " + "i.cvInteractorType.identifier in (:interactorTypeIdentifiers)"; Query query = getEntityManager().createQuery(sqlQuery); query.setParameter("interactorTypeIdentifiers", cvIdentifiers); return query; }
/** * Collect all children psi-mi identity identifier including the given root term's. * * @param root term from which we start traversing children. * @param collectedMIs non null collection in which we store collected MIs (if giving a List, you may have * duplicated in case some terms have multiple parents). */ public static void getChildrenMIs(CvDagObject root, Collection<String> collectedMIs) { if (root == null) { throw new IllegalArgumentException("You must give a non null root term"); } if (collectedMIs == null) { throw new IllegalArgumentException("The given collection must not be null"); } // 1. Add the current term final CvObjectXref xref = XrefUtils.getPsiMiIdentityXref(root); if (xref != null) { collectedMIs.add(xref.getPrimaryId()); } // 2. Add children recursively for (CvDagObject child : root.getChildren()) { getChildrenMIs(child, collectedMIs); } }
/** * Collect all children psi-mi identity identifier including the given root term's. * * @param root term from which we start traversing children. * @param collectedMIs non null collection in which we store collected MIs (if giving a List, you may have * duplicated in case some terms have multiple parents). */ public static void getChildrenMIs(CvDagObject root, Collection<String> collectedMIs) { if (root == null) { throw new IllegalArgumentException("You must give a non null root term"); } if (collectedMIs == null) { throw new IllegalArgumentException("The given collection must not be null"); } // 1. Add the current term final CvObjectXref xref = XrefUtils.getPsiMiIdentityXref(root); if (xref != null) { collectedMIs.add(xref.getPrimaryId()); } // 2. Add children recursively for (CvDagObject child : root.getChildren()) { getChildrenMIs(child, collectedMIs); } }
private Query createGetByInteractorTypeQuery(String cvIdentifer, boolean includeChildren, boolean isCount) { List<String> cvIdentifiers = new ArrayList<String>(); cvIdentifiers.add(cvIdentifer); if (includeChildren) { CvObjectDao<CvInteractorType> cvObjectDao = IntactContext.getCurrentInstance().getDaoFactory() .getCvObjectDao(CvInteractorType.class); CvDagObject cvInteractorType = cvObjectDao.getByPsiMiRef(cvIdentifer); if (cvInteractorType != null) { final Set<String> childrenMIs = CvObjectUtils.getChildrenMIs(cvInteractorType); cvIdentifiers.addAll(childrenMIs); } else { if (log.isDebugEnabled()) log.debug("CvInteractorType with this identifier was not found in the database: "+cvIdentifer); } } String sqlQuery = (isCount? "select count(*) " : "") + "from " + getEntityClass().getName() + " i where " + "i.cvInteractorType.identifier in (:interactorTypeIdentifiers)"; Query query = getEntityManager().createQuery(sqlQuery); query.setParameter("interactorTypeIdentifiers", cvIdentifiers); return query; }
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; }