Subversion Repositories SmartDukaan

Rev

Rev 4321 | Rev 4668 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4321 Rev 4323
Line 43... Line 43...
43
    def createAnonymousUser(self, jsessionId):
43
    def createAnonymousUser(self, jsessionId):
44
        try:
44
        try:
45
            cart = create_cart(-1)
45
            cart = create_cart(-1)
46
            return to_t_user(create_anonymous_user(jsessionId, cart))
46
            return to_t_user(create_anonymous_user(jsessionId, cart))
47
        finally:
47
        finally:
48
            UserDataAccessors.close_session()
48
            self.closeSession()
49
            CartDataAccessors.close_session()
-
 
50
 
49
 
51
    def getUserById(self, userId):
50
    def getUserById(self, userId):
52
        """
51
        """
53
        Parameters:
52
        Parameters:
54
        - userId
53
        - userId
55
        """
54
        """
56
        try:
55
        try:
57
            return to_t_user(get_user_by_id(userId))
56
            return to_t_user(get_user_by_id(userId))
58
        finally:
57
        finally:
59
            UserDataAccessors.close_session()
58
            self.closeSession()
60
 
59
 
61
    def getUserByMobileNumber(self, mobileNumber):
60
    def getUserByMobileNumber(self, mobileNumber):
62
        """
61
        """
63
        Parameters:
62
        Parameters:
64
        - mobileNumber
63
        - mobileNumber
65
        """
64
        """
66
        try:
65
        try:
67
            return to_t_user(get_user_by_mobile_number(mobileNumber))
66
            return to_t_user(get_user_by_mobile_number(mobileNumber))
68
        finally:
67
        finally:
69
            UserDataAccessors.close_session()
68
            self.closeSession()
70
 
69
 
71
    def getUserByEmail(self, email):
70
    def getUserByEmail(self, email):
72
        """
71
        """
73
        Parameters:
72
        Parameters:
74
         - email
73
         - email
75
        """
74
        """
76
        try:
75
        try:
77
            return to_t_user(get_user_by_email(email))
76
            return to_t_user(get_user_by_email(email))
78
        finally:
77
        finally:
79
            UserDataAccessors.close_session()
78
            self.closeSession()
80
 
-
 
81
 
79
 
82
    def createUser(self, user):
80
    def createUser(self, user):
83
        """
81
        """
84
        Parameters:
82
        Parameters:
85
        - user
83
        - user
86
        """
84
        """
87
        try:
85
        try:
88
            cart = create_cart(-1)
86
            cart = create_cart(-1)
89
            return to_t_user(create_user(user, cart))
87
            return to_t_user(create_user(user, cart))
90
        finally:
88
        finally:
91
            CartDataAccessors.close_session()
-
 
92
            UserDataAccessors.close_session()
89
            self.closeSession()
93
            
90
 
94
    def updateUser(self, user):
91
    def updateUser(self, user):
95
        """
92
        """
96
        Parameters:
93
        Parameters:
97
        - user
94
        - user
98
        """
95
        """
99
        try:
96
        try:
100
            return to_t_user(update_user(user))
97
            return to_t_user(update_user(user))
101
        finally:
98
        finally:
102
            UserDataAccessors.close_session()
99
            self.closeSession()
103
            
100
            
104
    def deleteUser(self, userId):
101
    def deleteUser(self, userId):
105
        """
102
        """
106
        Parameters:
103
        Parameters:
107
        - userId
104
        - userId
108
        """
105
        """
109
        try:
106
        try:
110
            return delete_user(userId)
107
            return delete_user(userId)
111
        finally:
108
        finally:
112
            UserDataAccessors.close_session()
109
            self.closeSession()
113
            
110
            
114
    def getUserState(self, userId):
111
    def getUserState(self, userId):
115
        """
112
        """
116
        Parameters:
113
        Parameters:
117
        - userId
114
        - userId
118
        """
115
        """
119
        log_entry(self, "get State")
116
        log_entry(self, "get State")
120
        try:
117
        try:
121
            return to_t_user_state(get_user_state(userId))
118
            return to_t_user_state(get_user_state(userId))
122
        finally:
119
        finally:
123
            UserDataAccessors.close_session()
120
            self.closeSession()
124
            
121
            
125
    def authenticateUser(self, email, password):
122
    def authenticateUser(self, email, password):
126
        """
123
        """
127
        Parameters:
124
        Parameters:
128
        - email
125
        - email
Line 130... Line 127...
130
        """
127
        """
131
        log_entry(self, "authenticate user")
128
        log_entry(self, "authenticate user")
132
        try:
129
        try:
133
            return to_t_user(authenticate_user(email, password))
130
            return to_t_user(authenticate_user(email, password))
134
        finally:
131
        finally:
135
            UserDataAccessors.close_session()
132
            self.closeSession()
136
            
133
            
137
    def userExists(self, email):
134
    def userExists(self, email):
138
        """
135
        """
139
        Parameters:
136
        Parameters:
140
        - email
137
        - email
141
        """
138
        """
142
        log_entry(self, "user exists")
139
        log_entry(self, "user exists")
143
        try:
140
        try:
144
            return user_exists(email)
