
/*
 * Business Process Definition: Ticket Tracker Process (ttracker_wf)
 *
 * Auto-generated by ACS Workflow Export, version 4.3
 *
 * Context: default
 */


/*
 * Cases table
 */
create table wf_ttracker_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 => 'ttracker_wf', 
        pretty_name => 'Ticket Tracker Process', 
        pretty_plural => 'Ticket Tracker Process', 
        description => 'Workflow for processing a ticket in the ticket-tracker', 
        table_name => 'wf_ttracker_cases'
    );
end;
/
show errors

        


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

begin
    workflow.add_place(
        workflow_key => 'ttracker_wf',
        place_key    => 'start', 
        place_name   => 'Needs to be resolved', 
        sort_order   => 1
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'ttracker_wf',
        place_key    => 'to_be_clarified', 
        place_name   => 'Needs to be clarified', 
        sort_order   => 2
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'ttracker_wf',
        place_key    => 'to_be_verified', 
        place_name   => 'Needs to be verified', 
        sort_order   => 3
    );
end;
/
show errors 
        
begin
    workflow.add_place(
        workflow_key => 'ttracker_wf',
        place_key    => 'end', 
        place_name   => 'Closed', 
        sort_order   => 4
    );
end;
/
show errors 
        
/*****
 * Roles
 *****/


begin
    workflow.add_role(
        workflow_key => 'ttracker_wf',
        role_key     => 'clarify',
        role_name    => 'Clarify ticket description',
        sort_order   => 2
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'ttracker_wf',
        role_key     => 'resolve',
        role_name    => 'Resolve ticket',
        sort_order   => 1
    );
end;
/
show errors
        
begin
    workflow.add_role(
        workflow_key => 'ttracker_wf',
        role_key     => 'verify',
        role_name    => 'Verify result',
        sort_order   => 3
    );
end;
/
show errors
        

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


begin
    workflow.add_transition(
        workflow_key    => 'ttracker_wf',
        transition_key  => 'resolve',
        transition_name => 'Resolve ticket',
        role_key        => 'resolve',
        sort_order      => 1,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'ttracker_wf',
        transition_key  => 'clarify',
        transition_name => 'Clarify ticket description',
        role_key        => 'clarify',
        sort_order      => 2,
        trigger_type    => 'user'
    );
end;
/
show errors
        
begin
    workflow.add_transition(
        workflow_key    => 'ttracker_wf',
        transition_key  => 'verify',
        transition_name => 'Verify result',
        role_key        => 'verify',
        sort_order      => 3,
        trigger_type    => 'user'
    );
end;
/
show errors
        

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


begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'clarify',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'clarify',
        place_key             => 'to_be_clarified',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'resolve',
        place_key             => 'start',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'resolve',
        place_key             => 'to_be_clarified',
        direction             => 'out',
        guard_callback        => 'wf_callback.guard_attribute_true',
        guard_custom_arg      => 'need_clarification',
        guard_description     => 'Description needs clarification'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'resolve',
        place_key             => 'to_be_verified',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => 'Description clear; issue resolved'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'verify',
        place_key             => 'end',
        direction             => 'out',
        guard_callback        => 'wf_callback.guard_attribute_true',
        guard_custom_arg      => 'verified',
        guard_description     => 'Result okay'
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'verify',
        place_key             => 'to_be_verified',
        direction             => 'in',
        guard_callback        => '',
        guard_custom_arg      => '',
        guard_description     => ''
    );
end;
/
show errors
        
begin
    workflow.add_arc(
        workflow_key          => 'ttracker_wf',
        transition_key        => 'verify',
        place_key             => 'start',
        direction             => 'out',
        guard_callback        => '#',
        guard_custom_arg      => '',
        guard_description     => 'Result not okay'
    );
end;
/
show errors
        

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


declare
    v_attribute_id number;
begin
    v_attribute_id := workflow.create_attribute(
        workflow_key => 'ttracker_wf',
        attribute_name => 'need_clarification',
        datatype => 'boolean',
        pretty_name => 'Description needs clarification',
        default_value => 'f'
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'ttracker_wf', 
        transition_key => 'resolve',
        attribute_name => 'need_clarification',
        sort_order     => 1
    );
end;
/
show errors
        
declare
    v_attribute_id number;
begin
    v_attribute_id := workflow.create_attribute(
        workflow_key => 'ttracker_wf',
        attribute_name => 'verified',
        datatype => 'boolean',
        pretty_name => 'Result is okay',
        default_value => 't'
    );
end;
/
show errors
        
begin
    workflow.add_trans_attribute_map(
        workflow_key   => 'ttracker_wf', 
        transition_key => 'verify',
        attribute_name => 'verified',
        sort_order     => 1
    );
end;
/
show errors
        
/*****
 * Transition-role-assignment-map
 *****/



/*
 * 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',
 'ttracker_wf',
 'clarify',
 null,
 '',
 '',
 '',
 'ttracker_callback.clarify_fire',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'ttracker_callback.notification',
 'Clarify Description',
 '',
 '');

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',
 'ttracker_wf',
 'resolve',
 null,
 '',
 '',
 '',
 'ttracker_callback.resolve_fire',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'ttracker_callback.notification',
 'Resolve Ticket',
 'ttracker_callback.notify_admin',
 '');

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',
 'ttracker_wf',
 'verify',
 null,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'ttracker_callback.notification',
 'Verify Result',
 '',
 '');



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

insert into wf_context_role_info
(context_key,
 workflow_key,
 role_key,
 assignment_callback,
 assignment_custom_arg)
values
('default',
 'ttracker_wf',
 'clarify',
 'ttracker_callback.assign_task_to_submitter',
 '');

insert into wf_context_role_info
(context_key,
 workflow_key,
 role_key,
 assignment_callback,
 assignment_custom_arg)
values
('default',
 'ttracker_wf',
 'resolve',
 'ttracker_callback.assign_task_to_assignee',
 '');

insert into wf_context_role_info
(context_key,
 workflow_key,
 role_key,
 assignment_callback,
 assignment_custom_arg)
values
('default',
 'ttracker_wf',
 'verify',
 'ttracker_callback.assign_task_to_submitter',
 '');



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

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'clarify',
 1,
 'Ticket Info',
 '/packages/ticket-tracker/wf-templates/ticket-info',
 'f',
 'f');

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'clarify',
 2,
 'What to do',
 '/packages/ticket-tracker/wf-templates/clarify',
'f',
'f');

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'resolve',
 1,
 'Ticket Info',
 '/packages/ticket-tracker/wf-templates/ticket-info',
 'f',
 'f');

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'resolve',
 2,
 'What to do',
 '/packages/ticket-tracker/wf-templates/resolve',
 'f',
 'f');

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'verify',
 1,
 'Ticket Info',
 '/packages/ticket-tracker/wf-templates/ticket-info',
 'f',
 'f');

insert into wf_context_task_panels 
(context_key,
 workflow_key,
 transition_key,
 sort_order,
 header,
 template_url,
 overrides_action_p,
 only_display_when_started_p)
values
('default',
 'ttracker_wf',
 'verify',
 2,
 'What to do',
 '/packages/ticket-tracker/wf-templates/verify',
 'f',
 'f');


commit;

