
/*
 * Business Process Definition: Full Term Publish Process (full_term_publish_process_wf)
 *
 * Auto-generated by ACS Workflow Export, version 4.3
 *
 * Context: default
 */


/*
 * Cases table
 */
create table full_term_publish_proces_cases (
  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 => 'full_term_publish_process_wf', 
        pretty_name => 'Full Term Publish Process', 
        pretty_plural => 'Full Term Publish Processes', 
        description => 'Fairly sophisticatd standard glossary term publishing.  Publisher or Editor create a term.  Author writes definition.  Editor edits definition.  Graphic designer adds and illustration.  Editor or publisher approve or reject new term.', 
        table_name => 'full_term_publish_proces_cases'
    );
end;
/
show errors

        


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

begin
    workflow.add_place(
        workflow_key => 'full_term_publish_process_wf',
        place_key    => 'start', 
        place_name   => 'Ready to Author Definition.', 
        sort_order   => 1
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'full_term_publish_process_wf',
        place_key    => 'before_edit_definition', 
        place_name   => 'Ready to Edit Definition', 
        sort_order   => 2
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'full_term_publish_process_wf',
        place_key    => 'before_add_illustration', 
        place_name   => 'Ready to Add Illustration', 
        sort_order   => 3
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'full_term_publish_process_wf',
        place_key    => 'before_approve_new_term', 
        place_name   => 'Ready to Approve New Term', 
        sort_order   => 4
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'full_term_publish_process_wf',
        place_key    => 'end', 
        place_name   => 'Process finished', 
        sort_order   => 5
    );
end;
/
show errors 
        
/*****
 * Roles
 *****/


begin
    workflow.add_role(
        workflow_key => 'full_term_publish_process_wf',
        role_key     => 'add_illustration',
        role_name    => 'Add Illustration',
        sort_order   => 3
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'full_term_publish_process_wf',
        role_key     => 'approve_new_term',
        role_name    => 'Approve New Term',
        sort_order   => 4
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'full_term_publish_process_wf',
        role_key     => 'author_definition',
        role_name    => 'Author Definition.',
        sort_order   => 1
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'full_term_publish_process_wf',
        role_key     => 'edit_definition',
        role_name    => 'Edit Definition',
        sort_order   => 2
    );
end;
/
show errors
        

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


begin
    workflow.add_transition(
        workflow_key    => 'full_term_publish_process_wf',
        transition_key  => 'author_definition',
        transition_name => 'Author Definition.',
        role_key        => 'author_definition',
        sort_order      => 1,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'full_term_publish_process_wf',
        transition_key  => 'edit_definition',
        transition_name => 'Edit Definition',
        role_key        => 'edit_definition',
        sort_order      => 2,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'full_term_publish_process_wf',
        transition_key  => 'add_illustration',
        transition_name => 'Add Illustration',
        role_key        => 'add_illustration',
        sort_order      => 3,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'full_term_publish_process_wf',
        transition_key  => 'approve_new_term',
        transition_name => 'Approve New Term',
        role_key        => 'approve_new_term',
        sort_order      => 4,
        trigger_type    => 'user'
    );
end;
/
show errors
        

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


begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'add_illustration',
        place_key             => 'before_add_illustration',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'add_illustration',
        place_key             => 'before_approve_new_term',
        direction             => 'out',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'approve_new_term',
        place_key             => 'before_approve_new_term',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'approve_new_term',
        place_key             => 'before_edit_definition',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => 'Not Approved'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'approve_new_term',
        place_key             => 'end',
        direction             => 'out',
        guard_callback        => 'wf_callback.guard_attribute_true',
        guard_custom_arg      => 'approve_new_term_approved_p',
        guard_description     => 'Approved'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'author_definition',
        place_key             => 'before_edit_definition',
        direction             => 'out',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'author_definition',
        place_key             => 'start',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'edit_definition',
        place_key             => 'before_add_illustration',
        direction             => 'out',
        guard_callback        => 'wf_callback.guard_attribute_true',
        guard_custom_arg      => 'edit_definition_is_definition_correct_p',
        guard_description     => 'Is definition correct'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'edit_definition',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => 'Not Is definition correct'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'full_term_publish_process_wf',
        transition_key        => 'edit_definition',
        place_key             => 'before_edit_definition',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        

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


