~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to etl/lib/etl/transition.py

  • Committer: Fabien Pinckaers
  • Date: 2009-02-03 11:36:48 UTC
  • mfrom: (3537.2.4 trunk-extra-addons)
  • Revision ID: fp@tinyerp.com-20090203113648-qdnwth30qbpm8xv2
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    ETL system- Extract Transfer Load system
 
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
6
#    $Id$
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
""" ETL Process.
 
23
 
 
24
    The class for ETL transition.
 
25
 
 
26
"""
 
27
import signal
 
28
import logger
 
29
class transition(signal.signal):
 
30
    """
 
31
       Base class of ETL transition.
 
32
    """
 
33
    
 
34
 
 
35
    def action_start(self,key,signal_data={},data={}):
 
36
        self.status='start'
 
37
        self.logger.notifyChannel("transition", logger.LOG_INFO, 
 
38
                     'the '+str(self)+' is start now...')
 
39
        return True 
 
40
 
 
41
    def action_pause(self,key,signal_data={},data={}):
 
42
        self.status='pause'
 
43
        self.logger.notifyChannel("transition", logger.LOG_INFO, 
 
44
                     'the '+str(self)+' is pause now...')
 
45
        return True 
 
46
 
 
47
    def action_stop(self,key,signal_data={},data={}):
 
48
        self.status='stop'
 
49
        self.logger.notifyChannel("transition", logger.LOG_INFO, 
 
50
                     'the '+str(self)+' is stop now...')
 
51
        return True    
 
52
 
 
53
    def __str__(self):
 
54
        return str(self.source)+' to '+str(self.destination)
 
55
 
 
56
    def __init__(self, source, destination, channel_source='main', channel_destination='main', type='data'):
 
57
        super(transition, self).__init__() 
 
58
        self.type = type
 
59
        self.source = source
 
60
        self.destination = destination
 
61
        self.channel_source = channel_source
 
62
        self.channel_destination = channel_destination
 
63
        self.destination.trans_in.append((channel_destination,self))
 
64
        self.source.trans_out.append((channel_source,self))
 
65
        self.status='open' # open,start,pause,stop,close 
 
66
                           # open : active, start : in running, pause : pause, stop: stop, close : inactive
 
67
 
 
68
        self.logger = logger.logger()
 
69
        self.signal_connect(self,'start',self.action_start)
 
70
        self.signal_connect(self,'pause',self.action_pause)
 
71
        self.signal_connect(self,'stop',self.action_stop)
 
72
 
 
73
 
 
74
 
 
75
 
 
76
 
 
77
 
 
78