Search in sources :

Example 1 with AnnotationProperty

use of com.hp.hpl.jena.ontology.AnnotationProperty in project stanbol by apache.

the class ConversionTester method testAnnotationPropJenaToOwl.

public void testAnnotationPropJenaToOwl() {
    JenaToOwlConvert j2o = new JenaToOwlConvert();
    OntModel model = ModelFactory.createOntologyModel();
    AnnotationProperty jp = model.createAnnotationProperty(label.toString());
    OWLAnnotationProperty wp = null;
    try {
        wp = j2o.AnnotationPropJenaToOwl(jp, RDFXML);
        if (wp == null) {
            fail("Some errors occur");
        } else {
            assertEquals(wp.getIRI().toURI().toString(), jp.getURI());
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception caugth");
    } finally {
        assertNotNull(wp);
    }
}
Also used : OWLAnnotationProperty(org.semanticweb.owlapi.model.OWLAnnotationProperty) AnnotationProperty(com.hp.hpl.jena.ontology.AnnotationProperty) OWLAnnotationProperty(org.semanticweb.owlapi.model.OWLAnnotationProperty) OntModel(com.hp.hpl.jena.ontology.OntModel) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException)

Example 2 with AnnotationProperty

use of com.hp.hpl.jena.ontology.AnnotationProperty in project stanbol by apache.

the class ConversionTester method testResourceJenaToOwlAxiom.

public void testResourceJenaToOwlAxiom() {
    JenaToOwlConvert j2o = new JenaToOwlConvert();
    OntModel model = ModelFactory.createOntologyModel();
    OntClass jenaclass = model.createClass(CLAZZ.toString());
    ObjectProperty jenaobprop = model.createObjectProperty(OP.toString());
    DatatypeProperty jenadataprop = model.createDatatypeProperty(DP.toString());
    Individual jenasub = model.createIndividual(SUBJECT.toString(), jenaclass);
    Individual jenaobj = model.createIndividual(OBJECT.toString(), jenaclass);
    AnnotationProperty jenaanno = model.createAnnotationProperty(label.toString());
    Literal value = model.createTypedLiteral(VALUE, DATATYPE.toString());
    model.add(jenasub, jenaobprop, jenaobj);
    model.add(jenasub, jenadataprop, value);
    model.add(jenasub, jenaanno, "Lucy", "en");
    Set<OWLAxiom> owlaxiom = null;
    try {
        owlaxiom = j2o.ResourceJenaToOwlAxiom(jenasub, RDFXML);
        if (owlaxiom == null) {
            fail("Some errors occur");
        } else {
            StmtIterator str = model.listStatements();
            int count = 0;
            while (str.hasNext()) {
                Statement stm = str.next();
                Resource subject = stm.getSubject();
                if (SUBJECT.toString().equals(subject.getURI()))
                    count++;
            }
            if (count == owlaxiom.size()) {
                assertEquals(count, owlaxiom.size());
            } else {
                fail("The number of axioms don't match the number of statement");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception caugth");
    } finally {
        assertNotNull(owlaxiom);
    }
}
Also used : OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty) ObjectProperty(com.hp.hpl.jena.ontology.ObjectProperty) StmtIterator(com.hp.hpl.jena.rdf.model.StmtIterator) Statement(com.hp.hpl.jena.rdf.model.Statement) Resource(com.hp.hpl.jena.rdf.model.Resource) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) AnnotationProperty(com.hp.hpl.jena.ontology.AnnotationProperty) OWLAnnotationProperty(org.semanticweb.owlapi.model.OWLAnnotationProperty) Individual(com.hp.hpl.jena.ontology.Individual) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLLiteral(org.semanticweb.owlapi.model.OWLLiteral) Literal(com.hp.hpl.jena.rdf.model.Literal) OntModel(com.hp.hpl.jena.ontology.OntModel) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) OntClass(com.hp.hpl.jena.ontology.OntClass) DatatypeProperty(com.hp.hpl.jena.ontology.DatatypeProperty)

Example 3 with AnnotationProperty

use of com.hp.hpl.jena.ontology.AnnotationProperty in project stanbol by apache.

the class ConversionTester method testAnnotationPropOwlToJena.

public void testAnnotationPropOwlToJena() {
    JenaToOwlConvert j2o = new JenaToOwlConvert();
    OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = mgr.getOWLDataFactory();
    OWLAnnotationProperty wp = factory.getOWLAnnotationProperty(IRI.create(label));
    AnnotationProperty jp = null;
    try {
        jp = j2o.AnnotationPropOwlToJena(wp, RDFXML);
        if (jp == null) {
            fail("Some errors occur");
        } else {
            assertEquals(wp.getIRI().toURI().toString(), jp.getURI());
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception caugth");
    } finally {
        assertNotNull(jp);
    }
}
Also used : OWLAnnotationProperty(org.semanticweb.owlapi.model.OWLAnnotationProperty) AnnotationProperty(com.hp.hpl.jena.ontology.AnnotationProperty) OWLAnnotationProperty(org.semanticweb.owlapi.model.OWLAnnotationProperty) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException)

Aggregations

AnnotationProperty (com.hp.hpl.jena.ontology.AnnotationProperty)3 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)3 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)3 OntModel (com.hp.hpl.jena.ontology.OntModel)2 DatatypeProperty (com.hp.hpl.jena.ontology.DatatypeProperty)1 Individual (com.hp.hpl.jena.ontology.Individual)1 ObjectProperty (com.hp.hpl.jena.ontology.ObjectProperty)1 OntClass (com.hp.hpl.jena.ontology.OntClass)1 Literal (com.hp.hpl.jena.rdf.model.Literal)1 Resource (com.hp.hpl.jena.rdf.model.Resource)1 Statement (com.hp.hpl.jena.rdf.model.Statement)1 StmtIterator (com.hp.hpl.jena.rdf.model.StmtIterator)1 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)1 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)1 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)1 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)1 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)1 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)1