comparison OrthancStone/Sources/Oracle/ParseDicomFromWadoCommand.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Oracle/ParseDicomFromWadoCommand.cpp@121d01aa328e
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "ParseDicomFromWadoCommand.h"
23
24 #include <OrthancException.h>
25
26 namespace OrthancStone
27 {
28 ParseDicomFromWadoCommand::ParseDicomFromWadoCommand(const DicomSource& source,
29 const std::string& sopInstanceUid,
30 IOracleCommand* restCommand) :
31 source_(source),
32 sopInstanceUid_(sopInstanceUid),
33 restCommand_(restCommand)
34 {
35 if (restCommand == NULL)
36 {
37 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
38 }
39
40 if (restCommand_->GetType() != Type_Http &&
41 restCommand_->GetType() != Type_OrthancRestApi)
42 {
43 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType);
44 }
45 }
46
47
48 IOracleCommand* ParseDicomFromWadoCommand::Clone() const
49 {
50 assert(restCommand_.get() != NULL);
51 return new ParseDicomFromWadoCommand(source_, sopInstanceUid_, restCommand_->Clone());
52 }
53
54
55 const IOracleCommand& ParseDicomFromWadoCommand::GetRestCommand() const
56 {
57 assert(restCommand_.get() != NULL);
58 return *restCommand_;
59 }
60
61
62 ParseDicomFromWadoCommand* ParseDicomFromWadoCommand::Create(
63 const DicomSource& source,
64 const std::string& studyInstanceUid,
65 const std::string& seriesInstanceUid,
66 const std::string& sopInstanceUid,
67 bool transcode,
68 Orthanc::DicomTransferSyntax transferSyntax,
69 Orthanc::IDynamicObject* payload)
70 {
71 std::unique_ptr<Orthanc::IDynamicObject> protection(payload);
72
73 const std::string uri = ("/studies/" + studyInstanceUid +
74 "/series/" + seriesInstanceUid +
75 "/instances/" + sopInstanceUid);
76
77 std::string s;
78 if (transcode)
79 {
80 s = Orthanc::GetTransferSyntaxUid(transferSyntax);
81 }
82 else
83 {
84 s = "*"; // No transcoding, keep source transfer syntax
85 }
86
87 std::map<std::string, std::string> arguments, headers;
88 headers["Accept"] = ("multipart/related; type=\"application/dicom\"; transfer-syntax=" + s);
89
90 std::unique_ptr<IOracleCommand> rest(
91 source.CreateDicomWebCommand(uri, arguments, headers, NULL));
92
93 std::unique_ptr<ParseDicomFromWadoCommand> command(
94 new ParseDicomFromWadoCommand(source, sopInstanceUid, rest.release()));
95
96 if (protection.get() != NULL)
97 {
98 command->AcquirePayload(protection.release());
99 }
100
101 return command.release();
102 }
103 }