Skip to content

Commit

Permalink
[refactor] Don't use deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kilativ-dotcom committed Sep 17, 2024
1 parent aed1f2c commit 44290b8
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ScAddr DownloaderHandler::getDownloadableClass(ScMemoryContext * context, ScAddr

for (ScAddr const & currentClass : downloadableClasses)
{
if (context->HelperCheckEdge(currentClass, nodeAddr, ScType::EdgeAccessConstPosPerm))
if (context->CheckConnector(currentClass, nodeAddr, ScType::EdgeAccessConstPosPerm))
{
downloadableClass = currentClass;
}
Expand All @@ -53,7 +53,7 @@ ScAddr DownloaderHandler::getUrlLinkClass(ScMemoryContext * context, ScAddr cons

for (ScAddr const & currentClass : downloadableUrls)
{
if (context->HelperCheckEdge(currentClass, linkAddr, ScType::EdgeAccessConstPosPerm))
if (context->CheckConnector(currentClass, linkAddr, ScType::EdgeAccessConstPosPerm))
{
urlLinkClass = currentClass;
}
Expand All @@ -77,7 +77,7 @@ bool DownloaderHandler::DownloadSpecification(ScMemoryContext * context, ScAddr
}

std::string urlAddress;
std::string const & nodeSystemIdentifier = context->HelperGetSystemIdtf(componentSpecificationAddr);
std::string const & nodeSystemIdentifier = context->GetElementSystemIdentifier(componentSpecificationAddr);
std::string const & downloadPath = m_downloadDir + SpecificationConstants::DIRECTORY_DELIMITER + nodeSystemIdentifier;
for (ScAddr const & currentAddressLinkAddr : nodeAddressLinkAddrs)
{
Expand Down
54 changes: 28 additions & 26 deletions src/manager/agents/common-module/module/utils/common_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ScAddr CommonUtils::GetMyselfDecompositionAddr(ScMemoryContext & context)

void CommonUtils::CreateMyselfDecomposition(ScMemoryContext & context)
{
ScAddr myselfDecompositionAddr = context.CreateNode(ScType::NodeConst);
ScAddr myselfDecompositionAddr = context.GenerateNode(ScType::NodeConst);
utils::GenerationUtils::generateRelationBetween(
&context,
keynodes::ScComponentManagerKeynodes::myself,
Expand All @@ -42,12 +42,12 @@ void CommonUtils::CreateMyselfDecomposition(ScMemoryContext & context)
for (ScAddrVector const & subsystemAndComponentClass : componentsClasses)
{
componentClassAddr = subsystemAndComponentClass[1];
componentAddr = context.CreateNode(ScType::NodeConst);
componentAddr = context.GenerateNode(ScType::NodeConst);

context.CreateEdge(ScType::EdgeAccessConstPosPerm, componentClassAddr, componentAddr);
context.CreateEdge(ScType::EdgeAccessConstPosPerm, myselfDecompositionAddr, componentAddr);
context.GenerateConnector(ScType::EdgeAccessConstPosPerm, componentClassAddr, componentAddr);
context.GenerateConnector(ScType::EdgeAccessConstPosPerm, myselfDecompositionAddr, componentAddr);

componentDecompositionAddr = context.CreateNode(ScType::NodeConst);
componentDecompositionAddr = context.GenerateNode(ScType::NodeConst);
utils::GenerationUtils::generateRelationBetween(
&context, componentAddr, componentDecompositionAddr, keynodes::ScComponentManagerKeynodes::nrel_decomposition);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ ScAddr GetSetAddrOfComponents(ScMemoryContext & context, ScAddr const & actionAd
!= relationAndSubRelations.second.end())
{
// If main parameter consists of several parameters
relationAddr = context.HelperFindBySystemIdtf(relationAndSubRelations.first);
relationAddr = context.SearchElementBySystemIdentifier(relationAndSubRelations.first);
break;
}
}
Expand All @@ -107,16 +107,16 @@ ScAddr GetSetAddrOfComponents(ScMemoryContext & context, ScAddr const & actionAd
setAddr = utils::IteratorUtils::getAnyByOutRelation(&context, actionAddr, relationAddr);
if (!context.IsElement(setAddr))
{
setAddr = context.CreateNode(ScType::NodeConst);
setAddr = context.GenerateNode(ScType::NodeConst);
}
ScAddr subSetAddr = context.CreateNode(ScType::NodeConst);
ScAddr subSetAddr = context.GenerateNode(ScType::NodeConst);
utils::GenerationUtils::generateRelationBetween(&context, actionAddr, setAddr, relationAddr);
utils::GenerationUtils::generateRelationBetween(&context, setAddr, subSetAddr, parameterRelNodeAddr);
endSetAddr = subSetAddr;
}
else
{
setAddr = context.CreateNode(ScType::NodeConst);
setAddr = context.GenerateNode(ScType::NodeConst);
utils::GenerationUtils::generateRelationBetween(&context, actionAddr, setAddr, parameterRelNodeAddr);
endSetAddr = setAddr;
}
Expand Down Expand Up @@ -150,20 +150,20 @@ bool CommonUtils::TranslateFromStringToScMemory(
if (parameter.first == CommandsConstantsFlags::EXPLANATION || parameter.first == CommandsConstantsFlags::NOTE
|| parameter.first == CommandsConstantsFlags::PURPOSE || parameter.first == CommandsConstantsFlags::MAIN_ID)
{
parameterValueAddr = context.CreateNode(ScType::LinkConst);
parameterValueAddr = context.GenerateNode(ScType::LinkConst);
context.SetLinkContent(parameterValueAddr, parameterValue);
}
else
{
parameterValueAddr = context.HelperFindBySystemIdtf(parameterValue);
parameterValueAddr = context.SearchElementBySystemIdentifier(parameterValue);
if (!context.IsElement(parameterValueAddr))
{
SC_LOG_WARNING("Transform to sc-structure: Unknown value: " << parameterValue);
parameterValueAddr = context.CreateNode(ScType::NodeConst);
context.HelperSetSystemIdtf(parameterValue, parameterValueAddr);
parameterValueAddr = context.GenerateNode(ScType::NodeConst);
context.SetElementSystemIdentifier(parameterValue, parameterValueAddr);
}
}
context.CreateEdge(ScType::EdgeAccessConstPosPerm, setAddr, parameterValueAddr);
context.GenerateConnector(ScType::EdgeAccessConstPosPerm, setAddr, parameterValueAddr);
}
}
return true;
Expand All @@ -185,13 +185,13 @@ ScAddrUnorderedSet CommonUtils::GetComponentsToInstall(ScMemoryContext & context
if (context.IsElement(parameterSetNode))
{
ScIterator3Ptr const & setsIterator =
context.Iterator3(parameterSetNode, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context.CreateIterator3(parameterSetNode, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
ScAddr componentClassAddr;
while (setsIterator->Next())
{
componentClassAddr = setsIterator->Get(2);
ScIterator3Ptr const & componentsIterator =
context.Iterator3(componentClassAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context.CreateIterator3(componentClassAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (componentsIterator->Next())
{
components.insert(componentsIterator->Get(2));
Expand All @@ -202,7 +202,7 @@ ScAddrUnorderedSet CommonUtils::GetComponentsToInstall(ScMemoryContext & context
if (context.IsElement(parameterComponentsNode))
{
ScIterator3Ptr const & componentsIterator =
context.Iterator3(parameterComponentsNode, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context.CreateIterator3(parameterComponentsNode, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (componentsIterator->Next())
{
components.insert(componentsIterator->Get(2));
Expand Down Expand Up @@ -299,12 +299,13 @@ std::map<std::string, ScAddr> CommonUtils::GetSetElements(ScMemoryContext & cont
if (!context.IsElement(setAddr))
return elementsIdtfAndAddr;
ScIterator3Ptr const & elementsIterator =
context.Iterator3(setAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context.CreateIterator3(setAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (elementsIterator->Next())
{
try
{
elementsIdtfAndAddr.insert({context.HelperGetSystemIdtf(elementsIterator->Get(2)), elementsIterator->Get(2)});
elementsIdtfAndAddr.insert(
{context.GetElementSystemIdentifier(elementsIterator->Get(2)), elementsIterator->Get(2)});
}
catch (std::exception const & exception)
{
Expand All @@ -322,7 +323,7 @@ std::map<std::string, ScAddr> CommonUtils::GetElementsLinksOfSet(ScMemoryContext
return elementsIdtfAndAddr;
std::string elementIdtf;
ScIterator3Ptr const & elementsIterator =
context.Iterator3(setAddr, ScType::EdgeAccessConstPosPerm, ScType::LinkConst);
context.CreateIterator3(setAddr, ScType::EdgeAccessConstPosPerm, ScType::LinkConst);
while (elementsIterator->Next())
{
context.GetLinkContent(elementsIterator->Get(2), elementIdtf);
Expand All @@ -342,7 +343,7 @@ ScAddr CommonUtils::GetSubsystemDecompositionAddr(ScMemoryContext & context, ScA

for (std::vector<ScAddr> const & commonComponentClass : common_utils::CommonUtils::componentsClasses)
{
if (context.HelperCheckEdge(commonComponentClass[0], component, ScType::EdgeAccessConstPosPerm))
if (context.CheckConnector(commonComponentClass[0], component, ScType::EdgeAccessConstPosPerm))
{
componentClass = commonComponentClass[1];
break;
Expand All @@ -358,11 +359,11 @@ ScAddr CommonUtils::GetSubsystemDecompositionAddr(ScMemoryContext & context, ScA
return componentDecomposition;
}
ScIterator3Ptr partsDecomposition =
context.Iterator3(myselfDecomposition, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context.CreateIterator3(myselfDecomposition, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);

while (partsDecomposition->Next())
{
if (!context.HelperCheckEdge(componentClass, partsDecomposition->Get(2), ScType::EdgeAccessConstPosPerm))
if (!context.CheckConnector(componentClass, partsDecomposition->Get(2), ScType::EdgeAccessConstPosPerm))
continue;

componentDecomposition = utils::IteratorUtils::getAnyByOutRelation(
Expand All @@ -378,7 +379,7 @@ bool CommonUtils::CheckIfInstalled(ScMemoryContext & context, ScAddr const & com
ScAddr decompositionAddr = GetSubsystemDecompositionAddr(context, component);
if (!context.IsElement(decompositionAddr) || !context.IsElement(component))
return false;
return context.HelperCheckEdge(decompositionAddr, component, ScType::EdgeAccessConstPosPerm);
return context.CheckConnector(decompositionAddr, component, ScType::EdgeAccessConstPosPerm);
}

ScAddr CommonUtils::GetComponentBySpecification(ScMemoryContext & context, ScAddr const & specification)
Expand All @@ -402,11 +403,12 @@ bool CommonUtils::CheckIfFullMyselfDecompositionExists(ScMemoryContext & context
{
componentClassAddr = subsystemAndComponentClass[1];

ScIterator3Ptr it = context.Iterator3(myselfDecompositionAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
ScIterator3Ptr it =
context.CreateIterator3(myselfDecompositionAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (it->Next())
{
myselfDecompositionPartAddr = it->Get(2);
if (context.HelperCheckEdge(componentClassAddr, myselfDecompositionPartAddr, ScType::EdgeAccessConstPosPerm))
if (context.CheckConnector(componentClassAddr, myselfDecompositionPartAddr, ScType::EdgeAccessConstPosPerm))
{
partDecompositionAddr = utils::IteratorUtils::getAnyByOutRelation(
&context, myselfDecompositionPartAddr, keynodes::ScComponentManagerKeynodes::nrel_decomposition);
Expand Down
18 changes: 9 additions & 9 deletions src/manager/agents/common-module/utils/sc_component_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace componentUtils
ScAddr SearchUtils::GetComponentAddress(ScMemoryContext * context, ScAddr const & componentAddr)
{
ScAddr componentAddressAddr;
ScIterator5Ptr const & componentAddressIterator = context->Iterator5(
ScIterator5Ptr const & componentAddressIterator = context->CreateIterator5(
componentAddr,
ScType::EdgeDCommonConst,
ScType::LinkConst,
Expand All @@ -59,7 +59,7 @@ ScAddrUnorderedSet SearchUtils::GetComponentDependencies(ScMemoryContext * conte
ScAddrUnorderedSet componentDependencies;
ScAddr componentDependenciesSet;

ScIterator5Ptr const & componentDependenciesSetIterator = context->Iterator5(
ScIterator5Ptr const & componentDependenciesSetIterator = context->CreateIterator5(
componentAddr,
ScType::EdgeDCommonConst,
ScType::NodeConst,
Expand All @@ -70,7 +70,7 @@ ScAddrUnorderedSet SearchUtils::GetComponentDependencies(ScMemoryContext * conte
{
componentDependenciesSet = componentDependenciesSetIterator->Get(2);
ScIterator3Ptr const & componentDependenciesIterator =
context->Iterator3(componentDependenciesSet, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context->CreateIterator3(componentDependenciesSet, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (componentDependenciesIterator->Next())
{
componentDependencies.insert(componentDependenciesIterator->Get(2));
Expand All @@ -89,7 +89,7 @@ ScAddrUnorderedSet SearchUtils::GetComponentDependencies(ScMemoryContext * conte
ScAddr SearchUtils::GetComponentInstallationMethod(ScMemoryContext * context, ScAddr const & componentAddr)
{
ScAddr componentInstallationMethod;
ScIterator5Ptr const & componentDependenciesIterator = context->Iterator5(
ScIterator5Ptr const & componentDependenciesIterator = context->CreateIterator5(
componentAddr,
ScType::EdgeDCommonConst,
ScType::NodeConst,
Expand All @@ -115,7 +115,7 @@ ScAddrVector SearchUtils::GetSpecificationAddress(ScMemoryContext * context, ScA
{
ScAddrVector specificationAddressLinks;

ScIterator5Ptr const & alternativeAddressesSetIterator = context->Iterator5(
ScIterator5Ptr const & alternativeAddressesSetIterator = context->CreateIterator5(
componentSpecificationAddr,
ScType::EdgeDCommonConst,
ScType::NodeTuple,
Expand Down Expand Up @@ -163,7 +163,7 @@ ScAddr SearchUtils::GetRepositoryAddress(ScMemoryContext * context, ScAddr const
{
ScAddr addressLinkAddr;

ScIterator5Ptr const & repositoryAddressIterator = context->Iterator5(
ScIterator5Ptr const & repositoryAddressIterator = context->CreateIterator5(
repositoryAddr,
ScType::EdgeDCommonConst,
ScType::NodeConst,
Expand All @@ -178,7 +178,7 @@ ScAddr SearchUtils::GetRepositoryAddress(ScMemoryContext * context, ScAddr const
ScAddr const & repositoryAddressAddr = repositoryAddressIterator->Get(2);

ScIterator3Ptr const & addressLinkIterator =
context->Iterator3(repositoryAddressAddr, ScType::EdgeAccessConstPosPerm, ScType::LinkConst);
context->CreateIterator3(repositoryAddressAddr, ScType::EdgeAccessConstPosPerm, ScType::LinkConst);

if (!addressLinkIterator->Next())
{
Expand Down Expand Up @@ -210,7 +210,7 @@ ScAddrVector SearchUtils::GetNeedToInstallComponents(ScMemoryContext * context)
bool InstallUtils::IsReusable(ScMemoryContext * context, ScAddr const & componentAddr)
{
bool result = true;
ScIterator3Ptr const reusableComponentCLassIterator = context->Iterator3(
ScIterator3Ptr const reusableComponentCLassIterator = context->CreateIterator3(
keynodes::ScComponentManagerKeynodes::concept_reusable_component, ScType::EdgeAccessConstPosPerm, componentAddr);
if (!reusableComponentCLassIterator->Next())
{
Expand All @@ -228,7 +228,7 @@ bool InstallUtils::IsReusable(ScMemoryContext * context, ScAddr const & componen
*/
std::vector<std::string> InstallUtils::GetInstallScripts(ScMemoryContext * context, ScAddr const & componentAddr)
{
ScIterator5Ptr const & installScriptsIterator = context->Iterator5(
ScIterator5Ptr const & installScriptsIterator = context->CreateIterator5(
componentAddr,
ScType::EdgeDCommonConst,
ScType::LinkConst,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ScAddrUnorderedSet ScComponentManagerCommandInit::Execute(ScAgentContext * conte
{
ScAddrUnorderedSet specifications;

ScIterator3Ptr const repositoriesIterator = context->Iterator3(
ScIterator3Ptr const repositoriesIterator = context->CreateIterator3(
keynodes::ScComponentManagerKeynodes::concept_repository, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);

ScAddr repository;
Expand Down Expand Up @@ -45,14 +45,14 @@ void ScComponentManagerCommandInit::ProcessRepository(
{
SC_LOG_WARNING(
"ScComponentManagerCommandInit: components specification not found in repository "
<< context->HelperGetSystemIdtf(repository));
<< context->GetElementSystemIdentifier(repository));
return;
}

ScAddr componentSpecification;
ScAddr component;
ScIterator3Ptr const specificationsIterator =
context->Iterator3(specificationsSetAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
context->CreateIterator3(specificationsSetAddr, ScType::EdgeAccessConstPosPerm, ScType::NodeConst);
while (specificationsIterator->Next())
{
componentSpecification = specificationsIterator->Get(2);
Expand All @@ -61,15 +61,16 @@ void ScComponentManagerCommandInit::ProcessRepository(
{
SC_LOG_WARNING(
"ScComponentManagerCommandInit: Specification is already loaded for component "
<< context->HelperGetSystemIdtf(component));
<< context->GetElementSystemIdentifier(component));
continue;
}
specifications.insert(componentSpecification);
downloaderHandler->DownloadSpecification(context, componentSpecification);
std::string const specificationPath = m_specificationsPath + SpecificationConstants::DIRECTORY_DELIMITER
+ context->HelperGetSystemIdtf(componentSpecification);
+ context->GetElementSystemIdentifier(componentSpecification);
componentUtils::LoadUtils::LoadScsFilesInDir(context, specificationPath);
SC_LOG_DEBUG(
"ScComponentManagerCommandInit: loaded specification " << context->HelperGetSystemIdtf(componentSpecification));
"ScComponentManagerCommandInit: loaded specification "
<< context->GetElementSystemIdentifier(componentSpecification));
}
}
Loading

0 comments on commit 44290b8

Please sign in to comment.