141
            return user_exists(email)
145
        finally:
142
        finally:
146
            UserDataAccessors.close_session()
143
            self.closeSession()
147
            
144
            
148
    def addAddressForUser(self, userId, address, setDefault):
145
    def addAddressForUser(self, userId, address, setDefault):
149
        """
146
        """
150
        Parameters:
147
        Parameters:
151
        - userId
148
        - userId
Line 154... Line 151...
154
        """
151
        """
155
        log_entry(self, "add address for user")
152
        log_entry(self, "add address for user")
156
        try:
153
        try:
157
            return add_address_for_user(address, userId, setDefault)
154
            return add_address_for_user(address, userId, setDefault)
158
        finally:
155
        finally:
159
            UserDataAccessors.close_session()
156
            self.closeSession()
160
            
157
            
161
    def removeAddressForUser(self, userid, addressId):
158
    def removeAddressForUser(self, userid, addressId):
162
        """
159
        """
163
        Parameters:
160
        Parameters:
164
        - userid
161
        - userid
Line 166... Line 163...
166
        """
163
        """
167
        log_entry(self, "removing address")
164
        log_entry(self, "removing address")
168
        try:
165
        try:
169
            return remove_address_for_user(userid, addressId)
166
            return remove_address_for_user(userid, addressId)
170
        finally:
167
        finally:
171
            UserDataAccessors.close_session()
168
            self.closeSession()
172
            
169
            
173
    def setUserAsLoggedIn(self, userId, timestamp):
170
    def setUserAsLoggedIn(self, userId, timestamp):
174
        """
171
        """
175
        Parameters:
172
        Parameters:
176
        - userId
173
        - userId
Line 178... Line 175...
178
        """
175
        """
179
        log_entry(self, "set_user_as_logged_in")
176
        log_entry(self, "set_user_as_logged_in")
180
        try:
177
        try:
181
            return set_user_as_logged_in(userId, timestamp)
178
            return set_user_as_logged_in(userId, timestamp)
182
        finally:
179
        finally:
183
            UserDataAccessors.close_session()
180
            self.closeSession()
184
            
181
            
185
    def setUserAsLoggedOut(self, userId, timestamp):
182
    def setUserAsLoggedOut(self, userId, timestamp):
186
        """
183
        """
187
        Parameters:
184
        Parameters:
188
        - userId
185
        - userId
Line 190... Line 187...
190
        """
187
        """
191
        log_entry(self, "set user as logged out")
188
        log_entry(self, "set user as logged out")
192
        try:
189
        try:
193
            return set_user_as_logged_out(userId, timestamp)
190
            return set_user_as_logged_out(userId, timestamp)
194
        finally:
191
        finally:
195
            UserDataAccessors.close_session()
192
            self.closeSession()
196
            
193
            
197
    def setDefaultAddress(self, userId, addressId):
194
    def setDefaultAddress(self, userId, addressId):
198
        """
195
        """
199
        Parameters:
196
        Parameters:
200
        - userId
197
        - userId
201
        - addressId
198
        - addressId
202
        """
199
        """
203
        try:
200
        try:
204
            return set_default_address(userId, addressId)
201
            return set_default_address(userId, addressId)
205
        finally:
202
        finally:
206
            UserDataAccessors.close_session()
203
            self.closeSession()
207
            
204
            
208
    def updatePassword(self, userid, oldPassword, newPassword):
205
    def updatePassword(self, userid, oldPassword, newPassword):
209
        """
206
        """
210
        Parameters:
207
        Parameters:
211
         - userid
208
         - userid
Line 214... Line 211...
214
        """
211
        """
215
        log_entry(self, "updating password")
212
        log_entry(self, "updating password")
216
        try:
213
        try:
217
            return update_password(userid, oldPassword, newPassword)
214
            return update_password(userid, oldPassword, newPassword)
218
        finally:
215
        finally:
219
            UserDataAccessors.close_session()
216
            self.closeSession()
220
            
217
            
221
    def forgotPassword(self, email, password):
218
    def forgotPassword(self, email, password):
222
        """
219
        """
223
        Parameters:
220
        Parameters:
224
         - email
221
         - email
225
        """
222
        """
226
        log_entry(self, "forgot password")
223
        log_entry(self, "forgot password")
227
        try:
224
        try:
228
            return forgot_password(email, password)
225
            return forgot_password(email, password)
229
        finally:
226
        finally:
230
            UserDataAccessors.close_session()
227
            self.closeSession()
231
            
228
 
232
    def getAllAddressesForUser(self, userId):
229
    def getAllAddressesForUser(self, userId):
233
        """
230
        """
234
        Parameters:
231
        Parameters:
235
         - userId
232
         - userId
236
        """
233
        """
Line 240... Line 237...
240
            t_addresses = list()
237
            t_addresses = list()
241
            for address in addresses:
238
            for address in addresses:
242
                t_addresses.append(to_t_address(address))
239
                t_addresses.append(to_t_address(address))
243
            return t_addresses
240
            return t_addresses
244
        finally:
241
        finally:
245
            UserDataAccessors.close_session()
242
            self.closeSession()
246
              
243
              
247
    def getAddressById(self, addressId):
