/** * Given an ontology, a data property, and a set, recursively fill the set with the descendants of * the property. * * @param ontology OWLOntology to get descendants from * @param property OWLDataProperty to get descendants of * @param descendants Set of OWLObjects to fill with descendants */ private static void selectDataPropertyDescendants( OWLOntology ontology, OWLDataProperty property, Set<OWLObject> descendants) { for (OWLDataPropertyExpression propertyExpression : EntitySearcher.getSubProperties(property, ontology)) { if (!propertyExpression.isAnonymous()) { OWLDataProperty subProperty = propertyExpression.getDataPropertiesInSignature().iterator().next(); descendants.add(subProperty); if (!EntitySearcher.getSubProperties(subProperty, ontology).isEmpty()) { selectDataPropertyDescendants(ontology, subProperty, descendants); } } else { descendants.add(propertyExpression); } } }
/** * Given an ontology, a data property, and a set, recursively fill the set with the ancestors of * the property. * * @param ontology OWLOntology to get ancestors from * @param property OWLDataProperty to get ancestors of * @param ancestors Set of OWLObjects to fill with ancestors */ private static void selectDataPropertyAncestors( OWLOntology ontology, OWLDataProperty property, Set<OWLObject> ancestors) { for (OWLDataPropertyExpression propertyExpression : EntitySearcher.getSuperProperties(property, ontology)) { if (!propertyExpression.isAnonymous()) { OWLDataProperty superProperty = propertyExpression.getDataPropertiesInSignature().iterator().next(); ancestors.add(superProperty); if (!superProperty.isTopEntity()) { selectDataPropertyAncestors(ontology, superProperty, ancestors); } } else { ancestors.add(propertyExpression); } } }