comparison OrthancServer/Sources/LuaScripting.cpp @ 4554:efd90f778cd2 db-changes

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Mar 2021 16:31:57 +0100
parents 350a22c094f2
children 456ed3fcff81
comparison
equal deleted inserted replaced
4552:beb8ba8a0b12 4554:efd90f778cd2
36 36
37 #include "OrthancConfiguration.h" 37 #include "OrthancConfiguration.h"
38 #include "OrthancRestApi/OrthancRestApi.h" 38 #include "OrthancRestApi/OrthancRestApi.h"
39 #include "ServerContext.h" 39 #include "ServerContext.h"
40 40
41 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
41 #include "../../OrthancFramework/Sources/HttpServer/StringHttpOutput.h" 42 #include "../../OrthancFramework/Sources/HttpServer/StringHttpOutput.h"
42 #include "../../OrthancFramework/Sources/Logging.h" 43 #include "../../OrthancFramework/Sources/Logging.h"
43 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h" 44 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h"
44 45
45 #include <OrthancServerResources.h> 46 #include <OrthancServerResources.h>
129 class GetInfoOperations : public ServerIndex::IReadOnlyOperations 130 class GetInfoOperations : public ServerIndex::IReadOnlyOperations
130 { 131 {
131 private: 132 private:
132 const ServerIndexChange& change_; 133 const ServerIndexChange& change_;
133 bool ok_; 134 bool ok_;
134 Json::Value tags_; 135 DicomMap tags_;
135 std::map<MetadataType, std::string> metadata_; 136 std::map<MetadataType, std::string> metadata_;
136 137
137 public: 138 public:
138 GetInfoOperations(const ServerIndexChange& change) : 139 GetInfoOperations(const ServerIndexChange& change) :
139 change_(change), 140 change_(change),
141 { 142 {
142 } 143 }
143 144
144 virtual void Apply(ServerIndex::ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE 145 virtual void Apply(ServerIndex::ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE
145 { 146 {
146 if (transaction.LookupResource(tags_, change_.GetPublicId(), change_.GetResourceType())) 147 int64_t internalId;
148 ResourceType level;
149 if (transaction.LookupResource(internalId, level, change_.GetPublicId()) &&
150 level == change_.GetResourceType())
147 { 151 {
148 transaction.GetAllMetadata(metadata_, change_.GetPublicId(), change_.GetResourceType()); 152 transaction.GetMainDicomTags(tags_, internalId);
153 transaction.GetAllMetadata(metadata_, internalId);
149 ok_ = true; 154 ok_ = true;
150 } 155 }
151 } 156 }
152 157
153 void CallLua(LuaScripting& that, 158 void CallLua(LuaScripting& that,
154 const char* name) const 159 const char* name) const
155 { 160 {
169 174
170 if (lock.GetLua().IsExistingFunction(name)) 175 if (lock.GetLua().IsExistingFunction(name))
171 { 176 {
172 that.InitializeJob(); 177 that.InitializeJob();
173 178
179 Json::Value json = Json::objectValue;
180
181 if (change_.GetResourceType() == ResourceType_Study)
182 {
183 DicomMap t;
184 tags_.ExtractStudyInformation(t); // Discard patient-related tags
185 FromDcmtkBridge::ToJson(json, t, true);
186 }
187 else
188 {
189 FromDcmtkBridge::ToJson(json, tags_, true);
190 }
191
174 LuaFunctionCall call(lock.GetLua(), name); 192 LuaFunctionCall call(lock.GetLua(), name);
175 call.PushString(change_.GetPublicId()); 193 call.PushString(change_.GetPublicId());
176 call.PushJson(tags_["MainDicomTags"]); 194 call.PushJson(json);
177 call.PushJson(formattedMetadata); 195 call.PushJson(formattedMetadata);
178 call.Execute(); 196 call.Execute();
179 197
180 that.SubmitJob(); 198 that.SubmitJob();
181 } 199 }