244
    def getAddressById(self, addressId):
248
        """
245
        """
249
        Parameters:
246
        Parameters:
250
         - addressId
247
         - addressId
251
        """
248
        """
252
        try:
249
        try:
253
            return to_t_address(get_address(addressId))
250
            return to_t_address(get_address(addressId))
254
        finally:
251
        finally:
255
            UserDataAccessors.close_session()
252
            self.closeSession()
256
              
253
              
257
    def getDefaultAddressId(self, userId):
254
    def getDefaultAddressId(self, userId):
258
        """
255
        """
259
        Parameters:
256
        Parameters:
260
         - userId
257
         - userId
261
        """
258
        """
262
        try:
259
        try:
263
            return get_default_address_id(userId)
260
            return get_default_address_id(userId)
264
        finally:
261
        finally:
265
            UserDataAccessors.close_session()
262
            self.closeSession()
266
 
263
 
267
    def getDefaultPincode(self, userId):
264
    def getDefaultPincode(self, userId):
268
        """
265
        """
269
        Parameters:
266
        Parameters:
270
         - userId
267
         - userId
271
        """
268
        """
272
        try:
269
        try:
273
            return get_default_pincode(userId)
270
            return get_default_pincode(userId)
274
        finally:
271
        finally:
275
            UserDataAccessors.close_session()
272
            self.closeSession()
276
 
273
 
277
    def createCart(self, userId):
274
    def createCart(self, userId):
278
        """
275
        """
279
        Parameters:
276
        Parameters:
280
        - userId
277
        - userId
281
        """
278
        """
282
        try:
279
        try:
283
            return create_cart(userId).id
280
            return create_cart(userId).id
284
        finally:
281
        finally:
285
            CartDataAccessors.close_session()
282
            self.closeSession()
286
            
283
            
287
    def getCurrentCart(self, userId):
284
    def getCurrentCart(self, userId):
288
        """
285
        """
289
        Parameters:
286
        Parameters:
290
         - userId
287
         - userId
Line 294... Line 291...
294
            if cart:
291
            if cart:
295
                return to_t_cart(cart)
292
                return to_t_cart(cart)
296
            else:
293
            else:
297
                raise ShoppingCartException(101, "not cart attached to this user")
294
                raise ShoppingCartException(101, "not cart attached to this user")
298
        finally:
295
        finally:
299
            CartDataAccessors.close_session()
296
            self.closeSession()
300
            
297
            
301
    def getCart(self, cartId):
298
    def getCart(self, cartId):
302
        """
299
        """
303
        Parameters:
300
        Parameters:
304
         - cartId
301
         - cartId
Line 308... Line 305...
308
            if cart:
305
            if cart:
309
                return to_t_cart(cart)
306
                return to_t_cart(cart)
310
            else:
307
            else:
311
                raise ShoppingCartException(101, "not cart attached to this id")
308
                raise ShoppingCartException(101, "not cart attached to this id")
312
        finally:
309
        finally:
313
            CartDataAccessors.close_session()
310
            self.closeSession()
314
            
311
            
315
    def getCartsForUser(self, userId, status):
312
    def getCartsForUser(self, userId, status):
316
        """
313
        """
317
        Parameters:
314
        Parameters:
318
         - userId
315
         - userId
Line 327... Line 324...
327
            if carts:
324
            if carts:
328
                for cart in carts:
325
                for cart in carts:
329
                    t_carts.append(to_t_cart(cart))
326
                    t_carts.append(to_t_cart(cart))
330
            return t_carts
327
            return t_carts
331
        finally:
328
        finally:
332
            CartDataAccessors.close_session()
329
            self.closeSession()
333
                
330
                
334
    def getCartsByStatus(self, status):
331
    def getCartsByStatus(self, status):
335
        """
332
        """
336
        Parameters:
333
        Parameters:
337
         - status
334
         - status
Line 342... Line 339...
342
            if carts:
339
            if carts:
343
                for cart in carts:
340
                for cart in carts:
344
                    t_carts.append(to_t_cart(cart))
341
                    t_carts.append(to_t_cart(cart))
345
            return t_carts
342
            return t_carts
346
        finally:
343
        finally:
347
            CartDataAccessors.close_session()
344
            self.closeSession()
348
            
345
            
349
    def getCartsByTime(self, from_time, to_time, status):
346
    def getCartsByTime(self, from_time, to_time, status):
350
        """
347
        """
351
        Parameters:
348
        Parameters:
352
         - from_time
349
         - from_time
Line 359... Line 356...
359
            if carts:
356
            if carts:
360
                for cart in carts:
357
                for cart in carts:
361
                    t_carts.append(to_t_cart(cart))
358
                    t_carts.append(to_t_cart(cart))
362
            return t_carts
359
            return t_carts
363
        finally:
360
        finally:
364
            CartDataAccessors.close_session()
361
            self.closeSession()
365
            
362
            
366
    def changeCartStatus(self, cartId, status):
363
    def changeCartStatus(self, cartId, status):
367
        """
364
        """
368
        Parameters:
365
        Parameters:
369
         - cartId
366
         - cartId
370
         - status
367
         - status
371
        """
368
        """
