comparison rdf/PluginRDFIndexer.cpp @ 481:a82645e788fc

* Auto-select RDF datastore/parsing backend; use trees datastore if available * Make CachedFile remember whether a file has already been successfully located locally (avoiding system call out to look at filesystem)
author Chris Cannam
date Fri, 14 Nov 2008 10:10:05 +0000
parents 3ffce691c9bf
children f54381e01141
comparison
equal deleted inserted replaced
480:3ffce691c9bf 481:a82645e788fc
259 259
260 localString = "file://" + cf.getLocalFilename(); //!!! crud - fix! 260 localString = "file://" + cf.getLocalFilename(); //!!! crud - fix!
261 } 261 }
262 262
263 // cerr << "PluginRDFIndexer::indexURL: url = <" << urlString.toStdString() << ">" << endl; 263 // cerr << "PluginRDFIndexer::indexURL: url = <" << urlString.toStdString() << ">" << endl;
264 264 /*!!!
265 SimpleSPARQLQuery query 265 SimpleSPARQLQuery query
266 (localString, 266 (localString,
267 QString 267 QString
268 ( 268 (
269 " PREFIX vamp: <http://purl.org/ontology/vamp/> " 269 " PREFIX vamp: <http://purl.org/ontology/vamp/> "
291 " vamp:identifier ?library_id " 291 " vamp:identifier ?library_id "
292 " } " 292 " } "
293 " } " 293 " } "
294 ) 294 )
295 .arg(localString)); 295 .arg(localString));
296 */
297 SimpleSPARQLQuery query
298 (localString,
299 QString
300 (
301 " PREFIX vamp: <http://purl.org/ontology/vamp/> "
302
303 " SELECT ?plugin ?library ?plugin_id "
304 " FROM <%1> "
305
306 " WHERE { "
307 " ?plugin a vamp:Plugin . "
308 " ?plugin vamp:identifier ?plugin_id . "
309
310 " OPTIONAL { "
311 " ?library vamp:available_plugin ?plugin "
312 " } "
313 " } "
314 )
315 .arg(localString));
296 316
297 SimpleSPARQLQuery::ResultList results = query.execute(); 317 SimpleSPARQLQuery::ResultList results = query.execute();
298 318
299 if (!query.isOK()) { 319 if (!query.isOK()) {
300 cerr << "ERROR: PluginRDFIndexer::indexURL: ERROR: Failed to index document at <" 320 cerr << "ERROR: PluginRDFIndexer::indexURL: ERROR: Failed to index document at <"
315 335
316 for (SimpleSPARQLQuery::ResultList::iterator i = results.begin(); 336 for (SimpleSPARQLQuery::ResultList::iterator i = results.begin();
317 i != results.end(); ++i) { 337 i != results.end(); ++i) {
318 338
319 QString pluginUri = (*i)["plugin"].value; 339 QString pluginUri = (*i)["plugin"].value;
320 QString soname = (*i)["library_id"].value; 340 //!!! QString soname = (*i)["library_id"].value;
341 QString soUri = (*i)["library"].value;
321 QString identifier = (*i)["plugin_id"].value; 342 QString identifier = (*i)["plugin_id"].value;
322 343
323 if (identifier == "") { 344 if (identifier == "") {
324 cerr << "PluginRDFIndexer::indexURL: NOTE: Document at <" 345 cerr << "PluginRDFIndexer::indexURL: NOTE: Document at <"
325 << urlString.toStdString() 346 << urlString.toStdString()
326 << "> fails to define any vamp:identifier for plugin <" 347 << "> fails to define any vamp:identifier for plugin <"
327 << pluginUri.toStdString() << ">" 348 << pluginUri.toStdString() << ">"
328 << endl; 349 << endl;
329 continue; 350 continue;
330 } 351 }
331 if (soname == "") { 352 if (soUri == "") {
332 cerr << "PluginRDFIndexer::indexURL: NOTE: Document at <" 353 cerr << "PluginRDFIndexer::indexURL: NOTE: Document at <"
333 << urlString.toStdString() << "> does not associate plugin <" 354 << urlString.toStdString() << "> does not associate plugin <"
334 << pluginUri.toStdString() << "> with any implementation library" 355 << pluginUri.toStdString() << "> with any implementation library"
335 << endl; 356 << endl;
336 continue; 357 continue;
337 } 358 }
359
360 QString sonameQuery =
361 QString(
362 " PREFIX vamp: <http://purl.org/ontology/vamp/> "
363 " SELECT ?library_id "
364 " FROM <%1> "
365 " WHERE { "
366 " <%2> vamp:identifier ?library_id "
367 " } "
368 )
369 .arg(localString)
370 .arg(soUri);
371
372 SimpleSPARQLQuery::Value sonameValue =
373 SimpleSPARQLQuery::singleResultQuery(localString, sonameQuery, "library_id");
374 QString soname = sonameValue.value;
375 if (soname == "") {
376 cerr << "PluginRDFIndexer::indexURL: NOTE: Document at <"
377 << urlString.toStdString() << "> omits identifier for library <"
378 << soUri.toStdString() << ">"
379 << endl;
380 continue;
381 }
382
383
338 /* 384 /*
339 cerr << "PluginRDFIndexer::indexURL: Document for plugin \"" 385 cerr << "PluginRDFIndexer::indexURL: Document for plugin \""
340 << soname.toStdString() << ":" << identifier.toStdString() 386 << soname.toStdString() << ":" << identifier.toStdString()
341 << "\" (uri <" << pluginUri.toStdString() << ">) is at url <" 387 << "\" (uri <" << pluginUri.toStdString() << ">) is at url <"
342 << urlString.toStdString() << ">" << endl; 388 << urlString.toStdString() << ">" << endl;