
/*
 * Business Process Definition: Simple Publishing Workflow (publishing_wf)
 *
 * Auto-generated by ACS Workflow Export, version 4.3
 *
 * Context: default
 */


/*
 * Cases table
 */
create table cr_workflows (
  case_id               integer primary key
                        references wf_cases on delete cascade
);

/* 
 * Declare the object type
 */

declare
    v_workflow_key varchar2(40);
begin
    v_workflow_key := workflow.create_workflow(
        workflow_key => 'publishing_wf', 
        pretty_name => 'Simple Publishing Workflow', 
        pretty_plural => 'Simple Publishing Workflows', 
        description => 'A simple linear workflow for authoring,
                          editing and scheduling content items.', 
        table_name => 'cr_workflows'
    );
end;
/
show errors

        


/*****
 * Places
 *****/

begin
    workflow.add_place(
        workflow_key => 'publishing_wf',
        place_key    => 'start', 
        place_name   => 'Created', 
        sort_order   => 1
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'publishing_wf',
        place_key    => 'authored', 
        place_name   => 'Authored', 
        sort_order   => 2
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'publishing_wf',
        place_key    => 'edited', 
        place_name   => 'Edited', 
        sort_order   => 3
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'publishing_wf',
        place_key    => 'end', 
        place_name   => 'Approved', 
        sort_order   => 4
    );
end;
/
show errors 
        
/*****
 * Roles
 *****/


begin
    workflow.add_role(
        workflow_key => 'publishing_wf',
        role_key     => 'approval',
        role_name    => 'Approval',
        sort_order   => 3
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'publishing_wf',
        role_key     => 'authoring',
        role_name    => 'Authoring',
        sort_order   => 1
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'publishing_wf',
        role_key     => 'editing',
        role_name    => 'Editing',
        sort_order   => 2
    );
end;
/
show errors
        

/*****
 * Transitions
 *****/


begin
    workflow.add_transition(
        workflow_key    => 'publishing_wf',
        transition_key  => 'authoring',
        transition_name => 'Authoring',
        role_key        => 'authoring',
        sort_order      => 1,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'publishing_wf',
        transition_key  => 'editing',
        transition_name => 'Editing',
        role_key        => 'editing',
        sort_order      => 2,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'publishing_wf',
        transition_key  => 'approval',
        transition_name => 'Approval',
        role_key        => 'approval',
        sort_order      => 3,
        trigger_type    => 'user'
    );
end;
/
show errors
        

/*****
 * Arcs
 *****/


begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'approval',
        place_key             => 'authored',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'approval',
        place_key             => 'edited',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'approval',
        place_key             => 'end',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'approval',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'approval',
        place_key             => 'edited',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'authoring',
        place_key             => 'authored',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'authoring',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'authoring',
        place_key             => 'start',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'editing',
        place_key             => 'authored',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'editing',
        place_key             => 'edited',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'editing',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => 'publishing_wf.is_next',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'publishing_wf',
        transition_key        => 'editing',
        place_key             => 'authored',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        

/*****
 * Attributes
 *****/


declare
    v_attribute_id integer;
begin
    v_attribute_id := workflow.create_attribute(
        workflow_key => 'publishing_wf',
        attribute_name => 'next_place',
        datatype => 'string',
        pretty_name => 'Next Place',
        default_value => 'start'
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'publishing_wf', 
        transition_key => 'approval',
        attribute_name => 'next_place',
        sort_order     => 1
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'publishing_wf', 
        transition_key => 'authoring',
        attribute_name => 'next_place',
        sort_order     => 1
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'publishing_wf', 
        transition_key => 'editing',
        attribute_name => 'next_place',
        sort_order     => 1
    );
end;
/
show errors
        
/*****
 * Transition-role-assignment-map
 *****/



/*
 * Context/Transition info
 * (for context = default)
 */



/*
 * Context/Role info
 * (for context = default)
 */



/*
 * Context Task Panels
 * (for context = default)
 */


commit;

