comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5297:c78138dc3889

When deleting a resource, its parents LastUpdate metadata is now updated
author Alain Mazy <am@osimis.io>
date Mon, 22 May 2023 17:58:06 +0200
parents 5053a10da5a2
children f26ed26a7793 03501a258d9e
comparison
equal deleted inserted replaced
5296:5053a10da5a2 5297:c78138dc3889
2034 { 2034 {
2035 remainingAncestor_["RemainingAncestor"] = Json::Value(Json::objectValue); 2035 remainingAncestor_["RemainingAncestor"] = Json::Value(Json::objectValue);
2036 remainingAncestor_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId); 2036 remainingAncestor_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId);
2037 remainingAncestor_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel); 2037 remainingAncestor_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel);
2038 remainingAncestor_["RemainingAncestor"]["ID"] = remainingPublicId; 2038 remainingAncestor_["RemainingAncestor"]["ID"] = remainingPublicId;
2039
2040 { // update the LastUpdate metadata of all parents
2041 std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */);
2042 ResourcesContent content(true);
2043
2044 int64_t parentId = 0;
2045 if (transaction.LookupResource(parentId, remainingLevel, remainingPublicId))
2046 {
2047
2048 do
2049 {
2050 content.AddMetadata(parentId, MetadataType_LastUpdate, now);
2051 }
2052 while (transaction.LookupParent(parentId, parentId));
2053
2054 transaction.SetResourcesContent(content);
2055 }
2056 }
2039 } 2057 }
2040 else 2058 else
2041 { 2059 {
2042 remainingAncestor_["RemainingAncestor"] = Json::nullValue; 2060 remainingAncestor_["RemainingAncestor"] = Json::nullValue;
2043 } 2061 }