Skip to content
Ignazio Palmisano edited this page Jan 30, 2016 · 2 revisions

Migration to 4: extra tricks

From Lorenz Bühmann

  • RDFXMLOntologyFormat -> RDFXMLDocumentFormat (Basically all formats are now renamed by Document instead of Ontology)
  • OWLAxiomVisitorExAdapter needs a default value now
  • OWLProfile implementations are covered by enum Profiles

From Ignazio: Where's ManchesterOWLSyntaxEditorParser and how do I parse a class expression again?

There's an interface: org.semanticweb.owlapi.util.mansyntax.ManchesterOWLSyntaxParser

It implements parseClassExpression() unchanged. To get instances of this class, you can use OWLManager (bit cumbersome at the moment):

public OWLClassExpression parseClassExpression(
        @Nonnull String classExpressionString) {
    // Set up the real parser
    ManchesterOWLSyntaxParser parser = OWLManager.createManchesterParser();
    parser.setStringToParse(classExpressionString);
    parser.setDefaultOntology(rootOntology);
    // Specify an entity checker that wil be used to check a class
    // expression contains the correct names.
    OWLEntityChecker entityChecker = new ShortFormEntityChecker(
            bidiShortFormProvider);
    parser.setOWLEntityChecker(entityChecker);
    // Do the actual parsing
    return parser.parseClassExpression();
}

This snippet of code is in the DLQueryExample file:

https://github.com/owlcs/owlapi/blob/version4/contract/src/test/java/org/semanticweb/owlapi/examples/DLQueryExample.java

The old implementation class has been renamed to: https://github.com/owlcs/owlapi/blob/version4/parsers/src/main/java/org/semanticweb/owlapi/manchestersyntax/parser/ManchesterOWLSyntaxParserImpl.java

All functionality should be usable through the interface - one difference between old and new is that the string to parse used to be passed in the constructor of the object, and is now set with setStringToParse().

From Vincent Vialard

  • OWLManager.createOWLOntologyManager(OWLDataFactory dataFactory) is no longer available. Skip the argument to fix.
  • OWLOntologyID.getOntologyIRI() now returns Optional<IRI>, replace calls with .getOntologyIRI().get(). Same goes for OntologyID::getVersionIRI() and OntologyID::getDefaultDocumentIRI().