Mercurial > hg > svcore
comparison rdf/PluginRDFIndexer.cpp @ 730:27c861cce97b dataquay
Further fixes for Dataquay compatibility
author | Chris Cannam |
---|---|
date | Mon, 21 May 2012 14:33:35 +0100 |
parents | 211efc770335 |
children | 760feced8380 |
comparison
equal
deleted
inserted
replaced
729:11289d40a57a | 730:27c861cce97b |
---|---|
83 void | 83 void |
84 PluginRDFIndexer::indexInstalledURLs() | 84 PluginRDFIndexer::indexInstalledURLs() |
85 { | 85 { |
86 vector<string> paths = PluginHostAdapter::getPluginPath(); | 86 vector<string> paths = PluginHostAdapter::getPluginPath(); |
87 | 87 |
88 // std::cerr << "\nPluginRDFIndexer::indexInstalledURLs: pid is " << getpid() << std::endl; | |
89 | |
88 QStringList filters; | 90 QStringList filters; |
89 filters << "*.n3"; | 91 filters << "*.n3"; |
90 filters << "*.N3"; | 92 filters << "*.N3"; |
91 filters << "*.rdf"; | 93 filters << "*.rdf"; |
92 filters << "*.RDF"; | 94 filters << "*.RDF"; |
256 bool | 258 bool |
257 PluginRDFIndexer::pullURL(QString urlString) | 259 PluginRDFIndexer::pullURL(QString urlString) |
258 { | 260 { |
259 Profiler profiler("PluginRDFIndexer::indexURL"); | 261 Profiler profiler("PluginRDFIndexer::indexURL"); |
260 | 262 |
261 // SVDEBUG << "PluginRDFIndexer::indexURL(" << urlString << ")" << endl; | 263 // std::cerr << "PluginRDFIndexer::indexURL(" << urlString.toStdString() << ")" << std::endl; |
262 | 264 |
263 QMutexLocker locker(&m_mutex); | 265 QMutexLocker locker(&m_mutex); |
264 | 266 |
265 QUrl local = urlString; | 267 QUrl local = urlString; |
266 | 268 |
272 return false; | 274 return false; |
273 } | 275 } |
274 | 276 |
275 local = QUrl::fromLocalFile(cf.getLocalFilename()); | 277 local = QUrl::fromLocalFile(cf.getLocalFilename()); |
276 | 278 |
279 } else if (urlString.startsWith("file:")) { | |
280 | |
281 local = QUrl(urlString); | |
282 | |
277 } else { | 283 } else { |
278 | 284 |
279 local = QUrl::fromLocalFile(urlString); | 285 local = QUrl::fromLocalFile(urlString); |
280 } | 286 } |
281 | 287 |
282 try { | 288 try { |
283 m_index->import(local, BasicStore::ImportFailOnDuplicates); | 289 m_index->import(local, BasicStore::ImportFailOnDuplicates); |
284 } catch (RDFDuplicateImportException &e) { | 290 } catch (RDFDuplicateImportException &e) { |
291 cerr << e.what() << endl; | |
285 cerr << "PluginRDFIndexer::pullURL: Document at " << urlString | 292 cerr << "PluginRDFIndexer::pullURL: Document at " << urlString |
286 << " duplicates triples found in earlier loaded document" << endl; | 293 << " duplicates triples found in earlier loaded document -- skipping it" << endl; |
287 return false; | 294 return false; |
288 } catch (RDFException &e) { | 295 } catch (RDFException &e) { |
296 cerr << e.what() << endl; | |
289 cerr << "PluginRDFIndexer::pullURL: Failed to import document from " | 297 cerr << "PluginRDFIndexer::pullURL: Failed to import document from " |
290 << urlString << ": " << e.what() << endl; | 298 << urlString << ": " << e.what() << endl; |
291 return false; | 299 return false; |
292 } | 300 } |
293 return true; | 301 return true; |
295 | 303 |
296 bool | 304 bool |
297 PluginRDFIndexer::reindex() | 305 PluginRDFIndexer::reindex() |
298 { | 306 { |
299 Triples tt = m_index->match | 307 Triples tt = m_index->match |
300 (Triple(Node(), "a", m_index->expand("vamp:Plugin"))); | 308 (Triple(Node(), Uri("a"), m_index->expand("vamp:Plugin"))); |
301 Nodes plugins = tt.a(); | 309 Nodes plugins = tt.subjects(); |
302 | 310 |
303 bool foundSomething = false; | 311 bool foundSomething = false; |
304 bool addedSomething = false; | 312 bool addedSomething = false; |
305 | 313 |
306 foreach (Node plugin, plugins) { | 314 foreach (Node plugin, plugins) { |
309 cerr << "PluginRDFIndexer::reindex: Plugin has no URI: node is " | 317 cerr << "PluginRDFIndexer::reindex: Plugin has no URI: node is " |
310 << plugin << endl; | 318 << plugin << endl; |
311 continue; | 319 continue; |
312 } | 320 } |
313 | 321 |
314 Triple idt = m_index->matchFirst | 322 Node idn = m_index->complete |
315 (Triple(plugin, "vamp:identifier", Node())); | 323 (Triple(plugin, m_index->expand("vamp:identifier"), Node())); |
316 | 324 |
317 if (idt.c.type != Node::Literal) { | 325 if (idn.type != Node::Literal) { |
318 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin | 326 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin |
319 << " lacks vamp:identifier literal" << endl; | 327 << " lacks vamp:identifier literal" << endl; |
320 continue; | 328 continue; |
321 } | 329 } |
322 | 330 |
323 Triple libt = m_index->matchFirst | 331 Node libn = m_index->complete |
324 (Triple(Node(), "vamp:available_plugin", plugin)); | 332 (Triple(Node(), m_index->expand("vamp:available_plugin"), plugin)); |
325 | 333 |
326 if (libt.a.type != Node::URI) { | 334 if (libn.type != Node::URI) { |
327 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin | 335 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin |
328 << " is not vamp:available_plugin in any library" << endl; | 336 << " is not vamp:available_plugin in any library" << endl; |
329 continue; | 337 continue; |
330 } | 338 } |
331 | 339 |
332 Triple sot = m_index->matchFirst | 340 Node son = m_index->complete |
333 (Triple(libt.a, "vamp:identifier", Node())); | 341 (Triple(libn, m_index->expand("vamp:identifier"), Node())); |
334 | 342 |
335 if (sot.c.type != Node::Literal) { | 343 if (son.type != Node::Literal) { |
336 cerr << "PluginRDFIndexer::reindex: Library " << libt.a | 344 cerr << "PluginRDFIndexer::reindex: Library " << libn |
337 << " lacks vamp:identifier for soname" << endl; | 345 << " lacks vamp:identifier for soname" << endl; |
338 continue; | 346 continue; |
339 } | 347 } |
340 | 348 |
341 QString pluginUri = plugin.value; | 349 QString pluginUri = plugin.value; |
342 QString identifier = idt.c.value; | 350 QString identifier = idn.value; |
343 QString soname = sot.c.value; | 351 QString soname = son.value; |
344 | 352 |
345 QString pluginId = PluginIdentifier::createIdentifier | 353 QString pluginId = PluginIdentifier::createIdentifier |
346 ("vamp", soname, identifier); | 354 ("vamp", soname, identifier); |
347 | 355 |
348 foundSomething = true; | 356 foundSomething = true; |