Mercurial > hg > svcore
comparison rdf/RDFTransformFactory.cpp @ 493:3931711b5671
* RDF importer: add model titles where possible
* RDF transform factory: report whether something appears to be RDF or
not (so we can avoid trying to load it as something else if the RDF
query fails)
author | Chris Cannam |
---|---|
date | Tue, 25 Nov 2008 13:43:56 +0000 |
parents | 23945cdd7161 |
children | 81963c51b488 |
comparison
equal
deleted
inserted
replaced
492:23945cdd7161 | 493:3931711b5671 |
---|---|
37 { | 37 { |
38 public: | 38 public: |
39 RDFTransformFactoryImpl(QString url); | 39 RDFTransformFactoryImpl(QString url); |
40 virtual ~RDFTransformFactoryImpl(); | 40 virtual ~RDFTransformFactoryImpl(); |
41 | 41 |
42 bool isRDF(); | |
42 bool isOK(); | 43 bool isOK(); |
43 QString getErrorString() const; | 44 QString getErrorString() const; |
44 | 45 |
45 std::vector<Transform> getTransforms(ProgressReporter *); | 46 std::vector<Transform> getTransforms(ProgressReporter *); |
46 | 47 |
47 protected: | 48 protected: |
48 QString m_urlString; | 49 QString m_urlString; |
49 QString m_errorString; | 50 QString m_errorString; |
51 bool m_isRDF; | |
50 bool setOutput(Transform &, QString); | 52 bool setOutput(Transform &, QString); |
51 bool setParameters(Transform &, QString); | 53 bool setParameters(Transform &, QString); |
52 }; | 54 }; |
53 | 55 |
54 | 56 |
67 { | 69 { |
68 delete m_d; | 70 delete m_d; |
69 } | 71 } |
70 | 72 |
71 bool | 73 bool |
74 RDFTransformFactory::isRDF() | |
75 { | |
76 return m_d->isRDF(); | |
77 } | |
78 | |
79 bool | |
72 RDFTransformFactory::isOK() | 80 RDFTransformFactory::isOK() |
73 { | 81 { |
74 return m_d->isOK(); | 82 return m_d->isOK(); |
75 } | 83 } |
76 | 84 |
85 { | 93 { |
86 return m_d->getTransforms(r); | 94 return m_d->getTransforms(r); |
87 } | 95 } |
88 | 96 |
89 RDFTransformFactoryImpl::RDFTransformFactoryImpl(QString url) : | 97 RDFTransformFactoryImpl::RDFTransformFactoryImpl(QString url) : |
90 m_urlString(url) | 98 m_urlString(url), |
99 m_isRDF(false) | |
91 { | 100 { |
92 } | 101 } |
93 | 102 |
94 RDFTransformFactoryImpl::~RDFTransformFactoryImpl() | 103 RDFTransformFactoryImpl::~RDFTransformFactoryImpl() |
95 { | 104 { |
96 SimpleSPARQLQuery::closeSingleSource(m_urlString); | 105 SimpleSPARQLQuery::closeSingleSource(m_urlString); |
106 } | |
107 | |
108 bool | |
109 RDFTransformFactoryImpl::isRDF() | |
110 { | |
111 return m_isRDF; | |
97 } | 112 } |
98 | 113 |
99 bool | 114 bool |
100 RDFTransformFactoryImpl::isOK() | 115 RDFTransformFactoryImpl::isOK() |
101 { | 116 { |
134 | 149 |
135 if (!transformsQuery.isOK()) { | 150 if (!transformsQuery.isOK()) { |
136 m_errorString = transformsQuery.getErrorString(); | 151 m_errorString = transformsQuery.getErrorString(); |
137 return transforms; | 152 return transforms; |
138 } | 153 } |
154 | |
155 m_isRDF = true; | |
139 | 156 |
140 if (transformResults.empty()) { | 157 if (transformResults.empty()) { |
141 cerr << "RDFTransformFactory: NOTE: No RDF/TTL transform descriptions found in document at <" << m_urlString.toStdString() << ">" << endl; | 158 cerr << "RDFTransformFactory: NOTE: No RDF/TTL transform descriptions found in document at <" << m_urlString.toStdString() << ">" << endl; |
142 return transforms; | 159 return transforms; |
143 } | 160 } |
287 if (outputValue.type == SimpleSPARQLQuery::NoValue) { | 304 if (outputValue.type == SimpleSPARQLQuery::NoValue) { |
288 return true; | 305 return true; |
289 } | 306 } |
290 | 307 |
291 if (outputValue.type != SimpleSPARQLQuery::URIValue) { | 308 if (outputValue.type != SimpleSPARQLQuery::URIValue) { |
292 m_errorString = "No vamp:output given, or not a URI"; | 309 m_errorString = QString("vamp:output given for transform <%1> is not a URI").arg(transformUri); |
293 return false; | 310 return false; |
294 } | 311 } |
295 | 312 |
296 SimpleSPARQLQuery::Value outputIdValue = | 313 SimpleSPARQLQuery::Value outputIdValue = |
297 SimpleSPARQLQuery::singleResultQuery | 314 SimpleSPARQLQuery::singleResultQuery |
308 ) | 325 ) |
309 .arg(outputValue.value), | 326 .arg(outputValue.value), |
310 "output_id"); | 327 "output_id"); |
311 | 328 |
312 if (outputIdValue.type != SimpleSPARQLQuery::LiteralValue) { | 329 if (outputIdValue.type != SimpleSPARQLQuery::LiteralValue) { |
313 m_errorString = "No output vamp:identifier available, or not a literal"; | 330 m_errorString = QString("No vamp:identifier found for output <%1>, or vamp:identifier is not a literal").arg(outputValue.value); |
314 return false; | 331 return false; |
315 } | 332 } |
316 | 333 |
317 transform.setOutput(outputIdValue.value); | 334 transform.setOutput(outputIdValue.value); |
318 | 335 |