comparison rdf/PluginRDFIndexer.cpp @ 520:e340b2fb9471

* Make FileSource able to indicate its preferred content type (e.g. application/rdf+xml in preference to text/html for rdf content) * Temp directory on Windows -- make $HOME expand to homedrive+homepath instead of user profile location (which may be networked)
author Chris Cannam
date Thu, 11 Dec 2008 15:18:10 +0000
parents 1b8c748fd7ea
children b4a8d8221eaf
comparison
equal deleted inserted replaced
519:21f86744d38e 520:e340b2fb9471
41 using Vamp::PluginHostAdapter; 41 using Vamp::PluginHostAdapter;
42 42
43 PluginRDFIndexer * 43 PluginRDFIndexer *
44 PluginRDFIndexer::m_instance = 0; 44 PluginRDFIndexer::m_instance = 0;
45 45
46 bool
47 PluginRDFIndexer::m_prefixesLoaded = false;
48
46 PluginRDFIndexer * 49 PluginRDFIndexer *
47 PluginRDFIndexer::getInstance() 50 PluginRDFIndexer::getInstance()
48 { 51 {
49 if (!m_instance) m_instance = new PluginRDFIndexer(); 52 if (!m_instance) m_instance = new PluginRDFIndexer();
50 return m_instance; 53 return m_instance;
234 bool 237 bool
235 PluginRDFIndexer::pullURL(QString urlString) 238 PluginRDFIndexer::pullURL(QString urlString)
236 { 239 {
237 Profiler profiler("PluginRDFIndexer::indexURL"); 240 Profiler profiler("PluginRDFIndexer::indexURL");
238 241
242 loadPrefixes();
243
239 // std::cerr << "PluginRDFIndexer::indexURL(" << urlString.toStdString() << ")" << std::endl; 244 // std::cerr << "PluginRDFIndexer::indexURL(" << urlString.toStdString() << ")" << std::endl;
240 245
241 QMutexLocker locker(&m_mutex); 246 QMutexLocker locker(&m_mutex);
242 247
243 QString localString = urlString; 248 QString localString = urlString;
244 249
245 if (FileSource::isRemote(urlString) && 250 if (FileSource::isRemote(urlString) &&
246 FileSource::canHandleScheme(urlString)) { 251 FileSource::canHandleScheme(urlString)) {
247 252
248 CachedFile cf(urlString); 253 CachedFile cf(urlString, 0, "application/rdf+xml");
249 if (!cf.isOK()) { 254 if (!cf.isOK()) {
250 return false; 255 return false;
251 } 256 }
252 257
253 localString = QUrl::fromLocalFile(cf.getLocalFilename()).toString(); 258 localString = QUrl::fromLocalFile(cf.getLocalFilename()).toString();
365 } 370 }
366 371
367 return addedSomething; 372 return addedSomething;
368 } 373 }
369 374
370 375 void
371 376 PluginRDFIndexer::loadPrefixes()
377 {
378 return;
379 //!!!
380 if (m_prefixesLoaded) return;
381 const char *prefixes[] = {
382 "http://purl.org/ontology/vamp/"
383 };
384 for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i) {
385 CachedFile cf(prefixes[i], 0, "application/rdf+xml");
386 if (!cf.isOK()) continue;
387 SimpleSPARQLQuery::addSourceToModel
388 (QUrl::fromLocalFile(cf.getLocalFilename()).toString());
389 }
390 m_prefixesLoaded = true;
391 }
392
393