Subversion Repositories SmartDukaan

Rev

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

Rev 691 Rev 766
Line 20... Line 20...
20
from shop2020.model.v1.user.impl.WidgetDataAccessor import add_widget,\
20
from shop2020.model.v1.user.impl.WidgetDataAccessor import add_widget,\
21
    add_items_to_widget, update_my_research, update_widget, get_widget_by_type,\
21
    add_items_to_widget, update_my_research, update_widget, get_widget_by_type,\
22
    get_my_research, get_ratings, update_ratings, get_browse_history,\
22
    get_my_research, get_ratings, update_ratings, get_browse_history,\
23
    update_browse_history, delete_item_from_my_research, delete_item_from_widget
23
    update_browse_history, delete_item_from_my_research, delete_item_from_widget
24
from shop2020.model.v1.user.impl.WidgetConverters import to_t_widget, to_t_ratings
24
from shop2020.model.v1.user.impl.WidgetConverters import to_t_widget, to_t_ratings
-
 
25
from shop2020.model.v1.user.impl import UserDataAccessors, CartDataAccessors,\
-
 
26
    WidgetDataAccessor
25
 
27
 
26
class UserContextServiceHandler:
28
class UserContextServiceHandler:
27
    
29
    
28
    
30
    
29
    def __init__(self):
31
    def __init__(self):
Line 31... Line 33...
31
 
33
 
32
    """
34
    """
33
    service
35
    service
34
    """
36
    """
35
    def createAnonymousUser(self, jsessionId):
37
    def createAnonymousUser(self, jsessionId):
-
 
38
        try:
36
        cart = create_cart(-1)
39
            cart = create_cart(-1)
37
        return to_t_user(create_anonymous_user(jsessionId, cart))
40
            return to_t_user(create_anonymous_user(jsessionId, cart))
38
    
41
        finally:
-
 
42
            UserDataAccessors.close_session()
39
    def getUserById(self, userId):
43
    def getUserById(self, userId):
40
        """
44
        """
41
        Parameters:
45
        Parameters:
42
        - userId
46
        - userId
43
        """
47
        """
-
 
48
        try:
44
        return to_t_user(get_user_by_id(userId))
49
            return to_t_user(get_user_by_id(userId))
-
 
50
        finally:
-
 
51
            UserDataAccessors.close_session()
45
    
52
            
46
    def createUser(self, user):
53
    def createUser(self, user):
47
        """
54
        """
48
        Parameters:
55
        Parameters:
49
        - user
56
        - user
50
        """
57
        """
-
 
58
        try:
51
        cart = create_cart(-1)
59
            cart = create_cart(-1)
52
        return to_t_user(create_user(user, cart))
60
            return to_t_user(create_user(user, cart))
-
 
61
        finally:
-
 
62
            UserDataAccessors.close_session()
53
    
63
            
54
    def updateUser(self, user):
64
    def updateUser(self, user):
55
        """
65
        """
56
        Parameters:
66
        Parameters:
57
        - user
67
        - user
58
        """
68
        """
-
 
69
        try:
59
        return to_t_user(update_user(user))
70
            return to_t_user(update_user(user))
-
 
71
        finally:
-
 
72
            UserDataAccessors.close_session()
60
    
73
            
61
    def deleteUser(self, userId):
74
    def deleteUser(self, userId):
62
        """
75
        """
63
        Parameters:
76
        Parameters:
64
        - userId
77
        - userId
65
        """
78
        """
-
 
79
        try:
66
        return delete_user(userId)
80
            return delete_user(userId)
-
 
81
        finally:
-
 
82
            UserDataAccessors.close_session()
67
    
83
            
68
    def getUserState(self, userId):
84
    def getUserState(self, userId):
69
        """
85
        """
70
        Parameters:
86
        Parameters:
71
        - userId
87
        - userId
72
        """
88
        """
73
        log_entry(self, "get State")
89
        log_entry(self, "get State")
-
 
90
        try:
74
        return to_t_user_state(get_user_state(userId))
91
            return to_t_user_state(get_user_state(userId))
-
 
92
        finally:
-
 