372
        try:
369
        try:
373
            change_cart_status(cartId, status)
370
            change_cart_status(cartId, status)
374
        finally:
371
        finally:
375
            CartDataAccessors.close_session()
372
            self.closeSession()
376
            
373
            
377
    def addItemToCart(self, cartId, itemId, quantity, sourceId):
374
    def addItemToCart(self, cartId, itemId, quantity, sourceId):
378
        """
375
        """
379
        Parameters:
376
        Parameters:
380
         - cartId
377
         - cartId
Line 382... Line 379...
382
         - quantity
379
         - quantity
383
        """
380
        """
384
        try:
381
        try:
385
            return add_item_to_cart(cartId, itemId, quantity, sourceId)
382
            return add_item_to_cart(cartId, itemId, quantity, sourceId)
386
        finally:
383
        finally:
387
            CartDataAccessors.close_session()
384
            self.closeSession()
388
            
385
            
389
    def deleteItemFromCart(self, cartId, itemId):
386
    def deleteItemFromCart(self, cartId, itemId):
390
        """
387
        """
391
        Parameters:
388
        Parameters:
392
         - cartId
389
         - cartId
393
         - itemId
390
         - itemId
394
        """
391
        """
395
        try:
392
        try:
396
            delete_item_from_cart(cartId, itemId)
393
            delete_item_from_cart(cartId, itemId)
397
        finally:
394
        finally:
398
            CartDataAccessors.close_session()
395
            self.closeSession()
399
            
396
            
400
    def changeItemStatus(self, cartId, itemId, status):
397
    def changeItemStatus(self, cartId, itemId, status):
401
        """
398
        """
402
        Parameters:
399
        Parameters:
403
         - cartId
400
         - cartId
404
         - itemId
401
         - itemId
405
        """
402
        """
406
        try:
403
        try:
407
            return change_item_status(cartId, itemId, status)
404
            return change_item_status(cartId, itemId, status)
408
        finally:
405
        finally:
409
            CartDataAccessors.close_session()
406
            self.closeSession()
410
            
407
            
411
    def addAddressToCart(self, cartId, addressId):
408
    def addAddressToCart(self, cartId, addressId):
412
        """
409
        """
413
        Parameters:
410
        Parameters:
414
         - cartId
411
         - cartId
415
         - addressId
412
         - addressId
416
        """
413
        """
417
        try:
414
        try:
418
            return add_address_to_cart(cartId, addressId)
415
            return add_address_to_cart(cartId, addressId)
419
        finally:
416
        finally:
420
            CartDataAccessors.close_session()
417
            self.closeSession()
421
    
418
    
422
    def applyCouponToCart(self, cartId, couponCode, totalPrice, discountedPrice):
419
    def applyCouponToCart(self, cartId, couponCode, totalPrice, discountedPrice):
423
        '''
420
        '''
424
        Parameters:
421
        Parameters:
425
        - cartId
422
        - cartId
Line 428... Line 425...
428
        - discountedPrice
425
        - discountedPrice
429
        '''
426
        '''
430
        try:
427
        try:
431
            apply_coupon_to_cart(cartId, couponCode, totalPrice, discountedPrice)
428
            apply_coupon_to_cart(cartId, couponCode, totalPrice, discountedPrice)
432
        finally:
429
        finally:
433
            CartDataAccessors.close_session()
430
            self.closeSession()
434
    
431
    
435
    def removeCoupon(self, cartId):
432
    def removeCoupon(self, cartId):
436
        '''
433
        '''
437
        Parameters:
434
        Parameters:
438
        - cartId
435
        - cartId
439
        '''
436
        '''
440
        try:
437
        try:
441
            remove_coupon(cartId)
438
            remove_coupon(cartId)
442
        finally:
439
        finally:
443
            CartDataAccessors.close_session()
440
            self.closeSession()
444
    
441
    
445
    def createOrders(self, cartId, sessionSource, sessionTime, firstSource, firstSourceTime):
442
    def createOrders(self, cartId, sessionSource, sessionTime, firstSource, firstSourceTime):
446
        """
443
        """
447
        Parameters:
444
        Parameters:
448
         - cartId
445
         - cartId
449
         - sessionSource
446
         - sessionSource
450
        """
447
        """
451
        try:
448
        try:
452
            return commit_cart(cartId, sessionSource, sessionTime, firstSource, firstSourceTime)
449
            return commit_cart(cartId, sessionSource, sessionTime, firstSource, firstSourceTime)
453
        finally:
450
        finally:
454
            CartDataAccessors.close_session()
-
 
455
            UserDataAccessors.close_session()
451
            self.closeSession()
456
 
452
 
457
    def validateCart(self, cartId, sourceId):
453
    def validateCart(self, cartId, sourceId):
458
        """
454
        """
459
        Validates that:
455
        Validates that:
460
        1. The checkout timestamp is greater than the updatedOn timestamp.
456
        1. The checkout timestamp is greater than the updatedOn timestamp.
Line 467... Line 463...
467
         - cartId
463
         - cartId
468
        """
464
        """
469
        try:
465
        try:
470
            return validate_cart(cartId, sourceId)
