comparison rdf/RDFTransformFactory.cpp @ 1163:d094598f84bd

Better error reporting for transform load (from RDF and XML)
author Chris Cannam
date Thu, 25 Feb 2016 10:53:10 +0000
parents 7d003fe48225
children
comparison
equal deleted inserted replaced
1162:1dd98a5432cf 1163:d094598f84bd
127 } else { 127 } else {
128 qurl = QUrl::fromLocalFile(url); 128 qurl = QUrl::fromLocalFile(url);
129 } 129 }
130 m_store->import(qurl, BasicStore::ImportIgnoreDuplicates); 130 m_store->import(qurl, BasicStore::ImportIgnoreDuplicates);
131 m_isRDF = true; 131 m_isRDF = true;
132 } catch (...) { } 132 } catch (const std::exception &e) {
133 // The file is not RDF -- we report this by returning false
134 // from isRDF (because we have not reached the m_isRDF = true
135 // line above), but we also set the error string
136 m_errorString = e.what();
137 }
133 } 138 }
134 139
135 RDFTransformFactoryImpl::~RDFTransformFactoryImpl() 140 RDFTransformFactoryImpl::~RDFTransformFactoryImpl()
136 { 141 {
137 delete m_store; 142 delete m_store;
144 } 149 }
145 150
146 bool 151 bool
147 RDFTransformFactoryImpl::isOK() 152 RDFTransformFactoryImpl::isOK()
148 { 153 {
149 return (m_errorString == ""); 154 return m_isRDF && (m_errorString == "");
150 } 155 }
151 156
152 QString 157 QString
153 RDFTransformFactoryImpl::getErrorString() const 158 RDFTransformFactoryImpl::getErrorString() const
154 { 159 {
158 std::vector<Transform> 163 std::vector<Transform>
159 RDFTransformFactoryImpl::getTransforms(ProgressReporter *) 164 RDFTransformFactoryImpl::getTransforms(ProgressReporter *)
160 { 165 {
161 std::vector<Transform> transforms; 166 std::vector<Transform> transforms;
162 167
168 if (!m_isRDF) return transforms;
169
163 std::map<QString, Transform> uriTransformMap; 170 std::map<QString, Transform> uriTransformMap;
164 171
165 Nodes tnodes = m_store->match 172 Nodes tnodes = m_store->match
166 (Triple(Node(), Uri("a"), m_store->expand("vamp:Transform"))).subjects(); 173 (Triple(Node(), Uri("a"), m_store->expand("vamp:Transform"))).subjects();
167 174