Skip to content

Commit b457bc0

Browse files
committed
fix search
1 parent d6a8555 commit b457bc0

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

src/manager/agents/common-module/module/utils/common_utils.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
*/
66

77
#include "common_utils.hpp"
8+
89
#include <sc-agents-common/utils/GenerationUtils.hpp>
910
#include <sc-agents-common/utils/IteratorUtils.hpp>
11+
#include <sc-agents-common/utils/CommonUtils.hpp>
1012
#include "sc-agents-common/keynodes/coreKeynodes.hpp"
1113

1214
#include "sc-memory/sc_memory.hpp"
@@ -371,4 +373,16 @@ bool CommonUtils::CheckIfFullMyselfDecompositionExists(ScMemoryContext & context
371373
}
372374
return true;
373375
}
376+
377+
void GenerateVarRelationInStructure(ScMemoryContext & context, ScAddr const & start, ScAddr const & finish, ScAddr const & relation, ScAddr const & structure)
378+
{
379+
bool const isRole = utils::CommonUtils::checkType(&context, relation, ScType::NodeConstRole);
380+
ScType const arcType = isRole ? ScType::EdgeAccessVarPosPerm : ScType::EdgeDCommonVar;
381+
ScAddr const edge = context.CreateEdge(arcType, start, finish);
382+
context.CreateEdge(ScType::EdgeAccessVarPosPerm, structure, edge);
383+
ScAddr const & relationEdge = context.CreateEdge(ScType::EdgeAccessVarPosPerm, relation, edge);
384+
385+
386+
}
387+
374388
} // namespace common_utils

src/manager/agents/common-module/module/utils/common_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ class CommonUtils
3737
static bool CheckIfInstalled(ScMemoryContext & context, ScAddr const & component);
3838
static ScAddr GetComponentBySpecification(ScMemoryContext & context, ScAddr const & specification);
3939
static bool CheckIfFullMyselfDecompositionExists(ScMemoryContext & context);
40+
static void GenerateVarRelationInStructure(ScMemoryContext & context, ScAddr const & start, ScAddr const & finish, ScAddr const & relation, ScAddr const & structure);
4041
};
4142
} // namespace common_utils

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

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,10 @@ ScComponentManagerCommandHandler::ScComponentManagerCommandHandler()
2525

2626
m_InstallParametersRelations = {
2727
{CommandsConstantsFlags::IDTF, keynodes::ScComponentManagerKeynodes::rrel_components},
28-
{CommandsConstantsFlags::SET, keynodes::ScComponentManagerKeynodes::rrel_sets},
29-
{CommandsConstantsFlags::AUTHOR, keynodes::ScComponentManagerKeynodes::rrel_author},
30-
{CommandsConstantsFlags::CLASS, keynodes::ScComponentManagerKeynodes::rrel_class},
31-
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
28+
{CommandsConstantsFlags::SET, keynodes::ScComponentManagerKeynodes::rrel_sets}};
3229

3330
m_SearchNodesParametersRelations = {
34-
{CommandsConstantsFlags::AUTHOR, keynodes::ScComponentManagerKeynodes::rrel_author},
35-
{CommandsConstantsFlags::CLASS, keynodes::ScComponentManagerKeynodes::rrel_class},
36-
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
31+
{CommandsConstantsFlags::AUTHOR, keynodes::ScComponentManagerKeynodes::nrel_authors}};
3732

3833
m_SearchLinksParametersRelations = {
3934
{CommandsConstantsFlags::EXPLANATION, keynodes::ScComponentManagerKeynodes::rrel_explanation}};
@@ -63,8 +58,6 @@ bool ScComponentManagerCommandHandler::Handle(
6358
FormSearchActionNodeParameter(action, commandParameters);
6459
}
6560

66-
common_utils::CommonUtils::TranslateFromStringToScMemory(*m_context, action, commandParameters);
67-
6861
utils::AgentUtils::applyAction(m_context, action, 30000);
6962

7063
bool const executionResult = m_context->HelperCheckEdge(
@@ -113,17 +106,43 @@ void ScComponentManagerCommandHandler::FormInstallActionNodeParameter(
113106

114107
void ScComponentManagerCommandHandler::FormSearchActionNodeParameter(ScAddr const & action, CommandParameters const & commandParameters)
115108
{
109+
ScAddr const & searchStructure = m_context->CreateNode(ScType::NodeConstStruct);
110+
ScAddr const & component = m_context->CreateNode(ScType::NodeVar);
111+
112+
ScAddr const & componentArc = m_context->CreateEdge(ScType::EdgeAccessVarPosPerm, searchStructure, component);
113+
m_context->CreateEdge(ScType::EdgeAccessVarPosPerm, searchStructure, scAgentsCommon::CoreKeynodes::rrel_key_sc_element);
114+
m_context->CreateEdge(ScType::EdgeAccessVarPosPerm, searchStructure, componentArc);
115+
116116
ScAddr paramsSet;
117117
ScAddr foundParamValue;
118118
for (auto const & params : commandParameters)
119119
{
120-
paramsSet = m_context->CreateNode(ScType::NodeConst);
120+
if (m_SearchNodesParametersRelations.find(params.first) != m_SearchNodesParametersRelations.cend())
121+
{
122+
common_utils::CommonUtils::GenerateVarRelationBetween(
123+
*m_context, searchStructure, component, scAgentsCommon::CoreKeynodes::rrel_key_sc_element);
124+
125+
paramsSet = m_context->CreateNode(ScType::NodeVar);
126+
for (std::string const & paramValue : params.second)
127+
{
128+
foundParamValue = m_context->HelperFindBySystemIdtf(paramValue);
129+
m_context->CreateEdge(ScType::EdgeAccessVarPosPerm, paramsSet, foundParamValue);
130+
}
131+
132+
}
133+
134+
121135
for (std::string const & paramValue : params.second)
122136
{
123137
// Process parameter if it is a link
124138
if (m_SearchNodesParametersRelations.find(params.first) != m_SearchNodesParametersRelations.cend())
125139
{
126140
foundParamValue = m_context->HelperFindBySystemIdtf(paramValue);
141+
if (m_context->GetElementType(foundParamValue) == ScType::NodeConstClass)
142+
{
143+
144+
}
145+
127146
utils::GenerationUtils::generateRelationBetween(m_context, action, paramsSet, m_SearchNodesParametersRelations.at(params.first));
128147
}
129148
// Process parameter if it is a node

0 commit comments

Comments
 (0)