93
            UserDataAccessors.close_session()
75
    
94
            
76
    def authenticateUser(self, email, password):
95
    def authenticateUser(self, email, password):
77
        """
96
        """
78
        Parameters:
97
        Parameters:
79
        - email
98
        - email
80
        - password
99
        - password
81
        """
100
        """
82
        log_entry(self, "authenticate user")
101
        log_entry(self, "authenticate user")
-
 
102
        try:
83
        return to_t_user(authenticate_user(email, password))
103
            return to_t_user(authenticate_user(email, password))
-
 
104
        finally:
-
 
105
            UserDataAccessors.close_session()
84
    
106
            
85
    def userExists(self, email):
107
    def userExists(self, email):
86
        """
108
        """
87
        Parameters:
109
        Parameters:
88
        - email
110
        - email
89
        """
111
        """
90
        log_entry(self, "user exists")
112
        log_entry(self, "user exists")
-
 
113
        try:
91
        return user_exists(email)
114
            return user_exists(email)
-
 
115
        finally:
-
 
116
            UserDataAccessors.close_session()
92
    
117
            
93
    def addAddressForUser(self, userId, address, setDefault):
118
    def addAddressForUser(self, userId, address, setDefault):
94
        """
119
        """
95
        Parameters:
120
        Parameters:
96
        - userId
121
        - userId
97
        - address
122
        - address
98
        - setDefault
123
        - setDefault
99
        """
124
        """
100
        log_entry(self, "add address for user")
125
        log_entry(self, "add address for user")
-
 
126
        try:
101
        return add_address_for_user(address, userId, setDefault)
127
            return add_address_for_user(address, userId, setDefault)
-
 
128
        finally:
-
 
129
            UserDataAccessors.close_session()
102
    
130
            
103
    def removeAddressForUser(self, userid, addressId):
131
    def removeAddressForUser(self, userid, addressId):
104
        """
132
        """
105
        Parameters:
133
        Parameters:
106
        - userid
134
        - userid
107
        - addressId
135
        - addressId
108
        """
136
        """
109
        log_entry(self, "removing address")
137
        log_entry(self, "removing address")
-
 
138
        try:
110
        return remove_address_for_user(userid, addressId)
139
            return remove_address_for_user(userid, addressId)
-
 
140
        finally:
-
 
141
            UserDataAccessors.close_session()
111
    
142
            
112
    def setUserAsLoggedIn(self, userId, timestamp):
143
    def setUserAsLoggedIn(self, userId, timestamp):
113
        """
144
        """
114
        Parameters:
145
        Parameters:
115
        - userId
146
        - userId
116
        - timestamp
147
        - timestamp
117
        """
148
        """
118
        log_entry(self, "set_user_as_logged_in")
149
        log_entry(self, "set_user_as_logged_in")
-
 
150
        try:
119
        return set_user_as_logged_in(userId, timestamp)
151
            return set_user_as_logged_in(userId, timestamp)
-
 
152
        finally:
-
 
153
            UserDataAccessors.close_session()
120
    
154
            
121
    def setUserAsLoggedOut(self, userId, timestamp):
155
    def setUserAsLoggedOut(self, userId, timestamp):
122
        """
156
        """
123
        Parameters:
157
        Parameters:
124
        - userId
158
        - userId
125
        - timestamp
159
        - timestamp
126
        """
160
        """
127
        log_entry(self, "set user as logged out")
161
        log_entry(self, "set user as logged out")
-
 
162
        try:
128
        return set_user_as_logged_out(userId, timestamp)
163
            return set_user_as_logged_out(userId, timestamp)
-
 
164
        finally:
-
 
165
            UserDataAccessors.close_session()
129
    
166
            
130
    def setDefaultAddress(self, userId, addressId):
167
    def setDefaultAddress(self, userId, addressId):
131
        """
168
        """
132
        Parameters:
169
        Parameters:
133
        - userId
170
        - userId
134
        - addressId
171
        - addressId
135
        """
172
        """
-
 
173
        try:
136
        return set_default_address(userId, addressId)
174
            return set_default_address(userId, addressId)
