851 classdict) |
851 classdict) |
852 if not abstract: |
852 if not abstract: |
853 make_workflowable(cls) |
853 make_workflowable(cls) |
854 return cls |
854 return cls |
855 |
855 |
856 def make_workflowable(cls): |
856 def make_workflowable(cls, in_state_descr=None): |
857 existing_rels = set(rdef.name for rdef in cls.__relations__) |
857 existing_rels = set(rdef.name for rdef in cls.__relations__) |
858 # let relation types defined in cw.schemas.workflow carrying |
858 # let relation types defined in cw.schemas.workflow carrying |
859 # cardinality, constraints and other relation definition properties |
859 # cardinality, constraints and other relation definition properties |
860 if 'custom_workflow' not in existing_rels: |
860 if 'custom_workflow' not in existing_rels: |
861 rdef = ybo.SubjectRelation('Workflow') |
861 rdef = ybo.SubjectRelation('Workflow') |
862 yams_add_relation(cls.__relations__, rdef, 'custom_workflow') |
862 yams_add_relation(cls.__relations__, rdef, 'custom_workflow') |
863 if 'in_state' not in existing_rels: |
863 if 'in_state' not in existing_rels: |
864 rdef = ybo.SubjectRelation('State') |
864 rdef = ybo.SubjectRelation('State', description=in_state_descr) |
865 yams_add_relation(cls.__relations__, rdef, 'in_state') |
865 yams_add_relation(cls.__relations__, rdef, 'in_state') |
866 if 'wf_info_for' not in existing_rels: |
866 if 'wf_info_for' not in existing_rels: |
867 rdef = ybo.ObjectRelation('TrInfo') |
867 rdef = ybo.ObjectRelation('TrInfo') |
868 yams_add_relation(cls.__relations__, rdef, 'wf_info_for') |
868 yams_add_relation(cls.__relations__, rdef, 'wf_info_for') |
869 |
869 |