Mercurial > hg > svcore
comparison rdf/PluginRDFDescription.cpp @ 718:f3fd2988fc9b
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
author | Chris Cannam |
---|---|
date | Mon, 09 Jan 2012 16:28:54 +0000 |
parents | 1424aa29ae95 |
children | c789deb83bd4 |
comparison
equal
deleted
inserted
replaced
712:7f76499ef4f2 | 718:f3fd2988fc9b |
---|---|
276 (m, | 276 (m, |
277 QString | 277 QString |
278 ( | 278 ( |
279 " PREFIX vamp: <http://purl.org/ontology/vamp/> " | 279 " PREFIX vamp: <http://purl.org/ontology/vamp/> " |
280 | 280 |
281 " SELECT ?output ?output_id ?output_type ?unit " | 281 " SELECT ?output " |
282 | 282 |
283 " WHERE { " | 283 " WHERE { " |
284 | |
285 " <%1> vamp:output ?output . " | 284 " <%1> vamp:output ?output . " |
286 | |
287 " ?output vamp:identifier ?output_id ; " | |
288 " a ?output_type . " | |
289 | |
290 " OPTIONAL { " | |
291 " ?output vamp:unit ?unit " | |
292 " } . " | |
293 | |
294 " } " | 285 " } " |
295 ) | 286 ) |
296 .arg(m_pluginUri)); | 287 .arg(m_pluginUri)); |
297 | 288 |
298 SimpleSPARQLQuery::ResultList results = query.execute(); | 289 SimpleSPARQLQuery::ResultList results = query.execute(); |
303 << query.getErrorString() << endl; | 294 << query.getErrorString() << endl; |
304 return false; | 295 return false; |
305 } | 296 } |
306 | 297 |
307 if (results.empty()) { | 298 if (results.empty()) { |
308 SVDEBUG << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <" | 299 cerr << "ERROR: PluginRDFDescription::indexURL: NOTE: No outputs defined for <" |
309 << m_pluginUri << ">" << endl; | 300 << m_pluginUri << ">" << endl; |
310 return false; | 301 return false; |
311 } | 302 } |
312 | 303 |
313 // Note that an output may appear more than once, if it inherits | 304 // Note that an output may appear more than once, if it inherits |
314 // more than one type (e.g. DenseOutput and QuantizedOutput). So | 305 // more than one type (e.g. DenseOutput and QuantizedOutput). So |
315 // these results must accumulate | 306 // these results must accumulate |
316 | 307 |
317 for (int i = 0; i < results.size(); ++i) { | 308 for (int i = 0; i < results.size(); ++i) { |
318 | 309 |
310 if (results[i]["output"].type != SimpleSPARQLQuery::URIValue || | |
311 results[i]["output"].value == "") { | |
312 cerr << "ERROR: PluginRDFDescription::indexURL: No valid URI for output " << i << " of plugin <" << m_pluginUri << ">" << endl; | |
313 return false; | |
314 } | |
315 | |
319 QString outputUri = results[i]["output"].value; | 316 QString outputUri = results[i]["output"].value; |
320 QString outputId = results[i]["output_id"].value; | 317 |
321 QString outputType = results[i]["output_type"].value; | 318 SimpleSPARQLQuery::Value v; |
319 | |
320 v = SimpleSPARQLQuery::singleResultQuery | |
321 (m, | |
322 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " | |
323 " SELECT ?output_id " | |
324 " WHERE { <%1> vamp:identifier ?output_id } ") | |
325 .arg(outputUri), "output_id"); | |
326 | |
327 if (v.type != SimpleSPARQLQuery::LiteralValue || v.value == "") { | |
328 cerr << "ERROR: PluginRDFDescription::indexURL: No identifier for output <" << outputUri << ">" << endl; | |
329 return false; | |
330 } | |
331 QString outputId = v.value; | |
332 | |
333 v = SimpleSPARQLQuery::singleResultQuery | |
334 (m, | |
335 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " | |
336 " SELECT ?output_type " | |
337 " WHERE { <%1> a ?output_type } ") | |
338 .arg(outputUri), "output_type"); | |
339 | |
340 QString outputType; | |
341 if (v.type == SimpleSPARQLQuery::URIValue) outputType = v.value; | |
342 | |
343 v = SimpleSPARQLQuery::singleResultQuery | |
344 (m, | |
345 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " | |
346 " SELECT ?unit " | |
347 " WHERE { <%1> vamp:unit ?unit } ") | |
348 .arg(outputUri), "unit"); | |
349 | |
350 QString outputUnit; | |
351 if (v.type == SimpleSPARQLQuery::LiteralValue) outputUnit = v.value; | |
322 | 352 |
323 m_outputUriMap[outputId] = outputUri; | 353 m_outputUriMap[outputId] = outputUri; |
324 | 354 |
325 if (outputType.contains("DenseOutput")) { | 355 if (outputType.contains("DenseOutput")) { |
326 m_outputDispositions[outputId] = OutputDense; | 356 m_outputDispositions[outputId] = OutputDense; |
330 m_outputDispositions[outputId] = OutputTrackLevel; | 360 m_outputDispositions[outputId] = OutputTrackLevel; |
331 } else { | 361 } else { |
332 m_outputDispositions[outputId] = OutputDispositionUnknown; | 362 m_outputDispositions[outputId] = OutputDispositionUnknown; |
333 } | 363 } |
334 | 364 |
335 if (results[i]["unit"].type == SimpleSPARQLQuery::LiteralValue) { | 365 if (outputUnit != "") { |
336 | 366 m_outputUnitMap[outputId] = outputUnit; |
337 QString unit = results[i]["unit"].value; | 367 } |
338 | |
339 if (unit != "") { | |
340 m_outputUnitMap[outputId] = unit; | |
341 } | |
342 } | |
343 | |
344 SimpleSPARQLQuery::Value v; | |
345 | 368 |
346 v = SimpleSPARQLQuery::singleResultQuery | 369 v = SimpleSPARQLQuery::singleResultQuery |
347 (m, | 370 (m, |
348 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " | 371 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " |
349 " PREFIX dc: <http://purl.org/dc/elements/1.1/> " | 372 " PREFIX dc: <http://purl.org/dc/elements/1.1/> " |
350 " SELECT ?title " | 373 " SELECT ?title " |
351 " WHERE { <%2> dc:title ?title } ") | 374 " WHERE { <%1> dc:title ?title } ") |
352 .arg(outputUri), "title"); | 375 .arg(outputUri), "title"); |
353 | 376 |
354 if (v.type == SimpleSPARQLQuery::LiteralValue && v.value != "") { | 377 if (v.type == SimpleSPARQLQuery::LiteralValue && v.value != "") { |
355 m_outputNames[outputId] = v.value; | 378 m_outputNames[outputId] = v.value; |
356 } | 379 } |
357 | 380 |
358 QString queryTemplate = | 381 QString queryTemplate = |
359 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " | 382 QString(" PREFIX vamp: <http://purl.org/ontology/vamp/> " |
360 " SELECT ?%3 " | 383 " SELECT ?%2 " |
361 " WHERE { <%2> vamp:computes_%3 ?%3 } ") | 384 " WHERE { <%1> vamp:computes_%2 ?%2 } ") |
362 .arg(outputUri); | 385 .arg(outputUri); |
363 | 386 |
364 v = SimpleSPARQLQuery::singleResultQuery | 387 v = SimpleSPARQLQuery::singleResultQuery |
365 (m, queryTemplate.arg("event_type"), "event_type"); | 388 (m, queryTemplate.arg("event_type"), "event_type"); |
366 | 389 |