Search in sources :

Example 1 with OntProperty

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

use of com.hp.hpl.jena.ontology.OntProperty in project fiware-iot-discovery-ngsi9 by telsaleh.

the class SemanticConverter method createJenaModel.

public void createJenaModel(RegisterContextRequest rcr) {
    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    // ontModel.loadImports();
    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    // if (formParams.containsKey(ontProp.getLocalName())) {
    // regIndividual.addProperty(ontProp, ontModel.getcreateTypedLiteral(formParams.get(ontProp.getLocalName())[0]));
    // }
    }
    // OntClass regClass = ontModel.getOntClass(ONT_URL + "iotReg");
    // OntClass entClass = ontModel.createOntClass(ONT_URL + "entity");
    // OntClass regClass = (OntClass) ontModel.createOntResource(OntClass.class, null,ONT_URL+"Registration" );
    // OntClass regClass = (OntClass) ontModel.createClass(ONT_URL + "Registration");
    // OntClass entityClass = (OntClass) ontModel.createClass(ONT_URL + "Entity");
    OntClass entityGroup = (OntClass) ontModel.getOntClass(ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(ONT_URL + "Entity");
    OntClass attribute = (OntClass) ontModel.getOntClass(ONT_URL + "Attribute");
    OntClass metadata = (OntClass) ontModel.getOntClass(ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");
    // System.out.println("Class type is: " + regClass.getLocalName());
    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "registrationId"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "regTimeStamp"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "duration"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(2).getName();
    // Individual metadata3 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    // attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata3);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(2).getType();
    // metadata3.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(2).getValue().toString();
    // metadata3.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    // System.out.println("has propertry \"expiry\":"+entityIndiv.hasProperty(ontModel.getProperty(ONT_URL, "expiry")));
    ontModel.write(System.out, "TURTLE");
// ontModel.write(System.out, "RDF/XML");
// ontModel.write(System.out, "JSON-LD");
}
Also used : OntProperty(com.hp.hpl.jena.ontology.OntProperty) Individual(com.hp.hpl.jena.ontology.Individual) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) OntModel(com.hp.hpl.jena.ontology.OntModel) Model(com.hp.hpl.jena.rdf.model.Model) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) OntModel(com.hp.hpl.jena.ontology.OntModel) OntClass(com.hp.hpl.jena.ontology.OntClass)

Example 3 with OntProperty

use of com.hp.hpl.jena.ontology.OntProperty in project fiware-iot-discovery-ngsi9 by telsaleh.

the class SemanticConverter2 method createJenaModel.

public void createJenaModel(RegisterContextRequest rcr) {
    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    // ontModel.loadImports();
    ontModel.setStrictMode(true);
    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }
    OntClass entityGroup = (OntClass) ontModel.getOntClass(ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(ONT_URL + "Entity");
    OntClass attribute = (OntClass) ontModel.getOntClass(ONT_URL + "Attribute");
    OntClass metadata = (OntClass) ontModel.getOntClass(ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");
    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "registrationId"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "regTimeStamp"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "duration"), ontModel.createLiteral(ngsiValue));
    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {
        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {
            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {
                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entityInstance);
                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
                        entityInstance.addProperty(ontModel.getProperty(ONT_URL + "hasAttribute"), attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
                            attrInstance.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), mdataInstance);
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
                        }
                    }
                }
            }
        }
    }
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    // Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    // entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    // Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    // attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    // Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    // attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    // metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    // metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    // Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    // attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    // metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    // metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
// ontModel.write(System.out, "RDF/XML");
// ontModel.write(System.out, "JSON-LD");
}
Also used : OntProperty(com.hp.hpl.jena.ontology.OntProperty) Individual(com.hp.hpl.jena.ontology.Individual) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) Model(com.hp.hpl.jena.rdf.model.Model) OntModel(com.hp.hpl.jena.ontology.OntModel) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) OntModel(com.hp.hpl.jena.ontology.OntModel) OntClass(com.hp.hpl.jena.ontology.OntClass)

Example 4 with OntProperty

use of com.hp.hpl.jena.ontology.OntProperty in project fiware-iot-discovery-ngsi9 by telsaleh.

the class SemanticConverter3 method createJenaModel.

