# lifecycles are used for transfering tickets from one queue to another
Set(
    %Lifecycles,
    incidents => {
        initial => [],
        active => ['open'],
        inactive => ['resolved', 'abandoned'],
        defaults => {
            on_create => 'open',
            on_merge => 'resolved',
        },
        transitions => {
            # from => [ to list ],
            '' => [qw(open)],
            open => [qw(resolved abandoned)],
            resolved => [qw(open)],
            abandoned => [qw(open)],
        },
        rights => { '* -> *' => 'ModifyTicket', },
        actions => [
            'open -> resolved' => {
                label => 'Resolve', update => 'Comment',
                All => 1,
                SelectedReportsAll => 1, SelectedInvestigationsAll => 1, SelectedCountermeasuresAll => 1,
            },
            'open -> resolved' => {
                label => 'Quick Resolve',
            },
            'open -> abandoned' => {
                label => 'Abandon', update => 'Comment',
                All => 1,
                SelectedReportsAll => 1, SelectedInvestigationsAll => 1, SelectedCountermeasuresAll => 1,
            },
            '* -> open' => {
                label => 'Re-open',
                All => 1,
                SelectedReportsAll => 1, SelectedInvestigationsAll => 1, SelectedCountermeasuresAll => 1,
            },
        ],
    },
    incident_reports => {
        initial => [ 'new' ],
        active => [ 'open' ],
        inactive => [ 'resolved', 'rejected' ],
        defaults => {
            on_create => 'new',
            on_merge => 'resolved',
            approved => 'open',
            denied => 'rejected',
        },
        transitions => {
            # from => [ to list ],
            '' => [qw(new open resolved)],
            new => [qw(open resolved rejected)],
            open => [qw(resolved rejected)],
            resolved => [qw(open)],
            rejected => [qw(open)],
        },
        rights => { '* -> *' => 'ModifyTicket', },
        actions => [
            'new -> open' => { label => 'Open It', update => 'Respond' },
            '* -> resolved' => { label => 'Resolve', update => 'Comment' },
            '* -> resolved' => { label => 'Quick Resolve' },
            '* -> rejected' =>
                { label => 'Reject', update => 'Respond', TakeOrStealFirst => 1 },
            '* -> rejected' => { label => 'Quick Reject', TakeOrStealFirst => 1 },
            '* -> open' => { label => 'Re-open' },
        ],
    },
    investigations => {
        initial => [],
        active => ['open'],
        inactive => ['resolved'],
        defaults => {
            on_create => 'open',
            on_merge => 'resolved',
            approved => 'open',
            denied => 'resolved',
        },
        transitions => {
            # from => [ to list ],
            '' => [qw(open resolved)],
            open => [qw(resolved)],
            resolved => [qw(open)],
        },
        rights => { '* -> *' => 'ModifyTicket', },
        actions => [
            '* -> resolved' => { label => 'Resolve', update => 'Comment' },
            '* -> resolved' => { label => 'Quick Resolve' },
            'resolved -> open' => { label => 'Re-open' },
        ],
    },
    countermeasures => {
        initial => ['pending activation'],
        active => [ 'active', 'pending removal' ],
        inactive => ['removed'],
        defaults => {
            on_create => 'pending activation',
            on_merge => 'removed',
            approved => 'active',
            denied => 'removed',
        },
        transitions => {
            '' => [ 'pending activation', 'active' ],
            'pending activation' => [ 'active', 'removed' ],
            active => [ 'pending removal', 'removed' ],
            'pending removal' => [ 'removed', 'active' ],
            removed => [ 'active' ],
        },
        rights => { '* -> *' => 'ModifyTicket', },
        actions => [
            '* -> active' => { label => 'Activate', update => 'Comment' },
            '* -> removed' => { label => 'Remove', update => 'Comment' },
            '* -> removed' => { label => 'Quick Remove' },
            '* -> pending removal' =>
                { label => 'Pending Removal', update => 'Comment' },
        ],
    },
    __maps__ => {
        'incidents -> incident_reports' => {
            'open' => 'open',
            'resolved' => 'resolved',
            'abandoned' => 'rejected',
        },
        'incidents -> investigations' => {
            'open' => 'open',
            'resolved' => 'resolved',
            'abandoned' => 'resolved',
        },
        'incidents -> countermeasures' => {
            'open' => 'active',
            'resolved' => 'removed',
            'abandoned' => 'removed',
        },
        'incident_reports -> incidents' => {
            'new' => 'open',
            'open' => 'open',
            'resolved' => 'resolved',
            'rejected' => 'abandoned',
        },
        'incident_reports -> investigations' => {
            'new' => 'open',
            'open' => 'open',
            'resolved' => 'resolved',
            'rejected' => 'resolved',
        },
        'incident_reports -> countermeasures' => {
            'new' => 'pending activation',
            'open' => 'active',
            'resolved' => 'removed',
            'rejected' => 'removed',
        },
        'investigations -> incidents' => {
            'open' => 'open',
            'resolved' => 'resolved',
        },
        'investigations -> incident_reports' => {
            'open' => 'open',
            'resolved' => 'resolved',
        },
        'investigations -> countermeasures' => {
            'open' => 'active',
            'resolved' => 'removed',
        },
        'countermeasures -> incidents' => {
            'pending activation' => 'open',
            'active' => 'open',
            'pending removal' => 'open',
            'removed' => 'resolved',
        },
        'countermeasures -> incident_reports' => {
            'pending activation' => 'new',
            'active' => 'open',
            'pending removal' => 'open',
            'removed' => 'resolved',
        },
        'countermeasures -> investigations' => {
            'pending activation' => 'open',
            'active' => 'open',
            'pending removal' => 'open',
            'removed' => 'resolved',
        },
        'default -> incident_reports' => {
            'new' => 'new',
            'open' => 'open',
            'resolved' => 'resolved',
            'rejected' => 'rejected'
        },
        'default -> incidents' => {
            'new' => 'open',
            'open' => 'open',
            'resolved' => 'resolved',
            'rejected' => 'abandoned',
            'stalled' => 'open'
        },
	'default -> investigations' => {
            'new'  => 'open',
	    'open' => 'open',
	    'resolved' => 'resolved',
            'rejected' => 'resolved',
	    'stalled'  => 'open',

	},
	'default -> countermeasures' => {
            'new' => 'active',
	    'open' => 'active',
	    'resolved' => 'removed',
	    'rejected' => 'removed',
	    'stalled' => 'pending activation',
	},
        'incident_reports -> default' => {
            'new' => 'new',
            'open' => 'open',
            'resolved' => 'resolved',
            'rejected' => 'rejected'
        },
        'incidents -> default' => {
            'open' => 'open',
            'resolved' => 'resolved',
            'abandoned' => 'rejected',
        },
	'investigations -> default' => {
	    'open'    => 'open',
	    'resolved'  => 'resolved',
	},
	'countermeasures -> default' => {
            'pending activation' => 'new',
	    'active'             => 'open',
	    'pending removal'    => 'open',
	    'removed'            => 'resolved',
	},
    },
);
