Constructs SQL query and retrieves child tag ID and Name from DB.
52 std::string parentNodeId, childNodeId, parentTagId;
56 m_msgStream << MSG::ERROR <<
"VersionAccessor: No connection to database!" <<
endmsg;
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");
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);
84 coral::ICursor& cursorTag2Node = queryTag2Node->execute();
86 while(cursorTag2Node.next()) {
89 throw std::runtime_error(
"The tag " +
m_parentTag +
" is not unique in HVS_TAG2NODE table!");
98 throw std::runtime_error(
"The tag " +
m_parentTag +
" not found in HVS_TAG2NODE table!");
101 delete queryTag2Node;
113 coral::IQuery* queryNodeIDs = tableNode.newQuery();
115 queryNodeIDs->addToOutputList(
"NODE_NAME");
116 queryNodeIDs->addToOutputList(
"NODE_ID");
117 queryNodeIDs->addToOutputList(
"BRANCH_FLAG");
118 queryNodeIDs->setMemoryCacheSize(2);
121 bindsNodeIDs.extend<std::string>(
"parentN");
122 bindsNodeIDs.extend<std::string>(
"childN");
124 queryNodeIDs->setCondition(
"NODE_NAME=:parentN OR NODE_NAME=:childN", bindsNodeIDs);
129 coral::ICursor& cursorNodeIDs = queryNodeIDs->execute();
132 while(cursorNodeIDs.next()) {
148 throw std::runtime_error(
"Error processing HVS_NODE, Number of fetched records !=2");
176 std::vector<std::string>
path;
177 path.push_back(childNodeId);
178 std::string currentParrent = childNodeId;
179 std::string currentChild = childNodeId;
182 bindsNode.extend<std::string>(
"nodeId");
184 while(currentParrent != parentNodeId) {
188 coral::IQuery* queryNode(tableNode.newQuery());
190 queryNode->addToOutputList(
"PARENT_ID");
191 queryNode->setMemoryCacheSize(1);
193 queryNode->setCondition(
"NODE_ID=:nodeId", bindsNode);
194 bindsNode[0].data<std::string>()=currentChild;
196 coral::ICursor& cursorNode = queryNode->execute();
201 while(cursorNode.next()) {
204 throw std::runtime_error(
"The node " + currentChild +
" has more than one parent!");
209 if(
row[0].isNull()) {
211 throw std::runtime_error(
"The requested child and parent nodes are not on the same branch!");
215 currentChild = currentParrent;
216 path.push_back(currentParrent);
220 throw std::runtime_error(
"The node " + currentChild +
" has no parent!");
231 bindsLtag2Ltag.extend<std::string>(
"childN");
232 bindsLtag2Ltag.extend<std::string>(
"parentT");
233 bindsLtag2Ltag.extend<std::string>(
"parentN");
241 coral::IQuery* queryLtag2Ltag(tableLtag2Ltag.newQuery());
243 queryLtag2Ltag->addToOutputList(
"CHILD_TAG");
244 queryLtag2Ltag->setMemoryCacheSize(1);
246 std::string conditionString =
"CHILD_NODE =:childN AND PARENT_TAG =:parentT AND PARENT_NODE =:parentN";
247 queryLtag2Ltag->setCondition(conditionString, bindsLtag2Ltag);
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];
253 coral::ICursor& cursorLtag2Ltag = queryLtag2Ltag->execute();
257 while(cursorLtag2Ltag.next()) {
259 delete queryLtag2Ltag;
260 throw std::runtime_error(
"Version " + parentTagId +
261 " has more than one child of type " +
path[
path.size()-
ind-1] +
"!");
268 delete queryLtag2Ltag;
269 throw std::runtime_error(
"Version " + parentTagId +
" has no child of type " +
path[
path.size()-
ind-1] +
"!");
272 delete queryLtag2Ltag;
284 coral::IQuery* queryTagName(tableTag2Node.newQuery());
286 queryTagName->addToOutputList(
"TAG_NAME");
287 queryTagName->setMemoryCacheSize(1);
290 bindsTagName.extend<std::string>(
"tagId");
292 queryTagName->setCondition(
"TAG_ID=:tagId", bindsTagName);
293 bindsTagName[0].data<std::string>() = parentTagId;
295 coral::ICursor& cursorTagName = queryTagName->execute();
298 while(cursorTagName.next()) {
301 throw std::runtime_error(
"More than one record retrieved when getting tag name for given ID");
316 catch(coral::SchemaException&
se)
318 m_msgStream << MSG::ERROR <<
"VersionAccessor: Schema Exception : " <<
se.what() <<
endmsg;