-
 
175
        finally:
-
 
176
            UserDataAccessors.close_session()
-
 
177
            
137
    def updatePassword(self, userid, oldPassword, newPassword):
178
    def updatePassword(self, userid, oldPassword, newPassword):
138
        """
179
        """
139
        Parameters:
180
        Parameters:
140
         - userid
181
         - userid
141
         - oldPassword
182
         - oldPassword
142
         - newPassword
183
         - newPassword
143
        """
184
        """
144
        log_entry(self, "updating password")
185
        log_entry(self, "updating password")
-
 
186
        try:
145
        return update_password(userid, oldPassword, newPassword)
187
            return update_password(userid, oldPassword, newPassword)
-
 
188
        finally:
-
 
189
            UserDataAccessors.close_session()
146
 
190
            
147
    def forgotPassword(self, email):
191
    def forgotPassword(self, email):
148
        """
192
        """
149
        Parameters:
193
        Parameters:
150
         - email
194
         - email
151
        """
195
        """
152
        log_entry(self, "forgot password")
196
        log_entry(self, "forgot password")
-
 
197
        try:
153
        return forgot_password(email)
198
            return forgot_password(email)
-
 
199
        finally:
-
 
200
            UserDataAccessors.close_session()
154
 
201
            
155
    def getAllAddressesForUser(self, userId):
202
    def getAllAddressesForUser(self, userId):
156
        """
203
        """
157
        Parameters:
204
        Parameters:
158
         - userId
205
         - userId
159
        """
206
        """
-
 
207
        try:
160
        addresses = get_all_addresses_for_user(userId)
208
            addresses = get_all_addresses_for_user(userId)
161
        
209
            
162
        t_addresses = list()
210
            t_addresses = list()
163
        for address in addresses:
211
            for address in addresses:
164
            t_addresses.append(to_t_address(address))
212
                t_addresses.append(to_t_address(address))
165
        return t_addresses
213
            return t_addresses
-
 
214
        finally:
-
 
215
            UserDataAccessors.close_session()
166
              
216
              
167
    def getDefaultAddressId(self, userId):
217
    def getDefaultAddressId(self, userId):
168
        """
218
        """
169
        Parameters:
219
        Parameters:
170
         - userId
220
         - userId
171
        """
221
        """
-
 
222
        try:
172
        return get_default_addredd_id(userId)
223
            return get_default_addredd_id(userId)
-
 
224
        finally:
-
 
225
            UserDataAccessors.close_session()
173
 
226
            
174
    def createCart(self, userId):
227
    def createCart(self, userId):
175
        """
228
        """
176
        Parameters:
229
        Parameters:
177
        - userId
230
        - userId
178
        """
231
        """
-
 
232
        try:
179
        return create_cart(userId).id
233
            return create_cart(userId).id
-
 
234
        finally:
-
 
235
            UserDataAccessors.close_session()
180
 
236
            
181
    def getCurrentCart(self, userId):
237
    def getCurrentCart(self, userId):
182
        """
238
        """
183
        Parameters:
239
        Parameters:
184
         - userId
240
         - userId
185
        """
241
        """
-
 
242
        try:
186
        cart = get_cart(userId)
243
            cart = get_cart(userId)
187
        if cart:
244
            if cart:
188
            return to_t_cart(cart)
245
                return to_t_cart(cart)
189
        else:
246
            else:
190
            raise ShoppingCartException(101, "not cart attached to this user")
247
                raise ShoppingCartException(101, "not cart attached to this user")
-
 
248
        finally:
-
 
249
            CartDataAccessors.close_session()
191
 
250
            
192
    def getCart(self, cartId):
251
    def getCart(self, cartId):
193
        """
252
        """
194
        Parameters:
253
        Parameters:
195
         - cartId
254
         - cartId
196
        """
255
        """
-
 
256
        try:
197
        cart = get_cart_by_id(cartId)
257
            cart = get_cart_by_id(cartId)
198
        if cart:
258
            if cart:
199
            return to_t_cart(cart)
259
                return to_t_cart(cart)
200
        else:
260
            else:
