Mercurial > hg > svcore
comparison rdf/PluginRDFDescription.cpp @ 1844:5b1b03c1d8d4
Accept more than one library URI for a plugin; consistency checks for packs
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2020 15:42:51 +0100 |
parents | 3ec563af0a4f |
children | 6f626cfdba51 |
comparison
equal
deleted
inserted
replaced
1843:3ec563af0a4f | 1844:5b1b03c1d8d4 |
---|---|
30 using Dataquay::Nodes; | 30 using Dataquay::Nodes; |
31 using Dataquay::Triple; | 31 using Dataquay::Triple; |
32 using Dataquay::Triples; | 32 using Dataquay::Triples; |
33 using Dataquay::BasicStore; | 33 using Dataquay::BasicStore; |
34 | 34 |
35 #define DEBUG_PLUGIN_RDF_DESCRIPTION 1 | |
36 | |
35 PluginRDFDescription::PluginRDFDescription(QString pluginId) : | 37 PluginRDFDescription::PluginRDFDescription(QString pluginId) : |
36 m_pluginId(pluginId), | 38 m_pluginId(pluginId), |
37 m_haveDescription(false) | 39 m_haveDescription(false) |
38 { | 40 { |
39 PluginRDFIndexer *indexer = PluginRDFIndexer::getInstance(); | 41 PluginRDFIndexer *indexer = PluginRDFIndexer::getInstance(); |
233 | 235 |
234 if (n.type == Node::URI && n.value != "") { | 236 if (n.type == Node::URI && n.value != "") { |
235 m_pluginInfoURL = n.value; | 237 m_pluginInfoURL = n.value; |
236 } | 238 } |
237 | 239 |
238 Node libn = index->complete | 240 // There may be more than one library node claiming this |
239 (Triple(Node(), index->expand("vamp:available_plugin"), plugin)); | 241 // plugin. That's because older RDF descriptions tend to use a |
240 | 242 // library node URI derived from the description's own URI, so it |
241 if (libn.value != "") { | 243 // varies depending on where you read the description from. It's |
244 // common therefore to end up with both a file: URI (from an | |
245 // installed older version) and an http: one (from an online | |
246 // updated version). We have no way to pick an authoritative one, | |
247 // but it's also common that only one of them will have the | |
248 // resources we need anyway, so let's iterate through them all. | |
249 | |
250 Nodes libnodes = index->match | |
251 (Triple(Node(), index->expand("vamp:available_plugin"), plugin)) | |
252 .subjects(); | |
253 | |
254 for (Node libn: libnodes) { | |
255 | |
256 if (libn.type != Node::URI || libn.value == "") { | |
257 continue; | |
258 } | |
242 | 259 |
243 n = index->complete | 260 n = index->complete |
244 (Triple(libn, index->expand("foaf:page"), Node())); | 261 (Triple(libn, index->expand("foaf:page"), Node())); |
245 if (n.type == Node::URI && n.value != "" && m_pluginInfoURL == "") { | 262 |
263 if (n.type == Node::URI && n.value != "") { | |
246 m_pluginInfoURL = n.value; | 264 m_pluginInfoURL = n.value; |
247 } | 265 } |
248 | 266 |
249 // And the download page for the library | |
250 n = index->complete | 267 n = index->complete |
251 (Triple(libn, index->expand("doap:download-page"), Node())); | 268 (Triple(libn, index->expand("doap:download-page"), Node())); |
252 | 269 |
253 if (n.type == Node::URI && n.value != "") { | 270 if (n.type == Node::URI && n.value != "") { |
254 | |
255 m_pluginDownloadURL = n.value; | 271 m_pluginDownloadURL = n.value; |
256 | 272 |
257 n = index->complete | 273 n = index->complete |
258 (Triple(libn, index->expand("vamp:has_source"), Node())); | 274 (Triple(libn, index->expand("vamp:has_source"), Node())); |
259 if (n.type == Node::Literal && n.value == "true") { | 275 if (n.type == Node::Literal && n.value == "true") { |
275 } else if (bin.value == "osx") { | 291 } else if (bin.value == "osx") { |
276 m_pluginDownloadTypes.insert(DownloadMac); | 292 m_pluginDownloadTypes.insert(DownloadMac); |
277 } | 293 } |
278 } | 294 } |
279 } | 295 } |
280 } | 296 |
281 | 297 Nodes packs = index->match |
282 Nodes packs = index->match | 298 (Triple(Node(), index->expand("vamp:available_library"), libn)) |
283 (Triple(Node(), index->expand("vamp:available_library"), libn)) | 299 .subjects(); |
284 .objects(); | 300 |
285 | 301 SVCERR << packs.size() << " matching pack(s) for library node " |
286 for (Node packn: packs) { | 302 << libn << endl; |
287 if (packn.type != Node::URI) continue; | 303 |
288 | 304 for (Node packn: packs) { |
289 Pack pack; | 305 if (packn.type != Node::URI) continue; |
290 n = index->complete | 306 |
291 (Triple(packn, index->expand("dc:title"), Node())); | 307 Pack pack; |
292 if (n.type == Node::Literal) { | 308 n = index->complete |
293 pack.name = n.value; | 309 (Triple(packn, index->expand("dc:title"), Node())); |
294 } | 310 if (n.type == Node::Literal) { |
295 n = index->complete | 311 pack.name = n.value; |
296 (Triple(packn, index->expand("foaf:page"), Node())); | 312 } |
297 if (n.type == Node::URI) { | 313 n = index->complete |
298 pack.downloadURL = n.value; | 314 (Triple(packn, index->expand("foaf:page"), Node())); |
299 } | 315 if (n.type == Node::URI) { |
300 | 316 pack.downloadURL = n.value; |
301 if (pack.name != "" && pack.downloadURL != "") { | 317 } |
302 m_pluginFoundInPacks[packn.value] = pack; | 318 |
303 } | 319 if (pack.name != "" && pack.downloadURL != "") { |
304 } | 320 m_pluginFoundInPacks[packn.value] = pack; |
305 | 321 } |
322 } | |
323 } | |
324 | |
325 #ifdef DEBUG_PLUGIN_RDF_DESCRIPTION | |
326 SVCERR << "PluginRDFDescription::indexMetadata:" << endl; | |
327 SVCERR << " * id: " << m_pluginId << endl; | |
328 SVCERR << " * uri: <" << m_pluginUri << ">" << endl; | |
329 SVCERR << " * name: " << m_pluginName << endl; | |
330 SVCERR << " * description: " << m_pluginDescription << endl; | |
331 SVCERR << " * maker: " << m_pluginMaker << endl; | |
332 SVCERR << " * info url: <" << m_pluginInfoURL << ">" << endl; | |
333 SVCERR << " * download url: <" << m_pluginDownloadURL << ">" << endl; | |
334 SVCERR << " * download types:" << endl; | |
335 for (auto t: m_pluginDownloadTypes) { | |
336 SVCERR << " * " << int(t) << endl; | |
337 } | |
338 SVCERR << " * packs:" << endl; | |
339 for (auto t: m_pluginFoundInPacks) { | |
340 SVCERR << " * " << t.first << " { name: " << t.second.name | |
341 << ", download url: " << t.second.downloadURL << " }" << endl; | |
342 } | |
343 SVCERR << endl; | |
344 #endif | |
345 | |
306 return true; | 346 return true; |
307 } | 347 } |
308 | 348 |
309 bool | 349 bool |
310 PluginRDFDescription::indexOutputs() | 350 PluginRDFDescription::indexOutputs() |