pho 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/CHANGES +6 -0
  2. data/README +9 -1
  3. data/Rakefile +1 -1
  4. data/doc/index.html +3 -1
  5. data/doc/rdoc/classes/Pho/Analyzers.html +310 -0
  6. data/doc/rdoc/classes/Pho/CommandLine.html +770 -0
  7. data/doc/rdoc/classes/Pho/DatatypeProperty.html +241 -0
  8. data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +410 -0
  9. data/doc/rdoc/classes/Pho/Enrichment.html +119 -0
  10. data/doc/rdoc/classes/Pho/Etags.html +310 -0
  11. data/doc/rdoc/classes/Pho/Facet/Results.html +299 -0
  12. data/doc/rdoc/classes/Pho/Facet/Term.html +177 -0
  13. data/doc/rdoc/classes/Pho/Facet.html +119 -0
  14. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +695 -0
  15. data/doc/rdoc/classes/Pho/FieldWeighting.html +230 -0
  16. data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +478 -0
  17. data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +264 -0
  18. data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +259 -0
  19. data/doc/rdoc/classes/Pho/FileManagement.html +121 -0
  20. data/doc/rdoc/classes/Pho/Job.html +627 -0
  21. data/doc/rdoc/classes/Pho/JobUpdate.html +141 -0
  22. data/doc/rdoc/classes/Pho/Jobs.html +538 -0
  23. data/doc/rdoc/classes/Pho/Namespaces.html +164 -0
  24. data/doc/rdoc/classes/Pho/OAI/Record.html +165 -0
  25. data/doc/rdoc/classes/Pho/OAI/Records.html +331 -0
  26. data/doc/rdoc/classes/Pho/OAI.html +118 -0
  27. data/doc/rdoc/classes/Pho/QueryProfile.html +524 -0
  28. data/doc/rdoc/classes/Pho/RDF/Parser.html +279 -0
  29. data/doc/rdoc/classes/Pho/RDF.html +120 -0
  30. data/doc/rdoc/classes/Pho/RDFCollection.html +119 -0
  31. data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +325 -0
  32. data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +241 -0
  33. data/doc/rdoc/classes/Pho/ResourceHash.html +123 -0
  34. data/doc/rdoc/classes/Pho/Snapshot.html +402 -0
  35. data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +594 -0
  36. data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +696 -0
  37. data/doc/rdoc/classes/Pho/Sparql.html +187 -0
  38. data/doc/rdoc/classes/Pho/Status.html +296 -0
  39. data/doc/rdoc/classes/Pho/Store.html +1569 -0
  40. data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
  41. data/doc/rdoc/classes/Pho/Update/Changeset.html +521 -0
  42. data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +330 -0
  43. data/doc/rdoc/classes/Pho/Update/ChangesetHelper.html +159 -0
  44. data/doc/rdoc/classes/Pho/Update/Changesets.html +205 -0
  45. data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +257 -0
  46. data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +237 -0
  47. data/doc/rdoc/classes/Pho/Update/Statement.html +303 -0
  48. data/doc/rdoc/classes/Pho/Update.html +128 -0
  49. data/doc/rdoc/classes/Pho.html +283 -0
  50. data/doc/rdoc/classes/String.html +146 -0
  51. data/doc/rdoc/created.rid +1 -0
  52. data/doc/rdoc/files/CHANGES.html +373 -0
  53. data/doc/rdoc/files/README.html +204 -0
  54. data/doc/rdoc/files/lib/pho/changeset_builder_rb.html +108 -0
  55. data/doc/rdoc/files/lib/pho/changeset_rb.html +108 -0
  56. data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
  57. data/doc/rdoc/files/lib/pho/converter_rb.html +108 -0
  58. data/doc/rdoc/files/lib/pho/enrichment_rb.html +101 -0
  59. data/doc/rdoc/files/lib/pho/etags_rb.html +108 -0
  60. data/doc/rdoc/files/lib/pho/facet_rb.html +101 -0
  61. data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +101 -0
  62. data/doc/rdoc/files/lib/pho/file_management_rb.html +101 -0
  63. data/doc/rdoc/files/lib/pho/file_manager_rb.html +108 -0
  64. data/doc/rdoc/files/lib/pho/job_rb.html +101 -0
  65. data/doc/rdoc/files/lib/pho/oai_rb.html +101 -0
  66. data/doc/rdoc/files/lib/pho/query_profile_rb.html +101 -0
  67. data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +101 -0
  68. data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
  69. data/doc/rdoc/files/lib/pho/resource_hash_rb.html +101 -0
  70. data/doc/rdoc/files/lib/pho/snapshot_rb.html +109 -0
  71. data/doc/rdoc/files/lib/pho/sparql_rb.html +101 -0
  72. data/doc/rdoc/files/lib/pho/status_rb.html +101 -0
  73. data/doc/rdoc/files/lib/pho/store_rb.html +108 -0
  74. data/doc/rdoc/files/lib/pho_rb.html +133 -0
  75. data/doc/rdoc/fr_class_index.html +72 -0
  76. data/doc/rdoc/fr_file_index.html +49 -0
  77. data/doc/rdoc/fr_method_index.html +239 -0
  78. data/doc/rdoc/index.html +24 -0
  79. data/doc/rdoc/rdoc-style.css +208 -0
  80. data/lib/pho/enrichment.rb +1 -0
  81. data/lib/pho/field_predicate_map.rb +5 -0
  82. data/lib/pho/query_profile.rb +5 -0
  83. data/lib/pho/store.rb +4 -1
  84. data/tests/tc_field_predicate_map.rb +7 -1
  85. data/tests/tc_query_profile.rb +6 -0
  86. data/tests/tc_store_util.rb +7 -0
  87. metadata +134 -21
