Mercurial > hg > svcore
comparison rdf/PluginRDFIndexer.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
688:be43b2fe68e8 | 689:573d45e9487b |
---|---|
115 } | 115 } |
116 | 116 |
117 bool | 117 bool |
118 PluginRDFIndexer::indexConfiguredURLs() | 118 PluginRDFIndexer::indexConfiguredURLs() |
119 { | 119 { |
120 std::cerr << "PluginRDFIndexer::indexConfiguredURLs" << std::endl; | 120 DEBUG << "PluginRDFIndexer::indexConfiguredURLs" << endl; |
121 | 121 |
122 QSettings settings; | 122 QSettings settings; |
123 settings.beginGroup("RDF"); | 123 settings.beginGroup("RDF"); |
124 | 124 |
125 QString indexKey("rdf-indices"); | 125 QString indexKey("rdf-indices"); |
127 | 127 |
128 for (int i = 0; i < indices.size(); ++i) { | 128 for (int i = 0; i < indices.size(); ++i) { |
129 | 129 |
130 QString index = indices[i]; | 130 QString index = indices[i]; |
131 | 131 |
132 std::cerr << "PluginRDFIndexer::indexConfiguredURLs: index url is " | 132 DEBUG << "PluginRDFIndexer::indexConfiguredURLs: index url is " |
133 << index.toStdString() << std::endl; | 133 << index << endl; |
134 | 134 |
135 CachedFile cf(index); | 135 CachedFile cf(index); |
136 if (!cf.isOK()) continue; | 136 if (!cf.isOK()) continue; |
137 | 137 |
138 FileSource indexSource(cf.getLocalFilename()); | 138 FileSource indexSource(cf.getLocalFilename()); |
141 if (!reader.isOK()) continue; | 141 if (!reader.isOK()) continue; |
142 | 142 |
143 PlaylistFileReader::Playlist list = reader.load(); | 143 PlaylistFileReader::Playlist list = reader.load(); |
144 for (PlaylistFileReader::Playlist::const_iterator j = list.begin(); | 144 for (PlaylistFileReader::Playlist::const_iterator j = list.begin(); |
145 j != list.end(); ++j) { | 145 j != list.end(); ++j) { |
146 std::cerr << "PluginRDFIndexer::indexConfiguredURLs: url is " | 146 DEBUG << "PluginRDFIndexer::indexConfiguredURLs: url is " |
147 << j->toStdString() << std::endl; | 147 << j->toStdString() << endl; |
148 pullURL(*j); | 148 pullURL(*j); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 QString urlListKey("rdf-urls"); | 152 QString urlListKey("rdf-urls"); |
184 // the uri as a document URL and reading that if possible. | 184 // the uri as a document URL and reading that if possible. |
185 | 185 |
186 // Because we may want to refer to this document again, we | 186 // Because we may want to refer to this document again, we |
187 // cache it locally if it turns out to exist. | 187 // cache it locally if it turns out to exist. |
188 | 188 |
189 cerr << "PluginRDFIndexer::getIdForPluginURI: NOTE: Failed to find a local RDF document describing plugin <" << uri.toStdString() << ">: attempting to retrieve one remotely by guesswork" << endl; | 189 cerr << "PluginRDFIndexer::getIdForPluginURI: NOTE: Failed to find a local RDF document describing plugin <" << uri << ">: attempting to retrieve one remotely by guesswork" << endl; |
190 | 190 |
191 QString baseUrl = QUrl(uri).toString(QUrl::RemoveFragment); | 191 QString baseUrl = QUrl(uri).toString(QUrl::RemoveFragment); |
192 | 192 |
193 indexURL(baseUrl); | 193 indexURL(baseUrl); |
194 | 194 |
239 { | 239 { |
240 Profiler profiler("PluginRDFIndexer::indexURL"); | 240 Profiler profiler("PluginRDFIndexer::indexURL"); |
241 | 241 |
242 loadPrefixes(); | 242 loadPrefixes(); |
243 | 243 |
244 // std::cerr << "PluginRDFIndexer::indexURL(" << urlString.toStdString() << ")" << std::endl; | 244 // DEBUG << "PluginRDFIndexer::indexURL(" << urlString << ")" << endl; |
245 | 245 |
246 QMutexLocker locker(&m_mutex); | 246 QMutexLocker locker(&m_mutex); |
247 | 247 |
248 QString localString = urlString; | 248 QString localString = urlString; |
249 | 249 |
286 | 286 |
287 SimpleSPARQLQuery::ResultList results = query.execute(); | 287 SimpleSPARQLQuery::ResultList results = query.execute(); |
288 | 288 |
289 if (!query.isOK()) { | 289 if (!query.isOK()) { |
290 cerr << "ERROR: PluginRDFIndexer::reindex: ERROR: Failed to query plugins from model: " | 290 cerr << "ERROR: PluginRDFIndexer::reindex: ERROR: Failed to query plugins from model: " |
291 << query.getErrorString().toStdString() << endl; | 291 << query.getErrorString() << endl; |
292 return false; | 292 return false; |
293 } | 293 } |
294 | 294 |
295 if (results.empty()) { | 295 if (results.empty()) { |
296 cerr << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl; | 296 DEBUG << "PluginRDFIndexer::reindex: NOTE: no vamp:Plugin resources found in indexed documents" << endl; |
297 return false; | 297 return false; |
298 } | 298 } |
299 | 299 |
300 bool foundSomething = false; | 300 bool foundSomething = false; |
301 bool addedSomething = false; | 301 bool addedSomething = false; |
306 QString pluginUri = (*i)["plugin"].value; | 306 QString pluginUri = (*i)["plugin"].value; |
307 QString soUri = (*i)["library"].value; | 307 QString soUri = (*i)["library"].value; |
308 QString identifier = (*i)["plugin_id"].value; | 308 QString identifier = (*i)["plugin_id"].value; |
309 | 309 |
310 if (identifier == "") { | 310 if (identifier == "") { |
311 cerr << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <" | 311 DEBUG << "PluginRDFIndexer::reindex: NOTE: No vamp:identifier for plugin <" |
312 << pluginUri.toStdString() << ">" | 312 << pluginUri << ">" |
313 << endl; | 313 << endl; |
314 continue; | 314 continue; |
315 } | 315 } |
316 if (soUri == "") { | 316 if (soUri == "") { |
317 cerr << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <" | 317 DEBUG << "PluginRDFIndexer::reindex: NOTE: No implementation library for plugin <" |
318 << pluginUri.toStdString() << ">" | 318 << pluginUri << ">" |
319 << endl; | 319 << endl; |
320 continue; | 320 continue; |
321 } | 321 } |
322 | 322 |
323 QString sonameQuery = | 323 QString sonameQuery = |
332 | 332 |
333 SimpleSPARQLQuery::Value sonameValue = | 333 SimpleSPARQLQuery::Value sonameValue = |
334 SimpleSPARQLQuery::singleResultQuery(m, sonameQuery, "library_id"); | 334 SimpleSPARQLQuery::singleResultQuery(m, sonameQuery, "library_id"); |
335 QString soname = sonameValue.value; | 335 QString soname = sonameValue.value; |
336 if (soname == "") { | 336 if (soname == "") { |
337 cerr << "PluginRDFIndexer::reindex: NOTE: No identifier for library <" | 337 DEBUG << "PluginRDFIndexer::reindex: NOTE: No identifier for library <" |
338 << soUri.toStdString() << ">" | 338 << soUri << ">" |
339 << endl; | 339 << endl; |
340 continue; | 340 continue; |
341 } | 341 } |
342 | 342 |
343 QString pluginId = PluginIdentifier::createIdentifier | 343 QString pluginId = PluginIdentifier::createIdentifier |
353 | 353 |
354 addedSomething = true; | 354 addedSomething = true; |
355 | 355 |
356 if (pluginUri != "") { | 356 if (pluginUri != "") { |
357 if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) { | 357 if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) { |
358 cerr << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl; | 358 DEBUG << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl; |
359 cerr << " 1. Plugin id \"" << m_uriToIdMap[pluginUri].toStdString() << "\"" << endl; | 359 cerr << " 1. Plugin id \"" << m_uriToIdMap[pluginUri] << "\"" << endl; |
360 cerr << " 2. Plugin id \"" << pluginId.toStdString() << "\"" << endl; | 360 cerr << " 2. Plugin id \"" << pluginId << "\"" << endl; |
361 cerr << "both claim URI <" << pluginUri.toStdString() << ">" << endl; | 361 cerr << "both claim URI <" << pluginUri << ">" << endl; |
362 } else { | 362 } else { |
363 m_uriToIdMap[pluginUri] = pluginId; | 363 m_uriToIdMap[pluginUri] = pluginId; |
364 } | 364 } |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 if (!foundSomething) { | 368 if (!foundSomething) { |
369 cerr << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl; | 369 DEBUG << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl; |
370 } | 370 } |
371 | 371 |
372 return addedSomething; | 372 return addedSomething; |
373 } | 373 } |
374 | 374 |