|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Mapping and data validation rules for CommsDat data |
|
15 // MAPPING |
|
16 // CCDMapper and derived classes implement mapping rules for elements in the database |
|
17 // wherever elements have been deprecated |
|
18 // There are Mapping rules for every supported deprecated data schema version translating |
|
19 // to the current data schema. |
|
20 // Mapping of deprecated elements is necessary for every operation (read, write and delete) |
|
21 // MAINTENANCE |
|
22 // - Every rule will need renaming whenever new version of Comms Data format is adopted. |
|
23 // - Many rules will need updating whenever new version of CommsData format is adopted |
|
24 // - Rules for deprecated data version need to be deleted when data version not supported. |
|
25 // |
|
26 // |
|
27 |
|
28 /** |
|
29 @file |
|
30 @internalTechnology |
|
31 */ |
|
32 |
|
33 |
|
34 #if (!defined COMMSDATMAPPER_H) |
|
35 #define COMMSDATMAPPER_H |
|
36 |
|
37 #include <cdbcols.h> |
|
38 #include "CommsDatMapperAndValidatorUtils.h" |
|
39 |
|
40 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
41 // Forward declarations of mapped elements |
|
42 namespace CommsDat |
|
43 { |
|
44 class CCDAccessPointRecord; |
|
45 class CCDBearerTypeRecord; |
|
46 class CCDIAPRecord; |
|
47 class CCDTierRecord; |
|
48 class CCDMCprRecord; |
|
49 class CCDCprRecord; |
|
50 class CCDSCprRecord; |
|
51 class CCDSCprRecord; |
|
52 class CCDIAPPrioritySelectionPolicyRecord; |
|
53 } |
|
54 |
|
55 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
56 |
|
57 namespace CommsDatInternal |
|
58 /* |
|
59 @internalTechnology |
|
60 */ |
|
61 { |
|
62 |
|
63 |
|
64 /************************************************************************************************** |
|
65 * 1/ MAPPER BASE CLASS |
|
66 ******************************************************************************************/ |
|
67 |
|
68 NONSHARABLE_CLASS(CCDMapper) : public CMDBRecordBase |
|
69 /* |
|
70 Base class for mapping rules |
|
71 |
|
72 Records and Fields can be mapped, but not Tables |
|
73 Generic Records are never mapped (fields, records or tables) |
|
74 |
|
75 |
|
76 NB Mapping class must only hold data that is a direct map of the original |
|
77 Other data can be created or modified during a map but must not be held |
|
78 in the mapper class as if it need not be directly loaded, deleted or stored |
|
79 via MMetaDatabase operations |
|
80 |
|
81 0/ The mapper class is created via a factory if there is anything to map |
|
82 in the input element. |
|
83 |
|
84 1/ First the mapper is constructed. |
|
85 Any changed data in the input element is copied into the mapper element. |
|
86 |
|
87 2/ When storing, a mapper client is then prepared with PrepareToStoreL |
|
88 which may call CMDBSessionImpl::MaybeCreateNodeL for mapper elements |
|
89 |
|
90 3/ VCT - When deleting a mapper client will call MaybeDeleteNode |
|
91 It may sometimes be necessary to do a custom operation on delete especially |
|
92 to delete a whole node if this has been created. |
|
93 Often this function will be a no-op as the general algorithm |
|
94 will handle normal deletion of mapped fields |
|
95 |
|
96 4/ A mapper client can then use the mapped data directly during database operations |
|
97 |
|
98 5/ When the client has finished the database operations it calls MapResults |
|
99 which transfers changed data from the map back to the original element following |
|
100 the individual mapper class's rules |
|
101 |
|
102 6/ The mapper can now be deleted |
|
103 |
|
104 |
|
105 @internalComponent |
|
106 */ |
|
107 { |
|
108 public : |
|
109 |
|
110 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
111 // Creates a mapping class of the appropriate type |
|
112 static CCDMapper* MaybeCreateMapperLC(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation); |
|
113 #endif |
|
114 |
|
115 virtual ~CCDMapper(); |
|
116 |
|
117 // Constructs the mapper by finding the id of each field |
|
118 // Populates the mapper with data from the input element |
|
119 virtual void ConstructL(); |
|
120 |
|
121 // Prepares the mapper for storage |
|
122 // will use data from the input element and may read the database too |
|
123 // Populates the mapper with data from the input element |
|
124 virtual void PrepareToStoreL(); |
|
125 |
|
126 // Maps the data the result of the mapping after the database operation |
|
127 // into related element |
|
128 // Should be called after a database operation has been performed |
|
129 virtual void MapResultsL(); |
|
130 |
|
131 // With this method some post mappings can be done after storing the mapper object. |
|
132 // By default it just returns but in the case of the IAPPrioritySelectionPolicy mapper |
|
133 // the IPProto layer generation happens here - as this requires the already mapped and |
|
134 // stored APPrioritySelectionPolicy table. |
|
135 virtual void PostMappingsL(); |
|
136 |
|
137 // With this method some pre mappings can be done before the actual mapping takes place. |
|
138 // Usually this method just returns however in the case of IAPPriotySelPol mapping this method |
|
139 // loads the original and yet unchanged mapped APPriotySelPol table. |
|
140 virtual void PreMappingsL(); |
|
141 |
|
142 // Return ETrue if there is a map for this element id |
|
143 // else return EFalse |
|
144 virtual TBool Mapped(TMDBElementId aElementId) =0; |
|
145 |
|
146 // Return ETrue if mapping is needed for this element |
|
147 // else return EFalse |
|
148 virtual TBool NeedsMapping(CMDBElement& aElement) =0; |
|
149 |
|
150 |
|
151 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
152 // only ever constructed from the factory |
|
153 CCDMapper(TMDBElementId aElementId, CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation); |
|
154 #endif |
|
155 |
|
156 private: |
|
157 |
|
158 CCDMapper(); |
|
159 |
|
160 protected: |
|
161 |
|
162 TInt FindLinkElementIdL(TInt aVal, TInt aTargetTable); |
|
163 |
|
164 TMDBElementId CheckIsSnapL(TMDBElementId aInputId); |
|
165 |
|
166 protected: |
|
167 |
|
168 CMDBElement& iElement; // A reference to the element that needs mapping |
|
169 |
|
170 CMDBSessionImpl& iSession; |
|
171 |
|
172 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
173 const TOperation iOperation; |
|
174 #endif |
|
175 }; |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 /************************************************************************************************** |
|
182 * 2/ MAPPER CLASSES FOR INDIVIDUAL RECORDS |
|
183 ****************************************************************************************/ |
|
184 |
|
185 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
186 |
|
187 /************************* 2 a) Mapper for GlobalSettings Table ************************************ |
|
188 * KCDTIdGlobalSettingsRecord |
|
189 * |
|
190 * These 2 fields are now stored against the Default Tier record in the Tier table |
|
191 * DefaultSnap KCDTIdDefaultSnap CCDGlobalSettingsRecord::iDefaultSnap |
|
192 * PromptUser KCDTIdPromptForSnap CCDGlobalSettingsRecord::iPromptForSnap |
|
193 * |
|
194 * Corresponding fields in the Tier table (KCDTIdTierRecord) are |
|
195 * DefaultSnap KCDTIdDefaultAccessPoint CCDTierRecord::iDefaultAccessPoint |
|
196 * PromptUser KCDTIdPromptUser CCDTierRecord::iPromptUser |
|
197 * |
|
198 * The mapping relies on the presence of the DefaultTier field in the GlobalSettings Table |
|
199 * DefaultTier KCDTIdDefaultTier CCDGlobalSettingsRecord::iDefaultTier |
|
200 * |
|
201 * The DefaultTier must always be present as a real or default value in the GlobalSettings |
|
202 * Table. A preface configuration file for Ced may be the best way to set this value. |
|
203 * |
|
204 * If KCDTIdDefaultTier field is not present, these fields cannot be mapped |
|
205 */ |
|
206 |
|
207 NONSHARABLE_CLASS(CCDMapperGlobalSettingsRecord) : public CCDMapper |
|
208 { |
|
209 public: |
|
210 |
|
211 void ConstructL(); |
|
212 |
|
213 virtual TBool NeedsMapping(CMDBElement& aElement); |
|
214 virtual TBool Mapped(TMDBElementId aElementId); |
|
215 /*virtual*/ void PrepareToStoreL(); |
|
216 |
|
217 void MapResultsL(); |
|
218 |
|
219 DATA_VTABLE |
|
220 |
|
221 virtual ~CCDMapperGlobalSettingsRecord(){} |
|
222 |
|
223 CCDMapperGlobalSettingsRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation); |
|
224 |
|
225 private: |
|
226 |
|
227 void CreateMapL(); |
|
228 |
|
229 public: |
|
230 |
|
231 CMDBField<TBool> iPromptUser; // Whether or not to prompt the user during selection. |
|
232 CMDBRecordLink<CCDAccessPointRecord> iDefaultAccessPoint; // Tier's default access point. |
|
233 |
|
234 }; |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 /************************* 2 b) Mapper for IAPPrioritySelectionPolicy Table ************** |
|
240 * KCDTIdIapPrioritySelectionPolicyRecord CCDIAPPrioritySelectionPolicyRecord |
|
241 * |
|
242 * The IAP Selection table is deprecated and completely replaced by the APSelectionTable, |
|
243 * |
|
244 * KCDTIdApPrioritySelectionPolicyRecord CCDIAPPrioritySelectionPolicyRecord |
|
245 * |
|
246 * As IAPs map directly to APs, the IAP Selection Table that links to IAPs can map directly to |
|
247 * an AP selecton Table that points to APs that each map to a single IAP |
|
248 * |
|
249 * The mapping can be very simple because the record id, name, tag and so on can be identical |
|
250 */ |
|
251 |
|
252 NONSHARABLE_CLASS(CCDMapperIAPPrioritySelectionPolicyRecord) : public CCDMapper |
|
253 { |
|
254 public: |
|
255 |
|
256 void ConstructL(); |
|
257 |
|
258 virtual TBool NeedsMapping(CMDBElement& aElement); |
|
259 virtual TBool Mapped(TMDBElementId aElementId); |
|
260 /*virtual*/ void PrepareToStoreL(); |
|
261 /*virtual*/ void PostMappingsL(); |
|
262 /*virtual*/ void PreMappingsL(); |
|
263 void MapResultsL(); |
|
264 |
|
265 DATA_VTABLE |
|
266 |
|
267 virtual ~CCDMapperIAPPrioritySelectionPolicyRecord(); |
|
268 |
|
269 CCDMapperIAPPrioritySelectionPolicyRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation); |
|
270 |
|
271 public: |
|
272 CMDBRecordLink<CCDAccessPointRecord> iAp1; |
|
273 CMDBRecordLink<CCDAccessPointRecord> iAp2; |
|
274 CMDBRecordLink<CCDAccessPointRecord> iAp3; |
|
275 CMDBRecordLink<CCDAccessPointRecord> iAp4; |
|
276 CMDBRecordLink<CCDAccessPointRecord> iAp5; |
|
277 CMDBRecordLink<CCDAccessPointRecord> iAp6; |
|
278 CMDBRecordLink<CCDAccessPointRecord> iAp7; |
|
279 CMDBRecordLink<CCDAccessPointRecord> iAp8; |
|
280 CMDBRecordLink<CCDAccessPointRecord> iAp9; |
|
281 CMDBRecordLink<CCDAccessPointRecord> iAp10; |
|
282 CMDBRecordLink<CCDAccessPointRecord> iAp11; |
|
283 CMDBRecordLink<CCDAccessPointRecord> iAp12; |
|
284 CMDBRecordLink<CCDAccessPointRecord> iAp13; |
|
285 CMDBRecordLink<CCDAccessPointRecord> iAp14; |
|
286 CMDBRecordLink<CCDAccessPointRecord> iAp15; |
|
287 |
|
288 CMDBField<TUint32> iApCount; |
|
289 CMDBField<TInt> iRecordTag; |
|
290 CMDBField<TDesC> iRecordName; |
|
291 private: |
|
292 /* |
|
293 * this field here is needed for example when mapping an IAPPrioritySelPol table modification. In this |
|
294 * case we need to know what was the original AP link in the APPrioritySelPol recrod because when someone |
|
295 * deletes an IAP record link form the IAPPriotitySelPol record we have to have some information that what |
|
296 * is the mapped AP link in the APPrioritySelPol record to be able to modify the linked IPProto level AP. |
|
297 */ |
|
298 |
|
299 CMDBElement* origMappedDataInDB; |
|
300 |
|
301 //Checks that the AP record, given as an ElementId, is a Network, IPProto or Link level AP |
|
302 CommsDatMapperAndValidator::TAPTypes CheckLinkLevelAPL(TMDBElementId aElementId); |
|
303 |
|
304 void GenerateIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityFieldToModify, |
|
305 TInt aLinkNumber, |
|
306 TBool aIsDefaultAP); |
|
307 |
|
308 void CheckIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField, |
|
309 TInt aLinkNumber, |
|
310 TBool aIsDefaultAP); |
|
311 |
|
312 void DeleteIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField); |
|
313 |
|
314 /* There is a little trick here. If there are 2 APPrioritySelPol records where |
|
315 * 1 link in each record is linking against the same IPProto AP then the situation |
|
316 * can be the following: |
|
317 * APPrioritySelPolRec_1: |
|
318 * AP1 = IPProto_link_record1 |
|
319 * |
|
320 * APPrioritySelPolRec_2: |
|
321 * AP1 = IPProto_link_record1 |
|
322 * |
|
323 * 1 APPrioritySelPol record can be already deleted (by the MaybeDeleteNodeL call). |
|
324 * So when the program logic tries to find that how many reference does a given |
|
325 * IPProto AP have (IPProto_link_record1) then it finds that it's only 1 because the |
|
326 * other record from which it was linked the 2nd time is already deleted. That's why |
|
327 * we give for the search algorithm the original (already deleted) APPrioritySelPol record. |
|
328 */ |
|
329 void DeleteIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField, |
|
330 CCDAPPrioritySelectionPolicyRecord* aTheAlreadyDeletedRecord); |
|
331 |
|
332 TInt GetTheLinkAPTagIdL(TMDBElementId aElementId); |
|
333 TInt GetTheLinkAPTagIdL(CCDIAPPrioritySelectionPolicyRecord* aOrigIAPPrioritySelPolRec, |
|
334 TInt aLinkNumber); |
|
335 TInt GetTheLinkAPTagIdL(CMDBRecordLink<CCDIAPRecord>* aOrigIAPPrioritySelPolField/*, |
|
336 TInt aLinkNumber*/); |
|
337 |
|
338 TBool IsItTheDefaultAPPrioritySelPolRec(/*CCDAPPrioritySelectionPolicyRecord* aDefAPPrioritySelPolRec*/); |
|
339 |
|
340 TInt ForcedCountAPLinks(); |
|
341 }; |
|
342 |
|
343 |
|
344 /************************* 2 c) Mapper for AccessPoint Table *************************************** |
|
345 * KCDTIdAccessPointRecord CCDAccessPointRecord |
|
346 * |
|
347 * The following fields are deprecated |
|
348 * APGID CCDAccessPointRecord::iAccessPointGID |
|
349 * |
|
350 * They map to new fields within the AccessPointRecord |
|
351 * APTier CCDAccessPointRecord::iTier |
|
352 * |
|
353 * The following fields have some deprecated usage which is mapped |
|
354 * though the same field remains |
|
355 * APSelectionPolicy CCDAccessPointRecord::iSelectionPolicy |
|
356 * |
|
357 * |
|
358 */ |
|
359 |
|
360 NONSHARABLE_CLASS(CCDMapperAccessPointRecord) : public CCDMapper |
|
361 { |
|
362 public: |
|
363 |
|
364 void ConstructL(); |
|
365 |
|
366 void PrepareToStoreL(); |
|
367 |
|
368 TBool NeedsMapping(CMDBElement& aElement); |
|
369 TBool Mapped(TMDBElementId aElementId); |
|
370 /*virtual*/ void PreMappingsL(); |
|
371 void MapResultsL(); |
|
372 |
|
373 /*virtual*/ void FinalPreparationsL(); |
|
374 |
|
375 DATA_VTABLE |
|
376 |
|
377 virtual ~CCDMapperAccessPointRecord(){} |
|
378 |
|
379 CCDMapperAccessPointRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation); |
|
380 |
|
381 public: |
|
382 CMDBRecordLink<CCDTierRecord> iTier; //Tier. The type of the access point. The tier this AP belongs to. Links to a record in the Tier table. |
|
383 CMDBRecordLink<CCDMCprRecord> iMCpr; //MCPR to load for this AP. Links to a record in the MCPR table. |
|
384 CMDBRecordLink<CCDCprRecord> iCpr; //CPR to load for this AP. Links to a record in the CPR table. |
|
385 CMDBRecordLink<CCDSCprRecord> iSCpr; //SCPR to load for this AP. Links to a record in the SCPR table. |
|
386 CMDBRecordLink<CCDSCprRecord> iProtocol; //CFP to load for this AP. Links to a record in teh CFProtocol table. |
|
387 CMDBField<TUint32> iCprConfig; //MCPR's config id. Value interpreted by an MCPR to configure the AP. |
|
388 CMDBField<TUint32> iAppSID; //Application SID. Marks this AP for use by single Application only |
|
389 CMDBField<TDesC> iConfigAPIdList; //List of additional SCprs (from ConfigAccessPoint table) |
|
390 |
|
391 /** |
|
392 The selection policy which links to the APPrioritySelectionPolicy record. As this is a mapper object |
|
393 we can be sure that this AP will be a network level AP which has to have a valid APPrioritySelPol link. |
|
394 The problem is that the linked record is not inserted (will be generated when the IAPPrioritySelPol record |
|
395 will be inserted), we just know from the input record that what will be the elementID of it, that's why |
|
396 it's a numeric field and not a linked one. |
|
397 */ |
|
398 CMDBField<TUint32> iSelectionPolicy; |
|
399 |
|
400 /* The mapper has to have its own TagId. If the input container doesn't |
|
401 * contain any this will be used to hold the generated TagId. |
|
402 */ |
|
403 CMDBField<TInt> iRecordTag; |
|
404 }; |
|
405 |
|
406 |
|
407 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
408 |
|
409 |
|
410 } //end namespace CommsDatInternal |
|
411 |
|
412 |
|
413 |
|
414 #endif //COMMSDATMAPPER_H |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |