@Override public String toString() { StringBuilder sb = new StringBuilder(profile.getName()); sb.append(" Profile Report: "); if (isInProfile()) { sb.append("[Ontology and imports closure in profile]\n"); } else { sb.append( "Ontology and imports closure NOT in profile. The following violations are present:\n"); } violations.forEach(v -> sb.append(v).append('\n')); return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(profile.getName()); sb.append(" Profile Report: "); if (isInProfile()) { sb.append("[Ontology and imports closure in profile]\n"); } else { sb.append( "Ontology and imports closure NOT in profile. The following violations are present:\n"); } violations.forEach(v -> sb.append(v).append('\n')); return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(profile.getName()); sb.append(" Profile Report: "); if (isInProfile()) { sb.append("[Ontology and imports closure in profile]\n"); } else { sb.append( "Ontology and imports closure NOT in profile. The following violations are present:\n"); } violations.forEach(v -> sb.append(v).append('\n')); return sb.toString(); } }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(profile.getName()); sb.append(" Profile Report: "); if(isInProfile()) { sb.append("[Ontology and imports closure in profile]\n"); } else { sb.append("Ontology and imports closure NOT in profile. "); sb.append("The following violations are present: "); sb.append(":\n"); } for(OWLProfileViolation na : violations) { sb.append(na); sb.append("\n"); } return sb.toString(); } }
private String getProfile(final OWLOntology ontology) { for (final OWLProfile profile : _profiles) if (profile.checkOntology(ontology).isInProfile()) return profile.getName(); return "Unknown Profile"; }
private String getOWL2DLProfileViolations(final OWLOntology ontology) { final OWL2DLProfile owl2Profile = new OWL2DLProfile(); final OWLProfileReport profileReport = owl2Profile.checkOntology(ontology); if (profileReport.isInProfile()) return "No OWL 2 DL violations found for ontology " + ontology.getOntologyID().toString(); final StringBuffer result = new StringBuffer(); result.append("\n=========================================================\n"); result.append("OWL 2 DL violations found for ontology ").append(ontology.getOntologyID().toString()).append(":\n"); for (final OWLProfileViolation violation : profileReport.getViolations()) { result.append(violation.toString()); result.append("\n"); } return result.toString(); }
/** * Check OWL2DL profile. * * @param directOntology the direct ontology * @throws Exception the exception */ public static void checkOWL2DLProfile(OWLOntology directOntology) throws Exception { // // Compliance testing - OWL 2 DL // OWL2DLProfile profile = new OWL2DLProfile(); OWLProfileReport report = profile.checkOntology(directOntology); if (!report.isInProfile()) { boolean flag = false; for (OWLProfileViolation violation : report.getViolations()) { // Allow violation: Use of undeclared annotation property if (violation.toString().indexOf( "Use of undeclared annotation property") == -1) { flag = true; break; } } if (flag) { throw new Exception("OWL is not in expected profile OWL DL 2 - " + report); } } }
@Override public ProfileMetricValue computeValue() { OWLProfileReport report = profile.checkOntology(getRootOntology()); return new ProfileMetricValue(profile.getName(), report.isInProfile()); }
/** * Checks an ontology and its import closure to see if it is within * this profile. * @param ontology The ontology to be checked. * @return An <code>OWLProfileReport</code> that describes whether or not the * ontology is within this profile. */ public OWLProfileReport checkOntology(OWLOntology ontology) { OWL2Profile owl2Profile = new OWL2Profile(); OWLProfileReport report = owl2Profile.checkOntology(ontology); Set<OWLProfileViolation> violations = new LinkedHashSet<OWLProfileViolation>(); if(!report.isInProfile()) { //We won't be in the OWL 2 DL Profile then! violations.addAll(report.getViolations()); } OWLOntologyWalker walker = new OWLOntologyWalker(ontology.getImportsClosure()); OWL2DLProfileObjectVisitor visitor = new OWL2DLProfileObjectVisitor(walker, ontology.getOWLOntologyManager()); walker.walkStructure(visitor); violations.addAll(visitor.getProfileViolations()); return new OWLProfileReport(this, violations); }
System.out.println(report.toString()); if (!report.isInProfile()) { throw new Exception( String.format(
@Test public void testCorrectOntology() throws OWLOntologyCreationException { final OWLOntology ontology = OWL._manager.loadOntologyFromOntologyDocument(new File("test/data/misc/agencies.owl")); try { final OWL2DLProfile owl2Profile = new OWL2DLProfile(); assertTrue(owl2Profile.checkOntology(ontology).isInProfile()); } finally { OWL._manager.removeOntology(ontology); } }
@Test public void testInvalidTransitivity() throws OWLOntologyCreationException { final OWLOntology ontology = OWL._manager.loadOntologyFromOntologyDocument(new File("test/data/misc/invalidTransitivity.owl")); try { final OWL2DLProfile owl2Profile = new OWL2DLProfile(); assertFalse(owl2Profile.checkOntology(ontology).isInProfile()); } finally { OWL._manager.removeOntology(ontology); } } }
@Test public void testSuperPropertyTopDataProperty() throws OWLOntologyCreationException { final OWLOntology ontology = OWL._manager.createOntology(); try { final OWLDataProperty property = OWL._factory.getOWLDataProperty(IRI.create("tag:clarkparsia.com,2008:pellint:test:superProperty")); final OWLDataProperty topProperty = OWL._factory.getOWLTopDataProperty(); final OWLAxiom axiom = OWL._factory.getOWLSubDataPropertyOfAxiom(topProperty, property); OWL._manager.addAxiom(ontology, axiom); final OWL2DLProfile owl2Profile = new OWL2DLProfile(); assertFalse(owl2Profile.checkOntology(ontology).isInProfile()); } finally { OWL._manager.removeOntology(ontology); } }