| 1 | 1 | ▶ | use 5.008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | package Data::Conveyor::Value::Ticket::Status; | ||
| 6 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | $Data::Conveyor::Value::Ticket::Status::VERSION = '1.103130'; | |
| 8 | } | ||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||
| 10 | 1 | ▶ | use parent 'Data::Conveyor::Value::Enum'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | sub get_valid_values_list { our $cache_values ||= $_[0]->delegate->TS } | ||
| 12 | |||
| 13 | sub send_notify_value_invalid { | ||
| 14 | my ($self, $value) = @_; | ||
| 15 | local $Error::Depth = $Error::Depth + 2; | ||
| 16 | $self->exception_container->record( | ||
| 17 | 'Data::Conveyor::Exception::Ticket::NoSuchStatus', | ||
| 18 | status => $value,); | ||
| 19 | } | ||
| 20 | |||
| 21 | # Apply a new status to the value object's existing status. When called by the | ||
| 22 | # payload methods this method makes sure that the resulting status is the | ||
| 23 | # worst of all exception's associated status's. That is, if there are only | ||
| 24 | # exceptions with | ||
| 25 | # | ||
| 26 | # The status is encoded as a character, but we can map each status to a | ||
| 27 | # numeric value and perform the same operation as in apply_rc(). The following | ||
| 28 | # op table holds: | ||
| 29 | # | ||
| 30 | # Again we use an op table. Here, 'RUN' stands for 'TS_RUNNING', 'HOLD' for | ||
| 31 | # 'TS_HOLD', and 'ERR' for 'TS_ERROR'. TS_PENDING is like TS_HOLD. We haven't | ||
| 32 | # decided yet what to do if a ticket has both a TS_HOLD and a TS_PENDING | ||
| 33 | # exception because we don't really use TS_HOLD anymore. | ||
| 34 | # | ||
| 35 | # rhs | | ||
| 36 | # lhs | RUN HOLD ERR | ||
| 37 | # -------+---------------------------- | ||
| 38 | # RUN | RUN HOLD ERR | ||
| 39 | # HOLD | HOLD HOLD ERR | ||
| 40 | # ERR | ERR ERR ERR | ||
| 41 | sub add { | ||
| 42 | my ($status1, $status2) = @_; | ||
| 43 | $status1 > $status2 ? $status1 : $status2; | ||
| 44 | } | ||
| 45 | |||
| 46 | sub num_cmp { | ||
| 47 | my ($status1, $status2) = @_; | ||
| 48 | my $delegate = Data::Conveyor::Environment->getenv; | ||
| 49 | my $get_status_number = sub { | ||
| 50 | return 0 if $_[0] eq $delegate->TS_RUNNING; | ||
| 51 | return 1 if $_[0] eq $delegate->TS_HOLD; | ||
| 52 | return 1 if $_[0] eq $delegate->TS_PENDING; | ||
| 53 | return 2 if $_[0] eq $delegate->TS_ERROR; | ||
| 54 | return 0; | ||
| 55 | }; | ||
| 56 | $get_status_number->($status1) <=> $get_status_number->($status2); | ||
| 57 | } | ||
| 58 | 1; | ||
| 59 | |||
| 60 | |||
| 61 | __END__ | ||