466
            return validate_cart(cartId, sourceId)
471
        finally:
467
        finally:
472
            CartDataAccessors.close_session()
468
            self.closeSession()
473
            
469
            
474
    def mergeCart(self, fromCartId, toCartId):
470
    def mergeCart(self, fromCartId, toCartId):
475
        """
471
        """
476
        Parameters:
472
        Parameters:
477
         - fromCartId
473
         - fromCartId
478
         - toCartId
474
         - toCartId
479
        """
475
        """
480
        try:
476
        try:
481
            merge_cart(fromCartId, toCartId)
477
            merge_cart(fromCartId, toCartId)
482
        finally:
478
        finally:
483
            CartDataAccessors.close_session()
479
            self.closeSession()
484
            
480
            
485
    def checkOut(self, cartId):
481
    def checkOut(self, cartId):
486
        """
482
        """
487
        Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
483
        Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
488
        
484
        
Line 490... Line 486...
490
         - cartId
486
         - cartId
491
        """
487
        """
492
        try:
488
        try:
493
            return check_out(cartId)
489
            return check_out(cartId)
494
        finally:
490
        finally:
495
            CartDataAccessors.close_session()
491
            self.closeSession()
496
            
492
            
497
    def resetCart(self, cartId, items):
493
    def resetCart(self, cartId, items):
498
        """
494
        """
499
        The second parameter is a map of item ids and their quantities which have been successfully processed.
495
        The second parameter is a map of item ids and their quantities which have been successfully processed.
500
        This methods removes the specified quantiry of the specified item from the cart.
496
        This methods removes the specified quantiry of the specified item from the cart.
Line 504... Line 500...
504
         - items
500
         - items
505
        """
501
        """
506
        try:
502
        try:
507
            return reset_cart(cartId, items)
503
            return reset_cart(cartId, items)
508
        finally:
504
        finally:
509
            CartDataAccessors.close_session()
505
            self.closeSession()
510
 
506
 
511
    #Widget related methods
507
    #Widget related methods
512
    def updateMyResearch(self, userId, itemId):
508
    def updateMyResearch(self, userId, itemId):
513
        """
509
        """
514
        Parameters:
510
        Parameters:
Line 516... Line 512...
516
         - item_id
512
         - item_id
517
        """
513
        """
518
        try:
514
        try:
519
            return update_my_research(userId, itemId)
515
            return update_my_research(userId, itemId)
520
        finally:
516
        finally:
521
            UserDataAccessors.close_session()
517
            self.closeSession()
522
 
518
 
523
    def deleteItemFromMyResearch(self, userId, itemId):
519
    def deleteItemFromMyResearch(self, userId, itemId):
524
        """
520
        """
525
        Parameters:
521
        Parameters:
526
         - user_id
522
         - user_id
527
         - item_id
523
         - item_id
528
        """
524
        """
529
        try:
525
        try:
530
            return delete_item_from_my_research(userId, itemId)
526
            return delete_item_from_my_research(userId, itemId)
531
        finally:
527
        finally:
532
            UserDataAccessors.close_session()
528
            self.closeSession()
533
            
529
            
534
    def updateBrowseHistory(self, userId, itemId):
530
    def updateBrowseHistory(self, userId, itemId):
535
        """
531
        """
536
        Parameters: 
532
        Parameters: 
537
        - user_id
533
        - user_id
538
        - item_id
534
        - item_id
539
        """
535
        """
540
        try:
536
        try:
541
            update_browse_history(userId, itemId)
537
            update_browse_history(userId, itemId)
542
        finally:
538
        finally:
543
            UserDataAccessors.close_session()
539
            self.closeSession()
544
            
540
            
545
    def mergeBrowseHistory(self, fromUserId, toUserId):
541
    def mergeBrowseHistory(self, fromUserId, toUserId):
546
        """
542
        """
547
        Parameters:
543
        Parameters:
548
         - user_id
544
         - user_id
Line 562... Line 558...
562
         - message
558
         - message
563
        """
559
        """
564
        try:
560
        try:
565
            return create_user_communication(userId, email, communicationType, orderId, awb, product, subject, message)
561
            return create_user_communication(userId, email, communicationType, orderId, awb, product, subject, message)
566
        finally:
562
        finally:
567
            UserDataAccessors.close_session()
563
            self.closeSession()
568
    
564
    
569
    def getUserCommunicationById(self, id):
565
    def getUserCommunicationById(self, id):
570
        """
566
        """
571
        Parameters:
567
        Parameters:
572
         - id
568
         - id
573
        """
569
        """
574
        try:
570
        try:
575
            return to_t_user_communication(get_user_communication_by_id(id))
571
            return to_t_user_communication(get_user_communication_by_id(id))
576
        finally:
572
        finally:
577
            UserDataAccessors.close_session()
573
            self.closeSession()
578
    
574
    
579
    def getUserCommunicationByUser(self, userId):
575
    def getUserCommunicationByUser(self, userId):
580
        """
576
        """
581
        Parameters:
577
        Parameters:
582
         - userId
578
         - userId
583
        """
579
        """
584
        try:
580
        try:
585
            return [to_t_user_communication(user_communication) for user_communication in get_user_communication_by_user(userId)]
