public boolean contains(OWLDataProperty prop) { if (prop.equals(owlOntologyManager.getOWLDataFactory().getOWLThing())) { return true; } else if (prop.equals(owlOntologyManager.getOWLDataFactory().getOWLNothing())) { return true; } return owlDataProperty2DataPropertyPointerMap.containsKey(prop); }
public void visit(OWLDataProperty owlDataProperty) { try { lastDataPropertyPointer = owlDataProperty2DataPropertyPointerMap.get(owlDataProperty); if (lastDataPropertyPointer == null) { lastDataPropertyPointer = faCTPlusPlus.getDataProperty(owlDataProperty.getURI().toString()); dataPropertyPointerMap.put(lastDataPropertyPointer, owlDataProperty); owlDataProperty2DataPropertyPointerMap.put(owlDataProperty, lastDataPropertyPointer); } } catch (Exception e) { throw new FaCTPlusPlusRuntimeException(e); } }
private void checkExpressivity() throws OWLException { try { /* * Here, we need to look at all the expressions used anywhere within * the ontology and check their level. */ /* For each ontology, we need to check everything within it */ expressivityLevel = LITE; SwoopExpressionValidatorVisitor evv = new SwoopExpressionValidatorVisitor(this, objectRenderer); for (Iterator it = allOntologies.iterator(); it.hasNext(); ) { OWLOntology onto = (OWLOntology) it.next(); for (Iterator cit = onto.getClasses().iterator(); cit.hasNext(); ) { OWLClass clazz = (OWLClass) cit.next(); if (!clazz.getEnumerations(onto).isEmpty()) { /* We're in DL. */ expressivityLevel = expressivityLevel | DL; URI uri = clazz.getURI(); explain( DL, ONEOF, "Enumeration used: " + encodeHLink(uri.toString(), myModel.shortForm(uri))); } for (Iterator superit = clazz.getSuperClasses(onto).iterator(); superit.hasNext(); ) { /* Check the expressivity of any superclasses */ /* * Tricky bit here -- if there's an intersection used at * the top level, we're still ok for LITE. This is *not* * currently catered for, so we will get some stuff * wrong. */ OWLDescription description = (OWLDescription) superit.next(); evv.reset(); evv.setTopLevelDescription(true); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } for (Iterator superit = clazz.getEquivalentClasses(onto).iterator(); superit.hasNext(); ) { /* Check the expressivity of any equivalences */ /* * This is tricky, as these expressions *can* be * intersections, as long as they're intersections of * Lite constructs. This is the only place that it can * happen in Lite. */ OWLDescription description = (OWLDescription) superit.next(); evv.reset(); evv.setTopLevelDescription(true); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } } for (Iterator iit = onto.getObjectProperties().iterator(); iit.hasNext(); ) { OWLObjectProperty op = (OWLObjectProperty) iit.next(); for (Iterator dit = op.getDomains(onto).iterator(); dit.hasNext(); ) { /* Check the expressivity of any equivalences */ OWLDescription description = (OWLDescription) dit.next(); evv.reset(); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } for (Iterator dit = op.getRanges(onto).iterator(); dit.hasNext(); ) { /* Check the expressivity of any equivalences */ OWLDescription description = (OWLDescription) dit.next(); evv.reset(); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } } for (Iterator iit = onto.getDataProperties().iterator(); iit.hasNext(); ) { OWLDataProperty dp = (OWLDataProperty) iit.next(); for (Iterator dit = dp.getDomains(onto).iterator(); dit.hasNext(); ) { /* Check the expressivity of any equivalences */ OWLDescription description = (OWLDescription) dit.next(); evv.reset(); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } for (Iterator dit = dp.getRanges(onto).iterator(); dit.hasNext(); ) { /* Check the expressivity of any equivalences */ OWLDataRange description = (OWLDataRange) dit.next(); evv.reset(); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } } for (Iterator iit = onto.getIndividuals().iterator(); iit.hasNext(); ) { OWLIndividual ind = (OWLIndividual) iit.next(); for (Iterator typeit = ind.getTypes(onto).iterator(); typeit.hasNext(); ) { /* Check the expressivity of any equivalences */ OWLDescription description = (OWLDescription) typeit.next(); evv.reset(); try { description.accept(evv); expressivityLevel = expressivityLevel | evv.getLevel(); } catch (OWLException ex) { explain(OTHER, UNKNOWN, ex.getMessage()); expressivityLevel = OTHER; } } } } Set complexProperties = evv.getComplexProperties(); /* * Gather all the properties that are known to be functional or * inverse functional */ for (Iterator it = allOntologies.iterator(); it.hasNext(); ) { OWLOntology onto = (OWLOntology) it.next(); for (Iterator pit = onto.getObjectProperties().iterator(); pit.hasNext(); ) { OWLObjectProperty prop = (OWLObjectProperty) pit.next(); if (prop.isFunctional(onto) || prop.isInverseFunctional(onto)) { complexProperties.add(prop); } } } /* * We aren't doing everything yet as we still need to grab those * that have complex superproperties. */ /* * Now check to see if they've been said to be transitive, in which * case we're in FULL. */ for (Iterator pit = complexProperties.iterator(); pit.hasNext(); ) { OWLObjectProperty prop = (OWLObjectProperty) pit.next(); for (Iterator it = allOntologies.iterator(); it.hasNext(); ) { OWLOntology onto = (OWLOntology) it.next(); if (prop.isTransitive(onto)) { expressivityLevel = FULL; URI uri = prop.getURI(); explain( FULL, COMPLEXTRANSITIVE, "Complex property " + encodeHLink(uri.toString(), myModel.shortForm(uri)) + " asserted to be transitive."); } } } } catch (Exception ex) { ex.printStackTrace(); throw new OWLException(ex.getMessage()); } }