201
            raise ShoppingCartException(101, "not cart attached to this id")
261
                raise ShoppingCartException(101, "not cart attached to this id")
-
 
262
        finally:
-
 
263
            CartDataAccessors.close_session()
202
    
264
            
203
    def getCartsForUser(self, userId, status):
265
    def getCartsForUser(self, userId, status):
204
        """
266
        """
205
        Parameters:
267
        Parameters:
206
         - userId
268
         - userId
207
         - status
269
         - status
208
        """
270
        """
-
 
271
        try:
209
        if not userId:
272
            if not userId:
210
            raise ShoppingCartException(101, "user_id is not provided")
273
                raise ShoppingCartException(101, "user_id is not provided")
211
        
274
            
212
        carts = get_cart_by_user_id_and_status(userId, status)
275
            carts = get_cart_by_user_id_and_status(userId, status)
213
        t_carts = []
276
            t_carts = []
214
        if carts:
277
            if carts:
215
            for cart in carts:
278
                for cart in carts:
216
                t_carts.append(to_t_cart(cart))
279
                    t_carts.append(to_t_cart(cart))
217
        return t_carts
280
            return t_carts
-
 
281
        finally:
-
 
282
            CartDataAccessors.close_session()
218
    
283
                
219
    def getCartsByStatus(self, status):
284
    def getCartsByStatus(self, status):
220
        """
285
        """
221
        Parameters:
286
        Parameters:
222
         - status
287
         - status
223
        """
288
        """
-
 
289
        try:
224
        carts = get_carts_by_status(status)
290
            carts = get_carts_by_status(status)
225
        t_carts = []
291
            t_carts = []
226
        if carts:
292
            if carts:
227
            for cart in carts:
293
                for cart in carts:
228
                t_carts.append(to_t_cart(cart))
294
                    t_carts.append(to_t_cart(cart))
229
        return t_carts
295
            return t_carts
-
 
296
        finally:
-
 
297
            CartDataAccessors.close_session()
230
    
298
            
231
    def getCartsByTime(self, from_time, to_time, status):
299
    def getCartsByTime(self, from_time, to_time, status):
232
        """
300
        """
233
        Parameters:
301
        Parameters:
234
         - from_time
302
         - from_time
235
         - to_time
303
         - to_time
236
         - status
304
         - status
237
        """
305
        """
-
 
306
        try:
238
        carts = get_carts_between(from_time, to_time, status)
307
            carts = get_carts_between(from_time, to_time, status)
239
        t_carts = []
308
            t_carts = []
240
        if carts:
309
            if carts:
241
            for cart in carts:
310
                for cart in carts:
242
                t_carts.append(to_t_cart(cart))
311
                    t_carts.append(to_t_cart(cart))
243
        return t_carts
312
            return t_carts
-
 
313
        finally:
-
 
314
            CartDataAccessors.close_session()
244
    
315
            
245
    def changeCartStatus(self, cartId, status):
316
    def changeCartStatus(self, cartId, status):
246
        """
317
        """
247
        Parameters:
318
        Parameters:
248
         - cartId
319
         - cartId
249
         - status
320
         - status
250
        """
321
        """
-
 
322
        try:
251
        change_cart_status(cartId, status)
323
            change_cart_status(cartId, status)
-
 
324
        finally:
-
 
325
            CartDataAccessors.close_session()
252
    
326
            
253
    def addItemToCart(self, cartId, itemId, quantity):
327
    def addItemToCart(self, cartId, itemId, quantity):
254
        """
328
        """
255
        Parameters:
329
        Parameters:
256
         - cartId
330
         - cartId
257
         - itemId
331
         - itemId
258
         - quantity
332
         - quantity
259
        """
333
        """
-
 
334
        try:
260
        add_item_to_cart(cartId, itemId, quantity)
335
            add_item_to_cart(cartId, itemId, quantity)
-
 
336
        finally:
-
 
337
            CartDataAccessors.close_session()
261
    
338
            
262
    def deleteItemFromCart(self, cartId, itemId):
339
    def deleteItemFromCart(self, cartId, itemId):
