Mercurial > hg > orthanc
annotate OrthancServer/Resources/Graveyard/FindRefactoringForSQLite.cpp @ 5765:247fc5368693 find-refactoring
un-sharing DatabaseConstraint and ISqlLookupFormatter with orthanc-databases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Sep 2024 16:14:22 +0200 |
parents | b1c86368af2b |
children |
rev | line source |
---|---|
5723
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #if 0 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 // TODO-FIND: Remove this implementation, as it should be done by |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 // the compatibility mode implemented by "GenericFind" |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 virtual void ExecuteFind(FindResponse& response, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 const FindRequest& request, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 const std::vector<DatabaseConstraint>& normalized) ORTHANC_OVERRIDE |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 #if 0 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 Compatibility::GenericFind find(*this); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 find.Execute(response, request); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 #else |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DROP TABLE IF EXISTS FilteredResourcesIds"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 s.Run(); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 LookupFormatter formatter; |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 std::string sqlLookup; |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 LookupFormatter::Apply(sqlLookup, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 formatter, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 normalized, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 request.GetLevel(), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 request.GetLabels(), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 request.GetLabelsConstraint(), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 (request.HasLimits() ? request.GetLimitsCount() : 0)); // TODO: handles since and count |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 // first create a temporary table that with the filtered and ordered results |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 sqlLookup = "CREATE TEMPORARY TABLE FilteredResourcesIds AS " + sqlLookup; |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 SQLite::Statement statement(db_, SQLITE_FROM_HERE_DYNAMIC(sqlLookup), sqlLookup); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 formatter.Bind(statement); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 statement.Run(); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 // create the response item with the public ids only |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 SQLite::Statement statement(db_, SQLITE_FROM_HERE, "SELECT publicId FROM FilteredResourcesIds"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 formatter.Bind(statement); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 const std::string resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 response.Add(new FindResponse::Resource(request.GetLevel(), resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 // request Each response content through INNER JOIN with the temporary table |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 if (request.IsRetrieveMainDicomTags()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 // TODO-FIND: handle the case where we request tags from multiple levels |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 "SELECT publicId, tagGroup, tagElement, value FROM MainDicomTags AS tags " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 " INNER JOIN FilteredResourcesIds ON tags.id = FilteredResourcesIds.internalId"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 formatter.Bind(statement); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 response.GetResource(resourceId).AddStringDicomTag(statement.ColumnInt(1), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 statement.ColumnInt(2), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 statement.ColumnString(3)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 if (request.IsRetrieveChildrenIdentifiers()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 "SELECT filtered.publicId, childLevel.publicId AS childPublicId " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 "FROM Resources as currentLevel " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = currentLevel.internalId " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 " INNER JOIN Resources childLevel ON childLevel.parentId = currentLevel.internalId"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 formatter.Bind(statement); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 response.GetResource(resourceId).AddChildIdentifier(GetChildResourceType(request.GetLevel()), statement.ColumnString(1)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 if (request.IsRetrieveParentIdentifier()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 "SELECT filtered.publicId, parentLevel.publicId AS parentPublicId " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 "FROM Resources as currentLevel " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = currentLevel.internalId " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 " INNER JOIN Resources parentLevel ON currentLevel.parentId = parentLevel.internalId"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 const std::string& parentId = statement.ColumnString(1); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 response.GetResource(resourceId).SetParentIdentifier(parentId); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 if (request.IsRetrieveMetadata()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 "SELECT filtered.publicId, metadata.type, metadata.value " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 "FROM Metadata " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = Metadata.id"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 response.GetResource(resourceId).AddMetadata(static_cast<MetadataType>(statement.ColumnInt(1)), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 statement.ColumnString(2)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 if (request.IsRetrieveLabels()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 "SELECT filtered.publicId, label " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 "FROM Labels " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = Labels.id"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 response.GetResource(resourceId).AddLabel(statement.ColumnString(1)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 if (request.IsRetrieveAttachments()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 "SELECT filtered.publicId, uuid, fileType, uncompressedSize, compressionType, compressedSize, " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 " uncompressedMD5, compressedMD5 " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 "FROM AttachedFiles " |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = AttachedFiles.id"); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 while (statement.Step()) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 const std::string& resourceId = statement.ColumnString(0); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 FileInfo attachment = FileInfo(statement.ColumnString(1), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 static_cast<FileContentType>(statement.ColumnInt(2)), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 statement.ColumnInt64(3), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 statement.ColumnString(6), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 static_cast<CompressionType>(statement.ColumnInt(4)), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 statement.ColumnInt64(5), |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 statement.ColumnString(7)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 assert(response.HasResource(resourceId)); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 response.GetResource(resourceId).AddAttachment(attachment); |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 }; |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 // TODO-FIND: implement other responseContent: ResponseContent_ChildInstanceId, ResponseContent_ChildrenMetadata (later: ResponseContent_IsStable) |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 #endif |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 } |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 #endif |
b1c86368af2b
moved experimental code to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 |