Python: remove unnecessary prefix map printout
[smartapi.git] / Common / Python / SmartAPI / factory / NotificationFactory.py
1 import datetime
2 from SmartAPI.common.RESOURCE import RESOURCE
3 from SmartAPI.common.Tools import Tools
4 from SmartAPI.model.Activity import Activity
5 from SmartAPI.model.Notification import Notification
6 from SmartAPI.smartapiexceptions.InsufficientDataException import InsufficientDataException
7
8 import traceback
9
10 class NotificationFactory(object):
11
12         def __init__(self):
13                 pass
14         
15         @classmethod
16         def create(cls, generatedBy):
17                 notification = Notification()
18                 if (generatedBy is None or (generatedBy is not None and generatedBy == "")):
19                         raise InsufficientDataException("Invalid seas:generatedBy URI.");
20
21                 notification.setGeneratedBy(generatedBy)
22
23                 # timestamp of when this message is being generated (now)
24                 notification.setGeneratedAt(datetime.datetime.now())
25                 
26                 return notification
27
28         def fromString(self, data, serialization):
29                 try:
30                         return Notification().parse(Tools().getResourceByType(RESOURCE.NOTIFICATION, Tools().fromString(data, serialization)))
31                 except:
32                         print "Unable to parse Evaluation by type seas:Notification from the given string."
33                         traceback.print_exc()
34                         return None
35