263
        """
340
        """
264
        Parameters:
341
        Parameters:
265
         - cartId
342
         - cartId
266
         - itemId
343
         - itemId
267
        """
344
        """
-
 
345
        try:
268
        delete_item_from_cart(cartId, itemId)
346
            delete_item_from_cart(cartId, itemId)
-
 
347
        finally:
-
 
348
            CartDataAccessors.close_session()
269
 
349
            
270
    def changeQuantity(self, cartId, itemId, quantity):
350
    def changeQuantity(self, cartId, itemId, quantity):
271
        """
351
        """
272
        Parameters:
352
        Parameters:
273
         - cartId
353
         - cartId
274
         - itemId
354
         - itemId
275
         - quantity
355
         - quantity
276
        """
356
        """
-
 
357
        try:
277
        add_item_to_cart(cartId, itemId, quantity)
358
            add_item_to_cart(cartId, itemId, quantity)
-
 
359
        finally:
-
 
360
            CartDataAccessors.close_session()
278
    
361
            
279
    def changeItemStatus(self, cartId, itemId, status):
362
    def changeItemStatus(self, cartId, itemId, status):
280
        """
363
        """
281
        Parameters:
364
        Parameters:
282
         - cartId
365
         - cartId
283
         - itemId
366
         - itemId
284
        """
367
        """
-
 
368
        try:
285
        return change_item_status(cartId, itemId, status)
369
            return change_item_status(cartId, itemId, status)
-
 
370
        finally:
-
 
371
            CartDataAccessors.close_session()
286
    
372
            
287
    def addAddressToCart(self, cartId, addressId):
373
    def addAddressToCart(self, cartId, addressId):
288
        """
374
        """
289
        Parameters:
375
        Parameters:
290
         - cartId
376
         - cartId
291
         - addressId
377
         - addressId
292
        """
378
        """
-
 
379
        try:
293
        return add_address_to_cart(cartId, addressId)
380
            return add_address_to_cart(cartId, addressId)
-
 
381
        finally:
-
 
382
            CartDataAccessors.close_session()
294
    
383
            
295
    def createOrders(self, cartId):
384
    def createOrders(self, cartId):
296
        """
385
        """
297
        Parameters:
386
        Parameters:
298
         - cartId
387
         - cartId
299
        """
388
        """
-
 
389
        try:
300
        return commit_cart(cartId)
390
            return commit_cart(cartId)
-
 
391
        finally:
-
 
392
            CartDataAccessors.close_session()
301
    
393
            
302
    def validateCart(self, cartId):
394
    def validateCart(self, cartId):
303
        """
395
        """
304
        Parameters:
396
        Parameters:
305
         - cartId
397
         - cartId
306
        """
398
        """
-
 
399
        try:
307
        return validate_cart(cartId)
400
            return validate_cart(cartId)
-
 
401
        finally:
-
 
402
            CartDataAccessors.close_session()
308
    
403
            
309
    def mergeCart(self, fromCartId, toCartId):
404
    def mergeCart(self, fromCartId, toCartId):
310
        """
405
        """
311
        Parameters:
406
        Parameters:
312
         - fromCartId
407
         - fromCartId
313
         - toCartId
408
         - toCartId
314
        """
409
        """
-
 
410
        try:
315
        merge_cart(fromCartId, toCartId)
411
            merge_cart(fromCartId, toCartId)
-
 
412
        finally:
-
 
413
            CartDataAccessors.close_session()
316
 
414
            
317
    def checkOut(self, cartId):
415
    def checkOut(self, cartId):
318
        """
416
        """
319
        Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
417
        Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
320
        
418
        
321
        Parameters:
419
        Parameters:
322
         - cartId
420
         - cartId
323
        """
421
        """
-
 
422
        try:
324
        return check_out(cartId)
423
            return check_out(cartId)
-
 
424
        finally:
-
 
425
            CartDataAccessors.close_session()
325
    
426
            
326
    def resetCart(self, cartId, items):
427
    def resetCart(self, cartId, items):
327
        """
428
        """
328
        The second parameter is a map of item ids and their quantities which have been successfully processed.
