Search in sources :

Example 16 with SimpleSelector

use of com.hp.hpl.jena.rdf.model.SimpleSelector in project ambit-mirror by ideaconsult.

the class RDFIteratingReader method parseFeatureValues.

protected void parseFeatureValues(Resource dataEntry, IStructureRecord record) throws Exception {
    StmtIterator values = jenaModel.listStatements(new SimpleSelector(dataEntry, OT.OTProperty.values.createProperty(jenaModel), (RDFNode) null));
    while (values.hasNext()) {
        Statement st = values.next();
        if (st.getObject().isResource()) {
            Resource fv = (Resource) st.getObject();
            Statement property = fv.getProperty(OT.DataProperty.value.createProperty(jenaModel));
            RDFNode value = null;
            if (property != null)
                value = property.getObject();
            RDFNode feature = fv.getProperty(OT.OTProperty.feature.createProperty(jenaModel)).getObject();
            Property key = null;
            String uri = null;
            if (feature.isURIResource() && (lookup != null)) {
                uri = ((Resource) feature).getURI();
                key = lookup.get(uri);
            }
            if (key == null) {
                key = propertyIterator.parseRecord(feature, key);
                if (uri != null) {
                    if (lookup == null)
                        lookup = new Hashtable<String, Property>();
                    lookup.put(uri, key);
                }
            }
            if (value != null)
                setFeatureValue(record, key, value);
        }
    }
}
Also used : StmtIterator(com.hp.hpl.jena.rdf.model.StmtIterator) SimpleSelector(com.hp.hpl.jena.rdf.model.SimpleSelector) Statement(com.hp.hpl.jena.rdf.model.Statement) Hashtable(java.util.Hashtable) Resource(com.hp.hpl.jena.rdf.model.Resource) Property(ambit2.base.data.Property) RDFNode(com.hp.hpl.jena.rdf.model.RDFNode)

Aggregations

SimpleSelector (com.hp.hpl.jena.rdf.model.SimpleSelector)16 Resource (com.hp.hpl.jena.rdf.model.Resource)14 Statement (com.hp.hpl.jena.rdf.model.Statement)14 StmtIterator (com.hp.hpl.jena.rdf.model.StmtIterator)14 RDFNode (com.hp.hpl.jena.rdf.model.RDFNode)13 Literal (com.hp.hpl.jena.rdf.model.Literal)5 ResourceException (org.restlet.resource.ResourceException)5 Property (ambit2.base.data.Property)4 IOException (java.io.IOException)4 MalformedURLException (java.net.MalformedURLException)3 Reference (org.restlet.data.Reference)3 OntModel (com.hp.hpl.jena.ontology.OntModel)2 Model (com.hp.hpl.jena.rdf.model.Model)2 Property (com.hp.hpl.jena.rdf.model.Property)2 Hashtable (java.util.Hashtable)2 OTProperty (net.idea.restnet.rdf.ns.OT.OTProperty)2 Attribute (weka.core.Attribute)2 PropertyAnnotation (ambit2.base.data.PropertyAnnotation)1 PropertyAnnotations (ambit2.base.data.PropertyAnnotations)1 RDFDatatype (com.hp.hpl.jena.datatypes.RDFDatatype)1