Skip to content

Commit

Permalink
post filter renaming patch
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq committed Apr 30, 2024
1 parent 49c56ef commit cb49d6a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 249 deletions.
134 changes: 0 additions & 134 deletions src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObject.cpp

This file was deleted.

106 changes: 0 additions & 106 deletions src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObject.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Parameters RenameDataObjectFilter::parameters() const
Parameters params;

params.insertSeparator(Parameters::Separator{"Input Parameters"});
params.insert(std::make_unique<BoolParameter>(k_AllowOverwrite_Key, "Allow Overwrite",
"If true existing object with `New Name` and all of its nested objects will be removed to free up the name for the target DataObject", false));
params.insert(std::make_unique<DataPathSelectionParameter>(k_SourceDataObjectPath_Key, "DataObject to Rename", "DataPath pointing to the target DataObject", DataPath()));
params.insert(std::make_unique<StringParameter>(k_NewName_Key, "New Name", "Target DataObject name", ""));
return params;
Expand All @@ -71,10 +73,11 @@ IFilter::UniquePointer RenameDataObjectFilter::clone() const
IFilter::PreflightResult RenameDataObjectFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto allowOverwrite = filterArgs.value<bool>(k_AllowOverwrite_Key);
auto dataGroupPath = filterArgs.value<DataPath>(k_SourceDataObjectPath_Key);
auto newName = filterArgs.value<std::string>(k_NewName_Key);

auto action = std::make_unique<RenameDataAction>(dataGroupPath, newName);
auto action = std::make_unique<RenameDataAction>(dataGroupPath, newName, allowOverwrite);

OutputActions actions;
actions.appendAction(std::move(action));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SIMPLNXCORE_EXPORT RenameDataObjectFilter : public IFilter
RenameDataObjectFilter& operator=(RenameDataObjectFilter&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_AllowOverwrite_Key = "allow_overwrite";
static inline constexpr StringLiteral k_SourceDataObjectPath_Key = "source_data_object_path";
static inline constexpr StringLiteral k_NewName_Key = "new_name";

Expand Down
16 changes: 8 additions & 8 deletions src/Plugins/SimplnxCore/test/RenameDataObjectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ TEST_CASE("SimplnxCore::RenameDataAction(Valid Overwrite)", "[SimplnxCore][Renam
static constexpr StringLiteral k_NewName = Constants::k_GroupHName;
static const DataPath k_DataPath({Constants::k_GroupAName, Constants::k_GroupCName, Constants::k_GroupDName, Constants::k_ArrayIName});

RenameDataObject filter;
RenameDataObjectFilter filter;
DataStructure dataStructure = UnitTest::CreateComplexMultiLevelDataGraph();
Arguments args;

args.insert(RenameDataObject::k_AllowOverwrite_Key, std::make_any<bool>(true));
args.insert(RenameDataObject::k_NewName_Key, std::make_any<std::string>(k_NewName));
args.insert(RenameDataObject::k_SourceDataObjectPath_Key, std::make_any<DataPath>(k_DataPath));
args.insert(RenameDataObjectFilter::k_AllowOverwrite_Key, std::make_any<bool>(true));
args.insert(RenameDataObjectFilter::k_NewName_Key, std::make_any<std::string>(k_NewName));
args.insert(RenameDataObjectFilter::k_SourceDataObjectPath_Key, std::make_any<DataPath>(k_DataPath));

auto preflightResult = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions);
Expand Down Expand Up @@ -126,14 +126,14 @@ TEST_CASE("SimplnxCore::RenameDataAction(InValid Overwrite)", "[SimplnxCore][Ren
static constexpr StringLiteral k_NewName = Constants::k_GroupDName;
static const DataPath k_DataPath({Constants::k_GroupAName, Constants::k_GroupCName, Constants::k_GroupDName, Constants::k_ArrayIName});

RenameDataObject filter;
RenameDataObjectFilter filter;

DataStructure dataStructure = UnitTest::CreateComplexMultiLevelDataGraph();
Arguments args;

args.insert(RenameDataObject::k_AllowOverwrite_Key, std::make_any<bool>(true));
args.insert(RenameDataObject::k_NewName_Key, std::make_any<std::string>(k_NewName));
args.insert(RenameDataObject::k_SourceDataObjectPath_Key, std::make_any<DataPath>(k_DataPath));
args.insert(RenameDataObjectFilter::k_AllowOverwrite_Key, std::make_any<bool>(true));
args.insert(RenameDataObjectFilter::k_NewName_Key, std::make_any<std::string>(k_NewName));
args.insert(RenameDataObjectFilter::k_SourceDataObjectPath_Key, std::make_any<DataPath>(k_DataPath));

auto preflightResult = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions);
Expand Down

0 comments on commit cb49d6a

Please sign in to comment.