comparison rdf/RDFTransformFactory.cpp @ 503:3176aade1a03

* Make RDFTransformFactory::writeTransformToRDF write out partial library and plugin descriptions adequate to identify the plugin on disk, if no RDF description for the plugin has been found
author Chris Cannam
date Fri, 05 Dec 2008 09:40:42 +0000
parents 81963c51b488
children 1b8c748fd7ea
comparison
equal deleted inserted replaced
502:bd7c46636bd0 503:3176aade1a03
25 25
26 #include "SimpleSPARQLQuery.h" 26 #include "SimpleSPARQLQuery.h"
27 #include "PluginRDFIndexer.h" 27 #include "PluginRDFIndexer.h"
28 #include "PluginRDFDescription.h" 28 #include "PluginRDFDescription.h"
29 #include "base/ProgressReporter.h" 29 #include "base/ProgressReporter.h"
30 #include "plugin/PluginIdentifier.h"
30 31
31 #include "transform/TransformFactory.h" 32 #include "transform/TransformFactory.h"
32 33
33 using std::cerr; 34 using std::cerr;
34 using std::endl; 35 using std::endl;
379 QString uri) 380 QString uri)
380 { 381 {
381 QString str; 382 QString str;
382 QTextStream s(&str); 383 QTextStream s(&str);
383 384
384 // assumes the usual prefixes are available 385 // assumes the usual prefixes are available; requires that uri be
385 386 // a local fragment (e.g. ":transform") rather than a uri enclosed
386 s << uri << " a vamp:Transform ;" << endl; 387 // in <>, so that we can suffix it if need be
387 388
388 QString pluginId = transform.getPluginIdentifier(); 389 QString pluginId = transform.getPluginIdentifier();
389 QString pluginUri = PluginRDFIndexer::getInstance()->getURIForPluginId(pluginId); 390 QString pluginUri = PluginRDFIndexer::getInstance()->getURIForPluginId(pluginId);
390 391
392 if (pluginUri != "") {
393 s << uri << " a vamp:Transform ;" << endl;
394 s << " vamp:plugin <" << pluginUri << "> ;" << endl;
395 } else {
396 std::cerr << "WARNING: RDFTransformFactory::writeTransformToRDF: No plugin URI available for plugin id \"" << pluginId.toStdString() << "\", writing synthetic plugin and library resources" << std::endl;
397 QString type, soname, label;
398 PluginIdentifier::parseIdentifier(pluginId, type, soname, label);
399 s << uri << "_plugin a vamp:Plugin ;" << endl;
400 s << " vamp:identifier \"" << label << "\" .\n" << endl;
401 s << uri << "_library a vamp:PluginLibrary ;" << endl;
402 s << " vamp:identifier \"" << soname << "\" ;" << endl;
403 s << " vamp:available_plugin " << uri << "_plugin .\n" << endl;
404 s << uri << " a vamp:Transform ;" << endl;
405 s << " vamp:plugin " << uri << "_plugin ;" << endl;
406 }
407
391 PluginRDFDescription description(pluginId); 408 PluginRDFDescription description(pluginId);
392 QString outputUri = description.getOutputUri(transform.getOutput()); 409 QString outputId = transform.getOutput();
410 QString outputUri = description.getOutputUri(outputId);
393 411
394 if (transform.getOutput() != "" && outputUri == "") { 412 if (transform.getOutput() != "" && outputUri == "") {
395 std::cerr << "WARNING: RDFTransformFactory::writeTransformToRDF: No output URI available for transform output id \"" << transform.getOutput().toStdString() << "\"" << std::endl; 413 std::cerr << "WARNING: RDFTransformFactory::writeTransformToRDF: No output URI available for transform output id \"" << transform.getOutput().toStdString() << "\", writing a synthetic output resource" << std::endl;
396 } 414 }
397
398 s << " vamp:plugin <" << pluginUri << "> ;" << endl;
399 415
400 if (transform.getStepSize() != 0) { 416 if (transform.getStepSize() != 0) {
401 s << " vamp:step_size \"" << transform.getStepSize() << "\"^^xsd:int ; " << endl; 417 s << " vamp:step_size \"" << transform.getStepSize() << "\"^^xsd:int ; " << endl;
402 } 418 }
403 if (transform.getBlockSize() != 0) { 419 if (transform.getBlockSize() != 0) {
430 s << " ] ;" << endl; 446 s << " ] ;" << endl;
431 } 447 }
432 448
433 if (outputUri != "") { 449 if (outputUri != "") {
434 s << " vamp:output <" << outputUri << "> ." << endl; 450 s << " vamp:output <" << outputUri << "> ." << endl;
451 } else if (outputId != "") {
452 s << " vamp:output [ vamp:identifier \"" << outputId << "\" ] ." << endl;
435 } else { 453 } else {
436 s << " ." << endl; 454 s << " ." << endl;
437 } 455 }
438 456
439 return str; 457 return str;