|
1 """workflow related schemas |
|
2 |
|
3 :organization: Logilab |
|
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
6 """ |
|
7 |
|
8 class State(MetaEntityType): |
|
9 """used to associate simple states to an entity type and/or to define |
|
10 workflows |
|
11 """ |
|
12 name = String(required=True, indexed=True, internationalizable=True, |
|
13 maxsize=256) |
|
14 description = RichString(fulltextindexed=True, default='text/rest', |
|
15 description=_('semantic description of this state')) |
|
16 |
|
17 state_of = SubjectRelation('EEType', cardinality='+*', |
|
18 description=_('entity types which may use this state'), |
|
19 constraints=[RQLConstraint('O final FALSE')]) |
|
20 allowed_transition = SubjectRelation('Transition', cardinality='**', |
|
21 constraints=[RQLConstraint('S state_of ET, O transition_of ET')], |
|
22 description=_('allowed transitions from this state')) |
|
23 |
|
24 initial_state = ObjectRelation('EEType', cardinality='?*', |
|
25 # S initial_state O, O state_of S |
|
26 constraints=[RQLConstraint('O state_of S')], |
|
27 description=_('initial state for entities of this type')) |
|
28 |
|
29 |
|
30 class Transition(MetaEntityType): |
|
31 """use to define a transition from one or multiple states to a destination |
|
32 states in workflow's definitions. |
|
33 """ |
|
34 name = String(required=True, indexed=True, internationalizable=True, |
|
35 maxsize=256) |
|
36 description_format = String(meta=True, internationalizable=True, maxsize=50, |
|
37 default='text/rest', constraints=[format_constraint]) |
|
38 description = String(fulltextindexed=True, |
|
39 description=_('semantic description of this transition')) |
|
40 condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject', |
|
41 description=_('a RQL expression which should return some results, ' |
|
42 'else the transition won\'t be available. ' |
|
43 'This query may use X and U variables ' |
|
44 'that will respectivly represents ' |
|
45 'the current entity and the current user')) |
|
46 |
|
47 require_group = SubjectRelation('EGroup', cardinality='**', |
|
48 description=_('group in which a user should be to be ' |
|
49 'allowed to pass this transition')) |
|
50 transition_of = SubjectRelation('EEType', cardinality='+*', |
|
51 description=_('entity types which may use this transition'), |
|
52 constraints=[RQLConstraint('O final FALSE')]) |
|
53 destination_state = SubjectRelation('State', cardinality='?*', |
|
54 constraints=[RQLConstraint('S transition_of ET, O state_of ET')], |
|
55 description=_('destination state for this transition')) |
|
56 |
|
57 |
|
58 class TrInfo(MetaEntityType): |
|
59 from_state = SubjectRelation('State', cardinality='?*') |
|
60 to_state = SubjectRelation('State', cardinality='1*') |
|
61 comment_format = String(meta=True, internationalizable=True, maxsize=50, |
|
62 default='text/rest', constraints=[format_constraint]) |
|
63 comment = String(fulltextindexed=True) |
|
64 # get actor and date time using owned_by and creation_date |
|
65 |
|
66 |
|
67 class from_state(MetaRelationType): |
|
68 inlined = True |
|
69 class to_state(MetaRelationType): |
|
70 inlined = True |
|
71 class wf_info_for(MetaRelationType): |
|
72 """link a transition information to its object""" |
|
73 permissions = { |
|
74 'read': ('managers', 'users', 'guests',),# RRQLExpression('U has_read_permission O')), |
|
75 'add': (), # handled automatically, no one should add one explicitly |
|
76 'delete': ('managers',), # RRQLExpression('U has_delete_permission O') |
|
77 } |
|
78 inlined = True |
|
79 composite = 'object' |
|
80 fulltext_container = composite |
|
81 |
|
82 class state_of(MetaRelationType): |
|
83 """link a state to one or more entity type""" |
|
84 class transition_of(MetaRelationType): |
|
85 """link a transition to one or more entity type""" |
|
86 |
|
87 class initial_state(MetaRelationType): |
|
88 """indicate which state should be used by default when an entity using |
|
89 states is created |
|
90 """ |
|
91 inlined = True |
|
92 |
|
93 class destination_state(MetaRelationType): |
|
94 """destination state of a transition""" |
|
95 inlined = True |
|
96 |
|
97 class allowed_transition(MetaRelationType): |
|
98 """allowed transition from this state""" |
|
99 |
|
100 class in_state(UserRelationType): |
|
101 """indicate the current state of an entity""" |
|
102 meta = True |
|
103 # not inlined intentionnaly since when using ldap sources, user'state |
|
104 # has to be stored outside the EUser table |
|
105 |
|
106 # add/delete perms given to managers/users, after what most of the job |
|
107 # is done by workflow enforcment |
|
108 |