Data-Conveyor
view release on metacpan or search on metacpan
lib/Data/Conveyor/Ticket/Payload.pm view on Meta::CPAN
}
sub check {
my ($self, $ticket) = @_;
# check object limits; also check the payload items while we're at it
for my $object_type ($self->delegate->OT) {
my $limit =
$self->delegate->get_object_limit($ticket->type, $object_type);
my $index;
for my $item ($self->get_list_for_object_type($object_type)) {
$index++;
# Ask the business object to check itself, accumulating exceptions
# into the business object's exception container.
$item->check($ticket);
next if $index <= $limit;
$item->exception_container->record(
'Data::Conveyor::Exception::ObjectLimitExceeded',
ticket_type => $ticket->type,
object_type => $object_type,
limit => $limit,
);
}
}
$self->common->check($ticket);
}
# determines the overall payload rc
sub rc {
my ($self, $ticket) = @_;
# Start with RC_OK; if a stage wants to use another default rc, it can do
# so by setting the common payload item's default_rc.
my $rc =
$self->delegate->make_obj('value_ticket_rc', $self->delegate->RC_OK) +
$self->common->rc($ticket);
for my $object_type ($self->delegate->OT) {
$rc += $_->rc($ticket)
for $self->get_list_for_object_type($object_type);
}
$rc;
}
# determines the overall payload status
sub status {
my ($self, $ticket) = @_;
# Start with TS_RUNNING; if a stage wants to use another default status,
# it can do so by setting the common payload item's default_status.
my $status =
$self->delegate->make_obj('value_ticket_status',
$self->delegate->TS_RUNNING) + $self->common->status($ticket);
for my $object_type ($self->delegate->OT) {
$status += $_->status($ticket)
for $self->get_list_for_object_type($object_type);
}
$status;
}
sub update_transaction_stati {
my ($self, $ticket) = @_;
$_->transaction->update_status($ticket) for $self->transactions;
}
sub filter_exceptions_by_rc {
my ($self, $ticket, @filter) = @_;
my $result = $self->delegate->make_obj('exception_container');
for my $object_type ($self->delegate->OT) {
for my $payload_item ($self->get_list_for_object_type($object_type)) {
$result->items_push(
$payload_item->exception_container->filter_exceptions_by_rc(
$ticket, @filter
)
);
}
}
$result->items_push(
$self->common->exception_container->filter_exceptions_by_rc(
$ticket, @filter
)
);
$result;
}
sub filter_exceptions_by_status {
my ($self, $ticket, @filter) = @_;
my $result = $self->delegate->make_obj('exception_container');
for my $object_type ($self->delegate->OT) {
for my $payload_item ($self->get_list_for_object_type($object_type)) {
$result->items_push(
$payload_item->exception_container->filter_exceptions_by_status(
$ticket, @filter
)
);
}
}
$result->items_push(
$self->common->exception_container->filter_exceptions_by_status(
$ticket, @filter
)
);
$result;
}
sub get_all_exceptions {
my $self = shift;
my $result = $self->delegate->make_obj('exception_container');
for my $object_type ($self->delegate->OT) {
for my $payload_item ($self->get_list_for_object_type($object_type)) {
$result->items_push($payload_item->exception_container->items);
}
}
$result->items_push($self->common->exception_container->items);
$result->delete_duplicate_exceptions; # returns $result
}
sub clear_all_exceptions {
my $self = shift;
for my $object_type ($self->delegate->OT) {
for my $payload_item ($self->get_list_for_object_type($object_type)) {
( run in 0.912 second using v1.01-cache-2.11-cpan-d8267643d1d )