429
        The second parameter is a map of item ids and their quantities which have been successfully processed.
329
        This methods removes the specified quantiry of the specified item from the cart.
430
        This methods removes the specified quantiry of the specified item from the cart.
330
        
431
        
331
        Parameters:
432
        Parameters:
332
         - cartId
433
         - cartId
333
         - items
434
         - items
334
        """
435
        """
-
 
436
        try:
335
        return reset_cart(cartId, items)
437
            return reset_cart(cartId, items)
-
 
438
        finally:
-
 
439
            CartDataAccessors.close_session()
336
 
440
            
337
    def addWidget(self, widget):
441
    def addWidget(self, widget):
338
        """
442
        """
339
        Parameters:
443
        Parameters:
340
         - widget
444
         - widget
341
        """
445
        """
-
 
446
        try:
342
        add_widget(widget)
447
            add_widget(widget)
-
 
448
        finally:
-
 
449
            WidgetDataAccessor.close_session()
343
    
450
    
344
    def addItemToWidget(self, widget_id, items):
451
    def addItemToWidget(self, widget_id, items):
345
        """
452
        """
346
        Parameters:
453
        Parameters:
347
         - widget_id
454
         - widget_id
348
         - items
455
         - items
349
        """
456
        """
-
 
457
        try:
350
        add_items_to_widget(widget_id, items)
458
            add_items_to_widget(widget_id, items)
-
 
459
        finally:
-
 
460
            WidgetDataAccessor.close_session()
351
    
461
            
352
    def updateMyResearch(self, user_id, item_id):
462
    def updateMyResearch(self, user_id, item_id):
353
        """
463
        """
354
        Parameters:
464
        Parameters:
355
         - user_id
465
         - user_id
356
         - item_id
466
         - item_id
357
        """
467
        """
-
 
468
        try:
358
        return update_my_research(user_id, item_id)
469
            return update_my_research(user_id, item_id)
-
 
470
        finally:
-
 
471
            WidgetDataAccessor.close_session()
359
    
472
            
360
    def updateWidget(self, widgetId, enable):
473
    def updateWidget(self, widgetId, enable):
361
        """
474
        """
362
        Parameters:
475
        Parameters:
363
         - widgetId
476
         - widgetId
364
         - enable
477
         - enable
365
        """
478
        """
-
 
479
        try:
366
        update_widget(widgetId, enable)
480
            update_widget(widgetId, enable)
-
 
481
        finally:
-
 
482
            WidgetDataAccessor.close_session()
367
    
483
            
368
    def updateWidgetItem(self, widgetId, enable):
484
    def updateWidgetItem(self, widgetId, enable):
369
        """
485
        """
370
        Parameters:
486
        Parameters:
371
         - widgetId
487
         - widgetId
372
         - enable
488
         - enable
373
        """
489
        """
-
 
490
        try:
374
        update_widget(widgetId, enable)
491
            update_widget(widgetId, enable)
-
 
492
        finally:
-
 
493
            WidgetDataAccessor.close_session()
375
        
494
            
376
    def deleteItemFromWidget(self, widget_id, item_id):
495
    def deleteItemFromWidget(self, widget_id, item_id):
377
        """
496
        """
378
        Parameters:
497
        Parameters:
379
         - widget_id
498
         - widget_id
380
         - item_id
499
         - item_id
381
        """
500
        """
-
 
501
        try:
382
        return delete_item_from_widget(widget_id, item_id)
502
            return delete_item_from_widget(widget_id, item_id)
-
 
503
        finally:
-
 
504
            WidgetDataAccessor.close_session()
383
    
505
            
384
    def deleteItemFromMyResearch(self, user_id, item_id):
506
    def deleteItemFromMyResearch(self, user_id, item_id):
385
        """
507
        """
386
        Parameters:
508
        Parameters:
387
         - user_id
509
         - user_id
388
         - item_id
510
         - item_id
389
        """
511
        """
-
 
512
        try:
390
        return delete_item_from_my_research(user_id, item_id)
513
            return delete_item_from_my_research(user_id, item_id)
-
 
514
        finally:
