| 1170 | } |
| 1171 | |
| 1172 | DataStorageBridge::ReplacePropertiesResult DataStorageBridge::ReplaceNodeProperties( |
| 1173 | const std::string& uid, |
| 1174 | const Json& properties, |
| 1175 | const PropertyQueryParams& params) |
| 1176 | { |
| 1177 | // Mutation operations only support Node and Data scopes, not All |
| 1178 | if (params.scope == PropertyScope::All) |
| 1179 | { |
| 1180 | return {OperationStatus::InvalidInput}; |
| 1181 | } |
| 1182 | |
| 1183 | std::lock_guard<std::mutex> lock(m_Mutex); |
| 1184 | return this->DispatchTask<ReplacePropertiesResult>([this, uid, properties, params]() |
| 1185 | { |
| 1186 | auto dataStorage = m_DataStorage.Lock(); |
| 1187 | if (dataStorage.IsNull()) |
| 1188 | { |
| 1189 | return ReplacePropertiesResult{OperationStatus::InternalError}; |
| 1190 | } |
| 1191 | |
| 1192 | auto node = m_UidMapper->FindNodeByUid(uid); |
| 1193 | if (node == nullptr) |
| 1194 | { |
| 1195 | return ReplacePropertiesResult{OperationStatus::NodeNotFound}; |
| 1196 | } |
| 1197 | |
| 1198 | if (!properties.is_object()) |
| 1199 | { |
| 1200 | return ReplacePropertiesResult{OperationStatus::InvalidInput}; |
| 1201 | } |
| 1202 | |
| 1203 | const std::string contextName = params.context.has_value() ? params.context.value() : ""; |
| 1204 | |
| 1205 | // Get the correct property list for the target scope |
| 1206 | PropertyList* propertyList = nullptr; |
| 1207 | if (params.scope == PropertyScope::Data) |
| 1208 | { |
| 1209 | auto data = node->GetData(); |
| 1210 | if (data != nullptr) |
| 1211 | { |
| 1212 | propertyList = data->GetPropertyList(); |
| 1213 | } |
| 1214 | } |
| 1215 | else |
| 1216 | { |
| 1217 | propertyList = node->GetPropertyList(contextName); |
| 1218 | } |
| 1219 | |
| 1220 | if (propertyList == nullptr) |
| 1221 | { |
| 1222 | return ReplacePropertiesResult{OperationStatus::InvalidInput}; |
| 1223 | } |
| 1224 | |
| 1225 | // Collect existing property keys using scope-aware helper |
| 1226 | const auto existingKeys = GetPropertyKeysForScope(node, contextName, params.scope); |
| 1227 | |
| 1228 | // Track what was replaced vs removed |
| 1229 | std::vector<std::string> replaced; |
no test coverage detected