
/*
 * 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
 */


create function inline_0 () returns integer as '
begin
    PERFORM workflow__create_workflow (
        ''ttracker_wf'', 
        ''Ticket Tracker Process'', 
        ''Ticket Tracker Process'', 
        ''Workflow for processing a ticket in the ticket-tracker'', 
        ''wf_ttracker_cases'',
        ''case_id''
    );

    return null;

end;' language 'plpgsql';

select inline_0 ();
drop function inline_0 ();

        


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


    select workflow__add_place(
        'ttracker_wf',
        'start', 
        'Needs to be resolved', 
        1
    );

        

    select workflow__add_place(
        'ttracker_wf',
        'to_be_clarified', 
        'Needs to be clarified', 
        2
    );

        

    select workflow__add_place(
        'ttracker_wf',
        'to_be_verified', 
        'Needs to be verified', 
        3
    );

        

    select workflow__add_place(
        'ttracker_wf',
        'end', 
        'Closed', 
        4
    );

        
/*****
 * Roles
 *****/



	select workflow__add_role (
         'ttracker_wf',
         'clarify',
         'Clarify ticket description',
         2
    );

        

	select workflow__add_role (
         'ttracker_wf',
         'resolve',
         'Resolve ticket',
         1
    );

        

	select workflow__add_role (
         'ttracker_wf',
         'verify',
         'Verify result',
         3
    );

        

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



	select workflow__add_transition (
         'ttracker_wf',
         'resolve',
         'Resolve ticket',
         'resolve',
         1,
         'user'
	);
	
        

	select workflow__add_transition (
         'ttracker_wf',
         'clarify',
         'Clarify ticket description',
         'clarify',
         2,
         'user'
	);
	
        

	select workflow__add_transition (
         'ttracker_wf',
         'verify',
         'Verify result',
         'verify',
         3,
         'user'
	);
	
        

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



	select workflow__add_arc (
         'ttracker_wf',
         'clarify',
         'start',
         'out',
         '',
         '',
         ''
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'clarify',
         'to_be_clarified',
         'in',
         '',
         '',
         ''
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'resolve',
         'start',
         'in',
         '',
         '',
         ''
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'resolve',
         'to_be_clarified',
         'out',
         'wf_callback__guard_attribute_true',
         'need_clarification',
         'Description needs clarification'
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'resolve',
         'to_be_verified',
         'out',
         '#',
         '',
         'Description clear; issue resolved'
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'verify',
         'end',
         'out',
         'wf_callback__guard_attribute_true',
         'verified',
         'Result okay'
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'verify',
         'start',
         'out',
         '#',
         '',
         'Result not okay'
	);

        

	select workflow__add_arc (
         'ttracker_wf',
         'verify',
         'to_be_verified',
         'in',
         '',
         '',
         ''
	);

        

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



    select workflow__create_attribute(
        'ttracker_wf',
        'verified',
        'boolean',
        'Result is okay',
	null,
	null,
	null,
        't',
	1,
	1,
	null,
	'generic'
    );

        

	select workflow__add_trans_attribute_map(
        	'ttracker_wf', 
        	'verify',
        	'verified',
        	1
    );

        

    select workflow__create_attribute(
        'ttracker_wf',
        'need_clarification',
        'boolean',
        'Description needs clarification',
	null,
	null,
	null,
        'f',
	1,
	1,
	null,
	'generic'
    );

        

	select workflow__add_trans_attribute_map(
        	'ttracker_wf', 
        	'resolve',
        	'need_clarification',
        	1
    );

        
/*****
 * 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_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_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_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;
