schemas/workflow.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 28 Sep 2009 11:06:18 +0200
branchstable
changeset 3499 9161c215b954
parent 3444 0ad4ef5d3737
child 3503 06bced8edddf
child 3528 77a69de16709
permissions -rw-r--r--
[schema] set composite on state_of / transition_of
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""workflow related schemas
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1572
diff changeset
     4
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1572
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
     8
__docformat__ = "restructuredtext en"
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
     9
_ = unicode
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    11
from yams.buildobjs import (EntityType, RelationType, SubjectRelation,
2459
d088d0ff48a1 move RichString and co to yams, keeping only a small monkeypatch for cw-page-template here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2234
diff changeset
    12
                            ObjectRelation, RichString, String)
2939
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    13
from cubicweb.schema import RQLConstraint, RQLUniqueConstraint
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    14
from cubicweb.schemas import (META_ETYPE_PERMS, META_RTYPE_PERMS,
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    15
                              HOOKS_RTYPE_PERMS)
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    16
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    17
class Workflow(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    18
    permissions = META_ETYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    19
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    20
    name = String(required=True, indexed=True, internationalizable=True,
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    21
                  maxsize=256)
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    22
    description = RichString(fulltextindexed=True, default_format='text/rest',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    23
                             description=_('semantic description of this workflow'))
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    24
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    25
    workflow_of = SubjectRelation('CWEType', cardinality='+*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    26
                                  description=_('entity types which may use this workflow'),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    27
                                  constraints=[RQLConstraint('O final FALSE')])
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    28
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    29
    initial_state = SubjectRelation('State', cardinality='?*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    30
                                   constraints=[RQLConstraint('O state_of S')],
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    31
                                   description=_('initial state for this workflow'))
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    32
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    33
2943
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    34
class default_workflow(RelationType):
3263
5129918c671b i18n update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2977
diff changeset
    35
    """default workflow for an entity type"""
2943
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    36
    permissions = META_RTYPE_PERMS
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    37
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    38
    subject = 'CWEType'
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    39
    object = 'Workflow'
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    40
    cardinality = '?*'
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    41
    constraints = [RQLConstraint('S final FALSE, O workflow_of S')]
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    42
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    43
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    44
class State(EntityType):
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
    """used to associate simple states to an entity type and/or to define
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
    workflows
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
    """
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    48
    permissions = META_ETYPE_PERMS
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    49
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
    name = String(required=True, indexed=True, internationalizable=True,
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
                  maxsize=256)
798
0015b33a7336 fix State's RichString definition: 'default' was used instead of 'default_format'
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 628
diff changeset
    52
    description = RichString(fulltextindexed=True, default_format='text/rest',
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    53
                             description=_('semantic description of this state'))
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    54
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    55
    # XXX should be on BaseTransition w/ AND/OR selectors when we will
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    56
    # implements #345274
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    57
    allowed_transition = SubjectRelation('BaseTransition', cardinality='**',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    58
                                         constraints=[RQLConstraint('S state_of WF, O transition_of WF')],
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
                                         description=_('allowed transitions from this state'))
3499
9161c215b954 [schema] set composite on state_of / transition_of
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3444
diff changeset
    60
    state_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
2939
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    61
                               description=_('workflow to which this state belongs'),
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    62
                               constraints=[RQLUniqueConstraint('S name N, Y state_of O, Y name N')])
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    63
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    65
class BaseTransition(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    66
    """abstract base class for transitions"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    67
    permissions = META_ETYPE_PERMS
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    68
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
    name = String(required=True, indexed=True, internationalizable=True,
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
                  maxsize=256)
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    71
    description = RichString(fulltextindexed=True,
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
                         description=_('semantic description of this transition'))
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
    condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject',
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
                                description=_('a RQL expression which should return some results, '
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
                                              'else the transition won\'t be available. '
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
                                              'This query may use X and U variables '
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
                                              'that will respectivly represents '
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
                                              'the current entity and the current user'))
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    79
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 798
diff changeset
    80
    require_group = SubjectRelation('CWGroup', cardinality='**',
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
                                    description=_('group in which a user should be to be '
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    82
                                                  'allowed to pass this transition'))
3499
9161c215b954 [schema] set composite on state_of / transition_of
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3444
diff changeset
    83
    transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
2939
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    84
                                    description=_('workflow to which this transition belongs'),
a613cc003ab7 make state/transition name unique within a workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    85
                                    constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N')])
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    86
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    87
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    88
class Transition(BaseTransition):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    89
    """use to define a transition from one or multiple states to a destination
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    90
    states in workflow's definitions.
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    91
    """
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    92
    __specializes_schema__ = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    93
2229
edf20a9ca376 destination_state should be mandatory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    94
    destination_state = SubjectRelation('State', cardinality='1*',
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    95
                                        constraints=[RQLConstraint('S transition_of WF, O state_of WF')],
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
                                        description=_('destination state for this transition'))
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    98
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    99
class WorkflowTransition(BaseTransition):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   100
    """special transition allowing to go through a sub-workflow"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   101
    __specializes_schema__ = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   102
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   103
    subworkflow = SubjectRelation('Workflow', cardinality='1*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   104
                                  constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET')])
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   105
    subworkflow_exit = SubjectRelation('SubWorkflowExitPoint', cardinality='+1',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   106
                                       composite='subject')
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   107
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   108
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   109
class SubWorkflowExitPoint(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   110
    """define how we get out from a sub-workflow"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   111
    subworkflow_state = SubjectRelation('State', cardinality='1*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   112
                                        constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF')],
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   113
                                        description=_('subworkflow state'))
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   114
    destination_state = SubjectRelation('State', cardinality='1*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   115
                                        constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF')],
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   116
                                        description=_('destination state'))
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   117
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   118
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   119
# XXX should we allow managers to delete TrInfo?
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   120
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   121
class TrInfo(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   122
    """workflow history item"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   123
    # 'add' security actually done by hooks
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   124
    permissions = {
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   125
        'read':   ('managers', 'users', 'guests',), # XXX U has_read_permission O ?
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   126
        'add':    ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   127
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   128
        'update': ('managers', 'owners',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   129
    }
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   130
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   131
    from_state = SubjectRelation('State', cardinality='1*')
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
    to_state = SubjectRelation('State', cardinality='1*')
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   133
    # make by_transition optional because we want to allow managers to set
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   134
    # entity into an arbitrary state without having to respect wf transition
2950
643570a7770f [schema] oops, should use BaseTransition here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2943
diff changeset
   135
    by_transition = SubjectRelation('BaseTransition', cardinality='?*')
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   136
    comment = RichString(fulltextindexed=True)
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   137
    # get actor and date time using owned_by and creation_date
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   138
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   139
class from_state(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   140
    permissions = HOOKS_RTYPE_PERMS.copy()
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   141
    inlined = True
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   143
class to_state(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   144
    permissions = {
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   145
        'read':   ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   146
        'add':    ('managers',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   147
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   148
    }
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
    inlined = True
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   150
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   151
class by_transition(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   152
    # 'add' security actually done by hooks
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   153
    permissions = {
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   154
        'read':   ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   155
        'add':    ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   156
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   157
    }
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   158
    inlined = True
2501
fa86d99c2c3a test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
   159
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   160
class workflow_of(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   161
    """link a workflow to one or more entity type"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   162
    permissions = META_RTYPE_PERMS
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   163
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   164
class state_of(RelationType):
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   165
    """link a state to one or more workflow"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   166
    permissions = META_RTYPE_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   167
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   168
class transition_of(RelationType):
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   169
    """link a transition to one or more workflow"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   170
    permissions = META_RTYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   171
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   172
class subworkflow(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   173
    """link a transition to one or more workflow"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   174
    permissions = META_RTYPE_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   175
    inlined = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   176
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   177
class exit_point(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   178
    """link a transition to one or more workflow"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   179
    permissions = META_RTYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   180
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   181
class subworkflow_state(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   182
    """link a transition to one or more workflow"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   183
    permissions = META_RTYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   184
    inlined = True
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   185
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   186
class initial_state(RelationType):
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   187
    """indicate which state should be used by default when an entity using
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   188
    states is created
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   189
    """
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   190
    permissions = META_RTYPE_PERMS
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   191
    inlined = True
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   192
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   193
class destination_state(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   194
    """destination state of a transition"""
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   195
    permissions = META_RTYPE_PERMS
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   196
    inlined = True
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   198
class allowed_transition(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   199
    """allowed transition from this state"""
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   200
    permissions = META_RTYPE_PERMS
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   201
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   202
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   203
# "abstract" relations, set by WorkflowableEntityType ##########################
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   204
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   205
class custom_workflow(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   206
    """allow to set a specific workflow for an entity"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   207
    permissions = META_RTYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   208
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   209
    cardinality = '?*'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   210
    constraints = [RQLConstraint('S is ET, O workflow_of ET')]
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   211
    object = 'Workflow'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   212
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   213
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   214
class wf_info_for(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   215
    """link a transition information to its object"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   216
    # 'add' security actually done by hooks
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   217
    permissions = {
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   218
        'read':   ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   219
        'add':    ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   220
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   221
    }
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   222
    inlined = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   223
3444
0ad4ef5d3737 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3303
diff changeset
   224
    cardinality = '1*'
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   225
    composite = 'object'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   226
    fulltext_container = composite
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   227
    subject = 'TrInfo'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   228
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   229
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   230
class in_state(RelationType):
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   231
    """indicate the current state of an entity"""
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   232
    permissions = HOOKS_RTYPE_PERMS
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   233
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   234
    # not inlined intentionnaly since when using ldap sources, user'state
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 798
diff changeset
   235
    # has to be stored outside the CWUser table
2602
7bfa83772d90 [F schema] set inlined=False to ensure it'is not inlined by accident
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2501
diff changeset
   236
    inlined = False
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   237
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   238
    cardinality = '1*'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   239
    constraints = [RQLConstraint('S is ET, O state_of WF, WF workflow_of ET')]
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   240
    object = 'State'