581
            return [to_t_user_communication(user_communication) for user_communication in get_user_communication_by_user(userId)]
586
        finally:
582
        finally:
587
            UserDataAccessors.close_session()
583
            self.closeSession()
588
    
584
    
589
    def getAllUserCommunications(self):
585
    def getAllUserCommunications(self):
590
        try:
586
        try:
591
            return [to_t_user_communication(user_communication) for user_communication in get_all_user_communications()]
587
            return [to_t_user_communication(user_communication) for user_communication in get_all_user_communications()]
592
        finally:
588
        finally:
593
            UserDataAccessors.close_session()
589
            self.closeSession()
594
 
590
 
595
    def createMasterAffiliate(self, name, addedOn):
591
    def createMasterAffiliate(self, name, addedOn):
596
        """
592
        """
597
        Parameters
593
        Parameters
598
         - name
594
         - name
599
         - addedOn
595
         - addedOn
600
        """
596
        """
601
        try:
597
        try:
602
            return to_t_master_affiliate(create_master_affiliate(name, addedOn))
598
            return to_t_master_affiliate(create_master_affiliate(name, addedOn))
603
        finally:
599
        finally:
604
            UserDataAccessors.close_session()
600
            self.closeSession()
605
    
601
    
606
    def getAllMasterAffiliates(self):
602
    def getAllMasterAffiliates(self):
607
        try:
603
        try:
608
            return [to_t_master_affiliate(masterAffiliate) for masterAffiliate in get_all_master_affiliates()]
604
            return [to_t_master_affiliate(masterAffiliate) for masterAffiliate in get_all_master_affiliates()]
609
        finally:
605
        finally:
610
            UserDataAccessors.close_session()
606
            self.closeSession()
611
    
607
    
612
    def getMasterAffiliateById(self, id):
608
    def getMasterAffiliateById(self, id):
613
        """
609
        """
614
        Parameters
610
        Parameters
615
         - id
611
         - id
616
        """
612
        """
617
        try:
613
        try:
618
            return to_t_master_affiliate(get_master_affiliate_by_id(id))
614
            return to_t_master_affiliate(get_master_affiliate_by_id(id))
619
        finally:
615
        finally:
620
            UserDataAccessors.close_session()
616
            self.closeSession()
621
    
617
    
622
    def getMasterAffiliateByName(self, name):
618
    def getMasterAffiliateByName(self, name):
623
        """
619
        """
624
        Parameters
620
        Parameters
625
         - id
621
         - id
626
        """
622
        """
627
        try:
623
        try:
628
            return to_t_master_affiliate(get_master_affiliate_by_name(name))
624
            return to_t_master_affiliate(get_master_affiliate_by_name(name))
629
        finally:
625
        finally:
630
            UserDataAccessors.close_session()
626
            self.closeSession()
631
    
627
    
632
    def createAffiliate(self, name, url, masterAffiliateId, addedOn):
628
    def createAffiliate(self, name, url, masterAffiliateId, addedOn):
633
        """
629
        """
634
        Parameters
630
        Parameters
635
         - name
631
         - name
Line 638... Line 634...
638
         - addedOn
634
         - addedOn
639
        """
635
        """
640
        try:
636
        try:
641
            return to_t_affiliate(create_affiliate(name, url, masterAffiliateId, addedOn))
637
            return to_t_affiliate(create_affiliate(name, url, masterAffiliateId, addedOn))
642
        finally:
638
        finally:
643
            UserDataAccessors.close_session()
639
            self.closeSession()
644
    
640
    
645
    def getAffiliateById(self, id):
641
    def getAffiliateById(self, id):
646
        """
642
        """
647
        Parameters
643
        Parameters
648
         - id
644
         - id
649
        """
645
        """
650
        try:
646
        try:
651
            return to_t_affiliate(get_affiliate_by_id(id))
647
            return to_t_affiliate(get_affiliate_by_id(id))
652
        finally:
648
        finally:
653
            UserDataAccessors.close_session()
649
            self.closeSession()
654
    
650
    
655
    def getAffiliateByName(self, name):
651
    def getAffiliateByName(self, name):
656
        """
652
        """
657
        Parameters
653
        Parameters
658
         - name
654
         - name
659
        """
655
        """
660
        try:
656
        try:
661
            return to_t_affiliate(get_affiliate_by_name(name))
657
            return to_t_affiliate(get_affiliate_by_name(name))
662
        finally:
658
        finally:
663
            UserDataAccessors.close_session()
659
            self.closeSession()
664
    
660
    
665
    def getAffiliatesByMasterAffiliate(self, masterAffiliateId):
661
    def getAffiliatesByMasterAffiliate(self, masterAffiliateId):
666
        """
662
        """
667
        Parameters
663
        Parameters
668
         - master_id
664
         - master_id
669
        """
665
        """
670
        try:
666
        try:
671
            return [to_t_affiliate(affiliate) for affiliate in get_affiliates_by_master_affiliate(masterAffiliateId)]
667
            return [to_t_affiliate(affiliate) for affiliate in get_affiliates_by_master_affiliate(masterAffiliateId)]
672
        finally:
668
        finally:
