Mercurial > hg > orthanc
comparison OrthancServer/StorageCommitmentReports.cpp @ 3737:f29843323daf storage-commitment
accessing storage commitment reports from REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Mar 2020 20:33:01 +0100 |
parents | 0540b54324f1 |
children | bff4da769f6f |
comparison
equal
deleted
inserted
replaced
3736:0540b54324f1 | 3737:f29843323daf |
---|---|
60 else | 60 else |
61 { | 61 { |
62 Success success; | 62 Success success; |
63 success.sopClassUid_ = sopClassUid; | 63 success.sopClassUid_ = sopClassUid; |
64 success.sopInstanceUid_ = sopInstanceUid; | 64 success.sopInstanceUid_ = sopInstanceUid; |
65 successes_.push_back(success); | 65 success_.push_back(success); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void StorageCommitmentReports::Report::AddFailure(const std::string& sopClassUid, | 69 void StorageCommitmentReports::Report::AddFailure(const std::string& sopClassUid, |
70 const std::string& sopInstanceUid, | 70 const std::string& sopInstanceUid, |
100 return Status_Failure; | 100 return Status_Failure; |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 void StorageCommitmentReports::Report::Format(Json::Value& json) const | |
106 { | |
107 static const char* const FIELD_STATUS = "Status"; | |
108 static const char* const FIELD_SOP_CLASS_UID = "SOPClassUID"; | |
109 static const char* const FIELD_SOP_INSTANCE_UID = "SOPInstanceUID"; | |
110 static const char* const FIELD_FAILURE_REASON = "FailureReason"; | |
111 static const char* const FIELD_DESCRIPTION = "Description"; | |
112 static const char* const FIELD_REMOTE_AET = "RemoteAET"; | |
113 static const char* const FIELD_SUCCESS = "Success"; | |
114 static const char* const FIELD_FAILURES = "Failures"; | |
115 | |
116 | |
117 json = Json::objectValue; | |
118 json[FIELD_REMOTE_AET] = remoteAet_; | |
119 | |
120 switch (GetStatus()) | |
121 { | |
122 case Status_Pending: | |
123 json[FIELD_STATUS] = "Pending"; | |
124 break; | |
125 | |
126 case Status_Success: | |
127 json[FIELD_STATUS] = "Success"; | |
128 break; | |
129 | |
130 case Status_Failure: | |
131 json[FIELD_STATUS] = "Failure"; | |
132 break; | |
133 | |
134 default: | |
135 throw OrthancException(ErrorCode_InternalError); | |
136 } | |
137 | |
138 { | |
139 Json::Value success = Json::arrayValue; | |
140 for (std::list<Success>::const_iterator | |
141 it = success_.begin(); it != success_.end(); ++it) | |
142 { | |
143 Json::Value item = Json::objectValue; | |
144 item[FIELD_SOP_CLASS_UID] = it->sopClassUid_; | |
145 item[FIELD_SOP_INSTANCE_UID] = it->sopInstanceUid_; | |
146 success.append(item); | |
147 } | |
148 | |
149 json[FIELD_SUCCESS] = success; | |
150 } | |
151 | |
152 { | |
153 Json::Value failures = Json::arrayValue; | |
154 for (std::list<Failure>::const_iterator | |
155 it = failures_.begin(); it != failures_.end(); ++it) | |
156 { | |
157 Json::Value item = Json::objectValue; | |
158 item[FIELD_SOP_CLASS_UID] = it->sopClassUid_; | |
159 item[FIELD_SOP_INSTANCE_UID] = it->sopInstanceUid_; | |
160 item[FIELD_FAILURE_REASON] = it->reason_; | |
161 item[FIELD_DESCRIPTION] = EnumerationToString(it->reason_); | |
162 failures.append(item); | |
163 } | |
164 | |
165 json[FIELD_FAILURES] = failures; | |
166 } | |
167 } | |
168 | |
169 | |
105 StorageCommitmentReports::~StorageCommitmentReports() | 170 StorageCommitmentReports::~StorageCommitmentReports() |
106 { | 171 { |
107 while (!content_.IsEmpty()) | 172 while (!content_.IsEmpty()) |
108 { | 173 { |
109 Report* report = NULL; | 174 Report* report = NULL; |