schemas/workflow.py
branchstable
changeset 3983 e2dc12753436
parent 3966 f742c525b7b4
child 3998 94cc7cad3d2d
child 4212 ab6573088b4a
--- a/schemas/workflow.py	Thu Dec 03 09:57:32 2009 +0100
+++ b/schemas/workflow.py	Thu Dec 03 09:57:55 2009 +0100
@@ -27,7 +27,8 @@
                                   constraints=[RQLConstraint('O final FALSE')])
 
     initial_state = SubjectRelation('State', cardinality='?*',
-                                   constraints=[RQLConstraint('O state_of S')],
+                                   constraints=[RQLConstraint('O state_of S',
+                                                              msg=_('state doesn\'t belong to this workflow'))],
                                    description=_('initial state for this workflow'))
 
 
@@ -38,7 +39,8 @@
     subject = 'CWEType'
     object = 'Workflow'
     cardinality = '?*'
-    constraints = [RQLConstraint('S final FALSE, O workflow_of S')]
+    constraints = [RQLConstraint('S final FALSE, O workflow_of S',
+                                 msg=_('workflow isn\'t a workflow of this type'))]
 
 
 class State(EntityType):
@@ -57,7 +59,8 @@
     # XXX should be on BaseTransition w/ AND/OR selectors when we will
     # implements #345274
     allowed_transition = SubjectRelation('BaseTransition', cardinality='**',
-                                         constraints=[RQLConstraint('S state_of WF, O transition_of WF')],
+                                         constraints=[RQLConstraint('S state_of WF, O transition_of WF',
+                                                                    msg=_('state and transition don\'t belong the the same workflow'))],
                                          description=_('allowed transitions from this state'))
     state_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
                                description=_('workflow to which this state belongs'),
@@ -89,7 +92,7 @@
     transition_of = SubjectRelation('Workflow', cardinality='1*', composite='object',
                                     description=_('workflow to which this transition belongs'),
                                     constraints=[RQLUniqueConstraint('S name N, Y transition_of O, Y name N', 'Y',
-                                                                     _('workflow already have a state of that name'))])
+                                                                     _('workflow already have a transition of that name'))])
 
 
 class Transition(BaseTransition):
@@ -100,7 +103,8 @@
 
     destination_state = SubjectRelation(
         'State', cardinality='1*',
-        constraints=[RQLConstraint('S transition_of WF, O state_of WF')],
+        constraints=[RQLConstraint('S transition_of WF, O state_of WF',
+                                   msg=_('state and transition don\'t belong the the same workflow'))],
         description=_('destination state for this transition'))
 
 
@@ -109,7 +113,9 @@
     __specializes_schema__ = True
 
     subworkflow = SubjectRelation('Workflow', cardinality='1*',
-                                  constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET')])
+                                  constraints=[RQLConstraint('S transition_of WF, WF workflow_of ET, O workflow_of ET',
+                                                             msg=_('subworkflow isn\'t a workflow for the same types as the transition\'s workflow'))]
+                                  )
     # XXX use exit_of and inline it
     subworkflow_exit = SubjectRelation('SubWorkflowExitPoint', cardinality='*1',
                                        composite='subject')
@@ -119,11 +125,13 @@
     """define how we get out from a sub-workflow"""
     subworkflow_state = SubjectRelation(
         'State', cardinality='1*',
-        constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF')],
+        constraints=[RQLConstraint('T subworkflow_exit S, T subworkflow WF, O state_of WF',
+                                   msg=_('exit state must a subworkflow state'))],
         description=_('subworkflow state'))
     destination_state = SubjectRelation(
         'State', cardinality='?*',
-        constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF')],
+        constraints=[RQLConstraint('T subworkflow_exit S, T transition_of WF, O state_of WF',
+                                   msg=_('destination state must be in the same workflow as our parent transition'))],
         description=_('destination state. No destination state means that transition '
                       'should go back to the state from which we\'ve entered the '
                       'subworkflow.'))
@@ -218,7 +226,8 @@
     permissions = META_RTYPE_PERMS
 
     cardinality = '?*'
-    constraints = [RQLConstraint('S is ET, O workflow_of ET')]
+    constraints = [RQLConstraint('S is ET, O workflow_of ET',
+                                 msg=_('workflow isn\'t a workflow for this type'))]
     object = 'Workflow'
 
 
@@ -247,5 +256,6 @@
     inlined = False
 
     cardinality = '1*'
-    constraints = [RQLConstraint('S is ET, O state_of WF, WF workflow_of ET')]
+    constraints = [RQLConstraint('S is ET, O state_of WF, WF workflow_of ET',
+                                 msg=_('state doesn\'t apply to this entity\'s type'))]
     object = 'State'