comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.h @ 5221:d0f7c742d397 db-protobuf

started implementation of labels
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Apr 2023 20:53:14 +0200
parents df39c7583a49
children 3a61fd50f804
comparison
equal deleted inserted replaced
5220:df39c7583a49 5221:d0f7c742d397
60 60
61 // for instances only 61 // for instances only
62 size_t fileSize_; 62 size_t fileSize_;
63 std::string fileUuid_; 63 std::string fileUuid_;
64 int indexInSeries_; 64 int indexInSeries_;
65
66 // New in Orthanc 1.12.0
67 std::set<std::string> labels_;
65 }; 68 };
66 69
67 enum ExpandResourceDbFlags 70 enum ExpandResourceDbFlags
68 { 71 {
69 ExpandResourceDbFlags_None = 0, 72 ExpandResourceDbFlags_None = 0,
70 ExpandResourceDbFlags_IncludeMetadata = (1 << 0), 73 ExpandResourceDbFlags_IncludeMetadata = (1 << 0),
71 ExpandResourceDbFlags_IncludeChildren = (1 << 1), 74 ExpandResourceDbFlags_IncludeChildren = (1 << 1),
72 ExpandResourceDbFlags_IncludeMainDicomTags = (1 << 2), 75 ExpandResourceDbFlags_IncludeMainDicomTags = (1 << 2),
76 ExpandResourceDbFlags_IncludeLabels = (1 << 3),
73 77
74 ExpandResourceDbFlags_Default = (ExpandResourceDbFlags_IncludeMetadata | 78 ExpandResourceDbFlags_Default = (ExpandResourceDbFlags_IncludeMetadata |
75 ExpandResourceDbFlags_IncludeChildren | 79 ExpandResourceDbFlags_IncludeChildren |
76 ExpandResourceDbFlags_IncludeMainDicomTags) 80 ExpandResourceDbFlags_IncludeMainDicomTags |
81 ExpandResourceDbFlags_IncludeLabels)
77 }; 82 };
78 83
79 class StatelessDatabaseOperations : public boost::noncopyable 84 class StatelessDatabaseOperations : public boost::noncopyable
80 { 85 {
81 public: 86 public:
82 typedef std::list<FileInfo> Attachments; 87 typedef std::list<FileInfo> Attachments;
83 typedef std::map<std::pair<ResourceType, MetadataType>, std::string> MetadataMap; 88 typedef std::map<std::pair<ResourceType, MetadataType>, std::string> MetadataMap;
89
90 enum LabelOperation
91 {
92 LabelOperation_Add,
93 LabelOperation_Remove
94 };
84 95
85 class ITransactionContext : public IDatabaseListener 96 class ITransactionContext : public IDatabaseListener
86 { 97 {
87 public: 98 public:
88 virtual ~ITransactionContext() 99 virtual ~ITransactionContext()
310 std::string& parentPublicId, 321 std::string& parentPublicId,
311 const std::string& publicId) 322 const std::string& publicId)
312 { 323 {
313 return transaction_.LookupResourceAndParent(id, type, parentPublicId, publicId); 324 return transaction_.LookupResourceAndParent(id, type, parentPublicId, publicId);
314 } 325 }
326
327 void ListLabels(std::set<std::string>& target,
328 int64_t id)
329 {
330 transaction_.ListLabels(target, id);
331 }
315 }; 332 };
316 333
317 334
318 class ReadWriteTransaction : public ReadOnlyTransaction 335 class ReadWriteTransaction : public ReadOnlyTransaction
319 { 336 {
422 439
423 bool IsRecyclingNeeded(uint64_t maximumStorageSize, 440 bool IsRecyclingNeeded(uint64_t maximumStorageSize,
424 unsigned int maximumPatients, 441 unsigned int maximumPatients,
425 uint64_t addedInstanceSize, 442 uint64_t addedInstanceSize,
426 const std::string& newPatientId); 443 const std::string& newPatientId);
444
445 void AddLabel(int64_t id,
446 const std::string& label)
447 {
448 transaction_.AddLabel(id, label);
449 }
450
451 void RemoveLabel(int64_t id,
452 const std::string& label)
453 {
454 transaction_.RemoveLabel(id, label);
455 }
427 }; 456 };
428 457
429 458
430 class IReadOnlyOperations : public boost::noncopyable 459 class IReadOnlyOperations : public boost::noncopyable
431 { 460 {
685 uint64_t maximumStorageSize, 714 uint64_t maximumStorageSize,
686 unsigned int maximumPatients, 715 unsigned int maximumPatients,
687 bool hasOldRevision, 716 bool hasOldRevision,
688 int64_t oldRevision, 717 int64_t oldRevision,
689 const std::string& oldMd5); 718 const std::string& oldMd5);
719
720 void ListLabels(std::set<std::string>& target,
721 const std::string& publicId,
722 ResourceType level);
723
724 void ModifyLabel(const std::string& publicId,
725 ResourceType level,
726 const std::string& label,
727 LabelOperation operation);
690 }; 728 };
691 } 729 }