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

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

Major refactoring about migration (now handles better create/update, even if the single updates have to be quite fully implemented)
Added the connection pool from SQLAlchemy

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 "%s %s %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 NoAssociatedAuthor(MigrationObjectException):
49    """
50        Raises a missing associatedAuthor exception.       
51    """   
52    def __init__(self, author, migrationObject = None, comment = ''):
53        self.author = author
54        super(NoAssociatedAuthor, self).__init__(migrationObject, comment = '')
55    def __str__(self):
56        return "The MigrationObject %s has no author mapping for %s" % (migrationObjectDescription(self.migrationObject), self.author)           
57
58class NoAssociatedDeployments(Exception):
59    def __init__(self, data_entityMigration, deploymentName = None):
60        """
61            @param data_entityMigration: the data_entity migration associated
62            @param deploymentName: the associated deployment document name
63        """
64        self._migrationObject = data_entityMigration
65        self._deploymentName = deploymentName       
66        super(NoAssociatedDeployments, self).__init__()
67    def __str__(self):
68        if self._deploymentName:
69            return "The DataEntity %s has no associated deployment named %s" % (migrationObjectDescription(self.migrationObject), self._deploymentName)
70        else:
71            return "The DataEntity %s has no associated deployment" % (migrationObjectDescription(self.migrationObject))
72   
73class NoDataLineage(MigrationObjectException):
74    """
75        Raises a missing dataLineage exception.       
76    """   
77    def __init__(self, migrationObject, comment = ''):       
78        super(NoDataLineage, self).__init__(migrationObject, comment = '')
Note: See TracBrowser for help on using the repository browser.