Mercurial > hg > svcore
comparison rdf/RDFImporter.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 | af7b6e55895b |
children | 76f6971c8433 |
comparison
equal
deleted
inserted
replaced
519:21f86744d38e | 520:e340b2fb9471 |
---|---|
33 #include "data/model/TextModel.h" | 33 #include "data/model/TextModel.h" |
34 #include "data/model/RegionModel.h" | 34 #include "data/model/RegionModel.h" |
35 #include "data/model/WaveFileModel.h" | 35 #include "data/model/WaveFileModel.h" |
36 | 36 |
37 #include "data/fileio/FileSource.h" | 37 #include "data/fileio/FileSource.h" |
38 #include "data/fileio/CachedFile.h" | |
38 | 39 |
39 using std::cerr; | 40 using std::cerr; |
40 using std::endl; | 41 using std::endl; |
41 | 42 |
42 class RDFImporterImpl | 43 class RDFImporterImpl |
56 QString m_uristring; | 57 QString m_uristring; |
57 QString m_errorString; | 58 QString m_errorString; |
58 std::map<QString, Model *> m_audioModelMap; | 59 std::map<QString, Model *> m_audioModelMap; |
59 int m_sampleRate; | 60 int m_sampleRate; |
60 | 61 |
62 static bool m_prefixesLoaded; | |
63 static void loadPrefixes(ProgressReporter *reporter); | |
64 | |
61 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *); | 65 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *); |
62 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *); | 66 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *); |
63 void getDataModelsDense(std::vector<Model *> &, ProgressReporter *); | 67 void getDataModelsDense(std::vector<Model *> &, ProgressReporter *); |
64 | 68 |
65 void getDenseModelTitle(Model *, QString, QString); | 69 void getDenseModelTitle(Model *, QString, QString); |
69 int &hopSize, int &width, int &height); | 73 int &hopSize, int &width, int &height); |
70 | 74 |
71 void fillModel(Model *, long, long, bool, std::vector<float> &, QString); | 75 void fillModel(Model *, long, long, bool, std::vector<float> &, QString); |
72 }; | 76 }; |
73 | 77 |
78 bool RDFImporterImpl::m_prefixesLoaded = false; | |
74 | 79 |
75 QString | 80 QString |
76 RDFImporter::getKnownExtensions() | 81 RDFImporter::getKnownExtensions() |
77 { | 82 { |
78 return "*.rdf *.n3 *.ttl"; | 83 return "*.rdf *.n3 *.ttl"; |
136 } | 141 } |
137 | 142 |
138 std::vector<Model *> | 143 std::vector<Model *> |
139 RDFImporterImpl::getDataModels(ProgressReporter *reporter) | 144 RDFImporterImpl::getDataModels(ProgressReporter *reporter) |
140 { | 145 { |
146 loadPrefixes(reporter); | |
147 | |
141 std::vector<Model *> models; | 148 std::vector<Model *> models; |
142 | 149 |
143 getDataModelsAudio(models, reporter); | 150 getDataModelsAudio(models, reporter); |
144 | 151 |
145 if (m_sampleRate == 0) { | 152 if (m_sampleRate == 0) { |
661 haveTime = true; | 668 haveTime = true; |
662 haveDuration = true; | 669 haveDuration = true; |
663 } else { | 670 } else { |
664 QString timestring = SimpleSPARQLQuery::singleResultQuery | 671 QString timestring = SimpleSPARQLQuery::singleResultQuery |
665 (s, timeQueryString.arg(thinguri), "time").value; | 672 (s, timeQueryString.arg(thinguri), "time").value; |
673 // std::cerr << "timestring = " << timestring.toStdString() << std::endl; | |
666 if (timestring != "") { | 674 if (timestring != "") { |
667 time = RealTime::fromXsdDuration(timestring.toStdString()); | 675 time = RealTime::fromXsdDuration(timestring.toStdString()); |
668 haveTime = true; | 676 haveTime = true; |
669 } | 677 } |
670 } | 678 } |
961 } | 969 } |
962 | 970 |
963 SimpleSPARQLQuery::closeSingleSource(url); | 971 SimpleSPARQLQuery::closeSingleSource(url); |
964 } | 972 } |
965 | 973 |
966 | 974 void |
975 RDFImporterImpl::loadPrefixes(ProgressReporter *reporter) | |
976 { | |
977 return; | |
978 //!!! | |
979 if (m_prefixesLoaded) return; | |
980 const char *prefixes[] = { | |
981 "http://purl.org/NET/c4dm/event.owl", | |
982 "http://purl.org/NET/c4dm/timeline.owl", | |
983 "http://purl.org/ontology/mo/", | |
984 "http://purl.org/ontology/af/", | |
985 "http://www.w3.org/2000/01/rdf-schema", | |
986 "http://purl.org/dc/elements/1.1/", | |
987 }; | |
988 for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i) { | |
989 CachedFile cf(prefixes[i], reporter, "application/rdf+xml"); | |
990 if (!cf.isOK()) continue; | |
991 SimpleSPARQLQuery::addSourceToModel | |
992 (QUrl::fromLocalFile(cf.getLocalFilename()).toString()); | |
993 } | |
994 m_prefixesLoaded = true; | |
995 } |