pho 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +18 -1
- data/README +10 -0
- data/Rakefile +2 -1
- data/doc/rdoc/classes/Pho.html +33 -22
- data/doc/rdoc/classes/Pho/DatatypeProperty.html +12 -12
- data/doc/rdoc/classes/Pho/{RDF_JSON.html → Enrichment.html} +8 -7
- data/doc/rdoc/classes/Pho/Enrichment/ResourceEnricher.html +310 -0
- data/doc/rdoc/classes/Pho/Etags.html +42 -42
- data/doc/rdoc/classes/Pho/Facet/Results.html +19 -19
- data/doc/rdoc/classes/Pho/Facet/Term.html +6 -6
- data/doc/rdoc/classes/Pho/FieldPredicateMap.html +110 -105
- data/doc/rdoc/classes/Pho/FieldWeighting.html +12 -12
- data/doc/rdoc/classes/Pho/FileManagement.html +121 -0
- data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +443 -0
- data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +258 -0
- data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +271 -0
- data/doc/rdoc/classes/Pho/Job.html +64 -64
- data/doc/rdoc/classes/Pho/Jobs.html +60 -60
- data/doc/rdoc/classes/Pho/QueryProfile.html +60 -60
- data/doc/rdoc/classes/Pho/RDFCollection.html +4 -378
- data/doc/rdoc/classes/Pho/ResourceHash.html +123 -0
- data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +323 -0
- data/doc/rdoc/classes/Pho/{RDF_JSON → ResourceHash}/SetAlgebra.html +18 -18
- data/doc/rdoc/classes/Pho/Snapshot.html +35 -35
- data/doc/rdoc/classes/Pho/Sparql.html +137 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +515 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +575 -0
- data/doc/rdoc/classes/Pho/Status.html +26 -26
- data/doc/rdoc/classes/Pho/Store.html +271 -241
- data/doc/rdoc/classes/Pho/Update/Changeset.html +73 -73
- data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +34 -34
- data/doc/rdoc/classes/Pho/Update/Changesets.html +14 -14
- data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +31 -23
- data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +45 -21
- data/doc/rdoc/classes/Pho/Update/Statement.html +29 -29
- data/doc/rdoc/classes/String.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +49 -3
- data/doc/rdoc/files/README.html +15 -1
- data/doc/rdoc/files/lib/pho/changeset_builder_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/changeset_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/converter_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/enrichment_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/etags_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/file_management_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/file_manager_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/resource_hash_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/{rdf_json_rb.html → sparql_rb.html} +4 -4
- data/doc/rdoc/files/lib/pho/store_rb.html +1 -1
- data/doc/rdoc/files/lib/pho_rb.html +7 -2
- data/doc/rdoc/fr_class_index.html +12 -2
- data/doc/rdoc/fr_file_index.html +6 -1
- data/doc/rdoc/fr_method_index.html +176 -139
- data/examples/sparql_construct_hash.rb +26 -0
- data/examples/sparql_select.rb +18 -0
- data/lib/pho.rb +6 -1
- data/lib/pho/changeset.rb +24 -9
- data/lib/pho/changeset_builder.rb +10 -10
- data/lib/pho/converter.rb +74 -0
- data/lib/pho/enrichment.rb +81 -0
- data/lib/pho/etags.rb +1 -0
- data/lib/pho/field_predicate_map.rb +6 -1
- data/lib/pho/file_management.rb +102 -0
- data/lib/pho/file_manager.rb +61 -0
- data/lib/pho/rdf_collection.rb +54 -120
- data/lib/pho/{rdf_json.rb → resource_hash.rb} +3 -4
- data/lib/pho/sparql.rb +332 -0
- data/lib/pho/store.rb +20 -14
- data/tests/tc_changeset.rb +46 -0
- data/tests/tc_changeset_builder.rb +122 -1
- data/tests/tc_converter.rb +95 -0
- data/tests/tc_enrichment.rb +83 -0
- data/tests/tc_file_manager.rb +88 -0
- data/tests/tc_rdf_collection.rb +3 -0
- data/tests/{tc_rdf_json.rb → tc_resource_hash.rb} +23 -23
- data/tests/tc_search.rb +1 -1
- data/tests/tc_sparql.rb +131 -6
- data/tests/tc_sparql_helper.rb +214 -0
- data/tests/ts_pho.rb +6 -2
- metadata +47 -8
data/CHANGES
CHANGED
@@ -2,11 +2,28 @@ Brief notes on significant changes and additions in each release
|
|
2
2
|
|
3
3
|
== Version 0.5
|
4
4
|
|
5
|
+
NOTE: Released 0.4.1 version of the gem at this point to support earlier versions of
|
6
|
+
Ruby.
|
7
|
+
|
8
|
+
* Added Enrichment module to support updating a store with results of simple inference (using
|
9
|
+
CONSTRUCT queries), merging data from external endpoints, and support for parameterized
|
10
|
+
lookup and enrichment of resources
|
11
|
+
* Added SparqlClient.multi_describe
|
12
|
+
* Added additional methods in SparqlHelper to support applying initial bindings to queries, and
|
13
|
+
generating initial bindings from SELECT results
|
14
|
+
* Added Pho::FileManagement::FileManager for pushing a directory of files into the content box
|
15
|
+
* RDFCollection is now deprecated
|
16
|
+
* Added Pho::FileManagement module and extracted code from RDFCollection to support creating similar util for other files
|
17
|
+
* Added SparqlHelper class to simplify a few common tasks
|
18
|
+
* Added new Sparql module and refactored store methods to use SparqlClient class
|
19
|
+
* Fixed bug in store.augment() method which was setting wrong headers on POST
|
20
|
+
* Added Converter class to convert between various RDF serializations and resource hashes. This uses the Redland API.
|
21
|
+
* Support Ruby 1.8.5 or above (to allow installation on Centos 5)
|
5
22
|
* Support for storing data in private graphs as well as metabox
|
6
23
|
* Support for submission of changesets to private graphs as well as metabox
|
7
24
|
* Multisparql options on all Store sparql methods
|
8
25
|
* Addition of ChangeSetBuilder class for constructing changesets from triple hashes
|
9
|
-
* Addition of
|
26
|
+
* Addition of ResourceHash module and SetAlgebra class for working with triple hashes
|
10
27
|
* Addition of Changeset, Statement classes for capturing and serializing Changeset data
|
11
28
|
* Fixed bugs in facet, search params
|
12
29
|
* Added submit_changeset method to Store to support submission of changeset data
|
data/README
CHANGED
@@ -11,6 +11,16 @@ The latest version of this library can be downloaded from:
|
|
11
11
|
|
12
12
|
http://pho.rubyforge.net
|
13
13
|
|
14
|
+
== Installation
|
15
|
+
|
16
|
+
From the 0.5 release onwards, Pho is dependent on the Ruby bindings for the Redland RDF library.
|
17
|
+
Ensure you have the librdf0 and librdf-ruby packages installed.
|
18
|
+
|
19
|
+
All other dependencies are for specific Ruby gems which should get automatically installed,
|
20
|
+
along with the Pho gem itself, by running:
|
21
|
+
|
22
|
+
sudo gem install pho
|
23
|
+
|
14
24
|
== Usage
|
15
25
|
|
16
26
|
To use Pho you can:
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
|
|
5
5
|
require 'rake/clean'
|
6
6
|
|
7
7
|
NAME = "pho"
|
8
|
-
VER = "0.
|
8
|
+
VER = "0.5"
|
9
9
|
|
10
10
|
RDOC_OPTS = ['--quiet', '--title', 'Pho (Talis Platform Client) Reference', '--main', 'README']
|
11
11
|
|
@@ -36,6 +36,7 @@ SPEC =
|
|
36
36
|
s.add_dependency("httpclient", ">= 2.1.3.1")
|
37
37
|
s.add_dependency("json", ">= 1.1.3")
|
38
38
|
s.add_dependency("mocha", ">= 0.9.5")
|
39
|
+
s.add_dependency("mime-types", ">= 1.16")
|
39
40
|
end
|
40
41
|
|
41
42
|
Rake::GemPackageTask.new(SPEC) do |pkg|
|
data/doc/rdoc/classes/Pho.html
CHANGED
@@ -63,13 +63,17 @@
|
|
63
63
|
lib/pho/changeset_builder.rb
|
64
64
|
</a>
|
65
65
|
<br />
|
66
|
-
<a href="../files/lib/pho/
|
67
|
-
lib/pho/
|
66
|
+
<a href="../files/lib/pho/file_manager_rb.html">
|
67
|
+
lib/pho/file_manager.rb
|
68
68
|
</a>
|
69
69
|
<br />
|
70
70
|
<a href="../files/lib/pho/etags_rb.html">
|
71
71
|
lib/pho/etags.rb
|
72
72
|
</a>
|
73
|
+
<br />
|
74
|
+
<a href="../files/lib/pho/enrichment_rb.html">
|
75
|
+
lib/pho/enrichment.rb
|
76
|
+
</a>
|
73
77
|
<br />
|
74
78
|
<a href="../files/lib/pho/status_rb.html">
|
75
79
|
lib/pho/status.rb
|
@@ -78,6 +82,10 @@
|
|
78
82
|
<a href="../files/lib/pho/rdf_collection_rb.html">
|
79
83
|
lib/pho/rdf_collection.rb
|
80
84
|
</a>
|
85
|
+
<br />
|
86
|
+
<a href="../files/lib/pho/converter_rb.html">
|
87
|
+
lib/pho/converter.rb
|
88
|
+
</a>
|
81
89
|
<br />
|
82
90
|
<a href="../files/lib/pho/store_rb.html">
|
83
91
|
lib/pho/store.rb
|
@@ -86,10 +94,22 @@
|
|
86
94
|
<a href="../files/lib/pho/field_predicate_map_rb.html">
|
87
95
|
lib/pho/field_predicate_map.rb
|
88
96
|
</a>
|
97
|
+
<br />
|
98
|
+
<a href="../files/lib/pho/sparql_rb.html">
|
99
|
+
lib/pho/sparql.rb
|
100
|
+
</a>
|
101
|
+
<br />
|
102
|
+
<a href="../files/lib/pho/resource_hash_rb.html">
|
103
|
+
lib/pho/resource_hash.rb
|
104
|
+
</a>
|
89
105
|
<br />
|
90
106
|
<a href="../files/lib/pho/changeset_rb.html">
|
91
107
|
lib/pho/changeset.rb
|
92
108
|
</a>
|
109
|
+
<br />
|
110
|
+
<a href="../files/lib/pho/file_management_rb.html">
|
111
|
+
lib/pho/file_management.rb
|
112
|
+
</a>
|
93
113
|
<br />
|
94
114
|
<a href="../files/lib/pho/facet_rb.html">
|
95
115
|
lib/pho/facet.rb
|
@@ -120,6 +140,12 @@
|
|
120
140
|
|
121
141
|
<div id="contextContent">
|
122
142
|
|
143
|
+
<div id="description">
|
144
|
+
<p>
|
145
|
+
TODO put together proper test suite for this
|
146
|
+
</p>
|
147
|
+
|
148
|
+
</div>
|
123
149
|
|
124
150
|
|
125
151
|
</div>
|
@@ -135,8 +161,11 @@
|
|
135
161
|
<div id="class-list">
|
136
162
|
<h3 class="section-bar">Classes and Modules</h3>
|
137
163
|
|
138
|
-
Module <a href="Pho/
|
139
|
-
Module <a href="Pho/
|
164
|
+
Module <a href="Pho/Enrichment.html" class="link">Pho::Enrichment</a><br />
|
165
|
+
Module <a href="Pho/Facet.html" class="link">Pho::Facet</a><br />
|
166
|
+
Module <a href="Pho/FileManagement.html" class="link">Pho::FileManagement</a><br />
|
167
|
+
Module <a href="Pho/ResourceHash.html" class="link">Pho::ResourceHash</a><br />
|
168
|
+
Module <a href="Pho/Sparql.html" class="link">Pho::Sparql</a><br />
|
140
169
|
Module <a href="Pho/Update.html" class="link">Pho::Update</a><br />
|
141
170
|
Class <a href="Pho/Analyzers.html" class="link">Pho::Analyzers</a><br />
|
142
171
|
Class <a href="Pho/DatatypeProperty.html" class="link">Pho::DatatypeProperty</a><br />
|
@@ -211,24 +240,6 @@ Cannot access the store
|
|
211
240
|
|
212
241
|
|
213
242
|
|
214
|
-
<div id="attribute-list">
|
215
|
-
<h3 class="section-bar">Attributes</h3>
|
216
|
-
|
217
|
-
<div class="name-list">
|
218
|
-
<table>
|
219
|
-
<tr class="top-aligned-row context-row">
|
220
|
-
<td class="context-item-name">dir</td>
|
221
|
-
<td class="context-item-value"> [R] </td>
|
222
|
-
<td class="context-item-desc"></td>
|
223
|
-
</tr>
|
224
|
-
<tr class="top-aligned-row context-row">
|
225
|
-
<td class="context-item-name">store</td>
|
226
|
-
<td class="context-item-value"> [R] </td>
|
227
|
-
<td class="context-item-desc"></td>
|
228
|
-
</tr>
|
229
|
-
</table>
|
230
|
-
</div>
|
231
|
-
</div>
|
232
243
|
|
233
244
|
|
234
245
|
|
@@ -92,8 +92,8 @@ Captures information about a mapped datatype from a Field Predicate Map
|
|
92
92
|
<h3 class="section-bar">Methods</h3>
|
93
93
|
|
94
94
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
95
|
+
<a href="#M000120">new</a>
|
96
|
+
<a href="#M000121">to_rdf</a>
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
|
@@ -155,19 +155,19 @@ URI for this mapping
|
|
155
155
|
<div id="methods">
|
156
156
|
<h3 class="section-bar">Public Class methods</h3>
|
157
157
|
|
158
|
-
<div id="method-
|
159
|
-
<a name="
|
158
|
+
<div id="method-M000120" class="method-detail">
|
159
|
+
<a name="M000120"></a>
|
160
160
|
|
161
161
|
<div class="method-heading">
|
162
|
-
<a href="#
|
162
|
+
<a href="#M000120" class="method-signature">
|
163
163
|
<span class="method-name">new</span><span class="method-args">(uri, property_uri, name, analyzer=nil)</span>
|
164
164
|
</a>
|
165
165
|
</div>
|
166
166
|
|
167
167
|
<div class="method-description">
|
168
168
|
<p><a class="source-toggle" href="#"
|
169
|
-
onclick="toggleCode('
|
170
|
-
<div class="method-source-code" id="
|
169
|
+
onclick="toggleCode('M000120-source');return false;">[Source]</a></p>
|
170
|
+
<div class="method-source-code" id="M000120-source">
|
171
171
|
<pre>
|
172
172
|
<span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 64</span>
|
173
173
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">property_uri</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">analyzer</span>=<span class="ruby-keyword kw">nil</span>)
|
@@ -183,11 +183,11 @@ URI for this mapping
|
|
183
183
|
|
184
184
|
<h3 class="section-bar">Public Instance methods</h3>
|
185
185
|
|
186
|
-
<div id="method-
|
187
|
-
<a name="
|
186
|
+
<div id="method-M000121" class="method-detail">
|
187
|
+
<a name="M000121"></a>
|
188
188
|
|
189
189
|
<div class="method-heading">
|
190
|
-
<a href="#
|
190
|
+
<a href="#M000121" class="method-signature">
|
191
191
|
<span class="method-name">to_rdf</span><span class="method-args">(ns=true)</span>
|
192
192
|
</a>
|
193
193
|
</div>
|
@@ -203,8 +203,8 @@ rdf:Description, optionally including namespaces
|
|
203
203
|
</td></tr>
|
204
204
|
</table>
|
205
205
|
<p><a class="source-toggle" href="#"
|
206
|
-
onclick="toggleCode('
|
207
|
-
<div class="method-source-code" id="
|
206
|
+
onclick="toggleCode('M000121-source');return false;">[Source]</a></p>
|
207
|
+
<div class="method-source-code" id="M000121-source">
|
208
208
|
<pre>
|
209
209
|
<span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 73</span>
|
210
210
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_rdf</span>(<span class="ruby-identifier">ns</span>=<span class="ruby-keyword kw">true</span>)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>Module: Pho::
|
8
|
+
<title>Module: Pho::Enrichment</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
11
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
@@ -50,13 +50,13 @@
|
|
50
50
|
<table class="header-table">
|
51
51
|
<tr class="top-aligned-row">
|
52
52
|
<td><strong>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Pho::
|
53
|
+
<td class="class-name-in-header">Pho::Enrichment</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="../../files/lib/pho/
|
59
|
-
lib/pho/
|
58
|
+
<a href="../../files/lib/pho/enrichment_rb.html">
|
59
|
+
lib/pho/enrichment.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
62
62
|
</td>
|
@@ -74,8 +74,9 @@
|
|
74
74
|
|
75
75
|
<div id="description">
|
76
76
|
<p>
|
77
|
-
|
78
|
-
|
77
|
+
<a href="Enrichment.html">Enrichment</a> module. Provides classes and
|
78
|
+
mixins for enriching data held in Platform stores using external SPARQL
|
79
|
+
endpoints and services
|
79
80
|
</p>
|
80
81
|
|
81
82
|
</div>
|
@@ -94,7 +95,7 @@ to the RDF in JSON spec
|
|
94
95
|
<div id="class-list">
|
95
96
|
<h3 class="section-bar">Classes and Modules</h3>
|
96
97
|
|
97
|
-
Class <a href="
|
98
|
+
Class <a href="Enrichment/ResourceEnricher.html" class="link">Pho::Enrichment::ResourceEnricher</a><br />
|
98
99
|
|
99
100
|
</div>
|
100
101
|
|
@@ -0,0 +1,310 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Pho::Enrichment::ResourceEnricher</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Pho::Enrichment::ResourceEnricher</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/pho/enrichment_rb.html">
|
59
|
+
lib/pho/enrichment.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000072">enrich</a>
|
90
|
+
<a href="#M000070">infer</a>
|
91
|
+
<a href="#M000071">merge</a>
|
92
|
+
<a href="#M000069">new</a>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="section">
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<div id="attribute-list">
|
108
|
+
<h3 class="section-bar">Attributes</h3>
|
109
|
+
|
110
|
+
<div class="name-list">
|
111
|
+
<table>
|
112
|
+
<tr class="top-aligned-row context-row">
|
113
|
+
<td class="context-item-name">sparql_client</td>
|
114
|
+
<td class="context-item-value"> [R] </td>
|
115
|
+
<td class="context-item-desc"></td>
|
116
|
+
</tr>
|
117
|
+
<tr class="top-aligned-row context-row">
|
118
|
+
<td class="context-item-name">store</td>
|
119
|
+
<td class="context-item-value"> [R] </td>
|
120
|
+
<td class="context-item-desc"></td>
|
121
|
+
</tr>
|
122
|
+
</table>
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<!-- if method_list -->
|
129
|
+
<div id="methods">
|
130
|
+
<h3 class="section-bar">Public Class methods</h3>
|
131
|
+
|
132
|
+
<div id="method-M000070" class="method-detail">
|
133
|
+
<a name="M000070"></a>
|
134
|
+
|
135
|
+
<div class="method-heading">
|
136
|
+
<a href="#M000070" class="method-signature">
|
137
|
+
<span class="method-name">infer</span><span class="method-args">(store, query)</span>
|
138
|
+
</a>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
<div class="method-description">
|
142
|
+
<p>
|
143
|
+
Enrich a store against itself
|
144
|
+
</p>
|
145
|
+
<p>
|
146
|
+
For the common case where a store needs to be enriched against itself by
|
147
|
+
inferring <a href="ResourceEnricher.html#M000069">new</a> data from old
|
148
|
+
using a CONSTRUCT query
|
149
|
+
</p>
|
150
|
+
<pre>
|
151
|
+
store:: the store to be updated
|
152
|
+
query:: the SPARQL CONSTRUCT query to be used to infer the new data
|
153
|
+
</pre>
|
154
|
+
<p><a class="source-toggle" href="#"
|
155
|
+
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
|
156
|
+
<div class="method-source-code" id="M000070-source">
|
157
|
+
<pre>
|
158
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 27</span>
|
159
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">ResourceEnricher</span>.<span class="ruby-identifier">infer</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">query</span>)
|
160
|
+
<span class="ruby-identifier">enricher</span> = <span class="ruby-constant">ResourceEnricher</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">store</span>, <span class="ruby-identifier">store</span>.<span class="ruby-identifier">sparql_client</span>() )
|
161
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">enricher</span>.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">query</span> )
|
162
|
+
<span class="ruby-keyword kw">end</span>
|
163
|
+
</pre>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div id="method-M000069" class="method-detail">
|
169
|
+
<a name="M000069"></a>
|
170
|
+
|
171
|
+
<div class="method-heading">
|
172
|
+
<a href="#M000069" class="method-signature">
|
173
|
+
<span class="method-name">new</span><span class="method-args">(store, sparql_client)</span>
|
174
|
+
</a>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
<div class="method-description">
|
178
|
+
<p>
|
179
|
+
Constructor
|
180
|
+
</p>
|
181
|
+
<pre>
|
182
|
+
store:: the store containing resource(s) to enrich
|
183
|
+
sparql_client:: SparqlClient object to be used as client for retrieving enrichments
|
184
|
+
</pre>
|
185
|
+
<p><a class="source-toggle" href="#"
|
186
|
+
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
|
187
|
+
<div class="method-source-code" id="M000069-source">
|
188
|
+
<pre>
|
189
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 15</span>
|
190
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">sparql_client</span>)
|
191
|
+
<span class="ruby-ivar">@store</span> = <span class="ruby-identifier">store</span>
|
192
|
+
<span class="ruby-ivar">@sparql_client</span> = <span class="ruby-identifier">sparql_client</span>
|
193
|
+
<span class="ruby-keyword kw">end</span>
|
194
|
+
</pre>
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
200
|
+
|
201
|
+
<div id="method-M000072" class="method-detail">
|
202
|
+
<a name="M000072"></a>
|
203
|
+
|
204
|
+
<div class="method-heading">
|
205
|
+
<a href="#M000072" class="method-signature">
|
206
|
+
<span class="method-name">enrich</span><span class="method-args">(locator_query, enrichment_query)</span>
|
207
|
+
</a>
|
208
|
+
</div>
|
209
|
+
|
210
|
+
<div class="method-description">
|
211
|
+
<p>
|
212
|
+
Enrich a store with data extracted from a SPARQL endpoint.
|
213
|
+
</p>
|
214
|
+
<p>
|
215
|
+
The locator_query is used to find resources in the Platform <a
|
216
|
+
href="../Store.html">Store</a> that should be enriched. The query should be
|
217
|
+
a SPARQL SELECT query that returns the data to be used to parameterize the
|
218
|
+
enrichment_query.
|
219
|
+
</p>
|
220
|
+
<p>
|
221
|
+
For each query result, the enrichment_query will be submitted to the
|
222
|
+
configured SPARQL endpoint, after first interpolating the string, providing
|
223
|
+
the query result bindings as parameters. (See
|
224
|
+
SparqlHelper.apply_initial_bindings and
|
225
|
+
SparqlHelper.results_to_query_bindings
|
226
|
+
</p>
|
227
|
+
<p>
|
228
|
+
If successful, the result of each enrichment query will then be pushed back
|
229
|
+
into the Platform <a href="../Store.html">Store</a> by posting the results
|
230
|
+
of the query to the metabox. <a href="../Enrichment.html">Enrichment</a>
|
231
|
+
queries should therefore be CONSTRUCT or DESCRIBE queries. The SPARQL
|
232
|
+
protocol request will be sent with an Accept header of application/rdf+xml
|
233
|
+
</p>
|
234
|
+
<pre>
|
235
|
+
locator_query:: query to locate resources to be enriched
|
236
|
+
enrichment_query:: query to be used to enrich the resource
|
237
|
+
</pre>
|
238
|
+
<p><a class="source-toggle" href="#"
|
239
|
+
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
|
240
|
+
<div class="method-source-code" id="M000072-source">
|
241
|
+
<pre>
|
242
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 62</span>
|
243
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enrich</span>(<span class="ruby-identifier">locator_query</span>, <span class="ruby-identifier">enrichment_query</span>)
|
244
|
+
<span class="ruby-identifier">results</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">locator_query</span>, <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">sparql_client</span>() )
|
245
|
+
<span class="ruby-identifier">bindings</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">results_to_query_bindings</span>(<span class="ruby-identifier">results</span>)
|
246
|
+
<span class="ruby-identifier">bindings</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">binding</span><span class="ruby-operator">|</span>
|
247
|
+
<span class="ruby-identifier">bound_query</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Sparql</span><span class="ruby-operator">::</span><span class="ruby-constant">SparqlHelper</span>.<span class="ruby-identifier">apply_initial_bindings</span>(<span class="ruby-identifier">enrichment_query</span>, <span class="ruby-identifier">binding</span>)
|
248
|
+
|
249
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-ivar">@sparql_client</span>.<span class="ruby-identifier">query</span>(<span class="ruby-identifier">bound_query</span>, <span class="ruby-value str">"application/rdf+xml"</span>)
|
250
|
+
|
251
|
+
<span class="ruby-comment cmt">#TODO error handling and callbacks </span>
|
252
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
|
253
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">result</span>.<span class="ruby-identifier">content</span> )
|
254
|
+
<span class="ruby-keyword kw">end</span>
|
255
|
+
|
256
|
+
<span class="ruby-keyword kw">end</span>
|
257
|
+
<span class="ruby-keyword kw">end</span>
|
258
|
+
</pre>
|
259
|
+
</div>
|
260
|
+
</div>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div id="method-M000071" class="method-detail">
|
264
|
+
<a name="M000071"></a>
|
265
|
+
|
266
|
+
<div class="method-heading">
|
267
|
+
<a href="#M000071" class="method-signature">
|
268
|
+
<span class="method-name">merge</span><span class="method-args">(query)</span>
|
269
|
+
</a>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p>
|
274
|
+
Execute the provided query against the configured SPARQL endpoint and store
|
275
|
+
the results in the Platform <a href="../Store.html">Store</a>
|
276
|
+
</p>
|
277
|
+
<pre>
|
278
|
+
query:: the SPARQL CONSTRUCT or DESCRIBE query to execute
|
279
|
+
</pre>
|
280
|
+
<p><a class="source-toggle" href="#"
|
281
|
+
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
|
282
|
+
<div class="method-source-code" id="M000071-source">
|
283
|
+
<pre>
|
284
|
+
<span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 36</span>
|
285
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">query</span>)
|
286
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@sparql_client</span>.<span class="ruby-identifier">query</span>( <span class="ruby-identifier">query</span>, <span class="ruby-value str">"application/rdf+xml"</span> )
|
287
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">200</span>
|
288
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Unable to execute query. Response: #{resp.status} #{resp.reason} #{resp.content}"</span>
|
289
|
+
<span class="ruby-keyword kw">end</span>
|
290
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span> )
|
291
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">resp</span>
|
292
|
+
<span class="ruby-keyword kw">end</span>
|
293
|
+
</pre>
|
294
|
+
</div>
|
295
|
+
</div>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
|
299
|
+
</div>
|
300
|
+
|
301
|
+
|
302
|
+
</div>
|
303
|
+
|
304
|
+
|
305
|
+
<div id="validator-badges">
|
306
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
307
|
+
</div>
|
308
|
+
|
309
|
+
</body>
|
310
|
+
</html>
|