__init__.py 7.8 KB
Newer Older
Frédéric Escudié's avatar
Frédéric Escudié committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Copyright (C) 2012 INRA
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

from jflow.workflow import Workflow
from jflow.parameter import InputFileList, InputFile

class Test (Workflow):
    
    def get_description(self):
        return "use for test jflow core modifications"

    def define_parameters(self, parameters_section=None):
        self.add_multiple_parameter_list("multi1", "Multiple.")
        self.add_parameter("test_A1", "Multiple float null.", add_to="multi1", type="float")
        self.add_parameter("test_A2", "Multiple float default 1.", add_to="multi1", type="float", default=1)
        self.add_parameter("test_A3", "Multiple int default 2.", add_to="multi1", type=int, default=2)
        self.add_parameter("test_A4", "Multiple int null.", add_to="multi1", type=int)
        self.add_parameter("test_A5", "Multiple date default str '20/08/2014'.", add_to="multi1", type="date", default="20/08/2014")
        self.add_parameter("test_A6", "date default null.", add_to="multi1", type="date")
        self.add_parameter("test_A7", "Multiple string default str 'None'.", add_to="multi1", default="None")
        self.add_parameter("test_A8", "Multiple string null.", add_to="multi1")
        self.add_parameter("test_A9", "Multiple bool default True.", add_to="multi1", type="bool", default=True)
        self.add_parameter("test_A10", "Multiple bool default 3.", add_to="multi1", type="bool", default=3)
        self.add_parameter("test_A11", "Multiple bool default null.", add_to="multi1", type="bool")
        self.add_input_file("test_A12", "Multiple InputFile default null.", add_to="multi1")
        self.add_input_file("test_A13", "Multiple InputFile default application.properties.", add_to="multi1", default="application.properties")
        self.add_parameter("test_B1", "float null.", type="float")
        self.add_parameter("test_B2", "float default 1.", type="float", default=1)
        self.add_parameter("test_B3", "int default 2.", type=int, default=2)
        self.add_parameter("test_B4", "int null.", type=int)
        self.add_parameter("test_B5", "date default str 20/08/2014.", type="date", default="20/08/2014")
        self.add_parameter("test_B6", "date default null.", type="date")
        self.add_parameter("test_B7", "string default str None.", default="None")
        self.add_parameter("test_B8", "string null.")
        self.add_parameter("test_B9", "bool default True.", type="bool", default=True)
        self.add_parameter("test_B10", "bool default false.", type="bool", default=False)
        self.add_parameter("test_B11", "bool default null.", type="bool")
        self.add_input_file("test_B12", "Multiple InputFile default null.")
        self.add_input_file("test_B13", "Multiple InputFile default application.properties.", default="application.properties")
        self.add_multiple_parameter_list("multi2", "Multiple required.", required=True)
        self.add_parameter("valid", "Multiple required.", add_to="multi2", default="ok")
        self.add_parameter("test_C1", "Multiple float null.", add_to="multi2", type="float")
        self.add_parameter("test_C2", "Multiple float default 1.", add_to="multi2", type="float", default=1)
        self.add_parameter("test_C3", "Multiple int default 2.", add_to="multi2", type=int, default=2)
        self.add_parameter("test_C4", "Multiple int null.", add_to="multi2", type=int)
        self.add_parameter("test_C5", "Multiple date default str '20/08/2014'.", add_to="multi2", type="date", default="20/08/2014")
        self.add_parameter("test_C6", "date default null.", add_to="multi2", type="date")
        self.add_parameter("test_C7", "Multiple string default str 'None'.", add_to="multi2", default="None")
        self.add_parameter("test_C8", "Multiple string null.", add_to="multi2")
        self.add_parameter("test_C9", "Multiple bool default True.", add_to="multi2", type="bool", default=True)
        self.add_parameter("test_C10", "Multiple bool default 3.", add_to="multi2", type="bool", default=3)
        self.add_parameter("test_C11", "Multiple bool default null.", add_to="multi2", type="bool")
        self.add_input_file("test_C12", "Multiple InputFile default null.", add_to="multi2")
        self.add_input_file("test_C13", "Multiple InputFile default application.properties.", add_to="multi2", default="application.properties")##### Pb localfile and urlfile

    def process(self):
        print "###################### Workflow ############################"
        for attr in self.params_order:
            value = getattr(self, attr)
            print attr
            print value
            print "class   : " + value.__class__.__name__
            print "is None : " + str(value is None)
            print "== None : " + str(value == None)
            print ""
        test_parameters = self.add_component("TestComponentParameters", [
                                                                         self.test_B1,
                                                                         self.test_B2,
                                                                         self.test_B3,
                                                                         self.test_B4,
                                                                         self.test_B5,
                                                                         self.test_B6,
                                                                         self.test_B7,
                                                                         self.test_B8,
                                                                         self.test_B9,
                                                                         self.test_B10,
                                                                         self.test_B11,
                                                                         self.test_B12,
                                                                         self.test_B13,
                                                                         self.multi2[0]["test_C1"],
                                                                         self.multi2[0]["test_C2"],
                                                                         self.multi2[0]["test_C3"],
                                                                         self.multi2[0]["test_C4"],
                                                                         self.multi2[0]["test_C5"],
                                                                         self.multi2[0]["test_C6"],
                                                                         self.multi2[0]["test_C7"],
                                                                         self.multi2[0]["test_C8"],
                                                                         self.multi2[0]["test_C9"],
                                                                         self.multi2[0]["test_C10"],
                                                                         self.multi2[0]["test_C11"],
                                                                         self.multi2[0]["test_C12"],
                                                                         self.multi2[0]["test_C13"]
                                                                         ])