annotate Framework/Oracle/ParseDicomFileCommand.cpp @ 1124:a8bf81756839 broker

unsuccessful attempt to cache ParseDicomFileCommand
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 Nov 2019 18:49:06 +0100
parents a08699daf78b
children 87fbeb823375
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1110
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "ParseDicomFileCommand.h"
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
24 #include <Core/OrthancException.h>
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
25
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
26 #include <boost/filesystem/path.hpp>
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
27
1110
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancStone
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
1124
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
30 void ParseDicomFileCommand::SuccessMessage::Setup()
1110
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
1116
a08699daf78b ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
32 if (!dicom_->GetTagValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID))
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
33 {
1116
a08699daf78b ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
34 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
a08699daf78b ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
35 "DICOM instance missing tag SOPInstanceUID");
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
36 }
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
37 }
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
38
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
39
1124
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
40 ParseDicomFileCommand::SuccessMessage::SuccessMessage(const ParseDicomFileCommand& command,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
41 DcmFileFormat& dicom,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
42 size_t fileSize,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
43 bool hasPixelData) :
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
44 OriginMessage(command),
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
45 fileSize_(fileSize),
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
46 hasPixelData_(hasPixelData)
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
47 {
1124
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
48 dicom_.reset(new Orthanc::ParsedDicomFile(dicom));
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
49 Setup();
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
50 }
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
51
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
52
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
53 ParseDicomFileCommand::SuccessMessage::SuccessMessage(const ParseDicomFileCommand& command,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
54 boost::shared_ptr<Orthanc::ParsedDicomFile> dicom,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
55 size_t fileSize,
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
56 bool hasPixelData) :
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
57 OriginMessage(command),
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
58 dicom_(dicom),
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
59 fileSize_(fileSize),
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
60 hasPixelData_(hasPixelData)
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
61 {
a8bf81756839 unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1116
diff changeset
62 Setup();
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
63 }
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
64
1116
a08699daf78b ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
65
1111
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
66 std::string ParseDicomFileCommand::GetDicomDirPath(const std::string& dicomDirPath,
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
67 const std::string& file)
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
68 {
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
69 std::string tmp = file;
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
70
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
71 #if !defined(_WIN32)
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
72 std::replace(tmp.begin(), tmp.end(), '\\', '/');
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
73 #endif
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
74
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
75 boost::filesystem::path base = boost::filesystem::path(dicomDirPath).parent_path();
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
76
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
77 return (base / tmp).string();
3730956f41a5 ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1110
diff changeset
78 }
1110
b82b74d13830 ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }