Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp @ 4979:f316413027fd more-tags
renamed DbOptizer into Housekeeper + add Scheduler & triggers
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 25 Apr 2022 15:30:51 +0200 |
parents | OrthancServer/Plugins/Samples/DbOptimizer/Plugin.cpp@1b76853e1797 |
children | d0c34145320c |
rev | line source |
---|---|
4961 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include "../../../../OrthancFramework/Sources/Compatibility.h" | |
24 #include "../Common/OrthancPluginCppWrapper.h" | |
25 | |
26 #include <boost/thread.hpp> | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
27 #include <boost/algorithm/string.hpp> |
4961 | 28 #include <json/value.h> |
29 #include <json/writer.h> | |
30 #include <string.h> | |
31 #include <iostream> | |
32 #include <algorithm> | |
33 #include <map> | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
34 #include <list> |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
35 #include <time.h> |
4961 | 36 |
37 static int globalPropertyId_ = 0; | |
38 static bool force_ = false; | |
39 static uint throttleDelay_ = 0; | |
40 static std::unique_ptr<boost::thread> workerThread_; | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
41 static bool workerThreadShouldStop_ = false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
42 static bool triggerOnStorageCompressionChange_ = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
43 static bool triggerOnMainDicomTagsChange_ = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
44 static bool triggerOnUnnecessaryDicomAsJsonFiles_ = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
45 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
46 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
47 struct RunningPeriod |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
48 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
49 int fromHour_; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
50 int toHour_; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
51 int weekday_; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
52 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
53 RunningPeriod(const std::string& weekday, const std::string& period) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
54 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
55 if (weekday == "Monday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
56 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
57 weekday_ = 1; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
58 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
59 else if (weekday == "Tuesday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
60 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
61 weekday_ = 2; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
62 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
63 else if (weekday == "Wednesday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
64 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
65 weekday_ = 3; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
66 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
67 else if (weekday == "Thursday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
68 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
69 weekday_ = 4; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
70 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
71 else if (weekday == "Friday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
72 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
73 weekday_ = 5; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
74 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
75 else if (weekday == "Saturday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
76 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
77 weekday_ = 6; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
78 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
79 else if (weekday == "Sunday") |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
80 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
81 weekday_ = 0; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
82 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
83 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
84 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
85 OrthancPlugins::LogWarning("Housekeeper: invalid schedule: unknown 'day': " + weekday); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
86 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
87 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
88 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
89 std::vector<std::string> hours; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
90 boost::split(hours, period, boost::is_any_of("-")); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
91 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
92 fromHour_ = boost::lexical_cast<int>(hours[0]); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
93 toHour_ = boost::lexical_cast<int>(hours[1]); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
94 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
95 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
96 bool isInPeriod() const |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
97 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
98 time_t now = time(NULL); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
99 tm* nowLocalTime = localtime(&now); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
100 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
101 if (nowLocalTime->tm_wday != weekday_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
102 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
103 return false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
104 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
105 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
106 if (nowLocalTime->tm_hour >= fromHour_ && nowLocalTime->tm_hour < toHour_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
107 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
108 return true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
109 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
110 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
111 return false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
112 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
113 }; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
114 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
115 struct RunningPeriods |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
116 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
117 std::list<RunningPeriod> runningPeriods_; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
118 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
119 void load(const Json::Value& scheduleConfiguration) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
120 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
121 // "Monday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
122 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
123 Json::Value::Members names = scheduleConfiguration.getMemberNames(); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
124 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
125 for (Json::Value::Members::const_iterator it = names.begin(); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
126 it != names.end(); it++) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
127 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
128 for (Json::Value::ArrayIndex i = 0; i < scheduleConfiguration[*it].size(); i++) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
129 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
130 runningPeriods_.push_back(RunningPeriod(*it, scheduleConfiguration[*it][i].asString())); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
131 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
132 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
133 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
134 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
135 bool isInPeriod() |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
136 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
137 if (runningPeriods_.size() == 0) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
138 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
139 return true; // if no config: always run |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
140 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
141 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
142 for (std::list<RunningPeriod>::const_iterator it = runningPeriods_.begin(); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
143 it != runningPeriods_.end(); it++) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
144 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
145 if (it->isInPeriod()) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
146 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
147 return true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
148 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
149 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
150 return false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
151 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
152 }; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
153 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
154 RunningPeriods runningPeriods_; |
4961 | 155 |
156 struct DbConfiguration | |
157 { | |
158 std::string orthancVersion; | |
159 std::map<OrthancPluginResourceType, std::string> mainDicomTagsSignature; | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
160 bool storageCompressionEnabled; |
4961 | 161 |
162 DbConfiguration() | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
163 : storageCompressionEnabled(false) |
4961 | 164 { |
165 } | |
166 | |
167 bool IsDefined() const | |
168 { | |
169 return !orthancVersion.empty() && mainDicomTagsSignature.size() == 4; | |
170 } | |
171 | |
172 void Clear() | |
173 { | |
174 orthancVersion.clear(); | |
175 mainDicomTagsSignature.clear(); | |
176 } | |
177 | |
178 void ToJson(Json::Value& target) | |
179 { | |
180 if (!IsDefined()) | |
181 { | |
182 target = Json::nullValue; | |
183 } | |
184 else | |
185 { | |
186 Json::Value signatures; | |
187 | |
188 target = Json::objectValue; | |
189 | |
190 // default main dicom tags signature are the one from Orthanc 1.4.2 (last time the list was changed): | |
191 signatures["Patient"] = mainDicomTagsSignature[OrthancPluginResourceType_Patient]; | |
192 signatures["Study"] = mainDicomTagsSignature[OrthancPluginResourceType_Study]; | |
193 signatures["Series"] = mainDicomTagsSignature[OrthancPluginResourceType_Series]; | |
194 signatures["Instance"] = mainDicomTagsSignature[OrthancPluginResourceType_Instance]; | |
195 | |
196 target["MainDicomTagsSignature"] = signatures; | |
197 target["OrthancVersion"] = orthancVersion; | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
198 target["StorageCompressionEnabled"] = storageCompressionEnabled; |
4961 | 199 } |
200 } | |
201 | |
202 void FromJson(Json::Value& source) | |
203 { | |
204 if (!source.isNull()) | |
205 { | |
206 orthancVersion = source["OrthancVersion"].asString(); | |
207 | |
208 const Json::Value& signatures = source["MainDicomTagsSignature"]; | |
209 mainDicomTagsSignature[OrthancPluginResourceType_Patient] = signatures["Patient"].asString(); | |
210 mainDicomTagsSignature[OrthancPluginResourceType_Study] = signatures["Study"].asString(); | |
211 mainDicomTagsSignature[OrthancPluginResourceType_Series] = signatures["Series"].asString(); | |
212 mainDicomTagsSignature[OrthancPluginResourceType_Instance] = signatures["Instance"].asString(); | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
213 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
214 storageCompressionEnabled = source["StorageCompressionEnabled"].asBool(); |
4961 | 215 } |
216 } | |
217 }; | |
218 | |
219 struct PluginStatus | |
220 { | |
221 int statusVersion; | |
222 int64_t lastProcessedChange; | |
223 int64_t lastChangeToProcess; | |
224 | |
225 DbConfiguration currentlyProcessingConfiguration; // last configuration being processed (has not reached last change yet) | |
226 DbConfiguration lastProcessedConfiguration; // last configuration that has been fully processed (till last change) | |
227 | |
228 PluginStatus() | |
229 : statusVersion(1), | |
230 lastProcessedChange(-1), | |
231 lastChangeToProcess(-1) | |
232 { | |
233 } | |
234 | |
235 void ToJson(Json::Value& target) | |
236 { | |
237 target = Json::objectValue; | |
238 | |
239 target["Version"] = statusVersion; | |
240 target["LastProcessedChange"] = Json::Value::Int64(lastProcessedChange); | |
241 target["LastChangeToProcess"] = Json::Value::Int64(lastChangeToProcess); | |
242 | |
243 currentlyProcessingConfiguration.ToJson(target["CurrentlyProcessingConfiguration"]); | |
244 lastProcessedConfiguration.ToJson(target["LastProcessedConfiguration"]); | |
245 } | |
246 | |
247 void FromJson(Json::Value& source) | |
248 { | |
249 statusVersion = source["Version"].asInt(); | |
250 lastProcessedChange = source["LastProcessedChange"].asInt64(); | |
251 lastChangeToProcess = source["LastChangeToProcess"].asInt64(); | |
252 | |
253 Json::Value& current = source["CurrentlyProcessingConfiguration"]; | |
254 Json::Value& last = source["LastProcessedConfiguration"]; | |
255 | |
256 currentlyProcessingConfiguration.FromJson(current); | |
257 lastProcessedConfiguration.FromJson(last); | |
258 } | |
259 }; | |
260 | |
261 | |
262 static void ReadStatusFromDb(PluginStatus& pluginStatus) | |
263 { | |
264 OrthancPlugins::OrthancString globalPropertyContent; | |
265 | |
266 globalPropertyContent.Assign(OrthancPluginGetGlobalProperty(OrthancPlugins::GetGlobalContext(), | |
267 globalPropertyId_, | |
268 "")); | |
269 | |
270 if (!globalPropertyContent.IsNullOrEmpty()) | |
271 { | |
272 Json::Value jsonStatus; | |
273 globalPropertyContent.ToJson(jsonStatus); | |
274 pluginStatus.FromJson(jsonStatus); | |
275 } | |
276 else | |
277 { | |
278 // default config | |
279 pluginStatus.statusVersion = 1; | |
280 pluginStatus.lastProcessedChange = -1; | |
281 pluginStatus.lastChangeToProcess = -1; | |
282 | |
283 pluginStatus.currentlyProcessingConfiguration.orthancVersion = "1.9.0"; // when we don't know, we assume some files were stored with Orthanc 1.9.0 (last version saving the dicom-as-json files) | |
284 | |
285 // default main dicom tags signature are the one from Orthanc 1.4.2 (last time the list was changed): | |
286 pluginStatus.currentlyProcessingConfiguration.mainDicomTagsSignature[OrthancPluginResourceType_Patient] = "0010,0010;0010,0020;0010,0030;0010,0040;0010,1000"; | |
287 pluginStatus.currentlyProcessingConfiguration.mainDicomTagsSignature[OrthancPluginResourceType_Study] = "0008,0020;0008,0030;0008,0050;0008,0080;0008,0090;0008,1030;0020,000d;0020,0010;0032,1032;0032,1060"; | |
288 pluginStatus.currentlyProcessingConfiguration.mainDicomTagsSignature[OrthancPluginResourceType_Series] = "0008,0021;0008,0031;0008,0060;0008,0070;0008,1010;0008,103e;0008,1070;0018,0010;0018,0015;0018,0024;0018,1030;0018,1090;0018,1400;0020,000e;0020,0011;0020,0037;0020,0105;0020,1002;0040,0254;0054,0081;0054,0101;0054,1000"; | |
289 pluginStatus.currentlyProcessingConfiguration.mainDicomTagsSignature[OrthancPluginResourceType_Instance] = "0008,0012;0008,0013;0008,0018;0020,0012;0020,0013;0020,0032;0020,0037;0020,0100;0020,4000;0028,0008;0054,1330"; | |
290 } | |
291 } | |
292 | |
293 static void SaveStatusInDb(PluginStatus& pluginStatus) | |
294 { | |
295 Json::Value jsonStatus; | |
296 pluginStatus.ToJson(jsonStatus); | |
297 | |
298 Json::StreamWriterBuilder builder; | |
299 builder.settings_["indentation"] = " "; | |
300 std::string serializedStatus = Json::writeString(builder, jsonStatus); | |
301 | |
302 OrthancPluginSetGlobalProperty(OrthancPlugins::GetGlobalContext(), | |
303 globalPropertyId_, | |
304 serializedStatus.c_str()); | |
305 } | |
306 | |
307 static void GetCurrentDbConfiguration(DbConfiguration& configuration) | |
308 { | |
309 Json::Value signatures; | |
310 Json::Value systemInfo; | |
311 | |
312 OrthancPlugins::RestApiGet(systemInfo, "/system", false); | |
313 configuration.mainDicomTagsSignature[OrthancPluginResourceType_Patient] = systemInfo["MainDicomTags"]["Patient"].asString(); | |
314 configuration.mainDicomTagsSignature[OrthancPluginResourceType_Study] = systemInfo["MainDicomTags"]["Study"].asString(); | |
315 configuration.mainDicomTagsSignature[OrthancPluginResourceType_Series] = systemInfo["MainDicomTags"]["Series"].asString(); | |
316 configuration.mainDicomTagsSignature[OrthancPluginResourceType_Instance] = systemInfo["MainDicomTags"]["Instance"].asString(); | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
317 configuration.storageCompressionEnabled = systemInfo["StorageCompression"].asBool(); |
4961 | 318 |
319 configuration.orthancVersion = OrthancPlugins::GetGlobalContext()->orthancVersion; | |
320 } | |
321 | |
322 static bool NeedsProcessing(const DbConfiguration& current, const DbConfiguration& last) | |
323 { | |
324 if (!last.IsDefined()) | |
325 { | |
326 return true; | |
327 } | |
328 | |
329 const char* lastVersion = last.orthancVersion.c_str(); | |
330 const std::map<OrthancPluginResourceType, std::string>& lastTags = last.mainDicomTagsSignature; | |
331 const std::map<OrthancPluginResourceType, std::string>& currentTags = current.mainDicomTagsSignature; | |
332 bool needsProcessing = false; | |
333 | |
334 if (!OrthancPlugins::CheckMinimalVersion(lastVersion, 1, 9, 1)) | |
335 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
336 if (triggerOnUnnecessaryDicomAsJsonFiles_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
337 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
338 OrthancPlugins::LogWarning("Housekeeper: your storage might still contain some dicom-as-json files -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
339 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
340 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
341 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
342 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
343 OrthancPlugins::LogWarning("Housekeeper: your storage might still contain some dicom-as-json files but the trigger has been disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
344 } |
4961 | 345 } |
346 | |
347 if (lastTags.at(OrthancPluginResourceType_Patient) != currentTags.at(OrthancPluginResourceType_Patient)) | |
348 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
349 if (triggerOnMainDicomTagsChange_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
350 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
351 OrthancPlugins::LogWarning("Housekeeper: Patient main dicom tags have changed, -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
352 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
353 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
354 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
355 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
356 OrthancPlugins::LogWarning("Housekeeper: Patient main dicom tags have changed but the trigger is disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
357 } |
4961 | 358 } |
359 | |
360 if (lastTags.at(OrthancPluginResourceType_Study) != currentTags.at(OrthancPluginResourceType_Study)) | |
361 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
362 if (triggerOnMainDicomTagsChange_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
363 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
364 OrthancPlugins::LogWarning("Housekeeper: Study main dicom tags have changed, -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
365 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
366 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
367 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
368 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
369 OrthancPlugins::LogWarning("Housekeeper: Study main dicom tags have changed but the trigger is disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
370 } |
4961 | 371 } |
372 | |
373 if (lastTags.at(OrthancPluginResourceType_Series) != currentTags.at(OrthancPluginResourceType_Series)) | |
374 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
375 if (triggerOnMainDicomTagsChange_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
376 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
377 OrthancPlugins::LogWarning("Housekeeper: Series main dicom tags have changed, -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
378 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
379 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
380 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
381 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
382 OrthancPlugins::LogWarning("Housekeeper: Series main dicom tags have changed but the trigger is disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
383 } |
4961 | 384 } |
385 | |
386 if (lastTags.at(OrthancPluginResourceType_Instance) != currentTags.at(OrthancPluginResourceType_Instance)) | |
387 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
388 if (triggerOnMainDicomTagsChange_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
389 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
390 OrthancPlugins::LogWarning("Housekeeper: Instance main dicom tags have changed, -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
391 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
392 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
393 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
394 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
395 OrthancPlugins::LogWarning("Housekeeper: Instance main dicom tags have changed but the trigger is disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
396 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
397 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
398 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
399 if (current.storageCompressionEnabled != last.storageCompressionEnabled) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
400 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
401 if (triggerOnStorageCompressionChange_) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
402 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
403 if (current.storageCompressionEnabled) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
404 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
405 OrthancPlugins::LogWarning("Housekeeper: storage compression is now enabled -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
406 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
407 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
408 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
409 OrthancPlugins::LogWarning("Housekeeper: storage compression is now disabled -> will perform housekeeping"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
410 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
411 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
412 needsProcessing = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
413 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
414 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
415 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
416 OrthancPlugins::LogWarning("Housekeeper: storage compression has changed but the trigger is disabled"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
417 } |
4961 | 418 } |
419 | |
420 return needsProcessing; | |
421 } | |
422 | |
423 static bool ProcessChanges(PluginStatus& pluginStatus, const DbConfiguration& currentDbConfiguration) | |
424 { | |
425 Json::Value changes; | |
426 | |
427 pluginStatus.currentlyProcessingConfiguration = currentDbConfiguration; | |
428 | |
429 OrthancPlugins::RestApiGet(changes, "/changes?since=" + boost::lexical_cast<std::string>(pluginStatus.lastProcessedChange) + "&limit=100", false); | |
430 | |
431 for (Json::ArrayIndex i = 0; i < changes["Changes"].size(); i++) | |
432 { | |
433 const Json::Value& change = changes["Changes"][i]; | |
434 int64_t seq = change["Seq"].asInt64(); | |
435 | |
436 if (change["ChangeType"] == "NewStudy") // some StableStudy might be missing if orthanc was shutdown during a StableAge -> consider only the NewStudy events that can not be missed | |
437 { | |
438 Json::Value result; | |
439 OrthancPlugins::RestApiPost(result, "/studies/" + change["ID"].asString() + "/reconstruct", std::string(""), false); | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
440 boost::this_thread::sleep(boost::posix_time::milliseconds(throttleDelay_ * 1000)); |
4961 | 441 } |
442 | |
443 if (seq >= pluginStatus.lastChangeToProcess) // we are done ! | |
444 { | |
445 return true; | |
446 } | |
447 | |
448 pluginStatus.lastProcessedChange = seq; | |
449 } | |
450 | |
451 return false; | |
452 } | |
453 | |
454 | |
455 static void WorkerThread() | |
456 { | |
457 PluginStatus pluginStatus; | |
458 DbConfiguration currentDbConfiguration; | |
459 | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
460 OrthancPluginLogWarning(OrthancPlugins::GetGlobalContext(), "Starting Housekeeper worker thread"); |
4961 | 461 |
462 ReadStatusFromDb(pluginStatus); | |
463 GetCurrentDbConfiguration(currentDbConfiguration); | |
464 | |
465 if (!NeedsProcessing(currentDbConfiguration, pluginStatus.lastProcessedConfiguration)) | |
466 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
467 OrthancPlugins::LogWarning("Housekeeper: everything has been processed already !"); |
4961 | 468 return; |
469 } | |
470 | |
471 if (force_ || NeedsProcessing(currentDbConfiguration, pluginStatus.currentlyProcessingConfiguration)) | |
472 { | |
473 if (force_) | |
474 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
475 OrthancPlugins::LogWarning("Housekeeper: forcing execution -> will perform housekeeping"); |
4961 | 476 } |
477 else | |
478 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
479 OrthancPlugins::LogWarning("Housekeeper: the DB configuration has changed since last run, will reprocess the whole DB !"); |
4961 | 480 } |
481 | |
482 Json::Value changes; | |
483 OrthancPlugins::RestApiGet(changes, "/changes?last", false); | |
484 | |
485 pluginStatus.lastProcessedChange = 0; | |
486 pluginStatus.lastChangeToProcess = changes["Last"].asInt64(); // the last change is the last change at the time we start. We assume that every new ingested file will be constructed correctly | |
487 } | |
488 else | |
489 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
490 OrthancPlugins::LogWarning("Housekeeper: the DB configuration has not changed since last run, will continue processing changes"); |
4961 | 491 } |
492 | |
493 bool completed = pluginStatus.lastChangeToProcess == 0; // if the DB is empty at start, no need to process anyting | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
494 bool loggedNotRightPeriodChangeMessage = false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
495 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
496 while (!workerThreadShouldStop_ && !completed) |
4961 | 497 { |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
498 if (runningPeriods_.isInPeriod()) |
4961 | 499 { |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
500 completed = ProcessChanges(pluginStatus, currentDbConfiguration); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
501 SaveStatusInDb(pluginStatus); |
4961 | 502 |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
503 if (!completed) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
504 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
505 OrthancPlugins::LogInfo("Housekeeper: processed changes " + |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
506 boost::lexical_cast<std::string>(pluginStatus.lastProcessedChange) + |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
507 " / " + boost::lexical_cast<std::string>(pluginStatus.lastChangeToProcess)); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
508 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
509 boost::this_thread::sleep(boost::posix_time::milliseconds(throttleDelay_ * 100)); // wait 1/10 of the delay between changes |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
510 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
511 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
512 loggedNotRightPeriodChangeMessage = false; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
513 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
514 else |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
515 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
516 if (!loggedNotRightPeriodChangeMessage) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
517 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
518 OrthancPlugins::LogInfo("Housekeeper: entering quiet period"); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
519 loggedNotRightPeriodChangeMessage = true; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
520 } |
4961 | 521 } |
522 } | |
523 | |
524 if (completed) | |
525 { | |
526 pluginStatus.lastProcessedConfiguration = currentDbConfiguration; | |
527 pluginStatus.currentlyProcessingConfiguration.Clear(); | |
528 | |
529 pluginStatus.lastProcessedChange = -1; | |
530 pluginStatus.lastChangeToProcess = -1; | |
531 | |
532 SaveStatusInDb(pluginStatus); | |
533 | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
534 OrthancPluginLogWarning(OrthancPlugins::GetGlobalContext(), "Housekeeper: finished processing all changes"); |
4961 | 535 } |
536 } | |
537 | |
538 extern "C" | |
539 { | |
540 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, | |
541 OrthancPluginResourceType resourceType, | |
542 const char* resourceId) | |
543 { | |
544 switch (changeType) | |
545 { | |
546 case OrthancPluginChangeType_OrthancStarted: | |
547 { | |
548 workerThread_.reset(new boost::thread(WorkerThread)); | |
549 return OrthancPluginErrorCode_Success; | |
550 } | |
551 case OrthancPluginChangeType_OrthancStopped: | |
552 { | |
553 if (workerThread_ && workerThread_->joinable()) | |
554 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
555 workerThreadShouldStop_ = true; |
4961 | 556 workerThread_->join(); |
557 } | |
558 } | |
559 default: | |
560 return OrthancPluginErrorCode_Success; | |
561 } | |
562 } | |
563 | |
564 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) | |
565 { | |
566 OrthancPlugins::SetGlobalContext(c); | |
567 | |
568 /* Check the version of the Orthanc core */ | |
569 if (OrthancPluginCheckVersion(c) == 0) | |
570 { | |
571 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
572 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
573 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
574 return -1; | |
575 } | |
576 | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
577 OrthancPlugins::LogWarning("Housekeeper plugin is initializing"); |
4961 | 578 OrthancPluginSetDescription(c, "Optimizes your DB and storage."); |
579 | |
580 OrthancPlugins::OrthancConfiguration configuration; | |
581 | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
582 OrthancPlugins::OrthancConfiguration housekeeper; |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
583 configuration.GetSection(housekeeper, "Housekeeper"); |
4961 | 584 |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
585 bool enabled = housekeeper.GetBooleanValue("Enable", false); |
4961 | 586 if (enabled) |
587 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
588 /* |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
589 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
590 "Housekeeper": { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
591 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
592 // Enables/disables the plugin |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
593 "Enable": false, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
594 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
595 // the Global Prooperty ID in which the plugin progress |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
596 // is stored. Must be > 1024 and must not be used by |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
597 // another plugin |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
598 "GlobalPropertyId": 1025, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
599 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
600 // Forces execution even if the plugin did not detect |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
601 // any changes in configuration |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
602 "Force": false, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
603 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
604 // Delay (in seconds) between reconstruction of 2 studies |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
605 // This avoids overloading Orthanc with the housekeeping |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
606 // process and leaves room for other operations. |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
607 "ThrottleDelay": 5, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
608 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
609 // Runs the plugin only at certain period of time. |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
610 // If not specified, the plugin runs all the time |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
611 // Examples: |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
612 // to run between 0AM and 6AM everyday + every night |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
613 // from 8PM to 12PM and 24h a day on the weekend: |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
614 // "Schedule": { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
615 // "Monday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
616 // "Tuesday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
617 // "Wednesday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
618 // "Thursday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
619 // "Friday": ["0-6", "20-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
620 // "Saturday": ["0-24"], |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
621 // "Sunday": ["0-24"] |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
622 // }, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
623 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
624 // configure events that can trigger a housekeeping processing |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
625 "Triggers" : { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
626 "StorageCompressionChange": true, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
627 "MainDicomTagsChange": true, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
628 "UnnecessaryDicomAsJsonFiles": true |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
629 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
630 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
631 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
632 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
633 */ |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
634 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
635 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
636 globalPropertyId_ = housekeeper.GetIntegerValue("GlobalPropertyId", 1025); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
637 force_ = housekeeper.GetBooleanValue("Force", false); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
638 throttleDelay_ = housekeeper.GetUnsignedIntegerValue("ThrottleDelay", 5); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
639 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
640 if (housekeeper.GetJson().isMember("Triggers")) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
641 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
642 triggerOnStorageCompressionChange_ = housekeeper.GetBooleanValue("StorageCompressionChange", true); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
643 triggerOnMainDicomTagsChange_ = housekeeper.GetBooleanValue("MainDicomTagsChange", true); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
644 triggerOnUnnecessaryDicomAsJsonFiles_ = housekeeper.GetBooleanValue("UnnecessaryDicomAsJsonFiles", true); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
645 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
646 |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
647 if (housekeeper.GetJson().isMember("Schedule")) |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
648 { |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
649 runningPeriods_.load(housekeeper.GetJson()["Schedule"]); |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
650 } |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
651 |
4961 | 652 OrthancPluginRegisterOnChangeCallback(c, OnChangeCallback); |
653 } | |
654 else | |
655 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
656 OrthancPlugins::LogWarning("Housekeeper plugin is disabled by the configuration file"); |
4961 | 657 } |
658 | |
659 return 0; | |
660 } | |
661 | |
662 | |
663 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
664 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
665 OrthancPlugins::LogWarning("Housekeeper plugin is finalizing"); |
4961 | 666 } |
667 | |
668 | |
669 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
670 { | |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
671 return "housekeeper"; |
4961 | 672 } |
673 | |
674 | |
675 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
676 { | |
677 return DB_OPTIMIZER_VERSION; | |
678 } | |
679 } |