Search in sources :

Example 1 with Individual

use of com.hp.hpl.jena.ontology.Individual in project hale by halestudio.

the class MdlLineageGenerator method generateLineage.

/**
 * @param mismatches the {@link List} of mismatches that should be
 * documented in the lineage
 * @param f the source Feature, used for gathering provenance information
 */
public void generateLineage(List<Mismatch> mismatches, Feature f) {
    URL provenanceLocation = MdlLineageGenerator.class.getResource("provenance.rdf");
    OntModel lineage = ModelFactory.createOntologyModel();
    lineage.read("" + provenanceLocation);
    OntClass dataItemClass = lineage.getOntClass("http://purl.org/net/provenance/ns#DataItem");
    for (OntProperty op : dataItemClass.listDeclaredProperties().toList()) {
        System.out.println(op.getLocalName());
    }
    // first, collect information about the original data item (the source feature).
    Individual name1individual = dataItemClass.createIndividual(f.getType().getName().getNamespaceURI() + ":" + f.getType().getName().getLocalPart() + ":" + f.getIdentifier().getID());
    System.out.println(name1individual.getURI());
// collect information about the transformed feature
// TODO
// attach a precededBy property to the transformed feature, identifying the
// source feature as an earlier version
// TODO
}
Also used : OntProperty(com.hp.hpl.jena.ontology.OntProperty) Individual(com.hp.hpl.jena.ontology.Individual) OntModel(com.hp.hpl.jena.ontology.OntModel) OntClass(com.hp.hpl.jena.ontology.OntClass) URL(java.net.URL)

Example 2 with Individual

use of com.hp.hpl.jena.ontology.Individual 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)

Aggregations

Individual (com.hp.hpl.jena.ontology.Individual)2 OntClass (com.hp.hpl.jena.ontology.OntClass)2 OntModel (com.hp.hpl.jena.ontology.OntModel)2 AnnotationProperty (com.hp.hpl.jena.ontology.AnnotationProperty)1 DatatypeProperty (com.hp.hpl.jena.ontology.DatatypeProperty)1 ObjectProperty (com.hp.hpl.jena.ontology.ObjectProperty)1 OntProperty (com.hp.hpl.jena.ontology.OntProperty)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 URL (java.net.URL)1 OWLAnnotationProperty (org.semanticweb.owlapi.model.OWLAnnotationProperty)1 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)1 OWLLiteral (org.semanticweb.owlapi.model.OWLLiteral)1 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)1 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)1 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)1