Skip to content

Commit d6a8555

Browse files
committed
[interface] Process search command parameters
1 parent d964e7d commit d6a8555

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/manager/console-interface/command_handler/sc_component_manager_command_handler.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ ScComponentManagerCommandHandler::ScComponentManagerCommandHandler()
3030
{CommandsConstantsFlags::CLASS, keynodes::ScComponentManagerKeynodes::rrel_class},
3131
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
3232

33-
m_SearchParametersRelations = {
33+
m_SearchNodesParametersRelations = {
3434
{CommandsConstantsFlags::AUTHOR, keynodes::ScComponentManagerKeynodes::rrel_author},
3535
{CommandsConstantsFlags::CLASS, keynodes::ScComponentManagerKeynodes::rrel_class},
3636
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
37+
38+
m_SearchLinksParametersRelations = {
39+
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
3740
}
3841

3942
bool ScComponentManagerCommandHandler::Handle(
@@ -111,11 +114,27 @@ void ScComponentManagerCommandHandler::FormInstallActionNodeParameter(
111114
void ScComponentManagerCommandHandler::FormSearchActionNodeParameter(ScAddr const & action, CommandParameters const & commandParameters)
112115
{
113116
ScAddr paramsSet;
114-
for (auto const & param : commandParameters)
117+
ScAddr foundParamValue;
118+
for (auto const & params : commandParameters)
115119
{
116-
if (m_SearchParametersRelations.find(param.first) != m_SearchParametersRelations.cend())
120+
paramsSet = m_context->CreateNode(ScType::NodeConst);
121+
for (std::string const & paramValue : params.second)
117122
{
118-
paramsSet = m_context->CreateNode(ScType::NodeConst);
123+
// Process parameter if it is a link
124+
if (m_SearchNodesParametersRelations.find(params.first) != m_SearchNodesParametersRelations.cend())
125+
{
126+
foundParamValue = m_context->HelperFindBySystemIdtf(paramValue);
127+
utils::GenerationUtils::generateRelationBetween(m_context, action, paramsSet, m_SearchNodesParametersRelations.at(params.first));
128+
}
129+
// Process parameter if it is a node
130+
else if (m_SearchLinksParametersRelations.find(params.first) != m_SearchLinksParametersRelations.cend())
131+
{
132+
foundParamValue = m_context->CreateLink();
133+
m_context->SetLinkContent(foundParamValue, paramValue);
134+
utils::GenerationUtils::generateRelationBetween(m_context, action, paramsSet, m_SearchLinksParametersRelations.at(params.first));
135+
}
136+
137+
m_context->CreateEdge(ScType::EdgeAccessConstPosPerm, paramsSet, foundParamValue);
119138
}
120139
}
121140
}

src/manager/console-interface/command_handler/sc_component_manager_command_handler.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class ScComponentManagerCommandHandler
2727
ScMemoryContext * m_context{};
2828
std::map<std::string, ScAddr> m_actions;
2929
std::map<std::string, ScAddr> m_InstallParametersRelations;
30-
std::map<std::string, ScAddr> m_SearchParametersRelations;
30+
std::map<std::string, ScAddr> m_SearchNodesParametersRelations;
31+
std::map<std::string, ScAddr> m_SearchLinksParametersRelations;
3132

3233
void FormInstallActionNodeParameter(
3334
ScAddr const & action,

0 commit comments

Comments
 (0)