59 std::string parentNodeId, childNodeId, parentTagId;
63 RDB_MSG_ERROR (
"VersionAccessor: No connection to database!");
69 "ChildNode = {} ParentNode = {} ParentTag = {}",
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");
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);
89 coral::ICursor& cursorTag2Node = queryTag2Node->execute();
91 while(cursorTag2Node.next()) {
94 RDB_MSG_DEBUG(
"The tag {} is not unique in HVS_TAG2NODE table!",
99 const coral::AttributeList& row = cursorTag2Node.currentRow();
104 delete queryTag2Node;
110 delete queryTag2Node;
120 coral::IQuery* queryNodeIDs = tableNode.newQuery();
122 queryNodeIDs->addToOutputList(
"NODE_NAME");
123 queryNodeIDs->addToOutputList(
"NODE_ID");
124 queryNodeIDs->addToOutputList(
"BRANCH_FLAG");
125 queryNodeIDs->setMemoryCacheSize(2);
128 bindsNodeIDs.extend<std::string>(
"parentN");
129 bindsNodeIDs.extend<std::string>(
"childN");
131 queryNodeIDs->setCondition(
"NODE_NAME=:parentN OR NODE_NAME=:childN", bindsNodeIDs);
136 coral::ICursor& cursorNodeIDs = queryNodeIDs->execute();
139 while(cursorNodeIDs.next()) {
143 const coral::AttributeList& row = cursorNodeIDs.currentRow();
155 RDB_MSG_DEBUG(
"Error processing HVS_NODE, Number of fetched records !=2");
166 m_tagID = std::move(parentTagId);
182 std::vector<std::string> path;
183 path.push_back(childNodeId);
184 std::string currentParrent = childNodeId;
185 std::string currentChild = std::move(childNodeId);
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) {
195 coral::IQuery* queryNode(tableNode.newQuery());
197 queryNode->addToOutputList(parentIdStr);
198 queryNode->setMemoryCacheSize(1);
200 queryNode->setCondition(conditionStr, bindsNode);
201 bindsNode[0].data<std::string>()=currentChild;
203 coral::ICursor& cursorNode = queryNode->execute();
208 while(cursorNode.next()) {
211 RDB_MSG_DEBUG(
"The node {} has more than one parent!", currentChild);
215 const coral::AttributeList& row = cursorNode.currentRow();
217 if(row[0].isNull()) {
219 RDB_MSG_DEBUG(
"The requested child and parent nodes are not on the same branch!");
224 currentChild = currentParrent;
225 path.push_back(currentParrent);
235 RDB_MSG_VERBOSE(
"VersionAccessor: Current Parrent = {}", currentParrent);
239 bindsLtag2Ltag.extend<std::string>(
"childN");
240 bindsLtag2Ltag.extend<std::string>(
"parentT");
241 bindsLtag2Ltag.extend<std::string>(
"parentN");
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++) {
250 coral::IQuery* queryLtag2Ltag(tableLtag2Ltag.newQuery());
252 queryLtag2Ltag->addToOutputList(childTagString);
253 queryLtag2Ltag->setMemoryCacheSize(1);
255 queryLtag2Ltag->setCondition(childConditionStr, bindsLtag2Ltag);
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];
261 coral::ICursor& cursorLtag2Ltag = queryLtag2Ltag->execute();
265 while(cursorLtag2Ltag.next()) {
267 delete queryLtag2Ltag;
268 RDB_MSG_DEBUG(
"Version {} has more than one child of type {}!",
269 parentTagId, path[path.size()-ind-1]);
273 const coral::AttributeList& row = cursorLtag2Ltag.currentRow();
277 delete queryLtag2Ltag;
279 parentTagId, path[path.size()-ind-1]);
283 delete queryLtag2Ltag;
293 coral::IQuery* queryTagName(tableTag2Node.newQuery());
294 const std::string tagNameStr{
"TAG_NAME"};
295 queryTagName->addToOutputList(tagNameStr);
296 queryTagName->setMemoryCacheSize(1);
299 bindsTagName.extend<std::string>(
"tagId");
301 queryTagName->setCondition(
"TAG_ID=:tagId", bindsTagName);
302 bindsTagName[0].data<std::string>() = parentTagId;
304 coral::ICursor& cursorTagName = queryTagName->execute();
307 while(cursorTagName.next()) {
310 RDB_MSG_DEBUG(
"More than one record retrieved when getting tag name for given ID");
314 const coral::AttributeList& row = cursorTagName.currentRow();
324 catch(coral::SchemaException& se)
326 RDB_MSG_ERROR(
"VersionAccessor: Schema Exception : {}", se.what());
328 catch(std::exception& e)