673
            UserDataAccessors.close_session()
669
            self.closeSession()
674
            
670
            
675
    def getTrackerById(self, trackerId):
671
    def getTrackerById(self, trackerId):
676
        """
672
        """
677
        Parameters
673
        Parameters
678
         - trackerId
674
         - trackerId
679
        """
675
        """
680
        try:
676
        try:
681
            return to_t_tracker(get_tracker_by_id(trackerId))
677
            return to_t_tracker(get_tracker_by_id(trackerId))
682
        finally:
678
        finally:
683
            UserDataAccessors.close_session()
679
            self.closeSession()
684
            
680
            
685
    def addTrackLog(self, affiliateId, userId, event, url, data, addedOn):
681
    def addTrackLog(self, affiliateId, userId, event, url, data, addedOn):
686
        """
682
        """
687
        Parameter
683
        Parameter
688
         - affiliateId
684
         - affiliateId
Line 693... Line 689...
693
         - addedOn
689
         - addedOn
694
        """
690
        """
695
        try:
691
        try:
696
            return add_track_log(affiliateId, userId, event, url, data, addedOn)
692
            return add_track_log(affiliateId, userId, event, url, data, addedOn)
697
        finally:
693
        finally:
698
            UserDataAccessors.close_session()
694
            self.closeSession()
699
    
695
    
700
    def getTrackLogById(self, id):
696
    def getTrackLogById(self, id):
701
        """
697
        """
702
        Parameter
698
        Parameter
703
         - id
699
         - id
704
        """
700
        """
705
        try:
701
        try:
706
            return to_t_track_log(get_track_log_by_id(id))
702
            return to_t_track_log(get_track_log_by_id(id))
707
        finally:
703
        finally:
708
            UserDataAccessors.close_session()
704
            self.closeSession()
709
    
705
    
710
    def getTrackLogsByAffiliate(self, affiliateId, startDate, endDate):
706
    def getTrackLogsByAffiliate(self, affiliateId, startDate, endDate):
711
        """
707
        """
712
        Parameter
708
        Parameter
713
         - affiliate_id
709
         - affiliate_id
714
        """
710
        """
715
        try:
711
        try:
716
            return [to_t_track_log(track_log) for track_log in get_track_logs_by_affiliate(affiliateId, startDate, endDate)]
712
            return [to_t_track_log(track_log) for track_log in get_track_logs_by_affiliate(affiliateId, startDate, endDate)]
717
        finally:
713
        finally:
718
            UserDataAccessors.close_session()
714
            self.closeSession()
719
    
715
    
720
    def getTrackLogsByUser(self, user_id):
716
    def getTrackLogsByUser(self, user_id):
721
        """
717
        """
722
        Parameter
718
        Parameter
723
         - user_id
719
         - user_id
724
        """
720
        """
725
        try:
721
        try:
726
            return [to_t_track_log(track_log) for track_log in get_track_logs_by_user(user_id)]
722
            return [to_t_track_log(track_log) for track_log in get_track_logs_by_user(user_id)]
727
        finally:
723
        finally:
728
            UserDataAccessors.close_session()
724
            self.closeSession()
729
    
725
    
730
    def getTrackLogs(self, affiliateId, userId, event, url):
726
    def getTrackLogs(self, affiliateId, userId, event, url):
731
        """
727
        """
732
        Parameter
728
        Parameter
733
         - affiliateId
729
         - affiliateId
Line 736... Line 732...
736
         - url
732
         - url
737
        """
733
        """
738
        try:
734
        try:
739
            return [to_t_track_log(track_log) for track_log in get_track_logs(affiliateId, userId, event, url)]
735
            return [to_t_track_log(track_log) for track_log in get_track_logs(affiliateId, userId, event, url)]
740
        finally:
736
        finally:
741
            UserDataAccessors.close_session()
737
            self.closeSession()
742
    
738
    
743
    def getUserCount(self, userType):
739
    def getUserCount(self, userType):
744
        """
740
        """
745
        Returns number of registered users.
741
        Returns number of registered users.
746
        If userType = null, then it returns count of all users, including anonymous
742
        If userType = null, then it returns count of all users, including anonymous
Line 751... Line 747...
751
         - userType
747
         - userType
752
        """
748
        """
753
        try:
749
        try:
754
            return UserDataAccessors.get_user_count(userType)
750
            return UserDataAccessors.get_user_count(userType)
755
        finally:
751
        finally:
756
            UserDataAccessors.close_session()
752
            self.closeSession()
757
 
753
 
758
    def getAllUsers(self, userType, startDate, endDate):
754
    def getAllUsers(self, userType, startDate, endDate):
759
        """
755
        """
760
        Returns list of users of type userType. If userType is null, then returns all the users.
756
        Returns list of users of type userType. If userType is null, then returns all the users.
761
        
757
        
Line 767... Line 763...
767
            t_users = list()
763
            t_users = list()
768
            for user in users:
764
            for user in users:
769
                t_users.append(to_t_user(user))
765
                t_users.append(to_t_user(user))
770
            return t_users
766
            return t_users
771
        finally:
767
        finally:
772
            UserDataAccessors.close_session()
768
            self.closeSession()
