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 const std::string parentIdStr{"PARENT_ID"};
184 const std::string conditionStr{"NODE_ID=:nodeId"};
185 while(currentParrent != parentNodeId) {
186
187
188
189 coral::IQuery* queryNode(tableNode.newQuery());
190
191 queryNode->addToOutputList(parentIdStr);
192 queryNode->setMemoryCacheSize(1);
193
194 queryNode->setCondition(conditionStr, bindsNode);
195 bindsNode[0].data<std::string>()=currentChild;
196
197 coral::ICursor& cursorNode = queryNode->execute();
198
200
201
202 while(cursorNode.next()) {
203 if(++nRows>1) {
204 delete queryNode;
205 throw std::runtime_error("The node " + currentChild + " has more than one parent!");
206 }
207
208 const coral::AttributeList&
row = cursorNode.currentRow();
209
210 if(row[0].isNull()) {
211 delete queryNode;
212 throw std::runtime_error("The requested child and parent nodes are not on the same branch!");
213 }
214
216 currentChild = currentParrent;
217 path.push_back(currentParrent);
218 }
219 if(nRows==0) {
220 delete queryNode;
221 throw std::runtime_error("The node " + currentChild + " has no parent!");
222 }
223
224 delete queryNode;
226 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Current Child = " << currentChild <<
endmsg;
227 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Current Parrent = " << currentParrent <<
endmsg;
228 }
229 }
230
232 bindsLtag2Ltag.extend<std::string>("childN");
233 bindsLtag2Ltag.extend<std::string>("parentT");
234 bindsLtag2Ltag.extend<std::string>("parentN");
235
236 const std::string childTagString{"CHILD_TAG"};
237 const std::string childConditionStr = "CHILD_NODE =:childN AND PARENT_TAG =:parentT AND PARENT_NODE =:parentN";
238 for(
unsigned int ind=1;
ind<
path.size();
ind++) {
239
240
241
242
243 coral::IQuery* queryLtag2Ltag(tableLtag2Ltag.newQuery());
244
245 queryLtag2Ltag->addToOutputList(childTagString);
246 queryLtag2Ltag->setMemoryCacheSize(1);
247
248 queryLtag2Ltag->setCondition(childConditionStr, bindsLtag2Ltag);
249
250 bindsLtag2Ltag[0].data<std::string>() = path[
path.size()-
ind-1];
251 bindsLtag2Ltag[1].data<std::string>() = parentTagId;
252 bindsLtag2Ltag[2].data<std::string>() = path[
path.size()-
ind];
253
254 coral::ICursor& cursorLtag2Ltag = queryLtag2Ltag->execute();
255
257
258 while(cursorLtag2Ltag.next()) {
259 if(++nRows>1) {
260 delete queryLtag2Ltag;
261 throw std::runtime_error("Version " + parentTagId +
262 " has more than one child of type " + path[
path.size()-ind-1] +
"!");
263 }
264
265 const coral::AttributeList&
row = cursorLtag2Ltag.currentRow();
267 }
268 if(nRows==0) {
269 delete queryLtag2Ltag;
270 throw std::runtime_error(
"Version " + parentTagId +
" has no child of type " + path[
path.size()-ind-1] +
"!");
271 }
272
273 delete queryLtag2Ltag;
274
276 m_msgStream << MSG::VERBOSE <<
"VersionAccessor: Parent Tag Id = " << parentTagId <<
endmsg;
277 }
278 }
279
280
281
282
283
284
285 coral::IQuery* queryTagName(tableTag2Node.newQuery());
286 const std::string tagNameStr{"TAG_NAME"};
287 queryTagName->addToOutputList(tagNameStr);
288 queryTagName->setMemoryCacheSize(1);
289
291 bindsTagName.extend<std::string>("tagId");
292
293 queryTagName->setCondition("TAG_ID=:tagId", bindsTagName);
294 bindsTagName[0].data<std::string>() = parentTagId;
295
296 coral::ICursor& cursorTagName = queryTagName->execute();
297
299 while(cursorTagName.next()) {
300 if(++nRows>1) {
301 delete queryTagName;
302 throw std::runtime_error("More than one record retrieved when getting tag name for given ID");
303 }
304
305 const coral::AttributeList&
row = cursorTagName.currentRow();
306
309
312 }
313 }
314 delete queryTagName;
315
316 }
317 catch(coral::SchemaException& se)
318 {
319 m_msgStream << MSG::ERROR <<
"VersionAccessor: Schema Exception : " <<
se.what() <<
endmsg;
320 }
321 catch(std::exception& e)
322 {
325 }
326 catch(...)
327 {
329 }
330}
#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 --------------------------------------—