6 Replies Latest reply on Jul 12, 2010 2:53 PM by 766393

    Oracle / Joseki: how to prevent non-existent model from being created ?

    766393
      Hi,

      I am trying to set up a Joseki endpoint which would be used to run read-only queries against a specific RDF model on a remote database.

      According to the documentation( http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11828/sem_jena.htm#sthref290 ), it seems that there is no way to prevent Joseki from creating the actual model in the database if it is not present.

      I would really prefer to see the service failing than creating the model in the database, since the Joseki client in my case should be showing "RDF model missing" instead of running queries on an empty model.

      Do I have to write my own servlet to make sure the model exists before sending any queries to Joseki ?

      Thanks,

      Julien
        • 1. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
          alwu-Oracle
          Hi,

          In the joseki configuration file, if you do not provide a name that does not exist, then it will not be created.
          Right now, Jena Adapter creates a model automatically if it is not there. This is for convenience.

          We can look into adding an option to avoid doing that if there is a good requirement from your application.

          Thanks,

          Zhe Wu
          • 2. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
            766393
            Hi,

            Here is why I needed this.

            I have integrated in an application a few features using SPARQL on both an in-memory Jena model and a larger remote RDF model on an Oracle database. However, some of my users do not have direct access to the actual RDF database. That is why I am also setting up a joseki SPARQL-protocol-compliant service, which will be used, like the Oracle Database, through Jena (QueryExecutionFactory.sparqlService) on the client side.

            At some point during the day, the database is completely rebuilt from scratch, and it gets "offline" (model does not exist) for some time. At this point, on the direct-to-Oracle-db side of the application, I use OracleUtils.getAllReadableModels to make sure the model already exists before running any query. The problem is that I cannot do this check through Joseki.

            So, basically, my best shot is to write my own Servlet which would use OracleUtils.getAllReadableModels ?

            Thanks

            Regards
            Julien
            • 3. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
              alwu-Oracle
              Hi Julien,

              Thanks for your explanation. One thing I am still not clear is that you mentioned "the database is completely rebuilt from scratch during the day." Is that just one time deal or it happens every day?

              You certainly can write a servlet to check if a model exists or not. However, do you care about the existence of a model, or you care more about whether a model is empty?

              Thanks,

              Zhe
              • 4. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
                766393
                Hi,

                Yes, what I meant was that the database is completely rebuilt every day from scratch.
                That is why there is a timespan every day during which I want to prevent users from connecting to the database and creating an empty model instead of just being rejected.

                Anyway, I wrote the servlet and it suits my needs perfectly.
                I just can't figure out how to use a connection from the Weblogic JDBC connection pool instead of creating a new Oracle instance in my servlet. (since OracleUtils needs an Oracle instance in order to get the list of available models). But that is not really an issue for me yet.

                Thanks.

                Julien
                • 5. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
                  alwu-Oracle
                  Hi,

                  For this purpose, you can instantiate an Oracle object out of an OracleConnection instance. There is a constructor for that.

                  When you say "rebuilt the database," you mean that a new database instance is created every day? Or you just remove/drop existing
                  RDF model and create a new one every day?

                  Thanks,

                  Zhe
                  1 person found this helpful
                  • 6. Re: Oracle / Joseki: how to prevent non-existent model from being created ?
                    766393
                    Hi,

                    Thanks for the tip about OracleConnection and Oracle.

                    And yes, I meant "model" instead of "database".

                    Thanks,
                    Julien