956 # cleanup unused constraints |
956 # cleanup unused constraints |
957 self.rqlexec('DELETE CWConstraint C WHERE NOT X constrained_by C') |
957 self.rqlexec('DELETE CWConstraint C WHERE NOT X constrained_by C') |
958 if commit: |
958 if commit: |
959 self.commit() |
959 self.commit() |
960 |
960 |
961 @deprecated('use sync_schema_props_perms(ertype, syncprops=False)') |
961 @deprecated('[3.2] use sync_schema_props_perms(ertype, syncprops=False)') |
962 def cmd_synchronize_permissions(self, ertype, commit=True): |
962 def cmd_synchronize_permissions(self, ertype, commit=True): |
963 self.cmd_sync_schema_props_perms(ertype, syncprops=False, commit=commit) |
963 self.cmd_sync_schema_props_perms(ertype, syncprops=False, commit=commit) |
964 |
964 |
965 # Workflows handling ###################################################### |
965 # Workflows handling ###################################################### |
966 |
966 |
993 {'et': etypes[0]}) |
993 {'et': etypes[0]}) |
994 if rset: |
994 if rset: |
995 return rset.get_entity(0, 0) |
995 return rset.get_entity(0, 0) |
996 return self.cmd_add_workflow('%s workflow' % ';'.join(etypes), etypes) |
996 return self.cmd_add_workflow('%s workflow' % ';'.join(etypes), etypes) |
997 |
997 |
998 @deprecated('use add_workflow and Workflow.add_state method') |
998 @deprecated('[3.5] use add_workflow and Workflow.add_state method') |
999 def cmd_add_state(self, name, stateof, initial=False, commit=False, **kwargs): |
999 def cmd_add_state(self, name, stateof, initial=False, commit=False, **kwargs): |
1000 """method to ease workflow definition: add a state for one or more |
1000 """method to ease workflow definition: add a state for one or more |
1001 entity type(s) |
1001 entity type(s) |
1002 """ |
1002 """ |
1003 wf = self._get_or_create_wf(stateof) |
1003 wf = self._get_or_create_wf(stateof) |
1004 state = wf.add_state(name, initial, **kwargs) |
1004 state = wf.add_state(name, initial, **kwargs) |
1005 if commit: |
1005 if commit: |
1006 self.commit() |
1006 self.commit() |
1007 return state.eid |
1007 return state.eid |
1008 |
1008 |
1009 @deprecated('use add_workflow and Workflow.add_transition method') |
1009 @deprecated('[3.5] use add_workflow and Workflow.add_transition method') |
1010 def cmd_add_transition(self, name, transitionof, fromstates, tostate, |
1010 def cmd_add_transition(self, name, transitionof, fromstates, tostate, |
1011 requiredgroups=(), conditions=(), commit=False, **kwargs): |
1011 requiredgroups=(), conditions=(), commit=False, **kwargs): |
1012 """method to ease workflow definition: add a transition for one or more |
1012 """method to ease workflow definition: add a transition for one or more |
1013 entity type(s), from one or more state and to a single state |
1013 entity type(s), from one or more state and to a single state |
1014 """ |
1014 """ |
1017 conditions, **kwargs) |
1017 conditions, **kwargs) |
1018 if commit: |
1018 if commit: |
1019 self.commit() |
1019 self.commit() |
1020 return tr.eid |
1020 return tr.eid |
1021 |
1021 |
1022 @deprecated('use Transition.set_transition_permissions method') |
1022 @deprecated('[3.5] use Transition.set_transition_permissions method') |
1023 def cmd_set_transition_permissions(self, treid, |
1023 def cmd_set_transition_permissions(self, treid, |
1024 requiredgroups=(), conditions=(), |
1024 requiredgroups=(), conditions=(), |
1025 reset=True, commit=False): |
1025 reset=True, commit=False): |
1026 """set or add (if `reset` is False) groups and conditions for a |
1026 """set or add (if `reset` is False) groups and conditions for a |
1027 transition |
1027 transition |
1030 tr = self.session.entity_from_eid(treid) |
1030 tr = self.session.entity_from_eid(treid) |
1031 tr.set_transition_permissions(requiredgroups, conditions, reset) |
1031 tr.set_transition_permissions(requiredgroups, conditions, reset) |
1032 if commit: |
1032 if commit: |
1033 self.commit() |
1033 self.commit() |
1034 |
1034 |
1035 @deprecated('use entity.fire_transition("transition") or entity.change_state("state")') |
1035 @deprecated('[3.5] use entity.fire_transition("transition") or entity.change_state("state")') |
1036 def cmd_set_state(self, eid, statename, commit=False): |
1036 def cmd_set_state(self, eid, statename, commit=False): |
1037 self.session.set_pool() # ensure pool is set |
1037 self.session.set_pool() # ensure pool is set |
1038 self.session.entity_from_eid(eid).change_state(statename) |
1038 self.session.entity_from_eid(eid).change_state(statename) |
1039 if commit: |
1039 if commit: |
1040 self.commit() |
1040 self.commit() |