comparison OrthancServer/Sources/ServerIndex.cpp @ 4573:f6bd5563b5df db-changes

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Mar 2021 17:47:43 +0100
parents c12d4e5f469b
children 855e43bb293c
comparison
equal deleted inserted replaced
4572:c12d4e5f469b 4573:f6bd5563b5df
1673 { 1673 {
1674 assert(writeOperations != NULL); 1674 assert(writeOperations != NULL);
1675 1675
1676 Transaction transaction(*this, TransactionType_ReadWrite); 1676 Transaction transaction(*this, TransactionType_ReadWrite);
1677 { 1677 {
1678 ReadWriteTransaction t(db_, *this); 1678 assert(listener_.get() != NULL);
1679 writeOperations->Apply(t, *listener_); 1679 ReadWriteTransaction t(db_, *listener_, *this);
1680 writeOperations->Apply(t);
1680 } 1681 }
1681 transaction.Commit(0); 1682 transaction.Commit(0);
1682 } 1683 }
1683 1684
1684 return; // Success 1685 return; // Success
2959 bool IsFound() const 2960 bool IsFound() const
2960 { 2961 {
2961 return found_; 2962 return found_;
2962 } 2963 }
2963 2964
2964 virtual void Apply(ReadWriteTransaction& transaction, 2965 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
2965 Listener& listener) ORTHANC_OVERRIDE
2966 { 2966 {
2967 int64_t id; 2967 int64_t id;
2968 ResourceType type; 2968 ResourceType type;
2969 if (!transaction.LookupResource(id, type, uuid_) || 2969 if (!transaction.LookupResource(id, type, uuid_) ||
2970 expectedType_ != type) 2970 expectedType_ != type)
2974 else 2974 else
2975 { 2975 {
2976 found_ = true; 2976 found_ = true;
2977 transaction.DeleteResource(id); 2977 transaction.DeleteResource(id);
2978 2978
2979 if (listener.HasRemainingLevel()) 2979 if (transaction.GetListener().HasRemainingLevel())
2980 { 2980 {
2981 ResourceType remainingType = listener.GetRemainingType(); 2981 ResourceType remainingType = transaction.GetListener().GetRemainingType();
2982 const std::string& remainingUuid = listener.GetRemainingPublicId(); 2982 const std::string& remainingUuid = transaction.GetListener().GetRemainingPublicId();
2983 2983
2984 target_["RemainingAncestor"] = Json::Value(Json::objectValue); 2984 target_["RemainingAncestor"] = Json::Value(Json::objectValue);
2985 target_["RemainingAncestor"]["Path"] = GetBasePath(remainingType, remainingUuid); 2985 target_["RemainingAncestor"]["Path"] = GetBasePath(remainingType, remainingUuid);
2986 target_["RemainingAncestor"]["Type"] = EnumerationToString(remainingType); 2986 target_["RemainingAncestor"]["Type"] = EnumerationToString(remainingType);
2987 target_["RemainingAncestor"]["ID"] = remainingUuid; 2987 target_["RemainingAncestor"]["ID"] = remainingUuid;
3015 publicId_(publicId), 3015 publicId_(publicId),
3016 remoteModality_(remoteModality) 3016 remoteModality_(remoteModality)
3017 { 3017 {
3018 } 3018 }
3019 3019
3020 virtual void Apply(ReadWriteTransaction& transaction, 3020 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3021 Listener& listener) ORTHANC_OVERRIDE
3022 { 3021 {
3023 int64_t id; 3022 int64_t id;
3024 ResourceType type; 3023 ResourceType type;
3025 if (!transaction.LookupResource(id, type, publicId_)) 3024 if (!transaction.LookupResource(id, type, publicId_))
3026 { 3025 {
3124 publicId_(publicId), 3123 publicId_(publicId),
3125 isProtected_(isProtected) 3124 isProtected_(isProtected)
3126 { 3125 {
3127 } 3126 }
3128 3127
3129 virtual void Apply(ReadWriteTransaction& transaction, 3128 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3130 Listener& listener) ORTHANC_OVERRIDE
3131 { 3129 {
3132 // Lookup for the requested resource 3130 // Lookup for the requested resource
3133 int64_t id; 3131 int64_t id;
3134 ResourceType type; 3132 ResourceType type;
3135 if (!transaction.LookupResource(id, type, publicId_) || 3133 if (!transaction.LookupResource(id, type, publicId_) ||
3177 type_(type), 3175 type_(type),
3178 value_(value) 3176 value_(value)
3179 { 3177 {
3180 } 3178 }
3181 3179
3182 virtual void Apply(ReadWriteTransaction& transaction, 3180 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3183 Listener& listener) ORTHANC_OVERRIDE
3184 { 3181 {
3185 ResourceType rtype; 3182 ResourceType rtype;
3186 int64_t id; 3183 int64_t id;
3187 if (!transaction.LookupResource(id, rtype, publicId_)) 3184 if (!transaction.LookupResource(id, rtype, publicId_))
3188 { 3185 {
3220 publicId_(publicId), 3217 publicId_(publicId),
3221 type_(type) 3218 type_(type)
3222 { 3219 {
3223 } 3220 }
3224 3221
3225 virtual void Apply(ReadWriteTransaction& transaction, 3222 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3226 Listener& listener) ORTHANC_OVERRIDE
3227 { 3223 {
3228 ResourceType rtype; 3224 ResourceType rtype;
3229 int64_t id; 3225 int64_t id;
3230 if (!transaction.LookupResource(id, rtype, publicId_)) 3226 if (!transaction.LookupResource(id, rtype, publicId_))
3231 { 3227 {
3266 uint64_t GetNewValue() const 3262 uint64_t GetNewValue() const
3267 { 3263 {
3268 return newValue_; 3264 return newValue_;
3269 } 3265 }
3270 3266
3271 virtual void Apply(ReadWriteTransaction& transaction, 3267 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3272 Listener& listener) ORTHANC_OVERRIDE
3273 { 3268 {
3274 std::string oldString; 3269 std::string oldString;
3275 3270
3276 if (transaction.LookupGlobalProperty(oldString, sequence_)) 3271 if (transaction.LookupGlobalProperty(oldString, sequence_))
3277 { 3272 {
3310 void ServerIndex::DeleteChanges() 3305 void ServerIndex::DeleteChanges()
3311 { 3306 {
3312 class Operations : public IReadWriteOperations 3307 class Operations : public IReadWriteOperations
3313 { 3308 {
3314 public: 3309 public:
3315 virtual void Apply(ReadWriteTransaction& transaction, 3310 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3316 Listener& listener) ORTHANC_OVERRIDE
3317 { 3311 {
3318 transaction.ClearChanges(); 3312 transaction.ClearChanges();
3319 } 3313 }
3320 }; 3314 };
3321 3315
3327 void ServerIndex::DeleteExportedResources() 3321 void ServerIndex::DeleteExportedResources()
3328 { 3322 {
3329 class Operations : public IReadWriteOperations 3323 class Operations : public IReadWriteOperations
3330 { 3324 {
3331 public: 3325 public:
3332 virtual void Apply(ReadWriteTransaction& transaction, 3326 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3333 Listener& listener) ORTHANC_OVERRIDE
3334 { 3327 {
3335 transaction.ClearExportedResources(); 3328 transaction.ClearExportedResources();
3336 } 3329 }
3337 }; 3330 };
3338 3331
3356 property_(property), 3349 property_(property),
3357 value_(value) 3350 value_(value)
3358 { 3351 {
3359 } 3352 }
3360 3353
3361 virtual void Apply(ReadWriteTransaction& transaction, 3354 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3362 Listener& listener) ORTHANC_OVERRIDE
3363 { 3355 {
3364 transaction.SetGlobalProperty(property_, value_); 3356 transaction.SetGlobalProperty(property_, value_);
3365 } 3357 }
3366 }; 3358 };
3367 3359
3385 publicId_(publicId), 3377 publicId_(publicId),
3386 type_(type) 3378 type_(type)
3387 { 3379 {
3388 } 3380 }
3389 3381
3390 virtual void Apply(ReadWriteTransaction& transaction, 3382 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3391 Listener& listener) ORTHANC_OVERRIDE
3392 { 3383 {
3393 ResourceType rtype; 3384 ResourceType rtype;
3394 int64_t id; 3385 int64_t id;
3395 if (!transaction.LookupResource(id, rtype, publicId_)) 3386 if (!transaction.LookupResource(id, rtype, publicId_))
3396 { 3387 {
3428 changeType_(changeType), 3419 changeType_(changeType),
3429 publicId_(publicId) 3420 publicId_(publicId)
3430 { 3421 {
3431 } 3422 }
3432 3423
3433 virtual void Apply(ReadWriteTransaction& transaction, 3424 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
3434 Listener& listener) ORTHANC_OVERRIDE
3435 { 3425 {
3436 int64_t id; 3426 int64_t id;
3437 ResourceType type; 3427 ResourceType type;
3438 if (!transaction.LookupResource(id, type, publicId_)) 3428 if (!transaction.LookupResource(id, type, publicId_))
3439 { 3429 {