declare
    v_attribute_id number;
begin
    v_attribute_id := workflow.create_attribute(
        workflow_key => 'full_term_publish_process_wf',
        attribute_name => 'edit_definition_is_definition_correct_p',
        datatype => 'boolean',
        pretty_name => 'Is definition correct',
        default_value => 't'
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'full_term_publish_process_wf', 
        transition_key => 'edit_definition',
        attribute_name => 'edit_definition_is_definition_correct_p',
        sort_order     => 1
    );
end;
/
show errors
        
declare
    v_attribute_id number;
begin
    v_attribute_id := workflow.create_attribute(
        workflow_key => 'full_term_publish_process_wf',
        attribute_name => 'approve_new_term_approved_p',
        datatype => 'boolean',
        pretty_name => 'Approved',
        default_value => 't'
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'full_term_publish_process_wf', 
        transition_key => 'approve_new_term',
        attribute_name => 'approve_new_term_approved_p',
        sort_order     => 1
    );
end;
/
show errors
        
/*****
 * Transition-role-assignment-map
 *****/


begin
    workflow.add_trans_role_assign_map(
        workflow_key    => 'full_term_publish_process_wf',
        transition_key  => 'edit_definition',
        assign_role_key => 'add_illustration'
    );
end;
/
show errors;
        

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

insert into wf_context_transition_info
(context_key,
 workflow_key,
 transition_key,
 estimated_minutes,
 instructions,
 enable_callback,
 enable_custom_arg,
 fire_callback,
 fire_custom_arg,
 time_callback,
 time_custom_arg,
 deadline_callback,
 deadline_custom_arg,
 deadline_attribute_name,
 hold_timeout_callback,
 hold_timeout_custom_arg,
 notification_callback,
 notification_custom_arg,
 unassigned_callback,
 unassigned_custom_arg)
values
('default',
 'full_term_publish_process_wf',
 'add_illustration',
 120,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '');

insert into wf_context_transition_info
(context_key,
 workflow_key,
 transition_key,
 estimated_minutes,
 instructions,
 enable_callback,
 enable_custom_arg,
 fire_callback,
 fire_custom_arg,
 time_callback,
 time_custom_arg,
 deadline_callback,
 deadline_custom_arg,
 deadline_attribute_name,
 hold_timeout_callback,
 hold_timeout_custom_arg,
 notification_callback,
 notification_custom_arg,
 unassigned_callback,
 unassigned_custom_arg)
values
('default',
 'full_term_publish_process_wf',
 'approve_new_term',
 10,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '');

insert into wf_context_transition_info
(context_key,
 workflow_key,
 transition_key,
 estimated_minutes,
 instructions,
 enable_callback,
 enable_custom_arg,
 fire_callback,
 fire_custom_arg,
 time_callback,
 time_custom_arg,
 deadline_callback,
 deadline_custom_arg,
 deadline_attribute_name,
 hold_timeout_callback,
 hold_timeout_custom_arg,
 notification_callback,
 notification_custom_arg,
 unassigned_callback,
 unassigned_custom_arg)
values
('default',
 'full_term_publish_process_wf',
 'author_definition',
 60,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '');

insert into wf_context_transition_info
(context_key,
 workflow_key,
 transition_key,
 estimated_minutes,
 instructions,
 enable_callback,
 enable_custom_arg,
 fire_callback,
 fire_custom_arg,
 time_callback,
 time_custom_arg,
 deadline_callback,
 deadline_custom_arg,
 deadline_attribute_name,
 hold_timeout_callback,
 hold_timeout_custom_arg,
 notification_callback,
 notification_custom_arg,
 unassigned_callback,
 unassigned_custom_arg)
values
('default',
 'full_term_publish_process_wf',
 'edit_definition',
 20,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '');



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



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


commit;