-
 
515
            WidgetDataAccessor.close_session()
391
    
516
            
392
    def getWidget(self, type, userId, onlyEnabled):
517
    def getWidget(self, type, userId, onlyEnabled):
393
        """
518
        """
394
        Parameters:
519
        Parameters:
395
         - type
520
         - type
396
         - userId
521
         - userId
397
         - onlyEnabled
522
         - onlyEnabled
398
        """
523
        """
-
 
524
        try:
399
        widget = get_widget_by_type(type, userId, onlyEnabled)
525
            widget = get_widget_by_type(type, userId, onlyEnabled)
400
        return to_t_widget(widget)
526
            return to_t_widget(widget)
-
 
527
        finally:
-
 
528
            WidgetDataAccessor.close_session()
401
    
529
            
402
    def getMyResearch(self, user_id):
530
    def getMyResearch(self, user_id):
403
        """
531
        """
404
        Parameters:
532
        Parameters:
405
         - user_id
533
         - user_id
406
        """
534
        """
-
 
535
        try:
407
        return to_t_widget(get_my_research(user_id))
536
            return to_t_widget(get_my_research(user_id))
-
 
537
        finally:
-
 
538
            WidgetDataAccessor.close_session()
408
    
539
            
409
    def updateRatings(self, item_id, type, rating, user_id):
540
    def updateRatings(self, item_id, type, rating, user_id):
410
        """
541
        """
411
        Parameters:
542
        Parameters:
412
        - item_id
543
        - item_id
413
        - type
544
        - type
414
        - rating
545
        - rating
415
        - user_id
546
        - user_id
416
        """
547
        """
-
 
548
        try:
417
        update_ratings(user_id, item_id, rating, type)
549
            update_ratings(user_id, item_id, rating, type)
418
        
550
        finally:
-
 
551
            WidgetDataAccessor.close_session()
419
            
552
            
420
    def getRatings(self, item_id, user_id):
553
    def getRatings(self, item_id, user_id):
421
        """
554
        """
422
        Parameters:
555
        Parameters:
423
        - item_id
556
        - item_id
424
        - user_id
557
        - user_id
425
        """
558
        """
-
 
559
        try:
426
        all_ratings, user_ratings = get_ratings(user_id, item_id)
560
            all_ratings, user_ratings = get_ratings(user_id, item_id)
427
        return to_t_ratings(user_ratings, all_ratings, item_id, user_id)
561
            return to_t_ratings(user_ratings, all_ratings, item_id, user_id)
-
 
562
        finally:
-
 
563
            WidgetDataAccessor.close_session()
428
 
564
            
429
    def updateBrowseHistory(self, user_id, item_id, is_session_id):
565
    def updateBrowseHistory(self, user_id, item_id, is_session_id):
430
        """
566
        """
431
        Parameters: 
567
        Parameters: 
432
        - user_id
568
        - user_id
433
        - item_id
569
        - item_id
434
        - isSessionId
570
        - isSessionId
435
        """
571
        """
-
 
572
        try:
436
        update_browse_history(user_id, item_id, is_session_id)
573
            update_browse_history(user_id, item_id, is_session_id)
-
 
574
        finally:
-
 
575
            WidgetDataAccessor.close_session()
437
        
576
            
438
    def getBrowseHistory(self, user_id, is_session_id):
577
    def getBrowseHistory(self, user_id, is_session_id):
439
        """
578
        """
440
        Parameters:
579
        Parameters:
441
         - user_id
580
         - user_id
442
         - is_session_id
581
         - is_session_id
443
        """
582
        """
444
        return to_t_widget(get_browse_history(user_id, is_session_id))
-
 
445
583
        try:
-
 
584
            return to_t_widget(get_browse_history(user_id, is_session_id))
-
 
585
        finally:
-
 
586
            WidgetDataAccessor.close_session()
-
 
587
            
-
 
588
    def closeSession(self, ):
-
 
589
        CartDataAccessors.close_session()
-
 
590
        UserDataAccessors.close_session()
-
 
591
        WidgetDataAccessor.close_session()
-
 
592
446
593