773
    
769
    
774
    def putUserNote(self, userId, entityId, slide, note):
770
    def putUserNote(self, userId, entityId, slide, note):
775
        """
771
        """
776
        Saves user's note for a particular slide of an entity
772
        Saves user's note for a particular slide of an entity
777
        
773
        
Line 782... Line 778...
782
        - note
778
        - note
783
        """
779
        """
784
        try:
780
        try:
785
            put_user_note(userId, entityId, slide, note)
781
            put_user_note(userId, entityId, slide, note)
786
        finally:
782
        finally:
787
            UserDataAccessors.close_session()
783
            self.closeSession()
788
    
784
    
789
    def getUserNotes(self, userId, entityId):
785
    def getUserNotes(self, userId, entityId):
790
        """
786
        """
791
        Retrieves user's notes associated with an entity
787
        Retrieves user's notes associated with an entity
792
        
788
        
Line 795... Line 791...
795
        - entityId
791
        - entityId
796
        """
792
        """
797
        try:
793
        try:
798
            return [to_t_user_note(user_note) for user_note in get_user_notes(userId, entityId)]
794
            return [to_t_user_note(user_note) for user_note in get_user_notes(userId, entityId)]
799
        finally:
795
        finally:
800
            UserDataAccessors.close_session()
796
            self.closeSession()
801
    
797
    
802
 
798
 
803
    def getMyResearchItems(self, userId):
799
    def getMyResearchItems(self, userId):
804
        """
800
        """
805
        Parameters:
801
        Parameters:
806
         - userId
802
         - userId
807
        """
803
        """
808
        try:
804
        try:
809
            return get_my_research_items(userId)
805
            return get_my_research_items(userId)
810
        finally:
806
        finally:
811
            UserDataAccessors.close_session()
807
            self.closeSession()
812
 
808
 
813
    def getBrowseHistoryItems(self, userId):
809
    def getBrowseHistoryItems(self, userId):
814
        """
810
        """
815
        Parameters:
811
        Parameters:
816
         - userId
812
         - userId
817
        """
813
        """
818
        try:
814
        try:
819
            return get_browse_history_items(userId)
815
            return get_browse_history_items(userId)
820
        finally:
816
        finally:
821
            UserDataAccessors.close_session()
817
            self.closeSession()
822
 
818
 
823
    def getCartsWithCouponCount(self, couponCode):
819
    def getCartsWithCouponCount(self, couponCode):
824
        '''
820
        '''
825
        Parameters:
821
        Parameters:
826
         - couponCode
822
         - couponCode
827
        '''
823
        '''
828
        try:
824
        try:
829
            return get_carts_with_coupon_count(couponCode)
825
            return get_carts_with_coupon_count(couponCode)
830
        finally:
826
        finally:
831
            CartDataAccessors.close_session()
827
            self.closeSession()
832
 
828
 
833
    def increaseTrustLevel(self, userId, trustLevelDelta):
829
    def increaseTrustLevel(self, userId, trustLevelDelta):
834
        """
830
        """
835
        Parameters:
831
        Parameters:
836
         - userId
832
         - userId
837
         - trustLevelDelta
833
         - trustLevelDelta
838
        """
834
        """
839
        try:
835
        try:
840
            return increase_trust_level(userId, trustLevelDelta)
836
            return increase_trust_level(userId, trustLevelDelta)
841
        finally:
837
        finally:
842
            UserDataAccessors.close_session()
838
            self.closeSession()
843
    
839
    
844
    def deleteDiscountsFromCart(self, cartId):
840
    def deleteDiscountsFromCart(self, cartId):
845
        '''
841
        '''
846
        Parameters:
842
        Parameters:
847
         - cartId
843
         - cartId
848
        '''
844
        '''
849
        try:
845
        try:
850
            return delete_discounts_from_cart(cart_id = cartId)
846
            return delete_discounts_from_cart(cart_id = cartId)
851
        finally:
847
        finally:
852
            CartDataAccessors.close_session()
848
            self.closeSession()
853
    
849
    
854
    def saveDiscounts(self, discounts):
850
    def saveDiscounts(self, discounts):
855
        '''
851
        '''
856
        Parameters:
852
        Parameters:
857
         - discounts
853
         - discounts
858
        '''
854
        '''
859
        try:
855
        try:
860
            return save_discounts(discounts)
856
            return save_discounts(discounts)
861
        finally:
857
        finally:
862
            CartDataAccessors.close_session()
858
            self.closeSession()
863
 
859
 
864
    def closeSession(self, ):
860
    def closeSession(self, ):
865
        CartDataAccessors.close_session()
861
        CartDataAccessors.close_session()
866
        UserDataAccessors.close_session()
862
        UserDataAccessors.close_session()
867
 
863
 
Line 870... Line 866...
870
        For checking weather service is active alive or not. It also checks connectivity with database
866
        For checking weather service is active alive or not. It also checks connectivity with database
871
        """
867
        """
872
        try:
868
        try:
873
            return is_alive()
869
            return is_alive()
874
        finally:
870
        finally:
875
            UserDataAccessors.close_session()
871
            self.closeSession()
876
    
872
    
877
873