activerdf_net7 1.6.16 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +63 -0
- data/activerdf-jena/lib/activerdf_jena/jena.rb +4 -4
- data/activerdf-jena/lib/activerdf_jena/jena_adapter.rb +55 -55
- data/activerdf-jena/lib/activerdf_jena/lucene.rb +1 -1
- data/activerdf-jena/lib/activerdf_jena/ng4j.rb +7 -7
- data/activerdf-jena/lib/activerdf_jena/ng4j_adapter.rb +47 -47
- data/activerdf-jena/lib/activerdf_jena/pellet.rb +1 -1
- data/activerdf-jena/test/test_jena_adapter.rb +121 -120
- data/activerdf-jena/test/test_ng4j_adapter.rb +111 -110
- data/activerdf-rdflite/lib/activerdf_rdflite/fetching.rb +23 -19
- data/activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb +153 -277
- data/activerdf-rdflite/lib/activerdf_rdflite/suggesting.rb +2 -2
- data/activerdf-rdflite/test/test_fetching.rb +7 -22
- data/activerdf-rdflite/test/test_rdflite.rb +44 -257
- data/activerdf-redland/lib/activerdf_redland/redland.rb +246 -282
- data/activerdf-redland/test/test_redland_adapter.rb +62 -224
- data/activerdf-sesame/ext/wrapper-sesame2.jar +0 -0
- data/activerdf-sesame/java/build.number +2 -2
- data/activerdf-sesame/java/build.xml +0 -0
- data/activerdf-sesame/java/lib/junit-3.8.2.jar +0 -0
- data/activerdf-sesame/java/settings.xml +0 -0
- data/activerdf-sesame/java/src/org/activerdf/wrapper/sesame2/WrapperForSesame2.java +0 -0
- data/activerdf-sesame/java/temp/build/org/activerdf/wrapper/sesame2/WrapperForSesame2.class +0 -0
- data/activerdf-sesame/java/temp/manifest/MANIFEST.MF +2 -2
- data/activerdf-sesame/java/test-src/org/activerdf/wrapper/sesame2/TestWrapperForSesame2.java +0 -0
- data/activerdf-sesame/lib/activerdf_sesame/sesame.rb +360 -364
- data/activerdf-sesame/test/test_sesame_adapter.rb +85 -83
- data/activerdf-sparql/lib/activerdf_sparql/sparql.rb +147 -148
- data/activerdf-sparql/lib/activerdf_sparql/sparql_result_parser.rb +5 -5
- data/activerdf-sparql/test/test_sparql_adapter.rb +2 -0
- data/activerdf-yars/lib/activerdf_yars/jars2.rb +85 -83
- data/lib/active_rdf/federation/active_rdf_adapter.rb +26 -39
- data/lib/active_rdf/federation/connection_pool.rb +119 -110
- data/lib/active_rdf/federation/federation_manager.rb +51 -51
- data/lib/active_rdf/objectmanager/bnode.rb +8 -2
- data/lib/active_rdf/objectmanager/literal.rb +81 -50
- data/lib/active_rdf/objectmanager/namespace.rb +117 -84
- data/lib/active_rdf/objectmanager/object_manager.rb +101 -96
- data/lib/active_rdf/objectmanager/ordered_set.rb +1 -1
- data/lib/active_rdf/objectmanager/property.rb +345 -0
- data/lib/active_rdf/objectmanager/property_list.rb +4 -4
- data/lib/active_rdf/objectmanager/property_lookup.rb +57 -0
- data/lib/active_rdf/objectmanager/resource.rb +293 -501
- data/lib/active_rdf/objectmanager/resource_like.rb +2 -2
- data/lib/active_rdf/objectmanager/resource_query.rb +85 -0
- data/lib/active_rdf/queryengine/ntriples_parser.rb +75 -68
- data/lib/active_rdf/queryengine/query.rb +237 -183
- data/lib/active_rdf/queryengine/query2jars2.rb +17 -15
- data/lib/active_rdf/queryengine/query2sparql.rb +107 -101
- data/lib/active_rdf.rb +28 -17
- data/lib/active_rdf_helpers.rb +37 -5
- data/lib/active_rdf_log.rb +11 -11
- data/test/adapters/test_activerdf_adapter.rb +138 -0
- data/test/{test_adapters.rb → adapters/test_adapters.rb} +6 -24
- data/test/adapters/test_bnode_capable_adapter.rb +31 -0
- data/test/adapters/test_context_aware_adapter.rb +31 -0
- data/test/adapters/test_network_aware_adapter.rb +29 -0
- data/test/adapters/test_persistent_adapter.rb +21 -0
- data/test/adapters/test_read_only_adapter.rb +15 -0
- data/test/adapters/test_reasoning_adapter.rb +11 -0
- data/test/adapters/test_writable_adapter.rb +163 -0
- data/test/common.rb +78 -96
- data/test/federation/test_connection_pool.rb +25 -44
- data/test/federation/test_federation_manager.rb +45 -45
- data/test/objectmanager/test_literal.rb +47 -26
- data/test/objectmanager/test_namespace.rb +3 -1
- data/test/objectmanager/test_object_manager.rb +35 -45
- data/test/objectmanager/test_ordered_set.rb +1 -1
- data/test/objectmanager/test_property.rb +261 -0
- data/test/objectmanager/test_resource_reading.rb +196 -104
- data/test/objectmanager/test_resource_reasoning.rb +26 -0
- data/test/objectmanager/test_resource_writing.rb +34 -25
- data/test/queryengine/my_external_resource.rb +5 -1
- data/test/queryengine/test_external_resource_class.rb +1 -8
- data/test/queryengine/test_ntriples_parser.rb +5 -3
- data/test/queryengine/test_query.rb +3 -3
- data/test/queryengine/test_query2jars2.rb +2 -2
- data/test/queryengine/test_query2sparql.rb +2 -2
- data/test/queryengine/test_query_engine.rb +46 -28
- metadata +16 -8
- data/activerdf-rdflite/test/test_bnode_data.nt +0 -5
- data/activerdf-rdflite/test/test_data.nt +0 -32
- data/activerdf-rdflite/test/test_escaped_data.nt +0 -2
- data/activerdf-redland/test/test_person_data.nt +0 -42
- data/test/objectmanager/test_talia_syntax.rb +0 -68
data/CHANGELOG
CHANGED
@@ -1,3 +1,66 @@
|
|
1
|
+
== activerdf (HEAD)
|
2
|
+
* ActiveRDF classes have been moved into their own module, ActiveRDF::.
|
3
|
+
* Registered predicates are being deprecated in favor of registered
|
4
|
+
namespaces instead.
|
5
|
+
|
6
|
+
* Added RDF::Property to manage properties and their values.
|
7
|
+
If it is associated with a resource on instantiation, that property then
|
8
|
+
provides access to the values belonging to the associated resource.
|
9
|
+
This changes the way properties are queried from RDFS::Resource. This
|
10
|
+
replaces all_ property methods. resource.property now returns a
|
11
|
+
RDF::Property. Values may be accessed via Enumerable methods.
|
12
|
+
|
13
|
+
* Resource refactored, DRY'd out.
|
14
|
+
* Resource.find(uri) for finding resources by uri. Returns nil if resource
|
15
|
+
not found. Use instead of Resource.new(uri) if you don't wish to create
|
16
|
+
a new resource if one is not found.
|
17
|
+
* Resource#to_s now returns URI's without enclosing braces(<>).
|
18
|
+
Use #to_literal_s for NTriple formatted URI's
|
19
|
+
* Resource#all_predicates, #instance_predicates, #empty_predicates added
|
20
|
+
* Resource#filter now takes a single filter at a time. returns self so
|
21
|
+
additional filters may be chained. #filter_regexp now simply #regexp
|
22
|
+
* Resource property lookups now have the following search priority:
|
23
|
+
custom methods first, namespaced properties second,
|
24
|
+
registered_predicates(deprecated) then finally a search on all
|
25
|
+
known properties for this class.
|
26
|
+
* Provide some limited RDF & RDFS reasoning. Enabled with a new global
|
27
|
+
variable $activerdf_internal_reasoning = false (default)
|
28
|
+
|
29
|
+
* Datatype support. ActiveRDF will by default use datatype for all
|
30
|
+
literals to provide typing support. A new global boolean variable
|
31
|
+
$activerdf_without_datatype will disable the use of datatypes if
|
32
|
+
set to true. This may be necessary when working with literals that
|
33
|
+
do not have a datatype specified in which case they will all be treated
|
34
|
+
as strings.
|
35
|
+
* Query#all_types uses regex matching to match all values, ignoring
|
36
|
+
datatype when $activerdf_without_datatype = false, ie enforcing type.
|
37
|
+
Use in datastores with mixed typed and non-typed literals
|
38
|
+
See discussion here: http://markmail.org/message/4rhqmb5jnaqbwfbs
|
39
|
+
* Query flatten argument now defaults to false
|
40
|
+
* Added FederationManager#contexts for querying contexts for all adapters
|
41
|
+
* NTriples parser now ignores comments and recognizes lang/datatype
|
42
|
+
|
43
|
+
* renamed adapter API method #query to #execute to match semantics of Query
|
44
|
+
* RDFLite has been refactored. Additional rapper syntax option(-i) to #fetch,#load:
|
45
|
+
fetch(url, syntax = nil), load(location, syntax = nil)
|
46
|
+
* Redland adapter initialization refactored. Redland store types
|
47
|
+
via :location parameter now supported: 'postgres','mysql','sqlite','memory',<filename>
|
48
|
+
:want_new parameter changed to :new.
|
49
|
+
* Redland adapter no longer calls eva(i)l('"%s"' % self) on all data.
|
50
|
+
|
51
|
+
* Code reformatting
|
52
|
+
|
53
|
+
* Bugfixes for
|
54
|
+
88428: queries with blocks don't work
|
55
|
+
48849: datatype support
|
56
|
+
64007: class names capitalisation leads sometimes to unintuitive results
|
57
|
+
106878: Dynamic finder behavior => now supported by RDF::Property when property known, nil when not found
|
58
|
+
62481: find_by_<Property> is now supported through chained ResourceFilter calls
|
59
|
+
185826: weird behavior with class compares
|
60
|
+
|
61
|
+
* reverted 461. This was a request to add additional filters to the property, specifically lang. This is now supported through RDF::Property#lang and #datatype. Support for arbitrary filters is on the todo list.
|
62
|
+
Namespace restriction should remain.
|
63
|
+
|
1
64
|
== activerdf (1.6.12)
|
2
65
|
* FederationManager passes delete correctly to adaptors
|
3
66
|
|
@@ -17,7 +17,7 @@ module Jena
|
|
17
17
|
|
18
18
|
module DB
|
19
19
|
include_package('com.hp.hpl.jena.db')
|
20
|
-
|
20
|
+
|
21
21
|
# this maps downcased Jena database types into drivers
|
22
22
|
DRIVER_MAP = {
|
23
23
|
'oracle' => 'oracle.jdbc.Driver',
|
@@ -27,8 +27,8 @@ module Jena
|
|
27
27
|
'hsql' => 'org.hsqldb.jdbcDriver',
|
28
28
|
'mssql' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
29
29
|
}
|
30
|
-
|
31
|
-
DRIVER_MAP.each do |name, driver|
|
30
|
+
|
31
|
+
DRIVER_MAP.each do |name, driver|
|
32
32
|
av = "#{name}_available"
|
33
33
|
(class << self ; self ; end).send(:bool_accessor, av.to_sym)
|
34
34
|
begin
|
@@ -39,7 +39,7 @@ module Jena
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
module Query
|
44
44
|
include_package('com.hp.hpl.jena.query')
|
45
45
|
end
|
@@ -32,7 +32,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
32
32
|
def close
|
33
33
|
self.datasource = nil
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def valid_connection?(cnxn)
|
37
37
|
true
|
38
38
|
end
|
@@ -47,9 +47,9 @@ class JenaAdapter < ActiveRdfAdapter
|
|
47
47
|
attr_accessor :model_maker, :base_model, :model, :lucene_index
|
48
48
|
attr_accessor :root_directory
|
49
49
|
|
50
|
-
# :database
|
50
|
+
# :database
|
51
51
|
# either use :url, :type, :username, AND :password (for a
|
52
|
-
# regular connection) OR :datasource AND :type (for a container
|
52
|
+
# regular connection) OR :datasource AND :type (for a container
|
53
53
|
# connection), default to memory data store
|
54
54
|
# example for a derby connection:
|
55
55
|
# :database => {:url => "jdbc:derby:superfunky;create=true", :type => "Derby", :username => "", :password => ""}
|
@@ -59,12 +59,12 @@ class JenaAdapter < ActiveRdfAdapter
|
|
59
59
|
# :model
|
60
60
|
# name of model to use, default is jena's default
|
61
61
|
# :ontology
|
62
|
-
# set to language type if this needs to be viewed as an ontology,
|
62
|
+
# set to language type if this needs to be viewed as an ontology,
|
63
63
|
# default nil, available :owl, :owl_dl, :owl_lite, :rdfs
|
64
|
-
# pellet only supports owl reasoning.
|
65
|
-
# :reasoner
|
66
|
-
# set to reasoner to use -- default nil (none). options: :pellet,
|
67
|
-
# :transitive, :rdfs, :rdfs_simple, :owl_micro, :owl_mini, :owl,
|
64
|
+
# pellet only supports owl reasoning.
|
65
|
+
# :reasoner
|
66
|
+
# set to reasoner to use -- default nil (none). options: :pellet,
|
67
|
+
# :transitive, :rdfs, :rdfs_simple, :owl_micro, :owl_mini, :owl,
|
68
68
|
# :generic_rule
|
69
69
|
# :lucene
|
70
70
|
# set to true to enable true lucene indexing of this store, default false
|
@@ -73,7 +73,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
73
73
|
self.ontology_type = params[:ontology]
|
74
74
|
self.reasoner = params[:reasoner]
|
75
75
|
self.keyword_search = params[:lucene]
|
76
|
-
|
76
|
+
|
77
77
|
# if the model name is not provided and file persistence is used, then jena just
|
78
78
|
# creates random files in the tmp dir. not good, as we need to know the model name
|
79
79
|
# to have persistence
|
@@ -82,7 +82,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
82
82
|
else
|
83
83
|
self.model_name = "default"
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
if params[:file]
|
87
87
|
if params[:file].respond_to? :path
|
88
88
|
self.root_directory = File.expand_path(params[:file].path)
|
@@ -95,7 +95,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
95
95
|
if self.keyword_search? && !LuceneARQ.lucene_available?
|
96
96
|
raise JenaAdapterConfigurationError, "Lucene requested but is not available"
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
if self.reasoner == :pellet && !Pellet.pellet_available?
|
100
100
|
raise JenaAdapterConfigurationError, "Pellet requested but not available"
|
101
101
|
end
|
@@ -117,28 +117,28 @@ class JenaAdapter < ActiveRdfAdapter
|
|
117
117
|
raise JenaAdapterConfigurationError, "database type #{dbparams[:type]} not recognized"
|
118
118
|
end
|
119
119
|
|
120
|
-
self.connection = Jena::DB::DBConnection.new(dbparams[:url],
|
120
|
+
self.connection = Jena::DB::DBConnection.new(dbparams[:url],
|
121
121
|
dbparams[:username],
|
122
122
|
dbparams[:password],
|
123
123
|
dbparams[:type])
|
124
124
|
end
|
125
125
|
|
126
126
|
self.model_maker = Jena::Model::ModelFactory.createModelRDBMaker(connection)
|
127
|
-
|
127
|
+
|
128
128
|
elsif self.root_directory
|
129
129
|
self.model_maker = Jena::Model::ModelFactory.createFileModelMaker(self.root_directory)
|
130
130
|
else
|
131
131
|
self.model_maker = Jena::Model::ModelFactory.createMemModelMaker
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
|
135
135
|
self.base_model = self.model_maker.openModel(model_name)
|
136
|
-
|
136
|
+
|
137
137
|
if self.ontology_type
|
138
138
|
rf = map_reasoner_factory(self.reasoner)
|
139
139
|
onturi = map_ontology_type(self.ontology_type)
|
140
140
|
|
141
|
-
spec =
|
141
|
+
spec =
|
142
142
|
Jena::Ontology::OntModelSpec.new(self.model_maker,
|
143
143
|
Jena::Ontology::OntDocumentManager.new,
|
144
144
|
rf, onturi)
|
@@ -150,10 +150,10 @@ class JenaAdapter < ActiveRdfAdapter
|
|
150
150
|
self.model = self.base_model
|
151
151
|
self.reasoning = false
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
self.reads = true
|
155
155
|
self.writes = true
|
156
|
-
|
156
|
+
|
157
157
|
self
|
158
158
|
end
|
159
159
|
|
@@ -212,17 +212,17 @@ class JenaAdapter < ActiveRdfAdapter
|
|
212
212
|
# :format
|
213
213
|
# format -- :ntriples, :n3, or :rdfxml, default :rdfxml
|
214
214
|
# :into
|
215
|
-
# either the name of a model, :default_model for the main model, or
|
215
|
+
# either the name of a model, :default_model for the main model, or
|
216
216
|
# :submodel to load into an anonymous memory model, default is :submodel
|
217
217
|
# if this is an ontology, :default_model if it's not.
|
218
|
-
# :rebind
|
218
|
+
# :rebind
|
219
219
|
# rebind with the inferencer, default true; no effect if no inferencer
|
220
220
|
def load(uri, params = {})
|
221
|
-
into = params[:into] ? params[:into] :
|
221
|
+
into = params[:into] ? params[:into] :
|
222
222
|
(self.ontology_type ? :submodel : :default_model)
|
223
223
|
format = params[:format] ? params[:format] : :rdfxml
|
224
224
|
rebind = params[:rebind] ? params[:rebind] : true
|
225
|
-
|
225
|
+
|
226
226
|
jena_format =
|
227
227
|
case format
|
228
228
|
when :rdfxml
|
@@ -236,30 +236,30 @@ class JenaAdapter < ActiveRdfAdapter
|
|
236
236
|
case into
|
237
237
|
when :default_model
|
238
238
|
self.model.read(uri, jena_format)
|
239
|
-
|
239
|
+
|
240
240
|
when :submodel
|
241
241
|
self.model.addSubModel(Jena::Model::ModelFactory.createDefaultModel.read(uri, jena_format))
|
242
|
-
|
242
|
+
|
243
243
|
else
|
244
244
|
self.model.addSubModel(self.model_maker.createModel(into).read(uri, jena_format))
|
245
245
|
end
|
246
|
-
|
246
|
+
|
247
247
|
if rebind && self.reasoner && self.model.respond_to?(:rebind)
|
248
248
|
self.model.rebind
|
249
249
|
end
|
250
250
|
|
251
251
|
self.lucene_index_behind = true
|
252
|
-
|
253
|
-
end
|
252
|
+
|
253
|
+
end
|
254
254
|
|
255
255
|
# this method gets called by the ActiveRDF query engine
|
256
|
-
def
|
256
|
+
def execute(query)
|
257
257
|
|
258
258
|
if self.keyword_search? && query.keyword?
|
259
|
-
|
259
|
+
|
260
260
|
# duplicate the query
|
261
261
|
query_with_keywords = query.dup
|
262
|
-
|
262
|
+
|
263
263
|
# now duplicate the where stuff so we can fiddle with it...
|
264
264
|
# this is GROSS -- fix this if Query ever sprouts a proper
|
265
265
|
# deep copy or a where_clauses setter
|
@@ -272,7 +272,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
272
272
|
#query.where("lucene_literal_#{var}".to_sym, LuceneARQ::KEYWORD_PREDICATE, keyword)
|
273
273
|
#query.where(var, "lucene_property_#{var}".to_sym, "lucene_literal_#{var}".to_sym)
|
274
274
|
|
275
|
-
# use this if activerdf expects the literal to come back, not the
|
275
|
+
# use this if activerdf expects the literal to come back, not the
|
276
276
|
# subject, or if using indexbuildersubject (which makes the subject
|
277
277
|
# come back instead of the literal
|
278
278
|
query_with_keywords.where(var, RDFS::Resource.new(LuceneARQ::KEYWORD_PREDICATE), keyword)
|
@@ -287,7 +287,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
287
287
|
# search requests expanded.
|
288
288
|
jena_results = query_jena(query_with_keywords)
|
289
289
|
|
290
|
-
# use the conjunctive query facility in pellet to get additional
|
290
|
+
# use the conjunctive query facility in pellet to get additional
|
291
291
|
# answers, if we're using pellet and we don't have a pure keyword
|
292
292
|
# query
|
293
293
|
if self.reasoner == :pellet && query.where_clauses.size > 0
|
@@ -303,17 +303,17 @@ class JenaAdapter < ActiveRdfAdapter
|
|
303
303
|
return [[true]] if results.size > 0
|
304
304
|
return [[false]]
|
305
305
|
end
|
306
|
-
|
306
|
+
|
307
307
|
if query.count?
|
308
308
|
return results.size
|
309
309
|
end
|
310
310
|
|
311
311
|
results
|
312
|
-
|
312
|
+
|
313
313
|
end
|
314
314
|
|
315
315
|
# ==========================================================================
|
316
|
-
# put private methods here to seperate api methods from the
|
316
|
+
# put private methods here to seperate api methods from the
|
317
317
|
# inner workings of the adapter
|
318
318
|
private
|
319
319
|
|
@@ -337,28 +337,28 @@ class JenaAdapter < ActiveRdfAdapter
|
|
337
337
|
case type
|
338
338
|
when :pellet
|
339
339
|
Pellet.reasoner_factory
|
340
|
-
|
340
|
+
|
341
341
|
when :transitive
|
342
342
|
com.hp.hpl.jena.reasoner.transitiveReasoner.TransitiveReasonerFactory.theInstance
|
343
|
-
|
343
|
+
|
344
344
|
when :rdfs
|
345
345
|
com.hp.hpl.jena.reasoner.rulesys.RDFSFBRuleReasonerFactory.theInstance
|
346
|
-
|
346
|
+
|
347
347
|
when :rdfs_simple
|
348
348
|
com.hp.hpl.jena.reasoner.rulesys.RDFSRuleReasonerFactory.theInstance
|
349
|
-
|
349
|
+
|
350
350
|
when :owl_micro
|
351
351
|
com.hp.hpl.jena.reasoner.rulesys.OWLMicroReasonerFactory.theInstance
|
352
|
-
|
352
|
+
|
353
353
|
when :owl_mini
|
354
354
|
com.hp.hpl.jena.reasoner.rulesys.OWLMiniReasonerFactory.theInstance
|
355
|
-
|
356
|
-
when :owl
|
355
|
+
|
356
|
+
when :owl
|
357
357
|
com.hp.hpl.jena.reasoner.rulesys.OWLFBRuleReasonerFactory.theInstance
|
358
|
-
|
358
|
+
|
359
359
|
when :generic_rule
|
360
360
|
com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasonerFactory.theInstance
|
361
|
-
|
361
|
+
|
362
362
|
else
|
363
363
|
type
|
364
364
|
end
|
@@ -379,7 +379,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
379
379
|
else
|
380
380
|
objlit = object
|
381
381
|
end
|
382
|
-
|
382
|
+
|
383
383
|
if objlit.type
|
384
384
|
type = Jena::Datatypes::TypeMapper.getInstance.getTypeByName(objlit.type.uri)
|
385
385
|
o = mod.createTypedLiteral(objlit.value, type)
|
@@ -388,11 +388,11 @@ class JenaAdapter < ActiveRdfAdapter
|
|
388
388
|
else
|
389
389
|
o = mod.createTypedLiteral(objlit.value, nil)
|
390
390
|
end
|
391
|
-
end
|
391
|
+
end
|
392
392
|
return o
|
393
393
|
end
|
394
394
|
|
395
|
-
def build_subject(subject, submodel = nil)
|
395
|
+
def build_subject(subject, submodel = nil)
|
396
396
|
# ensure it exists in the parent model
|
397
397
|
self.model.getResource(subject.uri) if submodel
|
398
398
|
appropriate_model(submodel).getResource(subject.uri)
|
@@ -426,8 +426,8 @@ class JenaAdapter < ActiveRdfAdapter
|
|
426
426
|
end
|
427
427
|
|
428
428
|
def query_jena(query)
|
429
|
-
query_sparql = translate(query)
|
430
|
-
|
429
|
+
query_sparql = translate(query)
|
430
|
+
|
431
431
|
qexec = Jena::Query::QueryExecutionFactory.create(query_sparql, self.model)
|
432
432
|
|
433
433
|
# PROBABLY A VERY EXPENSIVE OPERATION (rebuilds lucene index if ANYTHING
|
@@ -437,7 +437,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
437
437
|
LuceneARQ::LARQ.setDefaultIndex(qexec.getContext, retrieve_lucene_index)
|
438
438
|
end
|
439
439
|
|
440
|
-
begin
|
440
|
+
begin
|
441
441
|
results = perform_query(query, qexec)
|
442
442
|
ensure
|
443
443
|
qexec.close
|
@@ -449,25 +449,25 @@ class JenaAdapter < ActiveRdfAdapter
|
|
449
449
|
def query_pellet(query)
|
450
450
|
query_sparql = translate(query)
|
451
451
|
jena_query = Jena::Query::QueryFactory.create(query_sparql)
|
452
|
-
|
452
|
+
|
453
453
|
# bail if not a select
|
454
454
|
return [] if !jena_query.isSelectType
|
455
455
|
|
456
456
|
qexec = Pellet::Query::PelletQueryExecution.new(jena_query, self.model)
|
457
|
-
|
457
|
+
|
458
458
|
begin
|
459
459
|
results = perform_query(query, qexec)
|
460
460
|
ensure
|
461
461
|
qexec.close
|
462
462
|
end
|
463
|
-
|
463
|
+
|
464
464
|
results
|
465
465
|
end
|
466
466
|
|
467
467
|
def perform_query(query, qexec)
|
468
468
|
results = qexec.execSelect
|
469
469
|
arr_results = []
|
470
|
-
|
470
|
+
|
471
471
|
while results.hasNext
|
472
472
|
row = results.nextSolution
|
473
473
|
res_row = []
|
@@ -487,7 +487,7 @@ class JenaAdapter < ActiveRdfAdapter
|
|
487
487
|
# datatyped literal
|
488
488
|
res_row << Literal.new(thing.getValue, RDFS::Resource.new(thing.getDatatypeURI))
|
489
489
|
elsif thing.getDatatypeURI.nil?
|
490
|
-
# language tagged literal
|
490
|
+
# language tagged literal
|
491
491
|
res_row << Literal.new(thing.getLexicalForm, "@" + thing.getLanguage)
|
492
492
|
else
|
493
493
|
raise ActiveRdfError, "Jena Sparql returned a strange literal"
|
@@ -10,21 +10,21 @@ module NG4J
|
|
10
10
|
include_package('de.fuberlin.wiwiss.ng4j')
|
11
11
|
# This contains: NamedGraphSet, Quad
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
module DB
|
15
|
-
|
15
|
+
|
16
16
|
include_package('de.fuberlin.wiwiss.ng4j.db')
|
17
|
-
|
17
|
+
|
18
18
|
include_class('java.sql.DriverManager')
|
19
|
-
|
19
|
+
|
20
20
|
# this maps downcased Jena database types into drivers
|
21
21
|
DRIVER_MAP = {
|
22
22
|
'mysql' => 'com.mysql.jdbc.Driver',
|
23
23
|
'postgresql' => 'org.postgresql.Driver',
|
24
24
|
'hsql' => 'org.hsqldb.jdbcDriver',
|
25
25
|
}
|
26
|
-
|
27
|
-
DRIVER_MAP.each do |name, driver|
|
26
|
+
|
27
|
+
DRIVER_MAP.each do |name, driver|
|
28
28
|
av = "#{name}_available"
|
29
29
|
(class << self ; self ; end).send(:bool_accessor, av.to_sym)
|
30
30
|
begin
|
@@ -34,7 +34,7 @@ module NG4J
|
|
34
34
|
Jena::DB.send("#{av}=", false)
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
39
|
|
40
40
|
module Sparql
|