4 Replies Latest reply on Sep 8, 2009 8:18 PM by 696067

    Making changes via OntModel wrapping

    696067
      So I am creating a graph with an attachment like so:

      Attachment attachment = Attachment.createInstance(
      Attachment.NO_ADDITIONAL_MODELS, "OWLPRIME",
      InferenceMaintenanceMode.UPDATE_WHEN_COMMIT,
      QueryOptions.DEFAULT);
      graph = new GraphOracleSem(oracle, "mc_sem_model", attachment);

      And I am wrapping the ModelOracleSem with the OntModel interface like so:

      ModelOracleSem oracle_sem_model = new ModelOracleSem(graph);
      OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, oracle_sem_model);

      and then an trying to make changes via OntModel like so:

      graph.commitTransaction(); //making sure the rules index is valid
      model.begin();
      model.createClass(NS+"blin"); //it crashes here
      model.commit();
      graph.commitTransaction();

      On the afformentioned line I get the below error. Also, from a mdsys.sem_rules_index_info status field check I see that the rules index has become invalidated.

      Exception in thread "main" java.sql.SQLException:
      ORA-20000: We do not have a valid rules index for this Model-Rulebase combination
      ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 695
      ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 222
      ORA-06512: at line 1

      I can however make changes to ModelOracleSem like so:

      ModelOracleSem oracle_sem_model = new ModelOracleSem(graph);
      oracle_sem_model.createStatement(
           oracle_sem_model.createResource(NS+"sub"),
           oracle_sem_model.createProperty(NS+"prop"),
           oracle_sem_model.createResource(NS+"obj"));
      oracle_sem_model.commit();
      graph.commitTransaction();

      How come I can change ModelOracleSem but not the OntModel?
      -Alexi

      Edited by: user10960203 on Sep 3, 2009 6:44 PM - Forgot to mention the Attachment and the ModelOracleSem part...
        • 1. Re: Making changes via OntModel wrapping
          alwu-Oracle
          Hi,

          Could you try the following code instead?

          Attachment attachment = Attachment.createInstance(
          Attachment.NO_ADDITIONAL_MODELS, "OWLPRIME",
          InferenceMaintenanceMode.UPDATE_WHEN_COMMIT,
          QueryOptions.ALLOW_QUERY_INCOMPLETE);

          GraphOracleSem graph = new GraphOracleSem(oracle, modelName, attachment);
          graph.commitTransaction(); //making sure the rules index is valid

          ModelOracleSem oracle_sem_model = new ModelOracleSem(graph);
          OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, oracle_sem_model);

          model.begin();
          model.createClass ....

          There are two changes
          1) I moved the first commitTransaction above that createOntologyModel API call.
          2) I used ALLOW_QUERY_INCOMPLETE

          I am able to run the changed code (using the latest Jena Adaptor).

          1) is necessary because that createOntologyModel call will in turn call the graphBaseFind API of GraphOracleSem. However, the entailment was not created. So there was a bit of timing issue in your code.

          2) is necessary because model.create(...) will add new triple to the graph which causes the status to be incomplete. So we have to allow that status.

          Hope it helps,

          Zhe Wu
          • 2. Re: Making changes via OntModel wrapping
            696067
            Hum, interesting.
            So the command "ontModel.createClass(uri)"
            a) Causes the sem_model's (i.e. the thing beneath GraphOracleSem) rules index to become incomplete... and
            b) Makes a query against sem_model...
            which is why you need QueryOptions.ALLOW_QUERY_INCOMPLETE.

            So I have a few questions:
            1) Why does "ontModel.createClass(uri)" make a query against GraphOracleSem? To my understanding the only thing it's doing is adding the triple "uri rdf:type rdf:Class" to the database. The following code for instance will work with QueryOptions.DEFAULT:

            oracle_sem_model.begin();
            oracle_sem_model.add(
                      oracle_sem_model.createResource(NS+"newclass"),
                      RDF.type,
                      RDFS.Class);
            oracle_sem_model.commit();
            graph.commitTransaction();

            2) If the call "ontModel.createClass(uri)" indeed does make a query against GraphOracleSem, when does this happen? Does it happen before or after the statement "uri rdf:type rdf:Class" is added to the graph?
            • 3. Re: Making changes via OntModel wrapping
              alwu-Oracle
              Hi,

              All these behaviors are really Jena's own logic.

              Here are some details.

              When createOntologyModel is invoked, a pattern match query (?s @ow;:imports ?o) is sent to
              GraphOracleSem.

              When createClass() is invoked, at the GraphOracleSem object level, performAdd() is called, followed by
              a boolean query to verify that triple is added. Note that the follow up query is done by Jena.

              Hope it helps,

              Zhe Wu
              1 person found this helpful
              • 4. Re: Making changes via OntModel wrapping
                696067
                Ah, makes perfect sense. Thank you.

                -Alexi