Mercurial > hg > orthanc
annotate OrthancServer/Search/SetOfResources.cpp @ 3104:b311cff247ca
added a log in console to debug issue #1. Can't reproduce the issue since then so let's keep the log!
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 10 Jan 2019 11:19:39 +0100 |
parents | 4e43e67f8ecf |
children |
rev | line source |
---|---|
1746 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1746 | 4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
1746 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
1747 | 34 #include "../PrecompiledHeadersServer.h" |
1746 | 35 #include "SetOfResources.h" |
36 | |
1747 | 37 #include "../../Core/OrthancException.h" |
1746 | 38 |
39 | |
40 namespace Orthanc | |
41 { | |
42 void SetOfResources::Intersect(const std::list<int64_t>& resources) | |
43 { | |
44 if (resources_.get() == NULL) | |
45 { | |
46 resources_.reset(new Resources); | |
47 | |
48 for (std::list<int64_t>::const_iterator | |
49 it = resources.begin(); it != resources.end(); ++it) | |
50 { | |
51 resources_->insert(*it); | |
52 } | |
53 } | |
54 else | |
55 { | |
56 std::auto_ptr<Resources> filtered(new Resources); | |
57 | |
58 for (std::list<int64_t>::const_iterator | |
59 it = resources.begin(); it != resources.end(); ++it) | |
60 { | |
61 if (resources_->find(*it) != resources_->end()) | |
62 { | |
63 filtered->insert(*it); | |
64 } | |
65 } | |
66 | |
67 resources_ = filtered; | |
68 } | |
69 } | |
70 | |
71 | |
72 void SetOfResources::GoDown() | |
73 { | |
74 if (level_ == ResourceType_Instance) | |
75 { | |
76 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
77 } | |
78 | |
1753 | 79 if (resources_.get() != NULL) |
80 { | |
81 std::auto_ptr<Resources> children(new Resources); | |
1746 | 82 |
1753 | 83 for (Resources::const_iterator it = resources_->begin(); |
84 it != resources_->end(); ++it) | |
85 { | |
86 std::list<int64_t> tmp; | |
87 database_.GetChildrenInternalId(tmp, *it); | |
1746 | 88 |
1753 | 89 for (std::list<int64_t>::const_iterator |
90 child = tmp.begin(); child != tmp.end(); ++child) | |
91 { | |
92 children->insert(*child); | |
93 } | |
1746 | 94 } |
1753 | 95 |
96 resources_ = children; | |
1746 | 97 } |
98 | |
1747 | 99 switch (level_) |
100 { | |
101 case ResourceType_Patient: | |
102 level_ = ResourceType_Study; | |
103 break; | |
104 | |
105 case ResourceType_Study: | |
106 level_ = ResourceType_Series; | |
107 break; | |
108 | |
109 case ResourceType_Series: | |
110 level_ = ResourceType_Instance; | |
111 break; | |
112 | |
113 default: | |
114 throw OrthancException(ErrorCode_InternalError); | |
115 } | |
1746 | 116 } |
117 | |
118 | |
119 void SetOfResources::Flatten(std::list<std::string>& result) | |
120 { | |
121 result.clear(); | |
122 | |
123 if (resources_.get() == NULL) | |
124 { | |
125 // All the resources of this level are part of the filter | |
126 database_.GetAllPublicIds(result, level_); | |
127 } | |
128 else | |
129 { | |
130 for (Resources::const_iterator it = resources_->begin(); | |
131 it != resources_->end(); ++it) | |
132 { | |
133 result.push_back(database_.GetPublicId(*it)); | |
134 } | |
135 } | |
136 } | |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
137 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
138 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
139 void SetOfResources::Flatten(std::list<int64_t>& result) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
140 { |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
141 result.clear(); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
142 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
143 if (resources_.get() == NULL) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
144 { |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
145 // All the resources of this level are part of the filter |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
146 database_.GetAllInternalIds(result, level_); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
147 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
148 else |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
149 { |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
150 for (Resources::const_iterator it = resources_->begin(); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
151 it != resources_->end(); ++it) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
152 { |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
153 result.push_back(*it); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
154 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
155 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1747
diff
changeset
|
156 } |
1746 | 157 } |