25 workflow_of = SubjectRelation('CWEType', cardinality='+*', |
25 workflow_of = SubjectRelation('CWEType', cardinality='+*', |
26 description=_('entity types which may use this workflow'), |
26 description=_('entity types which may use this workflow'), |
27 constraints=[RQLConstraint('O final FALSE')]) |
27 constraints=[RQLConstraint('O final FALSE')]) |
28 |
28 |
29 initial_state = SubjectRelation('State', cardinality='?*', |
29 initial_state = SubjectRelation('State', cardinality='?*', |
30 constraints=[RQLConstraint('O state_of S')], |
30 constraints=[RQLConstraint('O state_of S', |
|
31 msg=_('state doesn\'t belong to this workflow'))], |
31 description=_('initial state for this workflow')) |
32 description=_('initial state for this workflow')) |
32 |
33 |
33 |
34 |
34 class default_workflow(RelationType): |
35 class default_workflow(RelationType): |
35 """default workflow for an entity type""" |
36 """default workflow for an entity type""" |
36 permissions = META_RTYPE_PERMS |
37 permissions = META_RTYPE_PERMS |
37 |
38 |
38 subject = 'CWEType' |
39 subject = 'CWEType' |
39 object = 'Workflow' |
40 object = 'Workflow' |
40 cardinality = '?*' |
41 cardinality = '?*' |
41 constraints = [RQLConstraint('S final FALSE, O workflow_of S')] |
42 constraints = [RQLConstraint('S final FALSE, O workflow_of S', |
|
43 msg=_('workflow isn\'t a workflow of this type'))] |
42 |
44 |
43 |
45 |
44 class State(EntityType): |
46 class State(EntityType): |
45 """used to associate simple states to an entity type and/or to define |
47 """used to associate simple states to an entity type and/or to define |
46 workflows |
48 workflows |
55 description=_('semantic description of this state')) |
57 description=_('semantic description of this state')) |
56 |
58 |
57 # XXX should be on BaseTransition w/ AND/OR selectors when we will |
59 # XXX should be on BaseTransition w/ AND/OR selectors when we will |
58 # implements #345274 |
60 # implements #345274 |
59 allowed_transition = SubjectRelation('BaseTransition', cardinality='**', |
61 allowed_transition = SubjectRelation('BaseTransition', cardinality='**', |
60 constraints=[RQLConstraint('S state_of WF, O transition_of WF')], |
62 constraints=[RQLConstraint('S state_of WF, O transition_of WF', |
|
63 msg=_('state and transition don\'t belong the the same workflow'))], |
61 description=_('allowed transitions from this state')) |
64 description=_('allowed transitions from this state')) |
62 state_of = SubjectRelation('Workflow', cardinality='1*', composite='object', |
65 state_of = SubjectRelation('Workflow', cardinality='1*', composite='object', |
63 description=_('workflow to which this state belongs'), |
66 description=_('workflow to which this state belongs'), |
64 constraints=[RQLUniqueConstraint('S name N, Y state_of O, Y name N', 'Y', |
67 constraints=[RQLUniqueConstraint('S name N, Y state_of O, Y name N', 'Y', |
65 _('workflow already have a state of that name'))]) |
68 _('workflow already have a state of that name'))]) |
87 description=_('group in which a user should be to be ' |
90 description=_('group in which a user should be to be ' |
88 'allowed to pass this transition')) |
91 'allowed to pass this transition')) |
89 transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object', |
92 transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object', |
90 description=_('workflow to which this transition belongs'), |
93 description=_('workflow to which this transition belongs'), |
91 constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N', 'Y', |
94 constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N', 'Y', |
92 _('workflow already have a state of that name'))]) |
95 _('workflow already have a transition of that name'))]) |
93 |
96 |
94 |
97 |
95 class Transition(BaseTransition): |
98 class Transition(BaseTransition): |
96 """use to define a transition from one or multiple states to a destination |
99 """use to define a transition from one or multiple states to a destination |
97 states in workflow's definitions. |
100 states in workflow's definitions. |
98 """ |
101 """ |
99 __specializes_schema__ = True |
102 __specializes_schema__ = True |
100 |
103 |
101 destination_state = SubjectRelation( |
104 destination_state = SubjectRelation( |
102 'State', cardinality='1*', |
105 'State', cardinality='1*', |
103 constraints=[RQLConstraint('S transition_of WF, O state_of WF')], |
106 constraints=[RQLConstraint('S transition_of WF, O state_of WF', |
|
107 msg=_('state and transition don\'t belong the the same workflow'))], |
104 description=_('destination state for this transition')) |
108 description=_('destination state for this transition')) |
105 |
109 |
106 |
110 |
107 class WorkflowTransition(BaseTransition): |
111 class WorkflowTransition(BaseTransition): |
108 """special transition allowing to go through a sub-workflow""" |
112 """special transition allowing to go through a sub-workflow""" |
109 __specializes_schema__ = True |
113 __specializes_schema__ = True |
110 |
114 |
111 subworkflow = SubjectRelation('Workflow', cardinality='1*', |
115 subworkflow = SubjectRelation('Workflow', cardinality='1*', |
112 constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET')]) |
116 constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET', |
|
117 msg=_('subworkflow isn\'t a workflow for the same types as the transition\'s workflow'))] |
|
118 ) |
113 # XXX use exit_of and inline it |
119 # XXX use exit_of and inline it |
114 subworkflow_exit = SubjectRelation('SubWorkflowExitPoint', cardinality='*1', |
120 subworkflow_exit = SubjectRelation('SubWorkflowExitPoint', cardinality='*1', |
115 composite='subject') |
121 composite='subject') |
116 |
122 |
117 |
123 |
118 class SubWorkflowExitPoint(EntityType): |
124 class SubWorkflowExitPoint(EntityType): |
119 """define how we get out from a sub-workflow""" |
125 """define how we get out from a sub-workflow""" |
120 subworkflow_state = SubjectRelation( |
126 subworkflow_state = SubjectRelation( |
121 'State', cardinality='1*', |
127 'State', cardinality='1*', |
122 constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF')], |
128 constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF', |
|
129 msg=_('exit state must a subworkflow state'))], |
123 description=_('subworkflow state')) |
130 description=_('subworkflow state')) |
124 destination_state = SubjectRelation( |
131 destination_state = SubjectRelation( |
125 'State', cardinality='?*', |
132 'State', cardinality='?*', |
126 constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF')], |
133 constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF', |
|
134 msg=_('destination state must be in the same workflow as our parent transition'))], |
127 description=_('destination state. No destination state means that transition ' |
135 description=_('destination state. No destination state means that transition ' |
128 'should go back to the state from which we\'ve entered the ' |
136 'should go back to the state from which we\'ve entered the ' |
129 'subworkflow.')) |
137 'subworkflow.')) |
130 |
138 |
131 |
139 |