# HG changeset patch # User Chris Cannam # Date 1326126534 0 # Node ID f3fd2988fc9b2e871cd3f44b61cfe5e3ed36c7e2 # Parent 7f76499ef4f2b961c069944c50467e685b38d1a1 Fix incorrect query structure for output type URIs. This led to some output RDF features being written with type URIs intended for different outputs. Also revert some SVDEBUGs to cerrs -- they are intended as user-visible errors or warnings rather than debug diff -r 7f76499ef4f2 -r f3fd2988fc9b rdf/PluginRDFDescription.cpp --- a/rdf/PluginRDFDescription.cpp Mon Oct 17 11:57:25 2011 +0100 +++ b/rdf/PluginRDFDescription.cpp Mon Jan 09 16:28:54 2012 +0000 @@ -278,19 +278,10 @@ ( " PREFIX vamp: " - " SELECT ?output ?output_id ?output_type ?unit " + " SELECT ?output " " WHERE { " - " <%1> vamp:output ?output . " - - " ?output vamp:identifier ?output_id ; " - " a ?output_type . " - - " OPTIONAL { " - " ?output vamp:unit ?unit " - " } . " - " } " ) .arg(m_pluginUri)); @@ -305,7 +296,7 @@ } if (results.empty()) { - SVDEBUG << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <" + cerr << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <" << m_pluginUri << ">" << endl; return false; } @@ -316,9 +307,48 @@ for (int i = 0; i < results.size(); ++i) { + if (results[i]["output"].type != SimpleSPARQLQuery::URIValue || + results[i]["output"].value == "") { + cerr << "ERROR: PluginRDFDescription::indexURL: No valid URI for output " << i << " of plugin <" << m_pluginUri << ">" << endl; + return false; + } + QString outputUri = results[i]["output"].value; - QString outputId = results[i]["output_id"].value; - QString outputType = results[i]["output_type"].value; + + SimpleSPARQLQuery::Value v; + + v = SimpleSPARQLQuery::singleResultQuery + (m, + QString(" PREFIX vamp: " + " SELECT ?output_id " + " WHERE { <%1> vamp:identifier ?output_id } ") + .arg(outputUri), "output_id"); + + if (v.type != SimpleSPARQLQuery::LiteralValue || v.value == "") { + cerr << "ERROR: PluginRDFDescription::indexURL: No identifier for output <" << outputUri << ">" << endl; + return false; + } + QString outputId = v.value; + + v = SimpleSPARQLQuery::singleResultQuery + (m, + QString(" PREFIX vamp: " + " SELECT ?output_type " + " WHERE { <%1> a ?output_type } ") + .arg(outputUri), "output_type"); + + QString outputType; + if (v.type == SimpleSPARQLQuery::URIValue) outputType = v.value; + + v = SimpleSPARQLQuery::singleResultQuery + (m, + QString(" PREFIX vamp: " + " SELECT ?unit " + " WHERE { <%1> vamp:unit ?unit } ") + .arg(outputUri), "unit"); + + QString outputUnit; + if (v.type == SimpleSPARQLQuery::LiteralValue) outputUnit = v.value; m_outputUriMap[outputId] = outputUri; @@ -332,23 +362,16 @@ m_outputDispositions[outputId] = OutputDispositionUnknown; } - if (results[i]["unit"].type == SimpleSPARQLQuery::LiteralValue) { - - QString unit = results[i]["unit"].value; - - if (unit != "") { - m_outputUnitMap[outputId] = unit; - } + if (outputUnit != "") { + m_outputUnitMap[outputId] = outputUnit; } - SimpleSPARQLQuery::Value v; - v = SimpleSPARQLQuery::singleResultQuery (m, QString(" PREFIX vamp: " " PREFIX dc: " " SELECT ?title " - " WHERE { <%2> dc:title ?title } ") + " WHERE { <%1> dc:title ?title } ") .arg(outputUri), "title"); if (v.type == SimpleSPARQLQuery::LiteralValue && v.value != "") { @@ -357,8 +380,8 @@ QString queryTemplate = QString(" PREFIX vamp: " - " SELECT ?%3 " - " WHERE { <%2> vamp:computes_%3 ?%3 } ") + " SELECT ?%2 " + " WHERE { <%1> vamp:computes_%2 ?%2 } ") .arg(outputUri); v = SimpleSPARQLQuery::singleResultQuery diff -r 7f76499ef4f2 -r f3fd2988fc9b rdf/PluginRDFIndexer.cpp --- a/rdf/PluginRDFIndexer.cpp Mon Oct 17 11:57:25 2011 +0100 +++ b/rdf/PluginRDFIndexer.cpp Mon Jan 09 16:28:54 2012 +0000 @@ -80,7 +80,7 @@ // rdf extension. for (vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { - + QDir dir(i->c_str()); if (!dir.exists()) continue; @@ -89,6 +89,7 @@ for (QStringList::const_iterator j = entries.begin(); j != entries.end(); ++j) { + QFileInfo fi(dir.filePath(*j)); pullFile(fi.absoluteFilePath()); } @@ -98,6 +99,7 @@ for (QStringList::const_iterator j = subdirs.begin(); j != subdirs.end(); ++j) { + QDir subdir(dir.filePath(*j)); if (subdir.exists()) { entries = subdir.entryList @@ -293,7 +295,7 @@ } if (results.empty()) { - SVDEBUG << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl; + cerr << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl; return false; } @@ -308,13 +310,13 @@ QString identifier = (*i)["plugin_id"].value; if (identifier == "") { - SVDEBUG << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <" + cerr << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <" << pluginUri << ">" << endl; continue; } if (soUri == "") { - SVDEBUG << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <" + cerr << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <" << pluginUri << ">" << endl; continue; @@ -334,7 +336,7 @@ SimpleSPARQLQuery::singleResultQuery(m, sonameQuery, "library_id"); QString soname = sonameValue.value; if (soname == "") { - SVDEBUG << "PluginRDFIndexer::reindex: NOTE: No identifier for library <" + cerr << "PluginRDFIndexer::reindex: NOTE: No identifier for library <" << soUri << ">" << endl; continue; @@ -355,7 +357,7 @@ if (pluginUri != "") { if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) { - SVDEBUG << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl; + cerr << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl; cerr << " 1. Plugin id \"" << m_uriToIdMap[pluginUri] << "\"" << endl; cerr << " 2. Plugin id \"" << pluginId << "\"" << endl; cerr << "both claim URI <" << pluginUri << ">" << endl; @@ -366,7 +368,7 @@ } if (!foundSomething) { - SVDEBUG << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl; + cerr << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl; } return addedSomething; diff -r 7f76499ef4f2 -r f3fd2988fc9b rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Mon Oct 17 11:57:25 2011 +0100 +++ b/rdf/RDFFeatureWriter.cpp Mon Jan 09 16:28:54 2012 +0000 @@ -141,10 +141,10 @@ m_rdfDescriptions[pluginId] = PluginRDFDescription(pluginId); if (m_rdfDescriptions[pluginId].haveDescription()) { - SVDEBUG << "NOTE: Have RDF description for plugin ID \"" + cerr << "NOTE: Have RDF description for plugin ID \"" << pluginId << "\"" << endl; } else { - SVDEBUG << "NOTE: No RDF description for plugin ID \"" + cerr << "NOTE: No RDF description for plugin ID \"" << pluginId << "\"" << endl; if (!m_network) { cerr << " Consider using the --rdf-network option to retrieve plugin descriptions" << endl; diff -r 7f76499ef4f2 -r f3fd2988fc9b rdf/SimpleSPARQLQuery.cpp --- a/rdf/SimpleSPARQLQuery.cpp Mon Oct 17 11:57:25 2011 +0100 +++ b/rdf/SimpleSPARQLQuery.cpp Mon Jan 09 16:28:54 2012 +0000 @@ -619,7 +619,7 @@ SimpleSPARQLQuery q(type, query); ResultList results = q.execute(); if (!q.isOK()) { - SVDEBUG << "SimpleSPARQLQuery::singleResultQuery: ERROR: " + cerr << "SimpleSPARQLQuery::singleResultQuery: ERROR: " << q.getErrorString() << endl; return Value(); }