public void createJenaModel(RegisterContextRequest rcr) {
    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    // ontModel.loadImports();
    ontModel.setStrictMode(true);
    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }
    OntClass entityGroup = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Entity");
    OntClass metadata = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");
    OntClass sensingDevice = (OntClass) ontModel.getOntClass(SSN_ONT_URL + "SensingDevice");
    OntClass iotObject = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Object");
    OntClass attribute = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Attribute");
    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "registrationId"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "regTimeStamp"), ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "duration"), ontModel.createLiteral(ngsiValue));
    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {
        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {
            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {
                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasEntity"), entityInstance);
                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, attribute);
                        entityInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasAttribute"), attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, metadata);
                            attrInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasMetadata"), mdataInstance);
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
                        }
                    }
                }
            }
        }
    }
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    // Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    // entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    // Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    // entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    // attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    // Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    // attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    // metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    // metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    // Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    // attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    // 
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    // metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    // ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    // metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
// ontModel.write(System.out, "RDF/XML");
// ontModel.write(System.out, "JSON-LD");
}
Also used : OntProperty(com.hp.hpl.jena.ontology.OntProperty) Individual(com.hp.hpl.jena.ontology.Individual) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) Model(com.hp.hpl.jena.rdf.model.Model) OntModel(com.hp.hpl.jena.ontology.OntModel) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) OntModel(com.hp.hpl.jena.ontology.OntModel) OntClass(com.hp.hpl.jena.ontology.OntClass)

Example 5 with OntProperty

use of com.hp.hpl.jena.ontology.OntProperty in project fiware-iot-discovery-ngsi9 by telsaleh.

the class SemanticConverter method createJenaModel.

public void createJenaModel(RegisterContextRequest rcr) {
    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    // OntClass regClass = ontModel.getOntClass(ONT_URL + "iotReg");
    // OntClass entClass = ontModel.createOntClass(ONT_URL + "entity");
    // OntClass regClass = (OntClass) ontModel.createOntResource(OntClass.class, null,ONT_URL+"Registration" );
    // OntClass regClass = (OntClass) ontModel.createClass(ONT_URL + "Registration");
    // OntClass entityClass = (OntClass) ontModel.createClass(ONT_URL + "Entity");
    OntClass entityClass = (OntClass) ontModel.getOntClass(ONT_URL + "Entity");
    // System.out.println("Class type is: " + regClass.getLocalName());
    // System.out.println(rcr.getRegistrationId());
    Individual regIndividual = ontModel.createIndividual(ONT_URL + "roomSensor13CII01", entityClass);
    System.out.println("has propertry \"expiry\":" + regIndividual.hasProperty(ontModel.getProperty(ONT_URL, "expiry")));
    // Property p = ontModel.createProperty(ONT_URL, "hasRegistrationId");
    // regIndividual.addProperty(p, "");
    regIndividual.setPropertyValue(ontModel.getProperty(ONT_URL, "registrationId"), ontModel.createLiteral(rcr.getRegistrationId()));
    // p = ontModel.createProperty(ONT_URL, "hasDuration");
    // regIndividual.addProperty(p, "");
    regIndividual.setPropertyValue(ontModel.getProperty(ONT_URL, "expiry"), ontModel.createLiteral(rcr.getDuration()));
    System.out.println("has propertry \"expiry\":" + regIndividual.hasProperty(ontModel.getProperty(ONT_URL, "expiry")));
    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    // if (formParams.containsKey(ontProp.getLocalName())) {
    // regIndividual.addProperty(ontProp, ontModel.getcreateTypedLiteral(formParams.get(ontProp.getLocalName())[0]));
    // }
    }
    ontModel.write(System.out, "TURTLE");
// ontModel.write(System.out, "RDF/XML");
// ontModel.write(System.out, "JSON-LD");
}
Also used : Individual(com.hp.hpl.jena.ontology.Individual) OntProperty(com.hp.hpl.jena.ontology.OntProperty) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) Model(com.hp.hpl.jena.rdf.model.Model) OntModel(com.hp.hpl.jena.ontology.OntModel) OntModel(com.hp.hpl.jena.assembler.JA.OntModel) OntModel(com.hp.hpl.jena.ontology.OntModel) OntClass(com.hp.hpl.jena.ontology.OntClass)

Aggregations

Individual (com.hp.hpl.jena.ontology.Individual)5 OntClass (com.hp.hpl.jena.ontology.OntClass)5 OntModel (com.hp.hpl.jena.ontology.OntModel)5 OntProperty (com.hp.hpl.jena.ontology.OntProperty)5 OntModel (com.hp.hpl.jena.assembler.JA.OntModel)4 Model (com.hp.hpl.jena.rdf.model.Model)4 URL (java.net.URL)1