@@ -0,0 +1,241 @@
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::DatatypeProperty</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::DatatypeProperty</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/pho/field_predicate_map_rb.html">
59
+ lib/pho/field_predicate_map.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
+ <div id="description">
82
+ <p>
83
+ Captures information about a mapped datatype from a Field Predicate Map
84
+ </p>
85
+
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+ <div id="method-list">
92
+ <h3 class="section-bar">Methods</h3>
93
+
94
+ <div class="name-list">
95
+ <a href="#M000153">new</a>&nbsp;&nbsp;
96
+ <a href="#M000154">to_rdf</a>&nbsp;&nbsp;
97
+ </div>
98
+ </div>
99
+
100
+ </div>
101
+
102
+
103
+ <!-- if includes -->
104
+
105
+ <div id="section">
106
+
107
+
108
+
109
+
110
+
111
+ <div id="attribute-list">
112
+ <h3 class="section-bar">Attributes</h3>
113
+
114
+ <div class="name-list">
115
+ <table>
116
+ <tr class="top-aligned-row context-row">
117
+ <td class="context-item-name">analyzer</td>
118
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
119
+ <td class="context-item-desc">
120
+ URI of the analyzer associated with this property
121
+
122
+ </td>
123
+ </tr>
124
+ <tr class="top-aligned-row context-row">
125
+ <td class="context-item-name">name</td>
126
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
127
+ <td class="context-item-desc">
128
+ Short name for the property
129
+
130
+ </td>
131
+ </tr>
132
+ <tr class="top-aligned-row context-row">
133
+ <td class="context-item-name">property_uri</td>
134
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
135
+ <td class="context-item-desc">
136
+ <a href="RDF.html">RDF</a> predicate URI for the mapped property
137
+
138
+ </td>
139
+ </tr>
140
+ <tr class="top-aligned-row context-row">
141
+ <td class="context-item-name">uri</td>
142
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
143
+ <td class="context-item-desc">
144
+ URI for this mapping
145
+
146
+ </td>
147
+ </tr>
148
+ </table>
149
+ </div>
150
+ </div>
151
+
152
+
153
+
154
+ <!-- if method_list -->
155
+ <div id="methods">
156
+ <h3 class="section-bar">Public Class methods</h3>
157
+
158
+ <div id="method-M000153" class="method-detail">
159
+ <a name="M000153"></a>
160
+
161
+ <div class="method-heading">
162
+ <a href="#M000153" class="method-signature">
163
+ <span class="method-name">new</span><span class="method-args">(uri, property_uri, name, analyzer=nil)</span>
164
+ </a>
165
+ </div>
166
+
167
+ <div class="method-description">
168
+ <p><a class="source-toggle" href="#"
169
+ onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
170
+ <div class="method-source-code" id="M000153-source">
171
+ <pre>
172
+ <span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 64</span>
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>)
174
+ <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">uri</span>
175
+ <span class="ruby-ivar">@property_uri</span> = <span class="ruby-identifier">property_uri</span>
176
+ <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
177
+ <span class="ruby-ivar">@analyzer</span> = <span class="ruby-identifier">analyzer</span>
178
+ <span class="ruby-keyword kw">end</span>
179
+ </pre>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <h3 class="section-bar">Public Instance methods</h3>
185
+
186
+ <div id="method-M000154" class="method-detail">
187
+ <a name="M000154"></a>
188
+
189
+ <div class="method-heading">
190
+ <a href="#M000154" class="method-signature">
191
+ <span class="method-name">to_rdf</span><span class="method-args">(ns=true)</span>
192
+ </a>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+ <p>
197
+ Convert this object into an <a href="RDF.html">RDF</a> representation.
198
+ Generates a simple rdf:Description, optionally including namespaces
199
+ </p>
200
+ <table>
201
+ <tr><td valign="top">ns:</td><td>include namespace declarations
202
+
203
+ </td></tr>
204
+ </table>
205
+ <p><a class="source-toggle" href="#"
206
+ onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
207
+ <div class="method-source-code" id="M000154-source">
208
+ <pre>
209
+ <span class="ruby-comment cmt"># File lib/pho/field_predicate_map.rb, line 73</span>
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>)
211
+ <span class="ruby-identifier">rdf</span> = <span class="ruby-value str">&quot;&lt;rdf:Description &quot;</span>
212
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ns</span>
213
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; xmlns:rdf=\&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#\&quot; xmlns:frm=\&quot;#{Pho::Namespaces::FRAME}\&quot; xmlns:bf=\&quot;#{Pho::Namespaces::CONFIG}\&quot; &quot;</span>
214
+ <span class="ruby-keyword kw">end</span>
215
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; rdf:about=\&quot;#{@uri}\&quot;&gt;&quot;</span>
216
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;frm:property rdf:resource=\&quot;#{@property_uri}\&quot;/&gt;&quot;</span>
217
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;frm:name&gt;#{@name}&lt;/frm:name&gt;&quot;</span>
218
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@analyzer</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
219
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; &lt;bf:analyzer rdf:resource=\&quot;#{@analyzer}\&quot; /&gt;&quot;</span>
220
+ <span class="ruby-keyword kw">end</span>
221
+ <span class="ruby-identifier">rdf</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/rdf:Description&gt;&quot;</span>
222
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rdf</span>
223
+ <span class="ruby-keyword kw">end</span>
224
+ </pre>
225
+ </div>
226
+ </div>
227
+ </div>
228
+
229
+
230
+ </div>
231
+
232
+
233
+ </div>
234
+
235
+
236
+ <div id="validator-badges">
237
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
238
+ </div>
239
+
240
+ </body>
241
+ </html>
@@ -0,0 +1,410 @@
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::StoreEnricher</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::StoreEnricher</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="#M000077">enrich</a>&nbsp;&nbsp;
90
+ <a href="#M000075">infer</a>&nbsp;&nbsp;
91
+ <a href="#M000076">merge</a>&nbsp;&nbsp;
92
+ <a href="#M000074">new</a>&nbsp;&nbsp;
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">&nbsp;[R]&nbsp;</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">&nbsp;[R]&nbsp;</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-M000075" class="method-detail">
133
+ <a name="M000075"></a>
134
+
135
+ <div class="method-heading">
136
+ <a href="#M000075" class="method-signature">
137
+ <span class="method-name">infer</span><span class="method-args">(store, query, &amp;block)</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="StoreEnricher.html#M000074">new</a> data from old using
148
+ a CONSTRUCT query
149
+ </p>
150
+ <table>
151
+ <tr><td valign="top">store:</td><td>the store to be updated
152
+
153
+ </td></tr>
154
+ <tr><td valign="top">query:</td><td>the SPARQL CONSTRUCT query to be used to <a
155
+ href="StoreEnricher.html#M000075">infer</a> the <a
156
+ href="StoreEnricher.html#M000074">new</a> data
157
+
158
+ </td></tr>
159
+ </table>
160
+ <p><a class="source-toggle" href="#"
161
+ onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
162
+ <div class="method-source-code" id="M000075-source">
163
+ <pre>
164
+ <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 28</span>
165
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">StoreEnricher</span>.<span class="ruby-identifier">infer</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">query</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
166
+ <span class="ruby-identifier">enricher</span> = <span class="ruby-constant">StoreEnricher</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>() )
167
+ <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>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
168
+ <span class="ruby-keyword kw">end</span>
169
+ </pre>
170
+ </div>
171
+ </div>
172
+ </div>
173
+
174
+ <div id="method-M000074" class="method-detail">
175
+ <a name="M000074"></a>
176
+
177
+ <div class="method-heading">
178
+ <a href="#M000074" class="method-signature">
179
+ <span class="method-name">new</span><span class="method-args">(store, sparql_client)</span>
180
+ </a>
181
+ </div>
182
+
183
+ <div class="method-description">
184
+ <p>
185
+ Constructor
186
+ </p>
187
+ <table>
188
+ <tr><td valign="top">store:</td><td>the store containing resource(s) to <a
189
+ href="StoreEnricher.html#M000077">enrich</a>
190
+
191
+ </td></tr>
192
+ <tr><td valign="top">sparql_client:</td><td>SparqlClient object to be used as client for retrieving enrichments
193
+
194
+ </td></tr>
195
+ </table>
196
+ <p><a class="source-toggle" href="#"
197
+ onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
198
+ <div class="method-source-code" id="M000074-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 16</span>
201
+ <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>)
202
+ <span class="ruby-ivar">@store</span> = <span class="ruby-identifier">store</span>
203
+ <span class="ruby-ivar">@sparql_client</span> = <span class="ruby-identifier">sparql_client</span>
204
+ <span class="ruby-keyword kw">end</span>
205
+ </pre>
206
+ </div>
207
+ </div>
208
+ </div>
209
+
210
+ <h3 class="section-bar">Public Instance methods</h3>
211
+
212
+ <div id="method-M000077" class="method-detail">
213
+ <a name="M000077"></a>
214
+
215
+ <div class="method-heading">
216
+ <a href="#M000077" class="method-signature">
217
+ <span class="method-name">enrich</span><span class="method-args">(locator_query, enrichment_query, callback=nil) {|:query, query_response| ...}</span>
218
+ </a>
219
+ </div>
220
+
221
+ <div class="method-description">
222
+ <p>
223
+ Enrich a store with data extracted from a SPARQL endpoint.
224
+ </p>
225
+ <p>
226
+ The locator_query is used to find resources in the Platform <a
227
+ href="../Store.html">Store</a> that should be enriched. The query should be
228
+ a SPARQL SELECT query that returns the data to be used to parameterize the
229
+ enrichment_query.
230
+ </p>
231
+ <p>
232
+ For each query result, the enrichment_query will be submitted to the
233
+ configured SPARQL endpoint, after first interpolating the string, providing
234
+ the query result bindings as parameters. (See
235
+ SparqlHelper.apply_initial_bindings and
236
+ SparqlHelper.results_to_query_bindings
237
+ </p>
238
+ <p>
239
+ If successful, the result of each enrichment query will then be pushed back
240
+ into the Platform <a href="../Store.html">Store</a> by posting the results
241
+ of the query to the metabox. <a href="../Enrichment.html">Enrichment</a>
242
+ queries should therefore be CONSTRUCT or DESCRIBE queries. The SPARQL
243
+ protocol request will be sent with an Accept header of application/rdf+xml
244
+ </p>
245
+ <p>
246
+ The method supports a callback object that can be provided as an optional
247
+ parameter to the query. If provided then then object should respond to
248
+ either or both of the following methods:
249
+ </p>
250
+ <pre>
251
+ pre_process(rdf_xml)
252
+ post_process(resp, rdf_xml)
253
+ </pre>
254
+ <p>
255
+ The first of these is invoked after each enrichment query has been executed
256
+ on the configured SPARQL endpoint. It is intended to support additional
257
+ filtering or annotation. If the <tt>pre_process</tt> method returns nil,
258
+ then no data will be written to the store, otherwise the return value is
259
+ substituted instead of the original value.
260
+ </p>
261
+ <p>
262
+ The second callback method, <tt>post_process</tt> is called after data has
263
+ been written to the store and provides access to the response from the
264
+ store, and the <a href="../RDF.html">RDF</a>/XML data that had been
265
+ attempted to be stored. As the request may have been un-successful, code
266
+ should check the status on the HTTPMessage parameter.
267
+ </p>
268
+ <pre>
269
+ class MyCallback
270
+ def pre_process(rdf)
271
+ if !should_store?(rdf)
272
+ return nil
273
+ end
274
+ return rdf
275
+ end
276
+ def post_process(resp, rdf)
277
+ puts &quot;Store returned #{resp.status} when storing: #{rdf}&quot;
278
+ end
279
+ end
280
+ callback = MyCallback.new()
281
+ enricher.enrich(&quot;SELECT ?item WHERE { ?item a ex:Class } LIMIT 10&quot;, &quot;DESCRIBE ?item&quot;, callback)
282
+ </pre>
283
+ <p>
284
+ The callback support is primarily intended to support filtering and
285
+ notification of activities. For simple logging purposes, the method also
286
+ supports a block parameter. This is invoked after each enrichment query,
287
+ and each store response. The block can receive two values: the first is a
288
+ symbol (either +:query+ or +:store+) indicating the source of the response,
289
+ and the response object itself. E.g:
290
+ </p>
291
+ <pre>
292
+ enricher.enrich(&quot;SELECT ?item WHERE { ?item a ex:Class } LIMIT 10&quot;, &quot;DESCRIBE ?item&quot;) do |source, resp|
293
+ if source == :query
294
+ puts &quot;Enrichment query returned #{resp.status}&quot;
295
+ else
296
+ puts &quot;Store returned #{resp.status} when storing data&quot;
297
+ end
298
+ end
299
+ </pre>
300
+ <table>
301
+ <tr><td valign="top">locator_query:</td><td>query to locate resources to be enriched
302
+
303
+ </td></tr>
304
+ <tr><td valign="top">enrichment_query:</td><td>query to be used to <a href="StoreEnricher.html#M000077">enrich</a> the
305
+ resource
306
+
307
+ </td></tr>
308
+ <tr><td valign="top">callback:</td><td>optional callback object
309
+
310
+ </td></tr>
311
+ </table>
312
+ <p><a class="source-toggle" href="#"
313
+ onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
314
+ <div class="method-source-code" id="M000077-source">
315
+ <pre>
316
+ <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 109</span>
317
+ <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>, <span class="ruby-identifier">callback</span>=<span class="ruby-keyword kw">nil</span>)
318
+ <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>() )
319
+ <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>)
320
+ <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>
321
+ <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>)
322
+
323
+ <span class="ruby-comment cmt">#TODO counting numbers of requests and responses?</span>
324
+ <span class="ruby-identifier">query_response</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">&quot;application/rdf+xml&quot;</span>)
325
+
326
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
327
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-operator">:</span><span class="ruby-identifier">query</span>, <span class="ruby-identifier">query_response</span>
328
+ <span class="ruby-keyword kw">end</span>
329
+
330
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">query_response</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
331
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">query_response</span>.<span class="ruby-identifier">content</span>
332
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:pre_process</span>)
333
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">pre_process</span>(<span class="ruby-identifier">result</span>)
334
+ <span class="ruby-keyword kw">end</span>
335
+
336
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
337
+ <span class="ruby-identifier">store_response</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">result</span> )
338
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">callback</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:post_process</span>)
339
+ <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">post_process</span>(<span class="ruby-identifier">store_response</span>, <span class="ruby-identifier">result</span>)
340
+ <span class="ruby-keyword kw">end</span>
341
+
342
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
343
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-operator">:</span><span class="ruby-identifier">store</span>, <span class="ruby-identifier">store_response</span>
344
+ <span class="ruby-keyword kw">end</span>
345
+ <span class="ruby-keyword kw">end</span>
346
+
347
+ <span class="ruby-keyword kw">end</span>
348
+ <span class="ruby-comment cmt">#end each binding</span>
349
+ <span class="ruby-keyword kw">end</span>
350
+ <span class="ruby-keyword kw">end</span>
351
+ </pre>
352
+ </div>
353
+ </div>
354
+ </div>
355
+
356
+ <div id="method-M000076" class="method-detail">
357
+ <a name="M000076"></a>
358
+
359
+ <div class="method-heading">
360
+ <a href="#M000076" class="method-signature">
361
+ <span class="method-name">merge</span><span class="method-args">(query) {|resp, data| ...}</span>
362
+ </a>
363
+ </div>
364
+
365
+ <div class="method-description">
366
+ <p>
367
+ Execute the provided query against the configured SPARQL endpoint and store
368
+ the results in the Platform <a href="../Store.html">Store</a>
369
+ </p>
370
+ <table>
371
+ <tr><td valign="top">query:</td><td>the SPARQL CONSTRUCT or DESCRIBE query to execute
372
+
373
+ </td></tr>
374
+ </table>
375
+ <p><a class="source-toggle" href="#"
376
+ onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
377
+ <div class="method-source-code" id="M000076-source">
378
+ <pre>
379
+ <span class="ruby-comment cmt"># File lib/pho/enrichment.rb, line 37</span>
380
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">query</span>)
381
+ <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">&quot;application/rdf+xml&quot;</span> )
382
+ <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>
383
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unable to execute query. Response: #{resp.status} #{resp.reason} #{resp.content}&quot;</span>
384
+ <span class="ruby-keyword kw">end</span>
385
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
386
+ <span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_data</span>( <span class="ruby-identifier">data</span> )
387
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
388
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>
389
+ <span class="ruby-keyword kw">end</span>
390
+
391
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">resp</span>
392
+ <span class="ruby-keyword kw">end</span>
393
+ </pre>
394
+ </div>
395
+ </div>
396
+ </div>
397
+
398
+
399
+ </div>
400
+
401
+
402
+ </div>
403
+
404
+
405
+ <div id="validator-badges">
406
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
407
+ </div>
408
+
409
+ </body>
410
+ </html>