58{
59 std::string parentNodeId, childNodeId, parentTagId;
61
63 RDB_MSG_ERROR (
"VersionAccessor: No connection to database!");
64 return;
65 }
66
67 try {
69 "ChildNode = {} ParentNode = {} ParentTag = {}",
71
72 coral::ITable& tableTag2Node =
m_session->nominalSchema().tableHandle(
"HVS_TAG2NODE");
73 coral::ITable& tableNode =
m_session->nominalSchema().tableHandle(
"HVS_NODE");
74 coral::ITable& tableLtag2Ltag =
m_session->nominalSchema().tableHandle(
"HVS_LTAG2LTAG");
75
76
77
78
79
80
81 coral::IQuery *queryTag2Node = tableTag2Node.newQuery();
82 queryTag2Node->addToOutputList("TAG_ID");
83 queryTag2Node->setMemoryCacheSize(1);
85 bindsTag2Node.extend<std::string>("tagN");
86 queryTag2Node->setCondition("TAG_NAME=:tagN", bindsTag2Node);
88
89 coral::ICursor& cursorTag2Node = queryTag2Node->execute();
91 while(cursorTag2Node.next()) {
92 if(++nRows>1) {
93 delete queryTag2Node;
94 RDB_MSG_DEBUG(
"The tag {} is not unique in HVS_TAG2NODE table!",
96 return;
97 }
98
99 const coral::AttributeList&
row = cursorTag2Node.currentRow();
101
102 }
103 if(nRows==0) {
104 delete queryTag2Node;
107 return;
108 }
109
110 delete queryTag2Node;
112
113
114
115
116
117
118
119
120 coral::IQuery* queryNodeIDs = tableNode.newQuery();
121
122 queryNodeIDs->addToOutputList("NODE_NAME");
123 queryNodeIDs->addToOutputList("NODE_ID");
124 queryNodeIDs->addToOutputList("BRANCH_FLAG");
125 queryNodeIDs->setMemoryCacheSize(2);
126
128 bindsNodeIDs.extend<std::string>("parentN");
129 bindsNodeIDs.extend<std::string>("childN");
130
131 queryNodeIDs->setCondition( "NODE_NAME=:parentN OR NODE_NAME=:childN", bindsNodeIDs);
132
135
136 coral::ICursor& cursorNodeIDs = queryNodeIDs->execute();
137
139 while(cursorNodeIDs.next()) {
140 if(++nRows>2) {
141 break;
142 }
143 const coral::AttributeList&
row = cursorNodeIDs.currentRow();
144
148 }
149 else {
151 }
152 }
154 delete queryNodeIDs;
155 RDB_MSG_DEBUG(
"Error processing HVS_NODE, Number of fetched records !=2");
156 return;
157 }
158
161
162 delete queryNodeIDs;
163
166 m_tagID = std::move(parentTagId);
167 return;
168 }
169
170
171
172
173
174
175
176
177
178
179
180
181
182 std::vector<std::string>
path;
183 path.push_back(childNodeId);
184 std::string currentParrent = childNodeId;
185 std::string currentChild = std::move(childNodeId);
186
188 bindsNode.extend<std::string>("nodeId");
189 const std::string parentIdStr{"PARENT_ID"};
190 const std::string conditionStr{"NODE_ID=:nodeId"};
191 while(currentParrent != parentNodeId) {
192
193
194
195 coral::IQuery* queryNode(tableNode.newQuery());
196
197 queryNode->addToOutputList(parentIdStr);
198 queryNode->setMemoryCacheSize(1);
199
200 queryNode->setCondition(conditionStr, bindsNode);
201 bindsNode[0].data<std::string>()=currentChild;
202
203 coral::ICursor& cursorNode = queryNode->execute();
204
206
207
208 while(cursorNode.next()) {
209 if(++nRows>1) {
210 delete queryNode;
211 RDB_MSG_DEBUG(
"The node {} has more than one parent!", currentChild);
212 return;
213 }
214
215 const coral::AttributeList&
row = cursorNode.currentRow();
216
217 if(row[0].isNull()) {
218 delete queryNode;
219 RDB_MSG_DEBUG(
"The requested child and parent nodes are not on the same branch!");
220 return;
221 }
222
224 currentChild = currentParrent;
225 path.push_back(currentParrent);
226 }
227 if(nRows==0) {
228 delete queryNode;
230 return;
231 }
232
233 delete queryNode;
235 RDB_MSG_VERBOSE(
"VersionAccessor: Current Parrent = {}", currentParrent);
236 }
237
239 bindsLtag2Ltag.extend<std::string>("childN");
240 bindsLtag2Ltag.extend<std::string>("parentT");
241 bindsLtag2Ltag.extend<std::string>("parentN");
242
243 const std::string childTagString{"CHILD_TAG"};
244 const std::string childConditionStr = "CHILD_NODE =:childN AND PARENT_TAG =:parentT AND PARENT_NODE =:parentN";
245 for(
unsigned int ind=1;
ind<
path.size();
ind++) {
246
247
248
249
250 coral::IQuery* queryLtag2Ltag(tableLtag2Ltag.newQuery());
251
252 queryLtag2Ltag->addToOutputList(childTagString);
253 queryLtag2Ltag->setMemoryCacheSize(1);
254
255 queryLtag2Ltag->setCondition(childConditionStr, bindsLtag2Ltag);
256
257 bindsLtag2Ltag[0].data<std::string>() = path[
path.size()-
ind-1];
258 bindsLtag2Ltag[1].data<std::string>() = parentTagId;
259 bindsLtag2Ltag[2].data<std::string>() = path[
path.size()-
ind];
260
261 coral::ICursor& cursorLtag2Ltag = queryLtag2Ltag->execute();
262
264
265 while(cursorLtag2Ltag.next()) {
266 if(++nRows>1) {
267 delete queryLtag2Ltag;
268 RDB_MSG_DEBUG(
"Version {} has more than one child of type {}!",
269 parentTagId, path[
path.size()-ind-1]);
270 return;
271 }
272
273 const coral::AttributeList&
row = cursorLtag2Ltag.currentRow();
275 }
276 if(nRows==0) {
277 delete queryLtag2Ltag;
279 parentTagId, path[
path.size()-ind-1]);
280 return;
281 }
282
283 delete queryLtag2Ltag;
284
286 }
287
288
289
290
291
292
293 coral::IQuery* queryTagName(tableTag2Node.newQuery());
294 const std::string tagNameStr{"TAG_NAME"};
295 queryTagName->addToOutputList(tagNameStr);
296 queryTagName->setMemoryCacheSize(1);
297
299 bindsTagName.extend<std::string>("tagId");
300
301 queryTagName->setCondition("TAG_ID=:tagId", bindsTagName);
302 bindsTagName[0].data<std::string>() = parentTagId;
303
304 coral::ICursor& cursorTagName = queryTagName->execute();
305
307 while(cursorTagName.next()) {
308 if(++nRows>1) {
309 delete queryTagName;
310 RDB_MSG_DEBUG(
"More than one record retrieved when getting tag name for given ID");
311 return;
312 }
313
314 const coral::AttributeList&
row = cursorTagName.currentRow();
315
318
320 }
321 delete queryTagName;
322
323 }
324 catch(coral::SchemaException& se)
325 {
327 }
328 catch(std::exception& e)
329 {
331 }
332 catch(...)
333 {
335 }
336}
#define RDB_MSG_ERROR(fmt,...)
#define RDB_MSG_DEBUG(fmt,...)
#define RDB_MSG_VERBOSE(fmt,...)
#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 --------------------------------------—