annotate Core/JobsEngine/SetOfInstancesJob.cpp @ 2648:e1893d31652a jobs

serialization of JobHandler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 May 2018 18:44:05 +0200
parents c691fcf66071
children a3f0f61a14ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../PrecompiledHeaders.h"
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "SetOfInstancesJob.h"
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../OrthancException.h"
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace Orthanc
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 SetOfInstancesJob::SetOfInstancesJob() :
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 started_(false),
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 permissive_(false),
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 position_(0)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 void SetOfInstancesJob::Reserve(size_t size)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 if (started_)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 instances_.reserve(size);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 void SetOfInstancesJob::AddInstance(const std::string& instance)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 if (started_)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 instances_.push_back(instance);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 void SetOfInstancesJob::SetPermissive(bool permissive)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 if (IsStarted())
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 permissive_ = permissive;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void SetOfInstancesJob::SignalResubmit()
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 if (started_)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 position_ = 0;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 failedInstances_.clear();
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 float SetOfInstancesJob::GetProgress()
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 if (instances_.size() == 0)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 return 0;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 return (static_cast<float>(position_) /
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 static_cast<float>(instances_.size()));
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
116 JobStepResult SetOfInstancesJob::ExecuteStep()
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
118 if (!started_)
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
119 {
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
120 throw OrthancException(ErrorCode_InternalError);
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
121 }
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
122
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
123 if (instances_.empty() &&
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
124 position_ == 0)
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 {
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
126 // No instance to handle, we're done
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
127 position_ = 1;
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
128 return JobStepResult::Success();
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
129 }
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
130
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
131 if (position_ >= instances_.size())
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
132 {
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
133 // Already done
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
134 throw OrthancException(ErrorCode_BadSequenceOfCalls);
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
137 const std::string currentInstance = instances_[position_];
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
138
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 bool ok;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 try
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
143 ok = HandleInstance(currentInstance);
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 if (!ok && !permissive_)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
147 return JobStepResult::Failure(ErrorCode_InternalError);
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 catch (OrthancException& e)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 if (permissive_)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 ok = false;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 throw;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 if (!ok)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 {
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
164 failedInstances_.insert(currentInstance);
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
167 position_ += 1;
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
169 if (position_ == instances_.size())
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
2586
ec09641d6f41 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2585
diff changeset
171 // We're done
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
172 return JobStepResult::Success();
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 else
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
2598
34dc57f4a7d2 simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2586
diff changeset
176 return JobStepResult::Continue();
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
2640
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
181 void SetOfInstancesJob::GetPublicContent(Json::Value& value)
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
182 {
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
183 value["Description"] = GetDescription();
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
184 value["InstancesCount"] = static_cast<uint32_t>(GetInstances().size());
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
185 value["FailedInstancesCount"] = static_cast<uint32_t>(GetFailedInstances().size());
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
186 }
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
187
c691fcf66071 ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
188
2648
e1893d31652a serialization of JobHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
189 void SetOfInstancesJob::Serialize(Json::Value& value)
2585
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 Json::Value v = Json::arrayValue;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 for (size_t i = 0; i < instances_.size(); i++)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 v.append(instances_[i]);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 value["Instances"] = v;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 v = Json::arrayValue;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 for (std::set<std::string>::const_iterator it = failedInstances_.begin();
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 it != failedInstances_.end(); ++it)
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 {
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 v.append(*it);
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 value["FailedInstances"] = v;
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 }
4c809711149e reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }