. . . . . . . . . "87616056a2d1573dc1a570757222a309" . . . . . . . . . "2017-06-13T05:38:09Z" . "VirtSesame2Provider" . "%VOSWARNING%\n%META:TOPICPARENT{name=\"VOSRDFDataProviders\"}%\n%VOSNAV%\n\n---+ Virtuoso Eclipse RDF4J and OpenRDF Sesame Providers\n\n%TOC%\n\n---++What is Eclipse RDF4J\n\nEclipse RDF4J ([[http://rdf4j.org/2016/05/18/goodbye-sesame-hello-rdf4j/][formerly known as OpenRDF Sesame]]) is an open source Java framework for storing, querying, and reasoning with RDF and \nRDF Schema. It can be used as a database for RDF and RDF Schema, or as a Java library for \napplications that need to work with RDF internally. For example, suppose you need to read \na big RDF file, find the relevant information for your application, and use that information. \nEclipse RDF4J provides you with the necessary tools to parse, interpret, query, and store all this \ninformation, embedded in your own application if you want, or, if you prefer, in a separate \ndatabase or even on a remote server. More generally: Eclipse RDF4J provides an application \ndeveloper with a toolbox that contains useful hammers, screwdrivers, etc., for 'Do-It-Yourself' \nprojects with RDF.\n\n---++What is the Virtuoso Eclipse RDF4J Provider\n\nThe Virtuoso Eclipse RDF4J Provider is a fully operational Native Graph Model Storage Provider for \nthe Eclipse RDF4J Framework, allowing users of Virtuoso to leverage the Eclipse RDF4J framework to \nmodify, query, and reason with the Virtuoso quad store using the Java language. The Eclipse RDF4J \nRepository API offers a central access point for connecting to the Virtuoso quad store. Its \npurpose is to provides a Java-friendly access point to Virtuoso. It offers various methods for \nquerying and updating the data, while abstracting the details of the underlying machinery. \nThe Providers has been tested against the latest currently available versions, \n[[http://rdf4j.org/download.docbook?view][Eclipse RDF4J]] 2.1 and the older Sesame 2.6.x, 2.7.x, 2.8.x, 4.x releases.\n\nFig. 1 Eclipse RDF4J Component Stack\n%BR%%BR%\"Sesame%BR%%BR%\n\nIf you need more information about how to set up your environment for working with the \nEclipse RDF4J APIs, take a look at Chapter 2 of the Sesame User Guide, \n[[http://rdf4j.org/sesame/2.7/docs/users.docbook?view#Downloading_and_Configuring_Sesame][Setting up to use the Sesame libraries]].\n\n---++ Setup\n\n---+++ Required Files\nThis tutorial assumes you have Virtuoso server installed and that the database is accessible \nat [[http://localhost:1111/][http://localhost:1111/]]. In addition, the relevant \nversion of the Virtuoso Eclipse RDF4J Provider, and Eclipse RDF4J framework need to be installed.\n\nYou should download the Virtuoso Eclipse RDF4J Provider JAR archive for the version of Eclipse RDF4J being used, Virtuoso JDBC Driver, Eclipse RDF4J \nFramework and associated classes and sample programs from our [[VOSDownload][download page]]. Note the version of the Eclipse RDF4J Provider (virt_rdf4j.jar or virt_sesameX.jar) can be determined with the commands:\n\n$ java -jar virt_rdf4j.jar \nOpenLink Virtuoso(TM) Provider for RDF4J(TM) Version 2.0.1 [Build 1.1]\n$ java -jar virt_sesame2.jar\nOpenLink Virtuoso(TM) Provider for Sesame2(TM) Version 2.6.5 [Build 1.7]\n$ java -jar virt_sesame4.jar \nOpenLink Virtuoso(TM) Provider for Sesame4(TM) Version 4.0.0 [Build 0.1]\n$\n\n\n---+++ Eclipse RDF4J Provider and Testsuite\n\n---++++ Preparation\n\n 1 Extract the Virtuoso RDF4J Provider and testsuite archive [[http://opldownload.s3.amazonaws.com/uda/virtuoso/7.2/rdfproviders/rdf4j/2/rdf4j_provider.zip][rdf4j_provider.zip]].\n 1 Open terminal session and go to the extracted rdf4j_provider directory.\n 1 Ensure, that you have a Java JDK1.8.x installation with the command:\n\n$ java -version\n\n 1 Ensure that the rdf4j_provider/libdirectory lib contains the required virtjdbc4_2.jar Virtuoso JDBC Driver JAR file. If not it can be obtained from, [[http://opldownload.s3.amazonaws.com/uda/virtuoso/7.2/jdbc/virtjdbc4.jar][virtjdbc4_2.jar]].\n\n---++++ Compilation\n\nRebuild Virtuoso RDF4J provider file virt_rdf4j.jar with the ./gradlew clean Build -x test command:\n\n$ ./gradlew clean Build -x test\nDownloading https://services.gradle.org/distributions/gradle-3.2.1-bin.zip\n.\n.\n.\nUnzipping /Users/hwilliams/.gradle/wrapper/dists/gradle-3.2.1-bin/erlz51pt56t1o6vc7t39cikug/gradle-3.2.1-bin.zip to /Users/hwilliams/.gradle/wrapper/dists/gradle-3.2.1-bin/erlz51pt56t1o6vc7t39cikug\nSet executable permissions for: /Users/hwilliams/.gradle/wrapper/dists/gradle-3.2.1-bin/erlz51pt56t1o6vc7t39cikug/gradle-3.2.1/bin/gradle\nStarting a Gradle Daemon (subsequent builds will be faster)\n:clean UP-TO-DATE\n:compileJava\nDownload https://jcenter.bintray.com/org/slf4j/slf4j-api/1.7.18/slf4j-api-1.7.18.pom\nDownload https://jcenter.bintray.com/org/slf4j/slf4j-parent/1.7.18/slf4j-parent-1.7.18.pom\nDownload https://jcenter.bintray.com/org/eclipse/rdf4j/rdf4j-runtime/2.1.4/rdf4j-runtime-2.1.4.pom\n.\n.\n.\nDownload https://jcenter.bintray.com/org/apache/httpcomponents/httpcore-nio/4.4.4/httpcore-nio-4.4.4.jar\nDownload https://jcenter.bintray.com/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar\nDownload https://jcenter.bintray.com/commons-io/commons-io/2.5/commons-io-2.5.jar\n:processResources\n:classes\n:jar\n:assemble\n:copyLibs\n------COPY JARS----------\n:check\n:build\n\nBUILD SUCCESSFUL\n\nTotal time: 1 mins 13.624 secs\n$ \n$ ls -ltr\ntotal 152\ndrwxr-xr-x@ 4 hwilliams staff 136 22 Dec 10:37 src\n-rw-r--r--@ 1 hwilliams staff 182 22 Dec 10:37 settings.gradle\n-rw-r--r--@ 1 hwilliams staff 2176 22 Dec 10:37 gradlew.bat\n-rwxr-xr-x@ 1 hwilliams staff 5299 22 Dec 10:37 gradlew\ndrwxr-xr-x@ 3 hwilliams staff 102 22 Dec 10:37 gradle\ndrwxr-xr-x@ 4 hwilliams staff 136 22 Dec 10:37 RDF4J_UI\ndrwxr-xr-x@ 4 hwilliams staff 136 22 Dec 10:40 lib\n-rw-r--r--@ 1 hwilliams staff 2668 22 Dec 13:41 build.gradle\ndrwxr-xr-x 7 hwilliams staff 238 23 Dec 15:14 build\n-rw-r--r--@ 1 hwilliams staff 56844 23 Dec 15:14 virt_rdf4j.jar\n$\n\n\n---++++ Testing \n\nBy default the Testsuite will try connect to a Virtuoso instance on the localhost:1111 and dba/dba uid/pwd. If an instance running with different values is to the used then edit the ./build.gradle file set accordingly:\n\n?.\ntest {\n systemProperty 'test_hostname', 'localhost'\n systemProperty 'test_port', '1111'\n systemProperty 'test_uid', 'dba'\n systemProperty 'test_pwd', 'dba'\n\n testLogging.showStandardStreams = true\n afterTest { desc, result -> \n println \"Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}\"\n }\n}\n?.\n\n\nRun the RDF4J provider testsuite with the ./gradlew clean testClasses test command:\n\n$ ./gradlew clean testClasses test\n:clean\n:compileJava\n:processResources\n:classes\n:compileTestJava\nDownload https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom\nDownload https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom\nDownload https://jcenter.bintray.com/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom\nDownload https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar\nDownload https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar\nNote: Some input files use or override a deprecated API.\nNote: Recompile with -Xlint:deprecation for details.\n:processTestResources\n:testClasses\n:test\n\ntestsuite.Test_BNode > test1 STANDARD_ERROR\n SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".\n SLF4J: Defaulting to no-operation (NOP) logger implementation\n SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n\ntestsuite.Test_BNode > test1 STANDARD_OUT\n Test with One Row operation (BNode as Virtuoso Native BNode)\n Insert data with BNodes\n Inserted data:\n (t:s1, t:p, _:nodeID://b26807) [test:blank]\n (_:nodeID://b26808, t:p, t:o1) [test:blank]\n Got bn1=_:nodeID://b26807\n Got bn2=_:nodeID://b26808\n Try hasStatement with BNodes\n hasStatement with bn1 OK\n hasStatement with bn2 OK\n Try getStatements with BNodes\n getStatements with bn1 OK\n getStatements with bn2 OK\n Try remove with BNodes\n After remove triple:\n (_:nodeID://b26808, t:p, t:o1) [test:blank]\n remove with bn1 OK\n After remove triple:\n remove with bn2 OK\n Insert data with BNode bn1 again (new BNode ID must be assigned)\n Inserted data:\n (t:s1, t:p, _:nodeID://b26809) [test:blank]\n Got bnew=_:nodeID://b26809\nExecuting test test1 [testsuite.Test_BNode] with result: SUCCESS\n\ntestsuite.Test_BNode > test2 STANDARD_OUT\n Test with One Row operation (BNode as Virtuoso IRI)\n Insert data with BNodes\n Inserted data:\n (t:s1, t:p, _:node1b4m6bs5rx3) [test:blank]\n (_:node1b4m6bs5rx4, t:p, t:o1) [test:blank]\n Got bn1=_:node1b4m6bs5rx3\n Got bn2=_:node1b4m6bs5rx4\n Try hasStatement with BNodes\n hasStatement with bn1 OK\n hasStatement with bn2 OK\n Try getStatements with BNodes\n getStatements with bn1 OK\n getStatements with bn2 OK\n Try remove with BNodes\n After remove triple:\n (_:node1b4m6bs5rx4, t:p, t:o1) [test:blank]\n remove with bn1 OK\n After remove triple:\n remove with bn2 OK\nExecuting test test2 [testsuite.Test_BNode] with result: SUCCESS\n\ntestsuite.Test_BNode > test3 STANDARD_OUT\n Test with Batch Operation (BNode as Virtuoso Native BNode)\n Insert data with BNodes\n Inserted data:\n (_:nodeID://b26810, t:p1, t:o1) [test:blank]\n (_:nodeID://b26810, t:p2, _:nodeID://b26811) [test:blank]\n (_:nodeID://b26811, t:p3, t:o3) [test:blank]\n Got ba=_:nodeID://b26810\n Got bb=_:nodeID://b26811\n Try hasStatement with BNodes\n hasStatement with ba OK\n hasStatement with ba & bb OK\n hasStatement with ba OK\n Try getStatements with BNodes\n getStatements with ba OK\n getStatements with ba & bb OK\n getStatements with bn2 OK\n Try remove with BNodes\n After remove 2 triple:\n (_:nodeID://b26811, t:p3, t:o3) [test:blank]\n remove with ba OK\n remove with ba & bb OK\n After remove triple:\n remove with bb OK\nExecuting test test3 [testsuite.Test_BNode] with result: SUCCESS\n\ntestsuite.Test_BNode > test4 STANDARD_OUT\n Test with Batch Operation (BNode as Virtuoso IRI)\n Insert data with BNodes\n Inserted data:\n (_:node1b4m6bs5rx7, t:p1, t:o1) [test:blank]\n (_:node1b4m6bs5rx7, t:p2, _:node1b4m6bs5rx8) [test:blank]\n (_:node1b4m6bs5rx8, t:p3, t:o3) [test:blank]\n Got ba=_:node1b4m6bs5rx7\n Got bb=_:node1b4m6bs5rx8\n Try hasStatement with BNodes\n hasStatement with ba OK\n hasStatement with ba & bb OK\n hasStatement with ba OK\n Try getStatements with BNodes\n getStatements with ba OK\n getStatements with ba & bb OK\n getStatements with bn2 OK\n Try remove with BNodes\n After remove 2 triple:\n (_:node1b4m6bs5rx8, t:p3, t:o3) [test:blank]\n remove with ba OK\n remove with ba & bb OK\n After remove triple:\n remove with bb OK\nExecuting test test4 [testsuite.Test_BNode] with result: SUCCESS\n\ntestsuite.Test_BNode > test5 STANDARD_OUT\n Test Import data from File (BNode as Virtuoso Native BNode)\n Insert data with BNodes from file sp2b.n3\n Time :1911 ms\n Inserted :50168 triples\n Try getStatements with BNodes\n BNodes loaded OK\n Got =[\"Rajab Sikora\"^^]\n for BNode:_:nodeID://b30524\n\n Got =[\"Yukari Pitcairn\"^^]\n for BNode:_:nodeID://b30525\n\n Got =[\"Reyes Kluesner\"^^]\n for BNode:_:nodeID://b30526\n\nExecuting test test5 [testsuite.Test_BNode] with result: SUCCESS\n\ntestsuite.Test_BNode > test6 STANDARD_OUT\n Test Import data from File (BNode as Virtuoso Native BNode)\n Insert data with BNodes from file sp2b.n3\n Time :1514 ms\n Inserted :50168 triples\n Try getStatements with BNodes\n BNodes loaded OK\n Got =[\"Rajab Sikora\"^^]\n for BNode:_:nodeID://b34722\n\n Got =[\"Yukari Pitcairn\"^^]\n for BNode:_:nodeID://b34723\n\n Got =[\"Reyes Kluesner\"^^]\n for BNode:_:nodeID://b34724\n\nExecuting test test6 [testsuite.Test_BNode] with result: SUCCESS\nExecuting test test1 [testsuite.Test_BNode_perf1] with result: SKIPPED\nExecuting test test2 [testsuite.Test_BNode_perf1] with result: SKIPPED\nExecuting test test1 [testsuite.VirtuosoTest] with result: SUCCESS\n\ntestsuite.VirtuosoTest > test2 STANDARD_OUT\n Loading data from URL: http://dbpedia.org/data/Berlin.rdf\n Clearing triple store\nExecuting test test2 [testsuite.VirtuosoTest] with result: SUCCESS\n\ntestsuite.VirtuosoTest > test3 STANDARD_OUT\n Execute query with parameter binding\nExecuting test test3 [testsuite.VirtuosoTest] with result: SUCCESS\n\ntestsuite.VirtuosoTest > test4 STANDARD_OUT\n Loading UNICODE single triple\nExecuting test test4 [testsuite.VirtuosoTest] with result: SUCCESS\n\ntestsuite.VirtuosoTest > test5 STANDARD_OUT\n Loading single triple\n Casted value type\n Selecting property\n Statement exists (by resultset size)\n Retrieving statement (http://myopenlink.net/dataspace/person/kidehen http://myopenlink.net/foaf/name null)\n Writing the statements to file: (/var/folders/51/ptp74p5x175_pgrdcz3pn85c0000gn/T/results.n33643690314785712247txt)\n Retrieving graph ids\n Retrieving triple store size\n Sending ask query\n Sending construct query\n Sending describe query\nExecuting test test5 [testsuite.VirtuosoTest] with result: SUCCESS\n\ntestsuite.VirtuosoTest > test6 STANDARD_OUT\n Retrieving namespaces\nExecuting test test6 [testsuite.VirtuosoTest] with result: SUCCESS\n\nBUILD SUCCESSFUL\n\nTotal time: 59.181 secs\n$\n\n\n---++++ Java API Docs\n\nCreate the JavaDocs files for the provider with the following command ./gradlew javadoc, which will create the file in the doc directory:\n\n$ ./gradlew javadoc\n:compileJava UP-TO-DATE\n:processResources UP-TO-DATE\n:classes UP-TO-DATE\n:javadoc\n:copyDocs\n------COPY DOCS----------\n\nBUILD SUCCESSFUL\n\nTotal time: 2.09 secs\n$ ls -ltr doc\ntotal 352\ndrwxr-xr-x 3 hwilliams staff 102 23 Dec 15:48 virtuoso\n-rw-r--r-- 1 hwilliams staff 12808 23 Dec 15:48 stylesheet.css\n-rw-r--r-- 1 hwilliams staff 827 23 Dec 15:48 script.js\n-rw-r--r-- 1 hwilliams staff 51 23 Dec 15:48 package-list\n-rw-r--r-- 1 hwilliams staff 8191 23 Dec 15:48 overview-tree.html\n-rw-r--r-- 1 hwilliams staff 4185 23 Dec 15:48 overview-summary.html\n-rw-r--r-- 1 hwilliams staff 929 23 Dec 15:48 overview-frame.html\n-rw-r--r-- 1 hwilliams staff 2843 23 Dec 15:48 index.html\n-rw-r--r-- 1 hwilliams staff 92894 23 Dec 15:48 index-all.html\n-rw-r--r-- 1 hwilliams staff 8246 23 Dec 15:48 help-doc.html\n-rw-r--r-- 1 hwilliams staff 5568 23 Dec 15:48 deprecated-list.html\n-rw-r--r-- 1 hwilliams staff 7023 23 Dec 15:48 constant-values.html\n-rw-r--r-- 1 hwilliams staff 2136 23 Dec 15:48 allclasses-noframe.html\n-rw-r--r-- 1 hwilliams staff 2376 23 Dec 15:48 allclasses-frame.html\n$\n\n\n---+++ Sesame 2 Sample Program\n\n---++++ Compilation\n\n 1 Ensure that full paths to the following files, or equivalents for your version of Sesame, are all included in the active CLASSPATH setting --\n * openrdf-sesame-2.1.2-onejar.jar\n * slf4j-api-1.5.0.jar\n * slf4j-jdk14-1.5.0.jar\n * commons-io-2.0.jar\n * virtjdbc3.jar\n * virt_sesame2.jar\n 1 Execute the following command --\n\njavac VirtuosoTest.java\n\n * Note: we recommend adding the following to the connect string, to use utf-8 and row-auto-commit:\n\n\"/charset=UTF-8/log_enable=2\"\n\n-- i.e., in VirtuosoTest.java, the line --\n\nRepository repository = new VirtuosoRepository(\"jdbc:virtuoso://\" + sa[0] + \":\" + sa[1], sa[2], sa[3]);\n\n-- should become --\n\nRepository repository = new VirtuosoRepository(\"jdbc:virtuoso://\" + sa[0] + \":\" + sa[1]+ \"/charset=UTF-8/log_enable=2\", sa[2], sa[3]);\n\n\n---++++ Testing\n \n 1 Ensure that full paths to the following files are all included in the active CLASSPATH \nsetting (note the addition of virtuoso_driver, here) --\n * openrdf-sesame-2.1.2-onejar.jar\n * slf4j-api-1.5.0.jar\n * slf4j-jdk14-1.5.0.jar\n * commons-io-2.0.jar\n * virtjdbc3.jar\n * virt_sesame2.jar\n * virtuoso_driver\n 1 Run the [[http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtSesame2Provider?att=VirtuosoTest.java][VirtuosoTest]]\nprogram to test the Sesame 2 Provider with the following command --\n\njava VirtuosoTest \n\n 1 The test run should look like this --\n\n$ java VirtuosoTest localhost 1111 dba dba\n\n== TEST 1: : Start\n Loading data from URL: http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com/foaf.rdf\n== TEST 1: : End\nPASSED: TEST 1\n\n== TEST 2: : Start\n Clearing triple store\n== TEST 2: : End\nPASSED: TEST 2\n\n== TEST 3: : Start\n Loading data from file: virtuoso_driver/data.nt\n== TEST 3: : End\nPASSED: TEST 3\n\n== TEST 4: : Start\n Loading UNICODE single triple\n== TEST 4: : End\nPASSED: TEST 4\n\n== TEST 5: : Start\n Loading single triple\n== TEST 5: : End\nPASSED: TEST 5\n\n== TEST 6: : Start\n Casted value type\n== TEST 6: : End\nPASSED: TEST 6\n\n== TEST 7: : Start\n Selecting property\n== TEST 7: : End\nPASSED: TEST 7\n\n== TEST 8: : Start\n Statement does not exists\n== TEST 8: : End\nPASSED: TEST 8\n\n== TEST 9: : Start\n Statement exists (by resultset size)\n== TEST 9: : End\nPASSED: TEST 9\n\n== TEST 10: : Start\n Statement exists (by hasStatement())\n== TEST 10: : End\nPASSED: TEST 10\n\n== TEST 11: : Start\n Retrieving namespaces\n== TEST 11: : End\nPASSED: TEST 11\n\n== TEST 12: : Start\n Retrieving statement (http://myopenlink.net/dataspace/person/kidehen http://myopenlink.net/foaf/name null)\n== TEST 12: : End\nPASSED: TEST 12\n\n== TEST 13: : Start\n Writing the statements to file: (/Users/src/virtuoso-opensource/binsrc/sesame2/results.n3.txt)\n== TEST 13: : End\nPASSED: TEST 13\n\n== TEST 14: : Start\n Retrieving graph ids\n== TEST 14: : End\nPASSED: TEST 14\n\n== TEST 15: : Start\n Retrieving triple store size\n== TEST 15: : End\nPASSED: TEST 15\n\n== TEST 16: : Start\n Sending ask query\n== TEST 16: : End\nPASSED: TEST 16\n\n== TEST 17: : Start\n Sending construct query\n== TEST 17: : End\nPASSED: TEST 17\n\n== TEST 18: : Start\n Sending describe query\n== TEST 18: : End\nPASSED: TEST 18\n\n============================\nPASSED:18 FAILED:0\n\n\n---+++ Sesame 4 Sample Program\n\n---++++ Compilation\n\n 1 Ensure that full paths to the following files, or equivalents for your version of Sesame, are all included in the active CLASSPATH setting --\n * openrdf-sesame-4.0.0-onejar.jar\n * slf4j-api-1.7.10.jar\n * commons-io-2.4.jar\n * virtjdbc4.jar\n * virt_sesame4.jar\n 1 Execute the following command --\n\njavac VirtuosoTest.java\n\n * Note: we recommend adding the following to the connect string, to use utf-8 and row-auto-commit:\n\n\"/charset=UTF-8/log_enable=2\"\n\n-- i.e., in VirtuosoTest.java, the line --\n\nRepository repository = new VirtuosoRepository(\"jdbc:virtuoso://\" + sa[0] + \":\" + sa[1], sa[2], sa[3]);\n\n-- should become --\n\nRepository repository = new VirtuosoRepository(\"jdbc:virtuoso://\" + sa[0] + \":\" + sa[1]+ \"/charset=UTF-8/log_enable=2\", sa[2], sa[3]);\n\n\n---++++ Testing\n \n 1 Ensure that full paths to the following files are all included in the active CLASSPATH \nsetting (note the addition of virtuoso_driver, here) --\n * openrdf-sesame-4.0.0-onejar.jar\n * slf4j-api-1.7.10.jar\n * commons-io-2.4.jar\n * virtjdbc4.jar\n * virt_sesame4.jar\n * virtuoso_driver\n 1 Run the [[http://opldownload.s3.amazonaws.com/uda/virtuoso/rdfproviders/sesame/40/VirtuosoTest.java][VirtuosoTest]]\nprogram to test the Sesame 2 Provider with the following command --\n\njava VirtuosoTest \n\n 1 The test run should look like this --\n\n$ java VirtuosoTest localhost 1111 dba dba\n\n== TEST 1: : Start\n== TEST 1: : End\nPASSED: TEST 1\n\n== TEST 2: : Start\n Loading data from URL: http://dbpedia.org/data/Berlin.rdf\nlog4j:WARN No appenders could be found for logger (org.openrdf.rio.RDFParserRegistry).\nlog4j:WARN Please initialize the log4j system properly.\n== TEST 2: : End\nPASSED: TEST 2\n\n== TEST 3: : Start\n Clearing triple store\n== TEST 3: : End\nPASSED: TEST 3\n\n== TEST 4: : Start\n Loading data from file: virtuoso_driver/data.nt\n== TEST 4: : End\nPASSED: TEST 4\n\n== TEST 5: : Start\n Loading UNICODE single triple\n== TEST 5: : End\nPASSED: TEST 5\n\n== TEST 6: : Start\n Loading single triple\n== TEST 6: : End\nPASSED: TEST 6\n\n== TEST 7: : Start\n Casted value type\n== TEST 7: : End\nPASSED: TEST 7\n\n== TEST 8: : Start\n Selecting property\n== TEST 8: : End\nPASSED: TEST 8\n\n== TEST 9: : Start\n Statement does not exists\n== TEST 9: : End\nPASSED: TEST 9\n\n== TEST 10: : Start\n Statement exists (by resultset size)\n== TEST 10: : End\nPASSED: TEST 10\n\n== TEST 11: : Start\n Statement exists (by hasStatement())\n== TEST 11: : End\nPASSED: TEST 11\n\n== TEST 12: : Start\n Retrieving namespaces\n== TEST 12: : End\nPASSED: TEST 12\n\n== TEST 13: : Start\n Retrieving statement (http://myopenlink.net/dataspace/person/kidehen http://myopenlink.net/foaf/name null)\n== TEST 13: : End\nPASSED: TEST 13\n\n== TEST 14: : Start\n Writing the statements to file: (/Users/hwilliams/src/git/vos-7-develop/binsrc/sesame4/results.n3.txt)\n== TEST 14: : End\nPASSED: TEST 14\n\n== TEST 15: : Start\n Retrieving graph ids\n== TEST 15: : End\nPASSED: TEST 15\n\n== TEST 16: : Start\n Retrieving triple store size\n== TEST 16: : End\nPASSED: TEST 16\n\n== TEST 17: : Start\n Sending ask query\n== TEST 17: : End\nPASSED: TEST 17\n\n== TEST 18: : Start\n Sending construct query\n== TEST 18: : End\nPASSED: TEST 18\n\n== TEST 19: : Start\n Sending describe query\n== TEST 19: : End\nPASSED: TEST 19\n\n============================\nPASSED:19 FAILED:0\n\n\n--++ Getting Started\n\nThis section covers the essentials for connecting to and manipulating data stored in a Virtuoso repository \nusing the Eclipse RDF4J API. More information on the Eclipse RDF4J Framework, including extended examples on how \nto use the API, can be found in the [[http://docs.rdf4j.org/programming/][Eclipse RDF4J Programmers guide]].\n\nThe interfaces for the Repository API can be found in packages virtuoso.rdf4j.driver \nand org.openrdf.repository. Several implementations for these interfaces exist in the \nVirtuoso Provider download package. The [[http://docs.rdf4j.org/javadoc/latest][Javadoc reference for the Eclipse RDF4J API]] \nis available online and can also be found in the doc directory of the download.\n\n---+++Creating a Virtuoso Repository RDF object\n\nThe first step to connecting to Virtuoso through the Sesame API is to create a Repository for it. The \nRepository object operates on (stacks of) Sail object(s) for storage and retrieval of RDF data.\n\nOne of the simplest configurations is a repository that just stores RDF data in main memory, without \napplying any inference. This is also by far the fastest type of repository that can be used. The following \ncode creates and initialize a non-inferencing main-memory repository:\n\n\nimport virtuoso.rdf4j.driver.VirtuosoRepository;\n\nRepository myRepository = VirtuosoRepository(\"jdbc:virtuoso://localhost:1111\",\"dba\",\"dba\");\n\nmyRepository.initialize();\n\n\nThe constructor of the VirtuosoRepository class accepts \nthe JDBC URL of the Virtuoso engine, and the username and password of an authorized user. \nFollowing this example, the repository needs to be initialized to prepare the Sail(s) that it \noperates on, which includes performing operations such as restoring previously stored data, \nsetting up connections to a relational database, etc.\n\nThe repository that is created by the above code is volatile: its contents are lost when the \nobject is garbage collected or when the program is shut down. This is fine for cases where, \nfor example, the repository is used as a means for manipulating an RDF model in memory. \n\n---+++Creating a Virtuoso Repository Connection\n\nNow that we have created a VirtuosoRepository object \ninstance, we want to do something with it. This is achieved through the use of the \nVirtuosoRepositoryConnection class, which can be created \nby the VirtuosoRepository class.\n\nA VirtuosoRepositoryConnection represents — as \nthe name suggests — a connection to the actual Virtuoso quad store. We can issue \noperations over this connection, and close it when we are done to make sure we are not \nkeeping resources unnecessarily occupied.\n\nIn the following sections, we will show some examples of basic operations using the Northwind \ndataset.\n\n---+++Adding RDF to Virtuoso\n\nThe Repository implements the Sesame Repository API, which offers various methods for adding \ndata to a repository. Data can be added programmatically by specifying the location of a file that \ncontains RDF data, and statements can be added individually or in collections.\n\n\nWe perform operations on the repository by requesting a RepositoryConnection \nfrom the repository, which returns a VirtuosoRepositoryConnection object. On \nthis VirtuosoRepositoryConnection object we can perform the various operations, \nsuch as query evaluation; getting, adding, or removing statements; etc.\n\nThe following example code adds two files, one local and one located on the Web, to a repository:\n\n\nimport org.openrdf.repository.RepositoryException;\n\nimport org.openrdf.repository.Repository;\n\nimport org.openrdf.repository.RepositoryConnection;\n\nimport org.openrdf.rio.RDFFormat;\n\nimport java.io.File;\n\nimport java.net.URL;\n\nFile file = new File(\"/path/to/example.rdf\");\n\nString baseURI = \"http://example.org/example/localRDF\";\n\n?\ntry {\n\n RepositoryConnection con = myRepository.getConnection();\n\n try {\n\n con.add(file, baseURI, RDFFormat.RDFXML);\n\n URL url = new URL(\"http://example.org/example/remoteRDF\");\n\n con.add(url, url.toString(), RDFFormat.RDFXML);\n\n }\n\n finally {\n\n con.close();\n\n }\n\n}\n\ncatch (RepositoryException rex) {\n\n // handle exception\n\n}\n\ncatch (java.io.IOEXception e) {\n\n // handle io exception\n\n}\n\n\nMore information on other available methods can be found in the javadoc reference of the \nRepositoryConnection interface.\n\n---+++Querying Virtuoso\n\nThe Repository API has a number of methods for creating and evaluating queries. Three \ntypes of queries are distinguished: tuple queries, graph queries, and Boolean queries. The \nquery types differ in the type of results that they produce.\n\n*Select Query*: The result of a select query is a set of tuples (or variable bindings), where \neach tuple represents a solution of the query. This type of query is commonly used to get \nspecific values (URIs, blank nodes, literals) from the stored RDF data. The method \nQueryFactory.executeQuery() returns a Value \n[ ][ ] for SPARQL \"SELECT\" queries. \nThe method QueryFactory.executeQuery() also calls \nthe QueryFactory.setResult() which populates a set of \ntuples for SPARQL \"SELECT\" queries. The graph can be retrieved using \nQueryFactory.getBooleanResult().\n\n*Graph Query*: The result of a graph query is an RDF graph (or set of statements). This \ntype of query is very useful for extracting sub-graphs from the stored RDF data, which can \nthen be queried further, serialized to an RDF document, etc. The method \nQueryFactory.executeQuery() calls the \nQueryFactory.setGraphResult() which populates a graph \nfor SPARQL \"DESCRIBE\" and \"CONSTRUCT\" queries. The \ngraph can be retrieved using QueryFactory.getGraphResult().\n\n*Boolean Query*: The result of a Boolean query is a simple Boolean value, i.e., TRUE \nor FALSE. This type of query can be used to check if a repository contains specific \ninformation. The method QueryFactory.executeQuery() calls \nthe QueryFactory.setBooleanResult() which sets a Boolean value \nfor SPARQL \"ASK\" queries. The value can be retrieved using \nQueryFactory.getBooleanResult().\n\nNote: Although Eclipse RDF4J 2 currently supports two query languages: SeRQL and SPARQL, the Virtuoso \nprovider only supports the W3C SPARQL specification at this time.\n\n---+++Evaluating a SELECT Query\n\nTo evaluate a tuple query we simply do the following:\n\n\nimport java.util.List;\n\nimport org.openrdf.OpenRDFException;\n\nimport org.openrdf.repository.RepositoryConnection;\n\nimport org.openrdf.query.TupleQuery;\n\nimport org.openrdf.query.TupleQueryResult;\n\nimport org.openrdf.query.BindingSet;\n\nimport org.openrdf.query.QueryLanguage;\n?\n\ntry {\n\n RepositoryConnection con = myRepository.getConnection();\n\n try {\n\n String queryString = \"SELECT x, y FROM WHERE {x} p {y}\";\n\n TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);\n\n TupleQueryResult result = tupleQuery.evaluate();\n\n try {\n\n ? // do something with the result\n\n }\n\n finally {\n\n result.close();\n\n }\n\n }\n\n finally {\n\n con.close();\n\n }\n\n}\n\ncatch (RepositoryException e) {\n\n // handle exception\n\n}\n\n\n\nThis evaluates a SPARQL query and returns a TupleQueryResult, \nwhich consists of a sequence of BindingSet objects. Each \nBindingSet contains a set of pairs called Binding \nobjects. A Binding object represents a name/value pair for each \nvariable in the query's projection.\n\nWe can use the TupleQueryResult to iterate over all results and \nget each individual result for x and y:\n\n\nwhile (result.hasNext()) {\n\n BindingSet bindingSet = result.next();\n\n Value valueOfX = bindingSet.getValue(\"x\");\n\n Value valueOfY = bindingSet.getValue(\"y\");\n\n // do something interesting with the query variable values here?\n\n}\n\n\nAs you can see, we retrieve values by name rather than by an index. The names used should be the names \nof variables as specified in your query. The TupleQueryResult.getBindingNames() \nmethod returns a list of binding names, in the order in which they were specified in the query. To process \nthe bindings in each binding set in the order specified by the projection, you can do the following:\n\n\nList bindingNames = result.getBindingNames();\n\nwhile (result.hasNext()) {\n\n BindingSet bindingSet = result.next();\n\n Value firstValue = bindingSet.getValue(bindingNames.get(0));\n\n Value secondValue = bindingSet.getValue(bindingNames.get(1));\n\n // do something interesting with the values here?\n\n}\n\n\n\nIt is important to invoke the close() operation on the TupleQueryResult, \nafter we are done with it. A TupleQueryResult evaluates lazily and keeps resources (such as connections \nto the underlying database) open. Closing the TupleQueryResult frees up these resources. Do not forget \nthat iterating over a result may cause exceptions! The best way to make sure no connections are kept open unnecessarily is to invoke \nclose() in the finally clause.\n\nAn alternative to producing a TupleQueryResult is to supply an object that implements the \nTupleQueryResultHandler interface to the query's evaluate() \nmethod. The main difference is that when using a return object, the caller has control over when the next answer is retrieved, \nwhereas with the use of a handler, the connection simply pushes answers to the handler object as soon as it has them available.\n\nAs an example we will use SPARQLResultsXMLWriter, which is a \nTupleQueryResultHandler implementation that writes SPARQL Results \nXML documents to an output stream or to a writer:\n\n\nimport org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter;\n\n?\nFileOutputStream out = new FileOutputStream(\"/path/to/result.srx\");\n\ntry {\n\n SPARQLResultsXMLWriter sparqlWriter = new SPARQLResultsXMLWriter(out);\n\n RepositoryConnection con = myRepository.getConnection();\n\n try {\n\n String queryString = \"SELECT * FROM WHERE {x} p {y}\";\n\n TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);\n\n tupleQuery.evaluate(sparqlWriter);\n\n }\n\n finally {\n\n con.close();\n\n }\n\n}\n\nfinally {\n\n out.close();\n\n}\n\n\n\nYou can just as easily supply your own application-specific implementation of \nTupleQueryResultHandler, if desired.\n\nLastly, an important warning: as soon as you are done with the RepositoryConnection \nobject, you should close it. Notice that during processing of the TupleQueryResult \nobject (for example, when iterating over its contents), the RepositoryConnection \nshould still be open. We can invoke con.close() after we have finished with the result.\n\n---+++Evaluating a CONSTRUCT query\n\nThe following code evaluates a graph query on a repository:\n\n\nimport org.openrdf.query.GraphQueryResult;\n\nGraphQueryResult graphResult = con.prepareGraphQuery(\n\n QueryLanguage.SPARQL, \"CONSTRUCT * FROM {x} p {y}\").evaluate();\n\n\nA GraphQueryResult is similar to TupleQueryResult \nin that it is an object that iterates over the query results. However, for graph queries the query results are RDF statements, \nso a GraphQueryResult iterates over Statement objects:\n\n\nwhile (graphResult.hasNext()) {\n\n Statement st = graphResult.next();\n\n // ? do something with the resulting statement here.\n\n}\n\n\nThe TupleQueryResultHandler equivalent for graph queries is \norg.openrdf.rio.RDFHandler. Again, this is a generic interface; \neach object implementing it can process the reported RDF statements in any way it wants.\n\nAll writers from Rio (such as the RDFXMLWriter, \nTurtleWriter, TriXWriter, etc.) \nimplement the RDFHandler interface. This allows them to be used \nin combination with querying quite easily. In the following example, we use a \nTurtleWriter to write the result of a SPARQL graph query to \nstandard output in Turtle format:\n\n\nimport org.openrdf.rio.turtle.TurtleWriter;\n\n?\nRepositoryConnection con = myRepository.getConnection();\n\ntry {\n\n TurtleWriter turtleWriter = new TurtleWriter(System.out);\n\n con.prepareGraphQuery(QueryLanguage.SPARQL, \"CONSTRUCT * FROM WHERE {x} p {y}\").evaluate(turtleWriter);\n\n}\n\nfinally {\n\n con.close();\n\n}\n\n\n\nAgain, note that as soon as we are done with the result of the query (either after iterating over the \ncontents of the GraphQueryResult or after invoking the \nRDFHandler), we invoke con.close() \nto close the connection and free resources.\n\n---++ Javadoc API Documentation\n\nJavadocs covers the complete set of classes, interfaces, and methods implemented by the provider:\n\n * [[http://docs.openlinksw.com/rdf4j2/][Javadoc API Documentation for the Eclipse RDF4J 2.x Provider]]\n * [[http://docs.openlinksw.com/sesame/][Javadoc API Documentation for the Sesame 2.6 Provider]]\n * [[http://docs.openlinksw.com/sesame2/][Javadoc API Documentation for the Sesame 2.7+ Provider]]\n * [[http://docs.openlinksw.com/sesame4/][Javadoc API Documentation for the Sesame 4.x Provider]]\n\n---++Related\n\n * [[VirtSesame2HttpRepository][Virtuoso RDF4J and Sesame HTTP Repository]]\n\nCategoryRDF CategoryOpenSource CategoryVirtuoso CategoryVOS CategorySesame CategoryDocumentation\n\n%VOSCOPY%" . . . "2017-06-13T05:38:09Z" . . . "VirtSesame2Provider" . . . "2017-06-13T05:38:09.777203"^^ . . "2017-06-13T05:38:09.777203"^^ . . . "VirtSesame2Provider" . . . . . . . . . . . . . . . . . . .