source: mauRepo/MolesManager/trunk/src/libs/migration/exception/exceptions.py @ 8433

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/exception/exceptions.py@8433
Revision 8433, 4.2 KB checked in by mnagni, 7 years ago (diff)

Two main new features:
1) the migration generate a report. The report is sent by mail to the subscribers defined in the settings.py
2) require to display a missing observation adds a message on the page and hides the some fields in the html form
3) a new javascript library (commons.js)

Line 
1'''
2Created on 15 Nov 2011
3
4@author: mnagni
5'''
6
7def migrationObjectDescription(migrationObject):
8    if migrationObject is None:
9        raise Exception("Migration object is None")
10    try:
11        return "STATUS:%s OWNER:%s NAME:%s" % (migrationObject.doc_status, migrationObject.doc_owner, migrationObject.doc_name)
12    except Exception as ex:
13        print ex
14   
15class NoCreationDate(Exception):
16    def __init__(self, value):
17        self.value = value
18    def __str__(self):
19        return "The resource %s has no creation date" % (self.value) 
20   
21class Moles3ObjectException(Exception):
22    def __init__(self, value):
23        self.value = value
24    def __str__(self):
25        return self.value   
26   
27class NoDocumentID(Exception):
28    def __init__(self, value):
29        self.value = value
30    def __str__(self):
31        return "The resource %s has no creation date" % (self.value)   
32
33class MigrationObjectException(Exception):
34    """
35        Raises a generic MigrationObject related exception.       
36    """
37    def __init__(self, migrationObject, comment = ''):
38        """
39            Creates a new instance
40            @param migrationObject: the MigrationObject instance that raised the error
41            @param comment:additional comment
42        """       
43        self.migrationObject = migrationObject
44        self.comment = comment
45    def __str__(self):
46        return "Error on migration object %s " % (migrationObjectDescription(self.migrationObject))
47
48class NoGeographicalExtensionException(MigrationObjectException):
49    """
50        Raises a generic MigrationObject related exception.       
51    """
52    def __init__(self, migrationObject, comment = ''):
53        """
54            Creates a new instance
55            @param migrationObject: the MigrationObject instance that raised the error
56            @param comment:additional comment
57        """
58        super(NoGeographicalExtensionException, self).__init__(migrationObject, comment = '')
59    def __str__(self):
60        return "No Geographical Extension associated with migration object %s " % (migrationObjectDescription(self.migrationObject))   
61   
62class NoCitationException(MigrationObjectException):
63    """
64        Raises a generic MigrationObject related exception.       
65    """
66    def __init__(self, migrationObject, comment = ''):
67        """
68            Creates a new instance
69            @param migrationObject: the MigrationObject instance that raised the error
70            @param comment:additional comment
71        """
72        super(NoCitationException, self).__init__(migrationObject, comment = '')
73    def __str__(self):
74        return "No cedacat:citation associated with migration object %s " % (migrationObjectDescription(self.migrationObject))   
75
76class NoAssociatedAuthor(MigrationObjectException):
77    """
78        Raises a missing associatedAuthor exception.       
79    """   
80    def __init__(self, author, migrationObject = None, comment = ''):
81        self.author = author
82        super(NoAssociatedAuthor, self).__init__(migrationObject, comment = '')
83    def __str__(self):
84        return "The MigrationObject %s has no author mapping for %s" % (migrationObjectDescription(self.migrationObject), self.author)           
85
86class NoAssociatedDeployments(Exception):
87    def __init__(self, migrationObject, deploymentName = None):
88        """
89            @param migrationObject: the associated migrationObject
90            @param deploymentName: the associated deployment document name
91        """
92        self._migrationObject = migrationObject
93        self._deploymentName = deploymentName       
94        super(NoAssociatedDeployments, self).__init__()
95    def __str__(self):
96        if self._deploymentName:
97            return "The DataEntity %s has no associated deployment named %s" % (migrationObjectDescription(self._migrationObject), self._deploymentName)
98        else:
99            return "The DataEntity %s has no associated deployment" % (migrationObjectDescription(self._migrationObject))
100   
101class NoDataLineage(MigrationObjectException):
102    """
103        Raises a missing dataLineage exception.       
104    """   
105    def __init__(self, migrationObject, comment = ''):       
106        super(NoDataLineage, self).__init__(migrationObject, comment = '')       
Note: See TracBrowser for help on using the repository browser.