51{
52 std::string parentNodeId, childNodeId, parentTagId;
54
56 m_msgStream << MSG::ERROR <<
"VersionAccessor: No connection to database!" <<
endmsg;
57 return;
58 }
59
60 try {
65 }
66
67 coral::ITable& tableTag2Node =
m_session->nominalSchema().tableHandle(
"HVS_TAG2NODE");
68 coral::ITable& tableNode =
m_session->nominalSchema().tableHandle(
"HVS_NODE");
69 coral::ITable& tableLtag2Ltag =
m_session->nominalSchema().tableHandle(
"HVS_LTAG2LTAG");
70
71
72
73
74
75
76 coral::IQuery *queryTag2Node = tableTag2Node.newQuery();
77 queryTag2Node->addToOutputList("TAG_ID");
78 queryTag2Node->setMemoryCacheSize(1);
80 bindsTag2Node.extend<std::string>("tagN");
81 queryTag2Node->setCondition("TAG_NAME=:tagN", bindsTag2Node);
83
84 coral::ICursor& cursorTag2Node = queryTag2Node->execute();
86 while(cursorTag2Node.next()) {
87 if(++nRows>1) {
88 delete queryTag2Node;
89 throw std::runtime_error(
"The tag " +
m_parentTag +
" is not unique in HVS_TAG2NODE table!");
90 }
91
92 const coral::AttributeList&
row = cursorTag2Node.currentRow();
94
95 }
96 if(nRows==0) {
97 delete queryTag2Node;
98 throw std::runtime_error(
"The tag " +
m_parentTag +
" not found in HVS_TAG2NODE table!");
99 }
100
101 delete queryTag2Node;
103 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Parent Tag Id = " << parentTagId <<
endmsg;
104 }
105
106
107
108
109
110
111
112
113 coral::IQuery* queryNodeIDs = tableNode.newQuery();
114
115 queryNodeIDs->addToOutputList("NODE_NAME");
116 queryNodeIDs->addToOutputList("NODE_ID");
117 queryNodeIDs->addToOutputList("BRANCH_FLAG");
118 queryNodeIDs->setMemoryCacheSize(2);
119
121 bindsNodeIDs.extend<std::string>("parentN");
122 bindsNodeIDs.extend<std::string>("childN");
123
124 queryNodeIDs->setCondition( "NODE_NAME=:parentN OR NODE_NAME=:childN", bindsNodeIDs);
125
128
129 coral::ICursor& cursorNodeIDs = queryNodeIDs->execute();
130
132 while(cursorNodeIDs.next()) {
133 if(++nRows>2) {
134 break;
135 }
136 const coral::AttributeList&
row = cursorNodeIDs.currentRow();
137
141 }
142 else {
144 }
145 }
147 delete queryNodeIDs;
148 throw std::runtime_error("Error processing HVS_NODE, Number of fetched records !=2");
149 }
150
152 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Child Node Id = " << childNodeId <<
endmsg;
153 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Parent Node Id = " << parentNodeId <<
endmsg;
154 }
155
156 delete queryNodeIDs;
157
160 m_tagID = std::move(parentTagId);
161 return;
162 }
163
164
165
166
167
168
169
170
171
172
173
174
175
176 std::vector<std::string>
path;
177 path.push_back(childNodeId);
178 std::string currentParrent = childNodeId;
179 std::string currentChild = std::move(childNodeId);
180
182 bindsNode.extend<std::string>("nodeId");
183
184 while(currentParrent != parentNodeId) {
185
186
187
188 coral::IQuery* queryNode(tableNode.newQuery());
189
190 queryNode->addToOutputList("PARENT_ID");
191 queryNode->setMemoryCacheSize(1);
192
193 queryNode->setCondition("NODE_ID=:nodeId", bindsNode);
194 bindsNode[0].data<std::string>()=currentChild;
195
196 coral::ICursor& cursorNode = queryNode->execute();
197
199
200
201 while(cursorNode.next()) {
202 if(++nRows>1) {
203 delete queryNode;
204 throw std::runtime_error("The node " + currentChild + " has more than one parent!");
205 }
206
207 const coral::AttributeList&
row = cursorNode.currentRow();
208
209 if(row[0].isNull()) {
210 delete queryNode;
211 throw std::runtime_error("The requested child and parent nodes are not on the same branch!");
212 }
213
215 currentChild = currentParrent;
216 path.push_back(currentParrent);
217 }
218 if(nRows==0) {
219 delete queryNode;
220 throw std::runtime_error("The node " + currentChild + " has no parent!");
221 }
222
223 delete queryNode;
225 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Current Child = " << currentChild <<
endmsg;
226 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Current Parrent = " << currentParrent <<
endmsg;
227 }
228 }
229
231 bindsLtag2Ltag.extend<std::string>("childN");
232 bindsLtag2Ltag.extend<std::string>("parentT");
233 bindsLtag2Ltag.extend<std::string>("parentN");
234
235
236 for(
unsigned int ind=1; ind<
path.size(); ind++) {
237
238
239
240
241 coral::IQuery* queryLtag2Ltag(tableLtag2Ltag.newQuery());
242
243 queryLtag2Ltag->addToOutputList("CHILD_TAG");
244 queryLtag2Ltag->setMemoryCacheSize(1);
245
246 std::string conditionString = "CHILD_NODE =:childN AND PARENT_TAG =:parentT AND PARENT_NODE =:parentN";
247 queryLtag2Ltag->setCondition(conditionString, bindsLtag2Ltag);
248
249 bindsLtag2Ltag[0].data<std::string>() = path[
path.size()-ind-1];
250 bindsLtag2Ltag[1].data<std::string>() = parentTagId;
251 bindsLtag2Ltag[2].data<std::string>() = path[
path.size()-ind];
252
253 coral::ICursor& cursorLtag2Ltag = queryLtag2Ltag->execute();
254
256
257 while(cursorLtag2Ltag.next()) {
258 if(++nRows>1) {
259 delete queryLtag2Ltag;
260 throw std::runtime_error("Version " + parentTagId +
261 " has more than one child of type " + path[
path.size()-ind-1] +
"!");
262 }
263
264 const coral::AttributeList&
row = cursorLtag2Ltag.currentRow();
266 }
267 if(nRows==0) {
268 delete queryLtag2Ltag;
269 throw std::runtime_error(
"Version " + parentTagId +
" has no child of type " + path[
path.size()-ind-1] +
"!");
270 }
271
272 delete queryLtag2Ltag;
273
275 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Parent Tag Id = " << parentTagId <<
endmsg;
276 }
277 }
278
279
280
281
282
283
284 coral::IQuery* queryTagName(tableTag2Node.newQuery());
285
286 queryTagName->addToOutputList("TAG_NAME");
287 queryTagName->setMemoryCacheSize(1);
288
290 bindsTagName.extend<std::string>("tagId");
291
292 queryTagName->setCondition("TAG_ID=:tagId", bindsTagName);
293 bindsTagName[0].data<std::string>() = parentTagId;
294
295 coral::ICursor& cursorTagName = queryTagName->execute();
296
298 while(cursorTagName.next()) {
299 if(++nRows>1) {
300 delete queryTagName;
301 throw std::runtime_error("More than one record retrieved when getting tag name for given ID");
302 }
303
304 const coral::AttributeList&
row = cursorTagName.currentRow();
305
308
311 }
312 }
313 delete queryTagName;
314
315 }
316 catch(coral::SchemaException& se)
317 {
318 m_msgStream << MSG::ERROR <<
"VersionAccessor: Schema Exception : " <<
se.what() <<
endmsg;
319 }
320 catch(std::exception& e)
321 {
324 }
325 catch(...)
326 {
328 }
329}
#define ATLAS_THREAD_SAFE
std::string attribute2String(const coral::AttributeList &attList, const std::string &fieldName)
row
Appending html table to final .html summary file.
unsigned int constexpr nRows
path
python interpreter configuration --------------------------------------—