Mercurial > hg > orthanc
comparison OrthancServer/ServerToolbox.h @ 3083:683d572424b6 db-changes
IDatabaseWrapper::SetResourcesContent
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jan 2019 15:52:19 +0100 |
parents | 4e43e67f8ecf |
children | d498ece73562 |
comparison
equal
deleted
inserted
replaced
3082:847a0ed92654 | 3083:683d572424b6 |
---|---|
31 **/ | 31 **/ |
32 | 32 |
33 | 33 |
34 #pragma once | 34 #pragma once |
35 | 35 |
36 #include "ServerContext.h" | 36 #include "ServerEnumerations.h" |
37 | 37 |
38 #include <json/json.h> | 38 #include <json/json.h> |
39 #include <boost/noncopyable.hpp> | |
40 #include <list> | |
39 | 41 |
40 namespace Orthanc | 42 namespace Orthanc |
41 { | 43 { |
44 class ServerContext; | |
45 class IDatabaseWrapper; | |
46 class DicomMap; | |
47 class IStorageArea; | |
48 | |
49 namespace Compatibility | |
50 { | |
51 class ISetResourcesContent; | |
52 } | |
53 | |
54 | |
55 // TODO - Move this to a separate file | |
56 class ResourcesContent : public boost::noncopyable | |
57 { | |
58 private: | |
59 struct TagValue | |
60 { | |
61 int64_t resourceId_; | |
62 bool isIdentifier_; | |
63 DicomTag tag_; | |
64 std::string value_; | |
65 | |
66 TagValue(int64_t resourceId, | |
67 bool isIdentifier, | |
68 const DicomTag& tag, | |
69 const std::string& value) : | |
70 resourceId_(resourceId), | |
71 isIdentifier_(isIdentifier), | |
72 tag_(tag), | |
73 value_(value) | |
74 { | |
75 } | |
76 }; | |
77 | |
78 struct Metadata | |
79 { | |
80 int64_t resourceId_; | |
81 MetadataType metadata_; | |
82 std::string value_; | |
83 | |
84 Metadata(int64_t resourceId, | |
85 MetadataType metadata, | |
86 const std::string& value) : | |
87 resourceId_(resourceId), | |
88 metadata_(metadata), | |
89 value_(value) | |
90 { | |
91 } | |
92 }; | |
93 | |
94 std::list<TagValue> tags_; | |
95 std::list<Metadata> metadata_; | |
96 | |
97 public: | |
98 void AddMainDicomTag(int64_t resourceId, | |
99 const DicomTag& tag, | |
100 const std::string& value) | |
101 { | |
102 tags_.push_back(TagValue(resourceId, false, tag, value)); | |
103 } | |
104 | |
105 void AddIdentifierTag(int64_t resourceId, | |
106 const DicomTag& tag, | |
107 const std::string& value) | |
108 { | |
109 tags_.push_back(TagValue(resourceId, true, tag, value)); | |
110 } | |
111 | |
112 void AddMetadata(int64_t resourceId, | |
113 MetadataType metadata, | |
114 const std::string& value) | |
115 { | |
116 metadata_.push_back(Metadata(resourceId, metadata, value)); | |
117 } | |
118 | |
119 void AddResource(int64_t resource, | |
120 ResourceType level, | |
121 const DicomMap& dicomSummary); | |
122 | |
123 // WARNING: The database should be locked with a transaction! | |
124 void Store(Compatibility::ISetResourcesContent& target) const; | |
125 }; | |
126 | |
127 | |
42 namespace ServerToolbox | 128 namespace ServerToolbox |
43 { | 129 { |
44 void SimplifyTags(Json::Value& target, | 130 void SimplifyTags(Json::Value& target, |
45 const Json::Value& source, | 131 const Json::Value& source, |
46 DicomToJsonFormat format); | 132 DicomToJsonFormat format); |
47 | |
48 void StoreMainDicomTags(IDatabaseWrapper& database, | |
49 int64_t resource, | |
50 ResourceType level, | |
51 const DicomMap& dicomSummary); | |
52 | 133 |
53 bool FindOneChildInstance(int64_t& result, | 134 bool FindOneChildInstance(int64_t& result, |
54 IDatabaseWrapper& database, | 135 IDatabaseWrapper& database, |
55 int64_t resource, | 136 int64_t resource, |
56 ResourceType type); | 137 ResourceType type); |