85
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: CASqlQueryCreator declaration
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CASQLQUERYCREATOR_H
|
|
19 |
#define CASQLQUERYCREATOR_H
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <e32std.h>
|
|
23 |
#include "cainnerquery.h"
|
|
24 |
|
|
25 |
// CLASS DECLARATION
|
|
26 |
|
|
27 |
class CCaSqlQuery;
|
|
28 |
class CCaInnerEntry;
|
|
29 |
class CCaInnerQuery;
|
|
30 |
class RSqlDatabase;
|
|
31 |
class TCaOperationParams;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* @ingroup group_catorage.
|
|
35 |
* CaSqlQueryCreator Helper class which prepares sql statements for
|
|
36 |
* execution.
|
|
37 |
*/
|
|
38 |
class CaSqlQueryCreator
|
|
39 |
{
|
|
40 |
public:
|
|
41 |
|
|
42 |
/**
|
|
43 |
* The icon types.
|
|
44 |
*/
|
|
45 |
enum TIconType
|
|
46 |
{
|
|
47 |
ENullIcon,
|
|
48 |
ENullIconToRemove,
|
|
49 |
EProperIcon
|
|
50 |
};
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Creates sql queries to be used to perform an add or
|
|
54 |
* update operation on the database.
|
|
55 |
*
|
|
56 |
* @param aEntry The entry to be added or updated in the database.
|
|
57 |
* @param aList A list to fill in with queries neccessary for the operation.
|
|
58 |
* @param iSqlDb The handle to the database needed for
|
|
59 |
* the created queries' member (RSqlStatement iStatement).
|
|
60 |
*/
|
|
61 |
static void CreateAddQueryL( CCaInnerEntry* aEntry, RPointerArray<
|
|
62 |
CCaSqlQuery>& aSqlQuery, RSqlDatabase& aSqlDb );
|
|
63 |
/**
|
|
64 |
* Creates an sql query to fetch data from the database.
|
|
65 |
*
|
|
66 |
* @param aQuery The query object which specifies
|
|
67 |
* the type of data to be fetched.
|
|
68 |
* @param aSqlQuery The sql query created to select the data.
|
|
69 |
*/
|
|
70 |
static void CreateGetEntriesQueryL( const CCaInnerQuery* aQuery,
|
|
71 |
CCaSqlQuery* aSqlQuery );
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Creates an sql query to fetch parents ids from the database.
|
|
75 |
*
|
|
76 |
* @param aEntryIdArray array with entries ids.
|
|
77 |
* @param aSqlQuery The sql query created to select parents ids.
|
|
78 |
* @param aParentIdArray array with groups ids.
|
|
79 |
*/
|
|
80 |
static void CreateGetParentsIdsQueryL(
|
|
81 |
const RArray<TInt>& aEntryIdArray, CCaSqlQuery* aSqlQuery,
|
|
82 |
const RArray<TInt>& aParentIdArray );
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Creates an sql query to remove data from the database.
|
|
86 |
*
|
|
87 |
* @param aList The result sql queries to be executed for remove.
|
|
88 |
* @param aSqlDb The handle to the database needed for
|
|
89 |
* the created queries' member (RSqlStatement iStatement).
|
|
90 |
*/
|
|
91 |
static void CreateRemoveQueryL( RPointerArray<CCaSqlQuery>& aSqlQuery,
|
|
92 |
RSqlDatabase& aSqlDb );
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Creates an sql query to fetch attributes for a given number of entries.
|
|
96 |
*
|
|
97 |
* @param aIdEntryCount The number of entry ids for which to get
|
|
98 |
* attributes.
|
|
99 |
* @param aSqlQuery The result fetch attributes query.
|
|
100 |
*/
|
|
101 |
static void CreateGetAttributesQueryL( const TInt aIdEntryCount,
|
|
102 |
CCaSqlQuery* aSqlQuery );
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Creates an sql query to modify touch data in the database.
|
|
106 |
*
|
|
107 |
* @param aSqlQuery The list of result queries needed for the touch
|
|
108 |
* operation.
|
|
109 |
* @param aSqlDb The handle to the database needed for the created
|
|
110 |
* queries' member (RSqlStatement iStatement).
|
|
111 |
*/
|
|
112 |
static void CreateTouchQueryL( RPointerArray<CCaSqlQuery>& aSqlQuery,
|
|
113 |
RSqlDatabase& aSqlDb );
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Creates an sql query to organize data within a group.
|
|
117 |
*
|
|
118 |
* @param aEntryIds The array of entry ids which are organized.
|
|
119 |
* @param aParams The specific parameters describing the type of
|
|
120 |
* organize to be done.
|
|
121 |
* @param aSqlDb The handle to the database needed for the created
|
|
122 |
* queries' member (RSqlStatement iStatement).
|
|
123 |
* @param aSqlRemoveQueries A result array of remove queries to be
|
|
124 |
* executed.
|
|
125 |
* @param aSqlPrependInsertQueries A result array of prepend insert
|
|
126 |
* queries queries to be executed.
|
|
127 |
* @param aSqlInsertQueries A result array of insert queries to be
|
|
128 |
* executed.
|
|
129 |
*/
|
|
130 |
|
|
131 |
static TBool CreateOrganizeQueryL( const RArray<TInt>& aEntryIds,
|
|
132 |
TCaOperationParams aParams, RSqlDatabase& aSqlDb,
|
|
133 |
RPointerArray<CCaSqlQuery>& aSqlQueries );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Populates a given query with a list of ids.
|
|
137 |
*
|
|
138 |
* @param The number of ids with which to populate the query.
|
|
139 |
* @param aQuery The query where to set the result query text.
|
|
140 |
* @param aSqlQueryText the sql text wich is populated
|
|
141 |
* with ids (in place of %S sequence);
|
|
142 |
*/
|
|
143 |
static void PopulateQueryWithIdListL( const TInt aIdEntryCount,
|
|
144 |
CCaSqlQuery* aQuery, const TDesC& aSqlQueryText );
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Creates an sql query to get a list of of localizations entries.
|
|
148 |
*
|
|
149 |
* @param aQuery The result query.
|
|
150 |
*/
|
|
151 |
static void CreateGetLocalizationsQueryL( CCaSqlQuery* aQuery );
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Creates an sql query to update db entry with localization.
|
|
155 |
*
|
|
156 |
* @param aQuery The result query.
|
|
157 |
*/
|
|
158 |
static void CreateLocalizeEntryQueryL( CCaSqlQuery* aQuery );
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Creates an sql query to custom sort order.
|
|
162 |
*
|
|
163 |
* @param aEntryIds The array of entry ids.
|
|
164 |
* @param aSqlQuery A result array of insert queries to be executed.
|
|
165 |
* @param aSqlDb The handle to the database.
|
|
166 |
*/
|
|
167 |
static void CreateCustomSortQueryL( const RArray<TInt>& aEntryIds,
|
|
168 |
RPointerArray<CCaSqlQuery>& aSqlQuery,
|
|
169 |
RSqlDatabase& aSqlDb );
|
|
170 |
|
|
171 |
private:
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Creates an sql query to add an icon into the icon table.
|
|
175 |
*
|
|
176 |
* @param aEntry the entry for which to add an icon.
|
|
177 |
* @param aQuery The result query.
|
|
178 |
* @param aSqlDb The handle to the database needed for
|
|
179 |
* the created queries' member (RSqlStatement iStatement).
|
|
180 |
*/
|
|
181 |
static void CreateAddIconQueryL( CCaInnerEntry* aEntry,
|
|
182 |
CCaSqlQuery* aQuery, RSqlDatabase& aSqlDb );
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Creates an sql query to add an icon for a new entry.
|
|
186 |
*
|
|
187 |
* @param aEntry the entry for which to add an icon.
|
|
188 |
* @param aQuery The result query.
|
|
189 |
* @param aSqlDb The handle to the database needed for
|
|
190 |
* the created queries' member (RSqlStatement iStatement).
|
|
191 |
*/
|
|
192 |
static void CreateAddIconQueryForNewL( CCaInnerEntry* aEntry,
|
|
193 |
CCaSqlQuery* aQuery, RSqlDatabase& aSqlDb );
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Creates an sql query to add an icon for an existing entry.
|
|
197 |
*
|
|
198 |
* @param aEntry the entry for which to add an icon.
|
|
199 |
* @param aQuery The result query.
|
|
200 |
* @param aSqlDb The handle to the database needed for
|
|
201 |
* the created queries' member (RSqlStatement iStatement).
|
|
202 |
*/
|
|
203 |
static void CreateAddIconQueryForUpdateL( CCaInnerEntry* aEntry,
|
|
204 |
CCaSqlQuery* aQuery, RSqlDatabase& aSqlDb );
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Creates an sql query to update an icon for an existing entry.
|
|
208 |
*
|
|
209 |
* @param aEntry the entry for which to update an icon.
|
|
210 |
* @param aQuery The result query.
|
|
211 |
*/
|
|
212 |
static void CreateUpdateIconQueryL( const CCaInnerEntry* aEntry,
|
|
213 |
CCaSqlQuery* aQuery );
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Creates an sql query to update an entry.
|
|
217 |
*
|
|
218 |
* @param aEntry The entry to be updated.
|
|
219 |
* @param aQuery The result query.
|
|
220 |
*/
|
|
221 |
static void CreateUpdateQueryEntryL( const CCaInnerEntry* aEntry,
|
|
222 |
CCaSqlQuery* aQuery );
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Creates an sql query to get a list of entries by the given ids.
|
|
226 |
*
|
|
227 |
* @param aIdEntryCount The number of entries to fetch.
|
|
228 |
* @param aQuery The result query.
|
|
229 |
*/
|
|
230 |
static void CreateGetEntriesQueryByIdL( const TInt aIdEntryCount,
|
|
231 |
CCaSqlQuery* aQuery );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Creates an sql query to get a list of entries by query data.
|
|
235 |
*
|
|
236 |
* @param aQuery The query to analize for
|
|
237 |
* a specific selection (result list of entries).
|
|
238 |
* @param aSqlQuery The result query.
|
|
239 |
*/
|
|
240 |
static void CreateGetEntriesQueryByQueryL( const CCaInnerQuery* aQuery,
|
|
241 |
CCaSqlQuery* aSqlQuery );
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Helper function which creates a string with
|
|
245 |
* a list of id mappings. e.g. (id0,id1,id2)
|
|
246 |
*
|
|
247 |
* @param aIdEntryCount the number of entries to create the id list.
|
|
248 |
* @param aEntryIdList The result text.
|
|
249 |
* @param aColName column name with specified id.
|
|
250 |
*/
|
|
251 |
static void CreateIdListL( const TInt aIdEntryCount,
|
|
252 |
RBuf& aEntryIdList, const TDesC& aColName );
|
|
253 |
|
|
254 |
/**
|
|
255 |
* Modifies a given query with sort order information.
|
|
256 |
*
|
|
257 |
* @param aSortType The sort order type.
|
|
258 |
* @param aQuery the query where the sort order will be included.
|
|
259 |
* @param aSortByGroup Additional information if to sort within a group.
|
|
260 |
*/
|
|
261 |
static void ModifyQueryForSortOrderL(
|
|
262 |
const CCaInnerQuery::TSortAttribute aSortType,
|
|
263 |
RBuf& aQuery, TBool aSortByGroup );
|
|
264 |
|
|
265 |
/**
|
|
266 |
* Modifies a given query with sort order last or most used.
|
|
267 |
*
|
|
268 |
* @param aSortType The sort order type.
|
|
269 |
* @param aQuery the query where the sort order will be included.
|
|
270 |
*/
|
|
271 |
static void ModifyQueryForSortOrderLastMostUsedL(
|
|
272 |
const CCaInnerQuery::TSortAttribute aSortType, RBuf& aQuery );
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Check if icon is set proper in CCaInnerEntry.
|
|
276 |
*
|
|
277 |
* @param aEntry The entry with icon params.
|
|
278 |
* @return TIconType .
|
|
279 |
*/
|
|
280 |
static TIconType CheckIconType( const CCaInnerEntry* aEntry );
|
|
281 |
|
|
282 |
};
|
|
283 |
|
|
284 |
#endif // CASQLQUERYCREATOR_H
|