comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 4694:da1edb7d6332

"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Jun 2021 17:37:47 +0200
parents 66109d24d26e
children 569d9ef165b1
comparison
equal deleted inserted replaced
4693:45bce660ce3a 4694:da1edb7d6332
1971 CopyListToVector(*instancesId, operations.GetInstancesList()); 1971 CopyListToVector(*instancesId, operations.GetInstancesList());
1972 } 1972 }
1973 } 1973 }
1974 1974
1975 1975
1976 bool StatelessDatabaseOperations::DeleteResource(Json::Value& target, 1976 bool StatelessDatabaseOperations::DeleteResource(Json::Value& remainingAncestor,
1977 const std::string& uuid, 1977 const std::string& uuid,
1978 ResourceType expectedType) 1978 ResourceType expectedType)
1979 { 1979 {
1980 class Operations : public IReadWriteOperations 1980 class Operations : public IReadWriteOperations
1981 { 1981 {
1982 private: 1982 private:
1983 bool found_; 1983 bool found_;
1984 Json::Value& target_; 1984 Json::Value& remainingAncestor_;
1985 const std::string& uuid_; 1985 const std::string& uuid_;
1986 ResourceType expectedType_; 1986 ResourceType expectedType_;
1987 1987
1988 public: 1988 public:
1989 Operations(Json::Value& target, 1989 Operations(Json::Value& remainingAncestor,
1990 const std::string& uuid, 1990 const std::string& uuid,
1991 ResourceType expectedType) : 1991 ResourceType expectedType) :
1992 found_(false), 1992 found_(false),
1993 target_(target), 1993 remainingAncestor_(remainingAncestor),
1994 uuid_(uuid), 1994 uuid_(uuid),
1995 expectedType_(expectedType) 1995 expectedType_(expectedType)
1996 { 1996 {
1997 } 1997 }
1998 1998
2017 2017
2018 std::string remainingPublicId; 2018 std::string remainingPublicId;
2019 ResourceType remainingLevel; 2019 ResourceType remainingLevel;
2020 if (transaction.GetTransactionContext().LookupRemainingLevel(remainingPublicId, remainingLevel)) 2020 if (transaction.GetTransactionContext().LookupRemainingLevel(remainingPublicId, remainingLevel))
2021 { 2021 {
2022 target_["RemainingAncestor"] = Json::Value(Json::objectValue); 2022 remainingAncestor_["RemainingAncestor"] = Json::Value(Json::objectValue);
2023 target_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId); 2023 remainingAncestor_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId);
2024 target_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel); 2024 remainingAncestor_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel);
2025 target_["RemainingAncestor"]["ID"] = remainingPublicId; 2025 remainingAncestor_["RemainingAncestor"]["ID"] = remainingPublicId;
2026 } 2026 }
2027 else 2027 else
2028 { 2028 {
2029 target_["RemainingAncestor"] = Json::nullValue; 2029 remainingAncestor_["RemainingAncestor"] = Json::nullValue;
2030 } 2030 }
2031 } 2031 }
2032 } 2032 }
2033 }; 2033 };
2034 2034
2035 Operations operations(target, uuid, expectedType); 2035 Operations operations(remainingAncestor, uuid, expectedType);
2036 Apply(operations); 2036 Apply(operations);
2037 return operations.IsFound(); 2037 return operations.IsFound();
2038 } 2038 }
2039 2039
2040 2040