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

RevLine 
[8014]1'''
2Created on 15 Nov 2011
3
4@author: mnagni
5'''
[8082]6
[8258]7def migrationObjectDescription(migrationObject):
[8269]8    if migrationObject is None:
9        raise Exception("Migration object is None")
[8180]10    try:
11        return "%s %s %s" % (migrationObject.doc_status, migrationObject.doc_owner, migrationObject.doc_name)
[8269]12    except Exception as ex:
[8180]13        print ex
[8014]14   
15class NoCreationDate(Exception):
16    def __init__(self, value):
17        self.value = value
18    def __str__(self):
[8147]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)   
[8082]32
33class MigrationObjectException(Exception):
[8147]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
[8082]45    def __str__(self):
[8258]46        return "Error on migration object %s " % (migrationObjectDescription(self.migrationObject))
[8082]47
[8147]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):
[8258]56        return "The MigrationObject %s has no author mapping for %s" % (migrationObjectDescription(self.migrationObject), self.author)           
[8147]57
[8082]58class NoAssociatedDeployments(Exception):
[8254]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        """
[8082]64        self._migrationObject = data_entityMigration
65        self._deploymentName = deploymentName       
66        super(NoAssociatedDeployments, self).__init__()
67    def __str__(self):
[8254]68        if self._deploymentName:
[8258]69            return "The DataEntity %s has no associated deployment named %s" % (migrationObjectDescription(self.migrationObject), self._deploymentName)
[8254]70        else:
[8258]71            return "The DataEntity %s has no associated deployment" % (migrationObjectDescription(self.migrationObject))
[8014]72   
[8082]73class NoDataLineage(MigrationObjectException):
[8147]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.