28 isession.commit() |
28 isession.commit() |
29 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
29 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_add_entity', '') |
30 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
30 repo.hm.register_hook(uniquecstrcheck_before_modification, 'before_update_entity', '') |
31 session.set_shared_data('do-not-insert-cwuri', False) |
31 session.set_shared_data('do-not-insert-cwuri', False) |
32 |
32 |
|
33 if applcubicwebversion < (3, 5, 0) and cubicwebversion >= (3, 5, 0): |
|
34 add_entity_type('Workflow') |
|
35 add_entity_type('BaseTransition') |
|
36 add_entity_type('WorkflowTransition') |
|
37 add_entity_type('SubWorkflowExitPoint') |
|
38 drop_relation_definition('State', 'allowed_transition', 'Transition') # should be infered |
|
39 schema.rebuild_infered_relations() # need to be explicitly called once everything is in place |
|
40 |
|
41 for et in rql('DISTINCT Any ET,ETN WHERE S state_of ET, ET name ETN', |
|
42 ask_confirm=False).entities(): |
|
43 wf = add_workflow(u'default %s workflow' % et.name, et.name, |
|
44 ask_confirm=False) |
|
45 rql('SET S state_of WF WHERE S state_of ET, ET eid %(et)s, WF eid %(wf)s', |
|
46 {'et': et.eid, 'wf': wf.eid}, 'et', ask_confirm=False) |
|
47 rql('SET T transition_of WF WHERE T transition_of ET, ET eid %(et)s, WF eid %(wf)s', |
|
48 {'et': et.eid, 'wf': wf.eid}, 'et', ask_confirm=False) |
|
49 rql('SET WF initial_state S WHERE ET initial_state S, S state_of ET, ET eid %(et)s, WF eid %(wf)s', |
|
50 {'et': et.eid, 'wf': wf.eid}, 'et', ask_confirm=False) |
|
51 |
|
52 |
|
53 rql('DELETE TrInfo TI WHERE NOT TI from_state S') |
|
54 rql('SET TI by_transition T WHERE TI from_state FS, TI to_state TS, ' |
|
55 'FS allowed_transition T, T destination_state TS') |
|
56 checkpoint() |
|
57 |
|
58 drop_relation_definition('State', 'state_of', 'CWEType') |
|
59 drop_relation_definition('Transition', 'transition_of', 'CWEType') |
|
60 drop_relation_definition('CWEType', 'initial_state', 'State') |
|
61 |
|
62 sync_schema_props_perms() |
|
63 |
33 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
64 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1): |
34 from base64 import b64encode |
65 from base64 import b64encode |
35 for table in ('entities', 'deleted_entities'): |
66 for table in ('entities', 'deleted_entities'): |
36 for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL' |
67 for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL' |
37 % table, ask_confirm=False): |
68 % table, ask_confirm=False): |