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); } } }
/** * 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()); } }