activerdf_net7 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +79 -0
- data/LICENSE +504 -0
- data/README.rdoc +34 -0
- data/activerdf-jena/CHANGELOG +14 -0
- data/activerdf-jena/LICENSE +504 -0
- data/activerdf-jena/README +57 -0
- data/activerdf-jena/Rakefile +87 -0
- data/activerdf-jena/TODO +18 -0
- data/activerdf-jena/VERSION +1 -0
- data/activerdf-jena/ext/antlr-2.7.5.jar +0 -0
- data/activerdf-jena/ext/arq-extra.jar +0 -0
- data/activerdf-jena/ext/arq.jar +0 -0
- data/activerdf-jena/ext/aterm-java-1.6.jar +0 -0
- data/activerdf-jena/ext/commons-logging-1.1.jar +0 -0
- data/activerdf-jena/ext/concurrent.jar +0 -0
- data/activerdf-jena/ext/icu4j_3_4.jar +0 -0
- data/activerdf-jena/ext/iri.jar +0 -0
- data/activerdf-jena/ext/jena.jar +0 -0
- data/activerdf-jena/ext/jenatest.jar +0 -0
- data/activerdf-jena/ext/json.jar +0 -0
- data/activerdf-jena/ext/junit.jar +0 -0
- data/activerdf-jena/ext/log4j-1.2.12.jar +0 -0
- data/activerdf-jena/ext/lucene-core-2.0.0.jar +0 -0
- data/activerdf-jena/ext/ng4j.jar +0 -0
- data/activerdf-jena/ext/pellet.jar +0 -0
- data/activerdf-jena/ext/relaxngDatatype.jar +0 -0
- data/activerdf-jena/ext/stax-api-1.0.jar +0 -0
- data/activerdf-jena/ext/wstx-asl-3.0.0.jar +0 -0
- data/activerdf-jena/ext/xercesImpl.jar +0 -0
- data/activerdf-jena/ext/xml-apis.jar +0 -0
- data/activerdf-jena/ext/xsdlib.jar +0 -0
- data/activerdf-jena/lib/activerdf_jena/init.rb +26 -0
- data/activerdf-jena/lib/activerdf_jena/jena.rb +59 -0
- data/activerdf-jena/lib/activerdf_jena/jena_adapter.rb +515 -0
- data/activerdf-jena/lib/activerdf_jena/lucene.rb +22 -0
- data/activerdf-jena/lib/activerdf_jena/ng4j.rb +50 -0
- data/activerdf-jena/lib/activerdf_jena/ng4j_adapter.rb +379 -0
- data/activerdf-jena/lib/activerdf_jena/pellet.rb +25 -0
- data/activerdf-jena/test/bnode_org_rss.rdf +793 -0
- data/activerdf-jena/test/eyal-foaf.nt +39 -0
- data/activerdf-jena/test/fun_with_bnodes.nt +2 -0
- data/activerdf-jena/test/s1.n3 +18 -0
- data/activerdf-jena/test/test_data.nt +32 -0
- data/activerdf-jena/test/test_jena_adapter.rb +451 -0
- data/activerdf-jena/test/test_ng4j_adapter.rb +354 -0
- data/activerdf-rdflite/CHANGELOG +31 -0
- data/activerdf-rdflite/LICENSE +504 -0
- data/activerdf-rdflite/README +16 -0
- data/activerdf-rdflite/Rakefile +73 -0
- data/activerdf-rdflite/VERSION +1 -0
- data/activerdf-rdflite/lib/activerdf_rdflite/fetching.rb +34 -0
- data/activerdf-rdflite/lib/activerdf_rdflite/init.rb +13 -0
- data/activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb +582 -0
- data/activerdf-rdflite/lib/activerdf_rdflite/suggesting.rb +87 -0
- data/activerdf-rdflite/test/test_bnode_data.nt +5 -0
- data/activerdf-rdflite/test/test_data.nt +32 -0
- data/activerdf-rdflite/test/test_escaped_data.nt +2 -0
- data/activerdf-rdflite/test/test_fetching.rb +33 -0
- data/activerdf-rdflite/test/test_rdflite.rb +277 -0
- data/activerdf-redland/CHANGELOG +12 -0
- data/activerdf-redland/LICENSE +504 -0
- data/activerdf-redland/README +9 -0
- data/activerdf-redland/Rakefile +72 -0
- data/activerdf-redland/VERSION +1 -0
- data/activerdf-redland/lib/activerdf_redland/init.rb +10 -0
- data/activerdf-redland/lib/activerdf_redland/redland.rb +362 -0
- data/activerdf-redland/test/test_person_data.nt +42 -0
- data/activerdf-redland/test/test_redland_adapter.rb +242 -0
- data/activerdf-sesame/CHANGELOG +6 -0
- data/activerdf-sesame/LICENSE +10 -0
- data/activerdf-sesame/LICENSE-aduna +10 -0
- data/activerdf-sesame/LICENSE-lgpl +504 -0
- data/activerdf-sesame/README +33 -0
- data/activerdf-sesame/Rakefile +77 -0
- data/activerdf-sesame/VERSION +1 -0
- data/activerdf-sesame/ext/commons-codec-1.3.jar +0 -0
- data/activerdf-sesame/ext/commons-dbcp-1.2.2.jar +0 -0
- data/activerdf-sesame/ext/commons-httpclient-3.1.jar +0 -0
- data/activerdf-sesame/ext/commons-logging-1.1.1.jar +0 -0
- data/activerdf-sesame/ext/commons-pool-1.3.jar +0 -0
- data/activerdf-sesame/ext/commons-pool-1.5.2.jar +0 -0
- data/activerdf-sesame/ext/junit-3.8.2.jar +0 -0
- data/activerdf-sesame/ext/openrdf-sesame-2.0-onejar.jar +0 -0
- data/activerdf-sesame/ext/openrdf-sesame-2.3-pr1-onejar.jar +0 -0
- data/activerdf-sesame/ext/slf4j-api-1.4.3.jar +0 -0
- data/activerdf-sesame/ext/slf4j-nop-1.4.3.jar +0 -0
- data/activerdf-sesame/ext/wrapper-sesame2.jar +0 -0
- data/activerdf-sesame/java/build.number +3 -0
- data/activerdf-sesame/java/build.xml +313 -0
- data/activerdf-sesame/java/javadoc/allclasses-frame.html +31 -0
- data/activerdf-sesame/java/javadoc/allclasses-noframe.html +31 -0
- data/activerdf-sesame/java/javadoc/constant-values.html +146 -0
- data/activerdf-sesame/java/javadoc/deprecated-list.html +146 -0
- data/activerdf-sesame/java/javadoc/help-doc.html +223 -0
- data/activerdf-sesame/java/javadoc/index-files/index-1.html +150 -0
- data/activerdf-sesame/java/javadoc/index-files/index-10.html +145 -0
- data/activerdf-sesame/java/javadoc/index-files/index-2.html +157 -0
- data/activerdf-sesame/java/javadoc/index-files/index-3.html +146 -0
- data/activerdf-sesame/java/javadoc/index-files/index-4.html +145 -0
- data/activerdf-sesame/java/javadoc/index-files/index-5.html +145 -0
- data/activerdf-sesame/java/javadoc/index-files/index-6.html +142 -0
- data/activerdf-sesame/java/javadoc/index-files/index-7.html +145 -0
- data/activerdf-sesame/java/javadoc/index-files/index-8.html +152 -0
- data/activerdf-sesame/java/javadoc/index-files/index-9.html +146 -0
- data/activerdf-sesame/java/javadoc/index.html +36 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/WrapperForSesame2.html +665 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/class-use/WrapperForSesame2.html +144 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-frame.html +32 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-summary.html +157 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-tree.html +150 -0
- data/activerdf-sesame/java/javadoc/org/activerdf/wrapper/sesame2/package-use.html +144 -0
- data/activerdf-sesame/java/javadoc/overview-summary.html +156 -0
- data/activerdf-sesame/java/javadoc/overview-tree.html +152 -0
- data/activerdf-sesame/java/javadoc/package-list +1 -0
- data/activerdf-sesame/java/javadoc/resources/inherit.gif +0 -0
- data/activerdf-sesame/java/javadoc/stylesheet.css +29 -0
- data/activerdf-sesame/java/lib/commons-codec-1.3.jar +0 -0
- data/activerdf-sesame/java/lib/commons-dbcp-1.2.2.jar +0 -0
- data/activerdf-sesame/java/lib/commons-httpclient-3.1.jar +0 -0
- data/activerdf-sesame/java/lib/commons-logging-1.1.1.jar +0 -0
- data/activerdf-sesame/java/lib/commons-pool-1.3.jar +0 -0
- data/activerdf-sesame/java/lib/commons-pool-1.5.2.jar +0 -0
- data/activerdf-sesame/java/lib/junit-3.8.2.jar +0 -0
- data/activerdf-sesame/java/lib/openrdf-sesame-2.0-onejar.jar +0 -0
- data/activerdf-sesame/java/lib/openrdf-sesame-2.3-pr1-onejar.jar +0 -0
- data/activerdf-sesame/java/lib/slf4j-api-1.4.3.jar +0 -0
- data/activerdf-sesame/java/lib/slf4j-nop-1.4.3.jar +0 -0
- data/activerdf-sesame/java/manifest.mf +3 -0
- data/activerdf-sesame/java/settings.xml +135 -0
- data/activerdf-sesame/java/src/org/activerdf/wrapper/sesame2/WrapperForSesame2.java +145 -0
- data/activerdf-sesame/java/test-src/org/activerdf/wrapper/sesame2/TestWrapperForSesame2.java +41 -0
- data/activerdf-sesame/lib/activerdf_sesame/init.rb +11 -0
- data/activerdf-sesame/lib/activerdf_sesame/sesame.rb +400 -0
- data/activerdf-sesame/test/eyal-foaf.nt +39 -0
- data/activerdf-sesame/test/eyal-foaf.rdf +65 -0
- data/activerdf-sesame/test/test_sesame_adapter.rb +341 -0
- data/activerdf-sparql/CHANGELOG +35 -0
- data/activerdf-sparql/LICENSE +504 -0
- data/activerdf-sparql/README +10 -0
- data/activerdf-sparql/Rakefile +78 -0
- data/activerdf-sparql/VERSION +1 -0
- data/activerdf-sparql/lib/activerdf_sparql/init.rb +10 -0
- data/activerdf-sparql/lib/activerdf_sparql/sparql.rb +212 -0
- data/activerdf-sparql/lib/activerdf_sparql/sparql_result_parser.rb +55 -0
- data/activerdf-sparql/test/test_sparql_adapter.rb +108 -0
- data/activerdf-yars/LICENSE +504 -0
- data/activerdf-yars/README +10 -0
- data/activerdf-yars/Rakefile +38 -0
- data/activerdf-yars/lib/activerdf_yars/init.rb +10 -0
- data/activerdf-yars/lib/activerdf_yars/jars2.rb +119 -0
- data/lib/active_rdf.rb +85 -0
- data/lib/active_rdf/directaccess/direct_access.rb +49 -0
- data/lib/active_rdf/federation/active_rdf_adapter.rb +47 -0
- data/lib/active_rdf/federation/connection_pool.rb +156 -0
- data/lib/active_rdf/federation/federation_manager.rb +112 -0
- data/lib/active_rdf/instance_exec.rb +13 -0
- data/lib/active_rdf/objectmanager/bnode.rb +7 -0
- data/lib/active_rdf/objectmanager/literal.rb +71 -0
- data/lib/active_rdf/objectmanager/namespace.rb +106 -0
- data/lib/active_rdf/objectmanager/object_manager.rb +119 -0
- data/lib/active_rdf/objectmanager/ordered_set.rb +116 -0
- data/lib/active_rdf/objectmanager/property_list.rb +76 -0
- data/lib/active_rdf/objectmanager/resource.rb +609 -0
- data/lib/active_rdf/objectmanager/resource_like.rb +28 -0
- data/lib/active_rdf/queryengine/ntriples_parser.rb +90 -0
- data/lib/active_rdf/queryengine/query.rb +245 -0
- data/lib/active_rdf/queryengine/query2jars2.rb +22 -0
- data/lib/active_rdf/queryengine/query2sparql.rb +139 -0
- data/lib/active_rdf_helpers.rb +30 -0
- data/lib/active_rdf_log.rb +100 -0
- data/test/common.rb +119 -0
- data/test/directaccess/test_direct_access.rb +64 -0
- data/test/federation/test_connection_pool.rb +86 -0
- data/test/federation/test_federation_manager.rb +145 -0
- data/test/objectmanager/test_literal.rb +52 -0
- data/test/objectmanager/test_namespace.rb +83 -0
- data/test/objectmanager/test_object_manager.rb +96 -0
- data/test/objectmanager/test_ordered_set.rb +110 -0
- data/test/objectmanager/test_resource_reading.rb +150 -0
- data/test/objectmanager/test_resource_writing.rb +39 -0
- data/test/objectmanager/test_talia_syntax.rb +68 -0
- data/test/queryengine/my_external_resource.rb +24 -0
- data/test/queryengine/test_external_resource_class.rb +49 -0
- data/test/queryengine/test_ntriples_parser.rb +71 -0
- data/test/queryengine/test_query.rb +55 -0
- data/test/queryengine/test_query2jars2.rb +51 -0
- data/test/queryengine/test_query2sparql.rb +76 -0
- data/test/queryengine/test_query_engine.rb +52 -0
- data/test/test_adapters.rb +58 -0
- metadata +266 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
org.activerdf.wrapper.sesame2
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* Javadoc style sheet */
|
|
2
|
+
|
|
3
|
+
/* Define colors, fonts and other style attributes here to override the defaults */
|
|
4
|
+
|
|
5
|
+
/* Page background color */
|
|
6
|
+
body { background-color: #FFFFFF; color:#000000 }
|
|
7
|
+
|
|
8
|
+
/* Headings */
|
|
9
|
+
h1 { font-size: 145% }
|
|
10
|
+
|
|
11
|
+
/* Table colors */
|
|
12
|
+
.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
|
|
13
|
+
.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
|
|
14
|
+
.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
|
|
15
|
+
|
|
16
|
+
/* Font used in left-hand frame lists */
|
|
17
|
+
.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
|
18
|
+
.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
|
19
|
+
.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
|
20
|
+
|
|
21
|
+
/* Navigation bar fonts and colors */
|
|
22
|
+
.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
|
|
23
|
+
.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
|
|
24
|
+
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
|
|
25
|
+
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
|
|
26
|
+
|
|
27
|
+
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
|
|
28
|
+
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
|
|
29
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<project name="rdf2go" basedir=".">
|
|
3
|
+
|
|
4
|
+
<!--
|
|
5
|
+
The buildmanager currently can handle 5 groups of capabilities:
|
|
6
|
+
|
|
7
|
+
1.) generic and required settings for the project (name, version, classes for which to generate java doc
|
|
8
|
+
and a list of all libraries used by the project)
|
|
9
|
+
2.) filesets and paths needed to build just the sources of the project
|
|
10
|
+
3.) data files (files needed at runtime by the project)
|
|
11
|
+
4.) files which have to be included as documentation
|
|
12
|
+
5.) tests to compile and run (and how these tests are named)
|
|
13
|
+
|
|
14
|
+
The groups are marked below (although some might be empty).
|
|
15
|
+
|
|
16
|
+
If you want to add new capabilities to this project please refer to buildmanager/settings-example.xml
|
|
17
|
+
to see how to configure them.
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
<!--
|
|
21
|
+
==========================================================================================================
|
|
22
|
+
1.) generic and required settings for the project
|
|
23
|
+
==========================================================================================================
|
|
24
|
+
-->
|
|
25
|
+
|
|
26
|
+
<property name="version-number" value="0.1" />
|
|
27
|
+
<property name="product-name" value="wrapper-sesame2" description="name for filenames" />
|
|
28
|
+
<property name="product-title" value="Wrapper-Sesame2" description="display title"/>
|
|
29
|
+
<property name="product-www" value="./../${product-name}-www"/>
|
|
30
|
+
<property name="creator" value="ActiveRDF Project"/>
|
|
31
|
+
<property name="javadoc-packages" value="
|
|
32
|
+
org.activerdf.wrapper.sesame2
|
|
33
|
+
" />
|
|
34
|
+
|
|
35
|
+
<fileset id="all-libs" dir="lib">
|
|
36
|
+
<include name="openrdf-*.jar"/>
|
|
37
|
+
<include name="junit-*.jar"/>
|
|
38
|
+
<include name="slf4j-*.jar"/>
|
|
39
|
+
<include name="commons-*.jar"/>
|
|
40
|
+
</fileset>
|
|
41
|
+
|
|
42
|
+
<fileset id="export-libs" dir="lib">
|
|
43
|
+
<include name="openrdf-*.jar"/>
|
|
44
|
+
<include name="slf4j-*.jar"/>
|
|
45
|
+
<include name="commons-*"/>
|
|
46
|
+
</fileset>
|
|
47
|
+
|
|
48
|
+
<fileset id="product-libs" dir="../ext">
|
|
49
|
+
<include name="wrapper-sesame2.jar"/>
|
|
50
|
+
</fileset>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<!--
|
|
54
|
+
==========================================================================================================
|
|
55
|
+
2.) filesets and paths needed to build just the sources of the project
|
|
56
|
+
==========================================================================================================
|
|
57
|
+
-->
|
|
58
|
+
|
|
59
|
+
<fileset id="src" dir=".">
|
|
60
|
+
<include name="src/**"/>
|
|
61
|
+
<!-- <include name="test-src/**"/> -->
|
|
62
|
+
</fileset>
|
|
63
|
+
|
|
64
|
+
<path id="src-path">
|
|
65
|
+
<pathelement location="src"/>
|
|
66
|
+
<!-- <pathelement location="test-src"/> -->
|
|
67
|
+
</path>
|
|
68
|
+
|
|
69
|
+
<!-- main class path -->
|
|
70
|
+
|
|
71
|
+
<path id="src-classpath"
|
|
72
|
+
description="define the classpath needed to build and run the sources">
|
|
73
|
+
<pathelement path="${classpath}"/>
|
|
74
|
+
<fileset refid="all-libs" />
|
|
75
|
+
<pathelement location="temp/build"/>
|
|
76
|
+
</path>
|
|
77
|
+
|
|
78
|
+
<!--
|
|
79
|
+
==========================================================================================================
|
|
80
|
+
3.) data files (files needed at runtime by the project)
|
|
81
|
+
==========================================================================================================
|
|
82
|
+
-->
|
|
83
|
+
|
|
84
|
+
<fileset id="data" dir=".">
|
|
85
|
+
<!-- this fileset has to be defined for the generic build -->
|
|
86
|
+
<include name="_NONE_"/>
|
|
87
|
+
</fileset>
|
|
88
|
+
|
|
89
|
+
<fileset id="jarfile-includes" dir="."
|
|
90
|
+
description="define files which need to be included in the base directory of the jar file">
|
|
91
|
+
<include name="_NONE_"/>
|
|
92
|
+
</fileset>
|
|
93
|
+
|
|
94
|
+
<!--
|
|
95
|
+
==========================================================================================================
|
|
96
|
+
4.) files which have to be included as documentation
|
|
97
|
+
==========================================================================================================
|
|
98
|
+
-->
|
|
99
|
+
|
|
100
|
+
<fileset id="documentation" dir="."
|
|
101
|
+
description="define the location of documentation for the project
|
|
102
|
+
(javadoc must not be included here, because it is handled automatically)">
|
|
103
|
+
<include name="_NONE_"/>
|
|
104
|
+
</fileset>
|
|
105
|
+
|
|
106
|
+
<!--
|
|
107
|
+
==========================================================================================================
|
|
108
|
+
5.) tests to compile and run (and how these tests are named)
|
|
109
|
+
==========================================================================================================
|
|
110
|
+
-->
|
|
111
|
+
|
|
112
|
+
<fileset id="test-src" dir=".">
|
|
113
|
+
<include name="test-src/**"/>
|
|
114
|
+
</fileset>
|
|
115
|
+
|
|
116
|
+
<path id="test-src-path"
|
|
117
|
+
description="define the location of the test sources as a path (fileset and path are different things for ant)">
|
|
118
|
+
<pathelement location="test-src"/>
|
|
119
|
+
</path>
|
|
120
|
+
|
|
121
|
+
<path id="test-src-classpath"
|
|
122
|
+
description="define the classpath needed to build and run the test">
|
|
123
|
+
<path refid="src-classpath"/>
|
|
124
|
+
<fileset refid="product-libs" />
|
|
125
|
+
<pathelement location="dest/jars"/>
|
|
126
|
+
<pathelement location="temp/build-test"/>
|
|
127
|
+
</path>
|
|
128
|
+
|
|
129
|
+
<fileset id="test-cases"
|
|
130
|
+
description="define the test cases and suits to be run "
|
|
131
|
+
dir="temp/build-test"
|
|
132
|
+
includes="**/*Test.class"
|
|
133
|
+
/>
|
|
134
|
+
|
|
135
|
+
</project>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
package org.activerdf.wrapper.sesame2;
|
|
2
|
+
|
|
3
|
+
import java.io.File;
|
|
4
|
+
|
|
5
|
+
// the new stuff
|
|
6
|
+
|
|
7
|
+
import org.openrdf.sail.Sail;
|
|
8
|
+
import org.openrdf.sail.NotifyingSail;
|
|
9
|
+
import org.openrdf.repository.Repository;
|
|
10
|
+
import org.openrdf.repository.sail.SailRepository;
|
|
11
|
+
import org.openrdf.sail.memory.MemoryStore;
|
|
12
|
+
import org.openrdf.sail.nativerdf.NativeStore;
|
|
13
|
+
import org.openrdf.sail.rdbms.RdbmsStore;
|
|
14
|
+
import org.openrdf.repository.http.HTTPRepository;
|
|
15
|
+
import org.openrdf.sail.inferencer.fc.ForwardChainingRDFSInferencer;
|
|
16
|
+
import org.openrdf.repository.RepositoryConnection;
|
|
17
|
+
import org.openrdf.repository.RepositoryException;
|
|
18
|
+
import org.openrdf.model.Resource;
|
|
19
|
+
import org.openrdf.rio.RDFFormat;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* construct a wrapper for a sesame2 repository.
|
|
24
|
+
* many sesame2 classes use an initialize method, which clashes with the
|
|
25
|
+
* ruby naming requirement, to name the constructor initialize.
|
|
26
|
+
* Because of this it is currently not possible to construct such objects from jruby
|
|
27
|
+
* but instead emberasing wrappers, such as this have to be used.
|
|
28
|
+
*
|
|
29
|
+
* check http://jira.codehaus.org/browse/JRUBY-45 to see if bug still exists.
|
|
30
|
+
*/
|
|
31
|
+
public class WrapperForSesame2 {
|
|
32
|
+
|
|
33
|
+
protected RepositoryConnection sesameConnection;
|
|
34
|
+
|
|
35
|
+
protected Repository sesameRepository;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* the constructor. it does nothing.
|
|
39
|
+
* all the real work has to be done by the callConstrcutor methods, because JRuby currently
|
|
40
|
+
* cant manage custom class loaders _and_ constructors with arguments.. yes, its sad.
|
|
41
|
+
*/
|
|
42
|
+
public WrapperForSesame2() {
|
|
43
|
+
// do nothing
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* Initialize the Wrapper with a NativeStore as a backend.
|
|
48
|
+
* @param File dir Data file that the native store will use.
|
|
49
|
+
* @param String indexes If not null, the store will use the given indexes to speed up queries
|
|
50
|
+
* @param boolean inferencing If true (and not null), it will activate rdfs inferencing
|
|
51
|
+
*/
|
|
52
|
+
public RepositoryConnection initWithNative(File dir, String indexes, boolean inferencing) {
|
|
53
|
+
Sail sailStack;
|
|
54
|
+
|
|
55
|
+
if(indexes == null) {
|
|
56
|
+
sailStack = new NativeStore(dir);
|
|
57
|
+
} else {
|
|
58
|
+
sailStack = new NativeStore(dir, indexes);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return initFromSail(sailStack, inferencing);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Initialize the Wrapper with a MemoryStore as a backend
|
|
66
|
+
* @param boolean inferencing If true (and not null), it will activate rdfs inferencing
|
|
67
|
+
*/
|
|
68
|
+
public RepositoryConnection initWithMemory(boolean inferencing) {
|
|
69
|
+
return initFromSail(new MemoryStore(), inferencing);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* Initialize the Wrapper with a RDBMS as a backend
|
|
74
|
+
* @param driver JDBC driver to use
|
|
75
|
+
* @param url JDBC connect URL
|
|
76
|
+
* @param user Username for the database, or null
|
|
77
|
+
* @param password Password for the database user, or null
|
|
78
|
+
*/
|
|
79
|
+
public RepositoryConnection initWithRDBMS(String driver, String url, String user, String password, boolean inferencing) {
|
|
80
|
+
Sail sailStack;
|
|
81
|
+
|
|
82
|
+
if(user == null) {
|
|
83
|
+
sailStack = new RdbmsStore(driver, url);
|
|
84
|
+
} else {
|
|
85
|
+
sailStack = new RdbmsStore(driver, url, user, password);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return initFromSail(sailStack, inferencing);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* Initialize th Wrapper with a connection to a remote HTTP repository
|
|
93
|
+
*/
|
|
94
|
+
public RepositoryConnection initWithHttp(String url, String user, String password) throws RepositoryException {
|
|
95
|
+
HTTPRepository httpRepository = new HTTPRepository(url);
|
|
96
|
+
if(user != null) {
|
|
97
|
+
httpRepository.setUsernameAndPassword(user, password);
|
|
98
|
+
}
|
|
99
|
+
httpRepository.initialize();
|
|
100
|
+
sesameRepository = httpRepository;
|
|
101
|
+
sesameConnection = sesameRepository.getConnection();
|
|
102
|
+
return sesameConnection;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @return the sesame connection of the sesame repository associated with this wrapper.
|
|
107
|
+
*/
|
|
108
|
+
public RepositoryConnection getSesameConnection() {
|
|
109
|
+
return sesameConnection;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Load data from file. This is a thin wrapper on the
|
|
114
|
+
* add method of the connection, creating only the File object for
|
|
115
|
+
* it to work on. And yes, we throw everything and let the Ruby
|
|
116
|
+
* side deal with it.
|
|
117
|
+
*/
|
|
118
|
+
public boolean load(String file, String baseUri, RDFFormat dataFormat, Resource... contexts) throws Exception {
|
|
119
|
+
sesameConnection.add(new File(file), baseUri, dataFormat, contexts);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
protected RepositoryConnection initFromSail(Sail sailStack, boolean inferencing) {
|
|
125
|
+
if (inferencing) {
|
|
126
|
+
if(sailStack instanceof NotifyingSail) {
|
|
127
|
+
sailStack = new ForwardChainingRDFSInferencer((NotifyingSail) sailStack);
|
|
128
|
+
} else {
|
|
129
|
+
throw new RuntimeException("Cannot create inferencing: Incompatible Sail type.");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
sesameRepository = new SailRepository(sailStack);
|
|
136
|
+
sesameRepository.initialize();
|
|
137
|
+
sesameConnection = sesameRepository.getConnection();
|
|
138
|
+
sesameConnection.setAutoCommit(true);
|
|
139
|
+
} catch (Exception e) {
|
|
140
|
+
throw new RuntimeException(e);
|
|
141
|
+
}
|
|
142
|
+
return sesameConnection;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package org.activerdf.wrapper.sesame2;
|
|
2
|
+
|
|
3
|
+
import java.io.File;
|
|
4
|
+
import java.io.IOException;
|
|
5
|
+
|
|
6
|
+
import org.activerdf.wrapper.sesame2.WrapperForSesame2;
|
|
7
|
+
import org.openrdf.repository.RepositoryConnection;
|
|
8
|
+
import org.openrdf.repository.RepositoryException;
|
|
9
|
+
|
|
10
|
+
import junit.framework.TestCase;
|
|
11
|
+
|
|
12
|
+
public class TestWrapperForSesame2 extends TestCase {
|
|
13
|
+
|
|
14
|
+
protected WrapperForSesame2 myWrapper;
|
|
15
|
+
|
|
16
|
+
protected void setUp() {
|
|
17
|
+
myWrapper = new WrapperForSesame2();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected void tearDown() throws RepositoryException {
|
|
21
|
+
myWrapper.getSesameConnection().close();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public void testJustGetTheWrapper() {
|
|
26
|
+
myWrapper.callConstructor(null, null, false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void testMemoryStorePersistence() throws IOException {
|
|
30
|
+
File location = new File(new File (".").getCanonicalFile().toString() + "/../test/sesame-persistence-test1");
|
|
31
|
+
myWrapper.callConstructor(location, null, false);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void NativeStorePersistence() throws IOException {
|
|
35
|
+
File location = new File(new File (".").getCanonicalFile().toString() + "/../test/sesame-persistence-test2");
|
|
36
|
+
myWrapper.callConstructor(location, "spoc,pocs", false);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# Author:: Eyal Oren
|
|
2
|
+
# Copyright:: (c) 2005-2006 Eyal Oren
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
|
|
5
|
+
# require 'active_rdf'
|
|
6
|
+
|
|
7
|
+
ActiveRdfLogger::log_info "Loading Sesame adapter", self
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# ----- java imports and extentsions
|
|
11
|
+
require 'java'
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
# Import the jars
|
|
15
|
+
Dir[File.join(File.dirname(__FILE__), '..', '..', 'ext', '*.jar')].each { |jar| require jar}
|
|
16
|
+
|
|
17
|
+
StringWriter = java.io.StringWriter
|
|
18
|
+
JFile = java.io.File
|
|
19
|
+
URLClassLoader = java.net.URLClassLoader
|
|
20
|
+
JURL = java.net.URL
|
|
21
|
+
JClass = java.lang.Class
|
|
22
|
+
JObject = java.lang.Object
|
|
23
|
+
JIOException = java.io.IOException
|
|
24
|
+
|
|
25
|
+
# sesame specific classes:
|
|
26
|
+
WrapperForSesame2 = org.activerdf.wrapper.sesame2.WrapperForSesame2
|
|
27
|
+
QueryLanguage = org.openrdf.query.QueryLanguage
|
|
28
|
+
NTriplesWriter = org.openrdf.rio.ntriples.NTriplesWriter
|
|
29
|
+
RDFFormat = org.openrdf.rio.RDFFormat
|
|
30
|
+
rescue Exception => e
|
|
31
|
+
puts "ERROR loading Java for Sesame: #{e.message}"
|
|
32
|
+
raise
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# TODO: about this adapter
|
|
36
|
+
class SesameAdapter < ActiveRdfAdapter
|
|
37
|
+
|
|
38
|
+
# This adapter supports context operations
|
|
39
|
+
supports_context
|
|
40
|
+
|
|
41
|
+
ConnectionPool.register_adapter(:sesame,self)
|
|
42
|
+
|
|
43
|
+
# Create a sesame adapter. The parameter array must contain a :backend that will identify
|
|
44
|
+
# the backend that Sesame will use for the storage. All backends (except the HTTP repositories)
|
|
45
|
+
# take the parameter :inferencing, which will turn on the internal inferencing engine in Sesame
|
|
46
|
+
# (default is off).
|
|
47
|
+
#
|
|
48
|
+
# For compatibility, this will use the native driver if no type is given.
|
|
49
|
+
#
|
|
50
|
+
# = :memory
|
|
51
|
+
# The in-memory store. No parameters.
|
|
52
|
+
#
|
|
53
|
+
# = :native
|
|
54
|
+
# The "Native" store that saves data to a file. This backend finally employs locking on the database,
|
|
55
|
+
# which means that the database can only be used from one script or program at a time.
|
|
56
|
+
# [*location*] - Path to the data file for Sesame
|
|
57
|
+
# [*indexes*] - Optional index for Sesame, example "spoc,posc,cosp"
|
|
58
|
+
#
|
|
59
|
+
# = :rdbms
|
|
60
|
+
# The RDBMS backend store. You need to give the JDBC driver class, and obviously the JDBC driver
|
|
61
|
+
# for your database needs to be installed.
|
|
62
|
+
# [*driver*] - JDBC driver to use
|
|
63
|
+
# [*url*] - URL for JDBC connection
|
|
64
|
+
# [*user*] - Username for database connection (optional)
|
|
65
|
+
# [*pass*] - Password for database connection (optional)
|
|
66
|
+
#
|
|
67
|
+
#
|
|
68
|
+
def initialize(params = {})
|
|
69
|
+
super()
|
|
70
|
+
ActiveRdfLogger::log_info "Initializing Sesame Adapter with params #{params.to_s}", self
|
|
71
|
+
|
|
72
|
+
@reads = true
|
|
73
|
+
@writes = true
|
|
74
|
+
|
|
75
|
+
# Use native type by default
|
|
76
|
+
backend = params[:backend] || 'native'
|
|
77
|
+
|
|
78
|
+
@myWrapperInstance = WrapperForSesame2.new
|
|
79
|
+
@db = case(backend)
|
|
80
|
+
when 'native'
|
|
81
|
+
init_native_store(params)
|
|
82
|
+
when 'memory'
|
|
83
|
+
init_memory_store(params)
|
|
84
|
+
when 'rdbms'
|
|
85
|
+
init_rdbms_store(params)
|
|
86
|
+
when 'http'
|
|
87
|
+
init_http_store(params)
|
|
88
|
+
else
|
|
89
|
+
raise(ArgumentError, "Unknown backend type for Sesame: #{backend}")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
@valueFactory = if(backend == 'http')
|
|
93
|
+
@db.getRepository.getValueFactory
|
|
94
|
+
else
|
|
95
|
+
@db.getRepository.getSail.getValueFactory
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# returns the number of triples in the datastore (incl. possible duplicates)
|
|
101
|
+
# * context => context (optional)
|
|
102
|
+
def size(context = nil)
|
|
103
|
+
@db.size(wrap_contexts(context))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# deletes all triples from datastore
|
|
107
|
+
# * context => context (optional)
|
|
108
|
+
def clear(context = nil)
|
|
109
|
+
@db.clear(wrap_contexts(context))
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# deletes triple(s,p,o,c) from datastore
|
|
113
|
+
# symbol parameters match anything: delete(:s,:p,:o) will delete all triples
|
|
114
|
+
# you can specify a context to limit deletion to that context:
|
|
115
|
+
# delete(:s,:p,:o, 'http://context') will delete all triples with that context
|
|
116
|
+
# * s => subject
|
|
117
|
+
# * p => predicate
|
|
118
|
+
# * o => object
|
|
119
|
+
# * c => context (optional)
|
|
120
|
+
# Nil parameters are treated as :s, :p, :o respectively.
|
|
121
|
+
def delete(s, p, o, c=nil)
|
|
122
|
+
# convert variables
|
|
123
|
+
params = activerdf_to_sesame(s, p, o, c, true)
|
|
124
|
+
|
|
125
|
+
begin
|
|
126
|
+
@db.remove(params[0], params[1], params[2], wrap_contexts(c))
|
|
127
|
+
true
|
|
128
|
+
rescue Exception => e
|
|
129
|
+
raise ActiveRdfError, "Sesame delete triple failed: #{e.message}"
|
|
130
|
+
end
|
|
131
|
+
@db
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# adds triple(s,p,o,c) to datastore
|
|
135
|
+
# s,p must be resources, o can be primitive data or resource
|
|
136
|
+
# * s => subject
|
|
137
|
+
# * p => predicate
|
|
138
|
+
# * o => object
|
|
139
|
+
# * c => context (optional)
|
|
140
|
+
def add(s,p,o,c=nil)
|
|
141
|
+
# TODO: handle context, especially if it is null
|
|
142
|
+
# TODO: do we need to handle errors from the java side ?
|
|
143
|
+
|
|
144
|
+
check_input = [s,p,o]
|
|
145
|
+
raise ActiveRdfError, "cannot add triple with nil or blank node subject, predicate, or object" if check_input.any? {|r| r.nil? || r.is_a?(Symbol) }
|
|
146
|
+
|
|
147
|
+
params = activerdf_to_sesame(s, p, o, c)
|
|
148
|
+
@db.add(params[0], params[1], params[2], wrap_contexts(c))
|
|
149
|
+
true
|
|
150
|
+
rescue Exception => e
|
|
151
|
+
raise ActiveRdfError, "Sesame add triple failed: #{e.message}"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# flushing is done automatically, because we run sesame2 in autocommit mode
|
|
155
|
+
def flush
|
|
156
|
+
true
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# saving is done automatically, because we run sesame2 in autocommit mode
|
|
160
|
+
def save
|
|
161
|
+
true
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# close the underlying sesame triple store.
|
|
165
|
+
# if not called there may be open iterators.
|
|
166
|
+
def close
|
|
167
|
+
@db.close
|
|
168
|
+
ConnectionPool.remove_data_source(self)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# returns all triples in the datastore
|
|
172
|
+
def dump
|
|
173
|
+
# the sesame connection has an export method, which writes all explicit statements to
|
|
174
|
+
# a to a RDFHandler, which we supply, by constructing a NTriplesWriter, which writes to StringWriter,
|
|
175
|
+
# and we kindly ask that StringWriter to make a string for us. Note, you have to use stringy.to_s,
|
|
176
|
+
# somehow stringy.toString does not work. yes yes, those wacky jruby guys ;)
|
|
177
|
+
_string = StringWriter.new
|
|
178
|
+
sesameWriter = NTriplesWriter.new(_string)
|
|
179
|
+
@db.export(sesameWriter)
|
|
180
|
+
return _string.to_s
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# loads triples from file in ntriples format
|
|
184
|
+
# * file => file to load
|
|
185
|
+
# * syntax => syntax of file to load. The syntax can be: n3, ntriples, rdfxml, trig, trix, turtle
|
|
186
|
+
# * context => context (optional)
|
|
187
|
+
def load(file, syntax="ntriples", context=nil)
|
|
188
|
+
# rdf syntax type
|
|
189
|
+
case syntax
|
|
190
|
+
when 'n3'
|
|
191
|
+
syntax_type = RDFFormat::N3
|
|
192
|
+
when 'ntriples'
|
|
193
|
+
syntax_type = RDFFormat::NTRIPLES
|
|
194
|
+
when 'rdfxml'
|
|
195
|
+
syntax_type = RDFFormat::RDFXML
|
|
196
|
+
when 'trig'
|
|
197
|
+
syntax_type = RDFFormat::TRIG
|
|
198
|
+
when 'trix'
|
|
199
|
+
syntax_type = RDFFormat::TRIX
|
|
200
|
+
when 'turtle'
|
|
201
|
+
syntax_type = RDFFormat::TURTLE
|
|
202
|
+
else
|
|
203
|
+
raise ActiveRdfError, "Sesame load file failed: syntax not valid."
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
begin
|
|
207
|
+
@myWrapperInstance.load(file, "", syntax_type, wrap_contexts(context))
|
|
208
|
+
rescue Exception => e
|
|
209
|
+
raise ActiveRdfError, "Sesame load file failed: #{e.message}\n#{e.backtrace}"
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# executes ActiveRDF query on the sesame triple store associated with this adapter
|
|
214
|
+
# * query => Query object
|
|
215
|
+
def query(query)
|
|
216
|
+
|
|
217
|
+
# we want to put the results in here
|
|
218
|
+
results = []
|
|
219
|
+
|
|
220
|
+
# translate the query object into a SPARQL query string
|
|
221
|
+
qs = Query2SPARQL.translate(query)
|
|
222
|
+
|
|
223
|
+
begin
|
|
224
|
+
# evaluate the query on the sesame triple store
|
|
225
|
+
# TODO: if we want to get inferred statements back we have to say so, as third boolean parameter
|
|
226
|
+
tuplequeryresult = @db.prepareTupleQuery(QueryLanguage::SPARQL, qs).evaluate
|
|
227
|
+
rescue Exception => e
|
|
228
|
+
ActiveRdfLogger.log_error(self) { "Error evaluating query (#{e.message}): #{qs}" }
|
|
229
|
+
raise
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# what are the variables of the query ?
|
|
233
|
+
variables = tuplequeryresult.getBindingNames
|
|
234
|
+
size_of_variables = variables.size
|
|
235
|
+
|
|
236
|
+
# the following is plainly ugly. the reason is that JRuby currently does not support
|
|
237
|
+
# using iterators in the ruby way: with "each". it is possible to define "each" for java.util.Iterator
|
|
238
|
+
# using JavaUtilities.extend_proxy but that fails in strange ways. this is ugly but works.
|
|
239
|
+
|
|
240
|
+
# TODO: null handling, if a value is null...
|
|
241
|
+
|
|
242
|
+
# if there only was one variable, then the results array should look like this:
|
|
243
|
+
# results = [ [first Value For The Variable], [second Value], ...]
|
|
244
|
+
if size_of_variables == 1 then
|
|
245
|
+
# the counter keeps track of the number of values, so we can insert them into the results at the right position
|
|
246
|
+
counter = 0
|
|
247
|
+
while tuplequeryresult.hasNext
|
|
248
|
+
solution = tuplequeryresult.next
|
|
249
|
+
|
|
250
|
+
temparray = []
|
|
251
|
+
# get the value associated with a variable in this specific solution
|
|
252
|
+
temparray[0] = convertSesame2ActiveRDF(solution.getValue(variables[0]), query.resource_class)
|
|
253
|
+
results[counter] = temparray
|
|
254
|
+
counter = counter + 1
|
|
255
|
+
end
|
|
256
|
+
else
|
|
257
|
+
# if there is more then one variable the results array looks like this:
|
|
258
|
+
# results = [ [Value From First Solution For First Variable, Value From First Solution For Second Variable, ...],
|
|
259
|
+
# [Value From Second Solution For First Variable, Value From Second Solution for Second Variable, ...], ...]
|
|
260
|
+
counter = 0
|
|
261
|
+
while tuplequeryresult.hasNext
|
|
262
|
+
solution = tuplequeryresult.next
|
|
263
|
+
|
|
264
|
+
temparray = []
|
|
265
|
+
for n in 1..size_of_variables
|
|
266
|
+
value = convertSesame2ActiveRDF(solution.getValue(variables[n-1]), query.resource_class)
|
|
267
|
+
temparray[n-1] = value
|
|
268
|
+
end
|
|
269
|
+
results[counter] = temparray
|
|
270
|
+
counter = counter + 1
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
return results
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
private
|
|
278
|
+
|
|
279
|
+
# Init a native Sesame backend
|
|
280
|
+
def init_native_store(params)
|
|
281
|
+
# if no inferencing is specified, we don't activate sesame2 rdfs inferencing
|
|
282
|
+
sesame_inferencing = params[:inferencing] || false
|
|
283
|
+
ActiveRdfLogger.log_debug(self) { "Creating Sesame Native Adapter (location: #{params[:location]}, indexes: #{params[:indexes]}, inferencing: #{sesame_inferencing}" }
|
|
284
|
+
sesame_location = JFile.new(params[:location]) if(params[:location])
|
|
285
|
+
|
|
286
|
+
@myWrapperInstance.initWithNative(sesame_location, params[:indexes], sesame_inferencing)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Init a in-memory Sesame backend
|
|
290
|
+
def init_memory_store(params)
|
|
291
|
+
# if no inferencing is specified, we don't activate sesame2 rdfs inferencing
|
|
292
|
+
sesame_inferencing = params[:inferencing] || false
|
|
293
|
+
ActiveRdfLogger.log_debug(self) { "Creating Sesame Memory Adapter (inferencing: #{sesame_inferencing}" }
|
|
294
|
+
|
|
295
|
+
@myWrapperInstance.initWithMemory(sesame_inferencing)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Init with an RDBMS backend
|
|
299
|
+
def init_rdbms_store(params)
|
|
300
|
+
sesame_inferencing = params[:inferencing] || false
|
|
301
|
+
ActiveRdfLogger.log_debug(self) { "Creating Sesame RDBMS Adapter (driver: #{params[:driver]}, url: #{params[:url]}, user: #{params[:user]}, pass: #{params[:pass]}, inferencing: #{sesame_inferencing}" }
|
|
302
|
+
|
|
303
|
+
@myWrapperInstance.initWithRDBMS(params[:driver], params[:url], params[:user], params[:pass], sesame_inferencing)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# Init the HTTP store
|
|
307
|
+
def init_http_store(params)
|
|
308
|
+
ActiveRdfLogger.log_debug(self) { "Creating Sesame HTTP Adapter (url: #{params[:url]}, user: #{params[:user]}, pass: #{params[:pass]} (inferencing settings are always ignored)" }
|
|
309
|
+
|
|
310
|
+
wrap = @myWrapperInstance.initWithHttp(params[:url], params[:user], params[:pass])
|
|
311
|
+
@writes = wrap.getRepository.isWritable
|
|
312
|
+
wrap
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# check if testee is a java subclass of reference
|
|
316
|
+
def jInstanceOf(testee, reference)
|
|
317
|
+
# for Java::JavaClass for a <=> b the comparison operator returns: -1 if a is subclass of b,
|
|
318
|
+
# 0 if a.jclass = b.jclass, +1 in any other case.
|
|
319
|
+
isSubclass = (testee <=> reference)
|
|
320
|
+
if isSubclass == -1 or isSubclass == 0
|
|
321
|
+
return true
|
|
322
|
+
else
|
|
323
|
+
return false
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
# takes a part of a sesame statement, and converts it to a RDFS::Resource if it is a URI,
|
|
328
|
+
# or to a String if it is a Literal. The assumption currently, is that we will only get stuff out of sesame,
|
|
329
|
+
# which we put in there ourselves, and currently we only put URIs or Literals there.
|
|
330
|
+
#
|
|
331
|
+
# result_type is the class that will be used for "resource" objects.
|
|
332
|
+
def convertSesame2ActiveRDF(input, result_type)
|
|
333
|
+
jclassURI = Java::JavaClass.for_name("org.openrdf.model.URI")
|
|
334
|
+
jclassLiteral = Java::JavaClass.for_name("org.openrdf.model.Literal")
|
|
335
|
+
jclassBNode = Java::JavaClass.for_name('org.openrdf.model.BNode')
|
|
336
|
+
|
|
337
|
+
if jInstanceOf(input.java_class, jclassURI)
|
|
338
|
+
result_type.new(input.toString)
|
|
339
|
+
elsif jInstanceOf(input.java_class, jclassLiteral)
|
|
340
|
+
# The string is wrapped in quotationn marks. However, there may be a language
|
|
341
|
+
# indetifier outside the quotation marks, e.g. "The label"@en
|
|
342
|
+
# We try to unwrap this correctly. For now we assume that there may be
|
|
343
|
+
# no quotation marks inside the string
|
|
344
|
+
input.toString.gsub('"', '')
|
|
345
|
+
elsif jInstanceOf(input.java_class, jclassBNode)
|
|
346
|
+
RDFS::BNode.new(input.toString)
|
|
347
|
+
else
|
|
348
|
+
raise ActiveRdfError, "the Sesame Adapter tried to return something which is neither a URI nor a Literal, but is instead a #{input.java_class.name}"
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# converts spoc input into sesame objects (RDFS::Resource into
|
|
353
|
+
# valueFactory.createURI etc.)
|
|
354
|
+
def activerdf_to_sesame(s, p, o, c, use_nil = false)
|
|
355
|
+
params = []
|
|
356
|
+
|
|
357
|
+
# construct sesame parameters from s,p,o,c
|
|
358
|
+
[s,p,o].each { |item|
|
|
359
|
+
params << wrap(item, use_nil)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
# wrap Context
|
|
363
|
+
params << wrap_contexts(c) unless (c.nil?)
|
|
364
|
+
|
|
365
|
+
params
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
# converts item into sesame object (RDFS::Resource into
|
|
369
|
+
# valueFactory.createURI etc.). You can opt to preserve the
|
|
370
|
+
# nil values, otherwise they'll be transformed
|
|
371
|
+
def wrap(item, use_nil = false)
|
|
372
|
+
result =
|
|
373
|
+
if(item.respond_to?(:uri))
|
|
374
|
+
if (item.uri.to_s[0..4].match(/http:/).nil?)
|
|
375
|
+
@valueFactory.createLiteral(item.uri.to_s)
|
|
376
|
+
else
|
|
377
|
+
@valueFactory.createURI(item.uri.to_s)
|
|
378
|
+
end
|
|
379
|
+
else
|
|
380
|
+
case item
|
|
381
|
+
when Symbol
|
|
382
|
+
@valueFactory.createLiteral('')
|
|
383
|
+
when NilClass
|
|
384
|
+
use_nil ? nil : @valueFactory.createLiteral('')
|
|
385
|
+
else
|
|
386
|
+
@valueFactory.createLiteral(item.to_s)
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
return result
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def wrap_contexts(*contexts)
|
|
393
|
+
contexts.compact!
|
|
394
|
+
contexts.collect! do |context|
|
|
395
|
+
raise ActiveRdfError, "context must be a Resource" unless(context.respond_to?(:uri))
|
|
396
|
+
@valueFactory.createURI(context.uri)
|
|
397
|
+
end
|
|
398
|
+
contexts.to_java(org.openrdf.model.Resource)
|
|
399
|
+
end
|
|
400
|
+
end
|