protected void addLinkToTerm(String parentId, String childId, Map<String, OntologyTerm> id2Terms){ OntologyTerm child = id2Terms.get( childId ); OntologyTerm parent = id2Terms.get( parentId ); if ( child == null ) { throw new NullPointerException( "You must give a non null child" ); } if ( parent == null ) { throw new NullPointerException( "You must give a non null parent" ); } if ( !child.getParents().contains(parent) ) { child.getParents().add(parent); } if ( !parent.getChildren().contains(child) ) { parent.getChildren().add(child); } } }
public Set<OntologyTerm> fetchRootTerms(CvTerm database) throws BridgeFailedException{ if (database != null && !DefaultCvTermComparator.areEquals(getOntologyDatabase(), database)){ return Collections.EMPTY_SET; } Set<OntologyTerm> terms = new HashSet<OntologyTerm>(); for ( Iterator<OntologyTerm> iterator = getId2Term().values().iterator(); iterator.hasNext(); ) { OntologyTerm ontologyTerm = iterator.next(); if ( ontologyTerm.getParents().isEmpty() ) { terms.add( ontologyTerm ); } } if ( terms.isEmpty() ) { return Collections.EMPTY_SET; } return terms; } }
public Set<OntologyTerm> fetchRootTerms(String database) throws BridgeFailedException { if (database != null && !getOntologyDatabase().getShortName().equalsIgnoreCase(database)){ return Collections.EMPTY_SET; } Set<OntologyTerm> terms = new HashSet<OntologyTerm>(); for ( Iterator<OntologyTerm> iterator = getId2Term().values().iterator(); iterator.hasNext(); ) { OntologyTerm ontologyTerm = iterator.next(); if ( ontologyTerm.getParents().isEmpty() ) { terms.add( ontologyTerm ); } } if ( terms.isEmpty() ) { return Collections.EMPTY_SET; } return terms; }
/** * This method will copy basic properties and parent/children from a ontology term source to a ontology term target * @param source : the cv term source to copy from * @param target : the cv term target to copy to */ public static void copyAndOverrideOntologyTermProperties(OntologyTerm source, OntologyTerm target){ if (source != null && target != null){ copyAndOverrideCvTermProperties(source, target); target.getParents().clear(); target.getParents().addAll(source.getParents()); target.getChildren().clear(); target.getChildren().addAll(source.getChildren()); target.setDefinition(source.getDefinition()); } }
return true; else if (!term.getParents().isEmpty()){ for (OntologyTerm parent : term.getParents()){ if (isCvTermChildOf(parent, mi, name)){ return true; return true; else if (!term.getParents().isEmpty()){ for (OntologyTerm parent : term.getParents()){ if (isCvTermChildOf(parent, mi, name)){ return true;