annotate OrthancServer/Resources/Graveyard/DatabaseOptimizations/LookupIdentifierQuery.cpp @ 5155:20911302c6e7

doc
author Alain Mazy <am@osimis.io>
date Wed, 01 Feb 2023 19:32:14 +0100
parents 6eff25f70121
children 0ea402b4d901
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1764
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
1747
ca69082ab200 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
23 #include "../PrecompiledHeadersServer.h"
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "LookupIdentifierQuery.h"
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
26 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
1747
ca69082ab200 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
27 #include "../../Core/OrthancException.h"
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
28 #include "../ServerToolbox.h"
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
29 #include "SetOfResources.h"
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <cassert>
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
37 LookupIdentifierQuery::SingleConstraint::
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
38 SingleConstraint(const DicomTag& tag,
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
39 IdentifierConstraintType type,
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
40 const std::string& value) :
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
41 tag_(tag),
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
42 type_(type),
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
43 value_(ServerToolbox::NormalizeIdentifier(value))
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
44 {
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
45 }
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
46
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
47
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
48 LookupIdentifierQuery::RangeConstraint::
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
49 RangeConstraint(const DicomTag& tag,
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
50 const std::string& start,
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
51 const std::string& end) :
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
52 tag_(tag),
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
53 start_(ServerToolbox::NormalizeIdentifier(start)),
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
54 end_(ServerToolbox::NormalizeIdentifier(end))
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
55 {
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
56 }
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
57
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
58
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1748
diff changeset
59 LookupIdentifierQuery::Disjunction::~Disjunction()
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
60 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
61 for (size_t i = 0; i < singleConstraints_.size(); i++)
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
62 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
63 delete singleConstraints_[i];
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
64 }
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
65
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
66 for (size_t i = 0; i < rangeConstraints_.size(); i++)
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
67 {
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
68 delete rangeConstraints_[i];
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
69 }
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
70 }
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
71
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
72
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1748
diff changeset
73 void LookupIdentifierQuery::Disjunction::Add(const DicomTag& tag,
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1748
diff changeset
74 IdentifierConstraintType type,
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1748
diff changeset
75 const std::string& value)
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
76 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
77 singleConstraints_.push_back(new SingleConstraint(tag, type, value));
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
78 }
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
79
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
80
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
81 void LookupIdentifierQuery::Disjunction::AddRange(const DicomTag& tag,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
82 const std::string& start,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
83 const std::string& end)
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
84 {
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
85 rangeConstraints_.push_back(new RangeConstraint(tag, start, end));
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
86 }
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
87
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
88
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
89 LookupIdentifierQuery::~LookupIdentifierQuery()
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
90 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
91 for (Disjunctions::iterator it = disjunctions_.begin();
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
92 it != disjunctions_.end(); ++it)
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
93 {
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
94 delete *it;
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
95 }
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
96 }
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
97
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
98
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
99 bool LookupIdentifierQuery::IsIdentifier(const DicomTag& tag)
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
100 {
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
101 return ServerToolbox::IsIdentifier(tag, level_);
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
102 }
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
103
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
104
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 void LookupIdentifierQuery::AddConstraint(DicomTag tag,
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 IdentifierConstraintType type,
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 const std::string& value)
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 assert(IsIdentifier(tag));
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
110 disjunctions_.push_back(new Disjunction);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
111 disjunctions_.back()->Add(tag, type, value);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
112 }
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
113
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
114
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
115 void LookupIdentifierQuery::AddRange(DicomTag tag,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
116 const std::string& start,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
117 const std::string& end)
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
118 {
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
119 assert(IsIdentifier(tag));
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
120 disjunctions_.push_back(new Disjunction);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
121 disjunctions_.back()->AddRange(tag, start, end);
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 }
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
1749
99f4a05f39fa various types of constraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1748
diff changeset
125 LookupIdentifierQuery::Disjunction& LookupIdentifierQuery::AddDisjunction()
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
127 disjunctions_.push_back(new Disjunction);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
128 return *disjunctions_.back();
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
132 void LookupIdentifierQuery::Apply(std::list<std::string>& result,
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
133 IDatabaseWrapper& database)
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
134 {
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
135 SetOfResources resources(database, level_);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
136 Apply(resources, database);
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
137
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
138 resources.Flatten(result);
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
139 }
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
140
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
141
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
142 void LookupIdentifierQuery::Apply(SetOfResources& result,
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
143 IDatabaseWrapper& database)
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
144 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
145 for (size_t i = 0; i < disjunctions_.size(); i++)
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
146 {
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
147 std::list<int64_t> a;
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
148
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
149 for (size_t j = 0; j < disjunctions_[i]->GetSingleConstraintsCount(); j++)
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
150 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
151 const SingleConstraint& constraint = disjunctions_[i]->GetSingleConstraint(j);
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
152 std::list<int64_t> b;
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
153 database.LookupIdentifier(b, level_, constraint.GetTag(),
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
154 constraint.GetType(), constraint.GetValue());
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
155
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
156 a.splice(a.end(), b);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
157 }
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
158
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
159 for (size_t j = 0; j < disjunctions_[i]->GetRangeConstraintsCount(); j++)
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
160 {
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
161 const RangeConstraint& constraint = disjunctions_[i]->GetRangeConstraint(j);
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
162 std::list<int64_t> b;
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
163 database.LookupIdentifierRange(b, level_, constraint.GetTag(),
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
164 constraint.GetStart(), constraint.GetEnd());
1748
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
165
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
166 a.splice(a.end(), b);
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
167 }
92203f713205 IFindConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
168
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
169 result.Intersect(a);
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
170 }
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1749
diff changeset
171 }
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
172
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
173
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
174 void LookupIdentifierQuery::Print(std::ostream& s) const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
175 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
176 s << "Constraint: " << std::endl;
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
177 for (Disjunctions::const_iterator
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
178 it = disjunctions_.begin(); it != disjunctions_.end(); ++it)
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
179 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
180 if (it == disjunctions_.begin())
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
181 s << " ";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
182 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
183 s << "OR ";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
184
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
185 for (size_t j = 0; j < (*it)->GetSingleConstraintsCount(); j++)
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
186 {
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2696
diff changeset
187 const SingleConstraint& c = (*it)->GetSingleConstraint(j);
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
188 s << FromDcmtkBridge::GetTagName(c.GetTag(), "");
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
189
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
190 switch (c.GetType())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
191 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
192 case IdentifierConstraintType_Equal: s << " == "; break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
193 case IdentifierConstraintType_SmallerOrEqual: s << " <= "; break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
194 case IdentifierConstraintType_GreaterOrEqual: s << " >= "; break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
195 case IdentifierConstraintType_Wildcard: s << " ~= "; break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
196 default:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
197 s << " ? ";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
198 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
199
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
200 s << c.GetValue() << std::endl;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
201 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
202 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
203 }
1745
38dda23c7d7d LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }