schemas/workflow.py
author Rémi Cardona <remi.cardona@logilab.fr>
Mon, 24 Aug 2015 14:33:14 +0200
changeset 10885 b3a192804b63
parent 10666 7f6b5f023884
child 10903 da30851f9706
permissions -rw-r--r--
[devtools/qunit] Remove unused code VerboseCalledProcessError is unused since 3905682ece11.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
     1
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4805
diff changeset
    17
# with CubicWeb.  If not, see <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
    18
"""workflow related schemas
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    21
__docformat__ = "restructuredtext en"
10666
7f6b5f023884 [py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10092
diff changeset
    22
from cubicweb import _
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    24
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    25
                            SubjectRelation,
6757
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
    26
                            RichString, String, Int)
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    27
from cubicweb.schema import RQLConstraint
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    28
from cubicweb.schemas import (PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS,
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    29
                              RO_REL_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
    30
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    31
class Workflow(EntityType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    32
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    33
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    34
    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
    35
                  maxsize=256)
4805
2d0aa2b7da02 [schema] do not fulltext index workflow entities'description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    36
    description = RichString(default_format='text/rest',
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    37
                             description=_('semantic description of this workflow'))
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    38
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    39
    workflow_of = SubjectRelation('CWEType', cardinality='+*',
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    40
                                  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
    41
                                  constraints=[RQLConstraint('O final FALSE')])
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    42
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    43
    initial_state = SubjectRelation('State', cardinality='?*',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
    44
                                   constraints=[RQLConstraint('O state_of S',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
    45
                                                              msg=_('state doesn\'t belong to this workflow'))],
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    46
                                   description=_('initial state for this workflow'))
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    47
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    48
2943
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    49
class default_workflow(RelationType):
3263
5129918c671b i18n update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2977
diff changeset
    50
    """default workflow for an entity type"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    51
    __permissions__ = PUB_SYSTEM_REL_PERMS
2943
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    52
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    53
    subject = 'CWEType'
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    54
    object = 'Workflow'
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    55
    cardinality = '?*'
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
    56
    constraints = [RQLConstraint('S final FALSE, O workflow_of S',
4535
71c86a315a9a update translatable docstring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    57
                                 msg=_('workflow isn\'t a workflow for this type'))]
2943
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    58
77622caef9bd [schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2939
diff changeset
    59
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    60
class State(EntityType):
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
    """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
    62
    workflows
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
    """
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    64
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    65
    __unique_together__ = [('name', 'state_of')]
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    66
    name = String(required=True, indexed=True, internationalizable=True, maxsize=256)
4805
2d0aa2b7da02 [schema] do not fulltext index workflow entities'description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    67
    description = RichString(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
    68
                             description=_('semantic description of this state'))
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    69
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    70
    # 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
    71
    # implements #345274
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    72
    allowed_transition = SubjectRelation('BaseTransition', cardinality='**',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
    73
                                         constraints=[RQLConstraint('S state_of WF, O transition_of WF',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
    74
                                                                    msg=_('state and transition don\'t belong the the same workflow'))],
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
                                         description=_('allowed transitions from this state'))
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    76
    state_of = SubjectRelation('Workflow', cardinality='1*', composite='object', inlined=True,
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    77
                               description=_('workflow to which this state belongs'))
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    78
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    80
class BaseTransition(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
    81
    """abstract base class for transitions"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    82
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    83
    __unique_together__ = [('name', 'transition_of')]
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    84
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    85
    name = String(required=True, indexed=True, internationalizable=True, maxsize=256)
3528
77a69de16709 support for automatic transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3499
diff changeset
    86
    type = String(vocabulary=(_('normal'), _('auto')), default='normal')
4805
2d0aa2b7da02 [schema] do not fulltext index workflow entities'description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4719
diff changeset
    87
    description = RichString(description=_('semantic description of this transition'))
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    88
10092
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    89
    transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object', inlined=True,
f0363da0b5a0 [schema] stop using RQLUniqueConstraint (closes #3753250)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9242
diff changeset
    90
                                    description=_('workflow to which this transition belongs'))
2920
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
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    93
class require_group(RelationDefinition):
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    94
    """group in which a user should be to be allowed to pass this transition"""
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    95
    __permissions__ = PUB_SYSTEM_REL_PERMS
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    96
    subject = 'BaseTransition'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    97
    object = 'CWGroup'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    98
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
    99
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   100
class condition(RelationDefinition):
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   101
    """a RQL expression which should return some results, else the transition
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   102
    won't be available.
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   103
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   104
    This query may use X and U variables that will respectivly represents the
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   105
    current entity and the current user.
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   106
    """
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   107
    __permissions__ = PUB_SYSTEM_REL_PERMS
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   108
    subject = 'BaseTransition'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   109
    object = 'RQLExpression'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   110
    cardinality = '*?'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   111
    composite = 'subject'
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   112
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   113
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   114
class Transition(BaseTransition):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   115
    """use to define a transition from one or multiple states to a destination
4644
021035b9a7ab introduce 'go back' transition: transition without destination state will go to the state we were coming from
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4589
diff changeset
   116
    states in workflow's definitions. Transition without destination state will
021035b9a7ab introduce 'go back' transition: transition without destination state will go to the state we were coming from
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4589
diff changeset
   117
    go back to the state from which we arrived to the current state.
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
    __specializes_schema__ = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   120
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   121
    destination_state = SubjectRelation(
4644
021035b9a7ab introduce 'go back' transition: transition without destination state will go to the state we were coming from
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4589
diff changeset
   122
        'State', cardinality='?*',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   123
        constraints=[RQLConstraint('S transition_of WF, O state_of WF',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   124
                                   msg=_('state and transition don\'t belong the the same workflow'))],
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   125
        description=_('destination state for this transition'))
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   128
class WorkflowTransition(BaseTransition):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   129
    """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
   130
    __specializes_schema__ = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   131
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   132
    subworkflow = SubjectRelation('Workflow', cardinality='1*',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   133
                                  constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   134
                                                             msg=_('subworkflow isn\'t a workflow for the same types as the transition\'s workflow'))]
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   135
                                  )
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   136
    # XXX use exit_of and inline it
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   137
    subworkflow_exit = SubjectRelation('SubWorkflowExitPoint', cardinality='*1',
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   138
                                       composite='subject')
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   139
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   140
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   141
class SubWorkflowExitPoint(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   142
    """define how we get out from a sub-workflow"""
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   143
    subworkflow_state = SubjectRelation(
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   144
        'State', cardinality='1*',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   145
        constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF',
6109
47d9c0e0f7b7 integrate Celso's work on translation file: proper/complete spanish translation, fixed some typos in french translation, occured -> occurred fix in various places
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   146
                                   msg=_('exit state must be a subworkflow state'))],
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   147
        description=_('subworkflow state'))
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   148
    destination_state = SubjectRelation(
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   149
        'State', cardinality='?*',
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   150
        constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   151
                                   msg=_('destination state must be in the same workflow as our parent transition'))],
3628
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   152
        description=_('destination state. No destination state means that transition '
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   153
                      'should go back to the state from which we\'ve entered the '
440931181322 [wf engine] support for subwf exit point with no destination state: go back to state from which we entered into the subworkflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3529
diff changeset
   154
                      'subworkflow.'))
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   155
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   156
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   157
class TrInfo(EntityType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   158
    """workflow history item"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   159
    # 'add' security actually done by hooks
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3628
diff changeset
   160
    __permissions__ = {
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   161
        '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
   162
        'add':    ('managers', 'users', 'guests',),
3529
87b5086fd6a7 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3528
diff changeset
   163
        'delete': (), # XXX should we allow managers to delete TrInfo?
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   164
        'update': ('managers', 'owners',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   165
    }
6757
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   166
    # The unique_together constraint ensures that 2 repositories
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   167
    # sharing the db won't be able to fire a transition simultaneously
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   168
    # on the same entity tr_count is filled in the FireTransitionHook
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   169
    # to the number of TrInfo attached to the entity on which we
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   170
    # attempt to fire a transition. In other word, it contains the
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   171
    # rank of the TrInfo for that entity, and the constraint says we
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   172
    # cannot have 2 TrInfo with the same rank.
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   173
    __unique_together__ = [('tr_count', 'wf_info_for')]
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   174
    from_state = SubjectRelation('State', cardinality='1*', inlined=True)
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   175
    to_state = SubjectRelation('State', cardinality='1*', inlined=True)
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   176
    # 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
   177
    # 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
   178
    by_transition = SubjectRelation('BaseTransition', cardinality='?*')
8336
7ccd4367ee1c [workflow] set default test/plain option for workflow default comment (closes #993083)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 7797
diff changeset
   179
    comment = RichString(fulltextindexed=True, default_format='text/plain')
6757
bc878ec35794 #1382705 forbid with sql level locking the simultaneous fireing of a transition on a given entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6109
diff changeset
   180
    tr_count = Int(description='autocomputed attribute used to ensure transition coherency')
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   181
    # 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
   182
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   183
class from_state(RelationType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   184
    __permissions__ = RO_REL_PERMS.copy()
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   185
    inlined = True
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   186
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   187
class to_state(RelationType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   188
    __permissions__ = RO_REL_PERMS.copy()
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   189
    inlined = True
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   190
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   191
class by_transition(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   192
    # 'add' security actually done by hooks
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3628
diff changeset
   193
    __permissions__ = {
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   194
        'read':   ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   195
        'add':    ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   196
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   197
    }
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
    inlined = True
2501
fa86d99c2c3a test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
   199
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   200
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   201
class workflow_of(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   202
    """link a workflow to one or more entity type"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   203
    __permissions__ = PUB_SYSTEM_REL_PERMS
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   204
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   205
class state_of(RelationType):
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   206
    """link a state to one or more workflow"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   207
    __permissions__ = PUB_SYSTEM_REL_PERMS
3433
401ea5e03e9d state_of/transition_of could now be inlined
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3303
diff changeset
   208
    inlined = True
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   209
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   210
class transition_of(RelationType):
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   211
    """link a transition to one or more workflow"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   212
    __permissions__ = PUB_SYSTEM_REL_PERMS
3433
401ea5e03e9d state_of/transition_of could now be inlined
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3303
diff changeset
   213
    inlined = True
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   214
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   215
class destination_state(RelationType):
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   216
    """destination state of a transition"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   217
    __permissions__ = PUB_SYSTEM_REL_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   218
    inlined = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   219
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   220
class allowed_transition(RelationType):
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   221
    """allowed transitions from this state"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   222
    __permissions__ = PUB_SYSTEM_REL_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   223
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   224
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
   225
    """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
   226
    states is created
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   227
    """
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   228
    __permissions__ = PUB_SYSTEM_REL_PERMS
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   229
    inlined = True
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   230
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   231
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   232
class subworkflow(RelationType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   233
    __permissions__ = PUB_SYSTEM_REL_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
   234
    inlined = True
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   235
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   236
class exit_point(RelationType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   237
    __permissions__ = PUB_SYSTEM_REL_PERMS
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   238
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   239
class subworkflow_state(RelationType):
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   240
    __permissions__ = PUB_SYSTEM_REL_PERMS
4589
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   241
    inlined = True
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   242
cc3ec1423ead fix permission of the condition permission
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4537
diff changeset
   243
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   244
# "abstract" relations, set by WorkflowableEntityType ##########################
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   245
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   246
class custom_workflow(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   247
    """allow to set a specific workflow for an entity"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   248
    __permissions__ = PUB_SYSTEM_REL_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   249
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   250
    cardinality = '?*'
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   251
    constraints = [RQLConstraint('S is ET, O workflow_of ET',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   252
                                 msg=_('workflow isn\'t a workflow for this type'))]
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   253
    object = 'Workflow'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   254
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   255
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   256
class wf_info_for(RelationType):
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   257
    """link a transition information to its object"""
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   258
    # 'add' security actually done by hooks
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3628
diff changeset
   259
    __permissions__ = {
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   260
        'read':   ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   261
        'add':    ('managers', 'users', 'guests',),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   262
        'delete': (),
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   263
    }
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   264
    inlined = True
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   265
3444
0ad4ef5d3737 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3303
diff changeset
   266
    cardinality = '1*'
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   267
    composite = 'object'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   268
    fulltext_container = composite
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   269
    subject = 'TrInfo'
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   270
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   271
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   272
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
   273
    """indicate the current state of an entity"""
7797
a71618a75b53 backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   274
    __permissions__ = RO_REL_PERMS
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   275
628
3a6f28a1ea21 extract workflow related schema definitions in its own file
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   276
    # 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
   277
    # 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
   278
    inlined = False
1572
469787f6ea2b delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   279
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   280
    cardinality = '1*'
3983
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   281
    constraints = [RQLConstraint('S is ET, O state_of WF, WF workflow_of ET',
e2dc12753436 nicer error message on rql constraints
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3966
diff changeset
   282
                                 msg=_('state doesn\'t apply to this entity\'s type'))]
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2602
diff changeset
   283
    object = 'State'