3 Replies Latest reply on Feb 11, 2011 9:43 PM by alwu-Oracle

    Is reification supported by the Jena Adapter?

      I have two statements "the sky is blue" and "the sky is red". Only "the sky is blue" is approved. I try to query for approved statements. If I use the default model with ModelFactory.createDefaultModel(), it works. But if I use the Oracle one, the query results are empty.

      Please tell me reification actually supported by the Oracle Jena Adapter? See my code below...

      import oracle.spatial.rdf.client.jena.ModelOracleSem;
      import oracle.spatial.rdf.client.jena.Oracle;

      import com.hp.hpl.jena.query.Query;
      import com.hp.hpl.jena.query.QueryExecution;
      import com.hp.hpl.jena.query.QueryExecutionFactory;
      import com.hp.hpl.jena.query.QueryFactory;
      import com.hp.hpl.jena.query.ResultSet;
      import com.hp.hpl.jena.query.ResultSetFormatter;
      import com.hp.hpl.jena.rdf.model.Model;
      import com.hp.hpl.jena.rdf.model.ModelFactory;
      import com.hp.hpl.jena.rdf.model.Property;
      import com.hp.hpl.jena.rdf.model.ReifiedStatement;
      import com.hp.hpl.jena.rdf.model.Resource;
      import com.hp.hpl.jena.rdf.model.Statement;

      * Test reification with oracle jena adapter
      * @author kpauli
      public class OracleJenaAdapterReificationTest {

           public static void main(String[] args) throws Exception {
                String szJdbcURL = "jdbc:oracle:thin:@dragon12:1521:mydb";
                String szUser = "mydb";
                String szPasswd = "yeahright";
                String szModelName = "kp_mydb_model";
                Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
                Model model = ModelOracleSem.createOracleSemModel(oracle, szModelName);
                // use this one and it works
      //          Model model = ModelFactory.createDefaultModel();

                String mydbRoot = "http://com.example.mydb/";
                Property isApproved = model.createProperty(mydbRoot + "isApproved");

                String exampleRoot = "http://com.example/";
                Resource theSky = model.createResource(exampleRoot + "theSky");
                Property hasColor = model.createProperty(exampleRoot + "hasColor");
                Resource blue = model.createResource(exampleRoot + "blue");
                Resource red = model.createResource(exampleRoot + "red");

                Statement theSkyIsBlue = model.createStatement(theSky, hasColor, blue);

                Statement theSkyIsRed = model.createStatement(theSky, hasColor, red);

                // approve theSkyIsBlue
                ReifiedStatement theSkyIsBlueReified = model
                Statement blueApprovalStatement = model
                          .createStatement(theSkyIsBlueReified, isApproved,

                // show all statements
                     System.out.println("All statements:");
                     Query query = QueryFactory
                               .create("select ?s ?p ?o where {?s ?p ?o .}");
                     QueryExecution qexec = QueryExecutionFactory.create(query, model);
                     ResultSet results = qexec.execSelect();
                     ResultSetFormatter.out(System.out, results, query);

                // show only approved statements
                     System.out.println("Approved statements:");
                     Query query = QueryFactory
                               .create("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
                                         "PREFIX mydb: <http://com.example.mydb/> " +
                                         "select ?s ?p ?o where {" +
                                         "?t rdf:subject ?s . " +
                                         "?t rdf:predicate ?p . " +
                                         "?t rdf:object ?o . " +
                                         "?t mydb:isApproved true .}");
                     QueryExecution qexec = QueryExecutionFactory.create(query, model);
                     ResultSet results = qexec.execSelect();
                     ResultSetFormatter.out(System.out, results, query);

        • 1. Re: Is reification supported by the Jena Adapter?

          We don't have direct support for reification in Jena Adapter. Specifically, we haven't extended Jena's ModelReifier. Please let us know if it is a strong requirement.
          For now, you have to add those reified triples yourself into an ModelOracleSem object

          Sorry for the inconvenience,

          Zhe Wu
          • 2. Re: Is reification supported by the Jena Adapter?
            Well, it would be really nice for my use case... we're trying to give the users a dynamic data model backed by RDF, but we want to store some general metadata about the data such as approval, last modified timestamps, etc. And we want to do this in a consistent, systematic way across the whole data set. So native reification for that purpose would have been nice.

            I understand I can do it by creating the quad myself, but I expect that to have an impact on performance. Can you tell me if it is likely to be a big impact?
            • 3. Re: Is reification supported by the Jena Adapter?
              Hi Kevin,

              In this case, I don't think it affects performance, not at all. The reason is that if we were going to extend Jena's reifier logic, we would manually insert a few triples every time you ask us to create an reified statement. Your logic will do the same thing.

              Actually you have a chance to optimize if you have many (say millions) of reified statements. You can add those statements against an in memory model and bulk load them into Oracle (See OracleBulkUpdateHandler) in one shot.

              Hope it helps,

              Zhe Wu