Data-Conveyor
view release on metacpan or search on metacpan
lib/Data/Conveyor/Ticket.pm view on Meta::CPAN
rows => scalar $self->storage->get_ticket_journal($self),
fields => [qw/stage status rc ts osuser oshost/],
);
}
# This is a service method, which doesn't just set the state attribute, so it
# gets its own method (as opposed to just setting state() from within a
# service interface).
#
# FIXME: Doesn't write sif log yet.
sub sif_set_stage {
my ($self, %opt) = @_;
assert_getopt $opt{ticket}, 'Called without ticket number.';
assert_getopt $opt{stage}, 'Called without stage.';
$self->ticket_no($opt{ticket});
$self->read;
my $prev_stage = $self->stage;
$self->stage($opt{stage});
$self->store;
$self->delegate->make_obj(
'service_result_scalar',
result =>
sprintf "Ticket [%s]: Previous stage [%s]\n",
$self->ticket_no, $prev_stage
);
}
sub sif_get_ticket_payload {
my ($self, %args) = @_;
my $ticket = $self->delegate->make_obj('ticket',);
my $res = {};
$ticket->ticket_no($args{ticket});
$ticket->read;
for my $object_type ($self->delegate->OT) {
next if $object_type eq $self->delegate->OT_LOCK;
next if $object_type eq $self->delegate->OT_TRANSACTION;
for my $payload_item (
$ticket->payload->get_list_for_object_type($object_type)) {
my $pref = $payload_item->comparable(1);
$pref = Hash::Flatten::flatten $pref;
$res->{$object_type} = $pref;
}
}
foreach
my $facet (qw/authoritative_registrar ignore_exceptions_as_registrar/) {
$res->{facets}->{$facet} =
sprintf("%s", $ticket->facets->$facet->protocol_id);
}
$res->{protokoll_id} = $ticket->registrar->protocol_id;
$self->delegate->make_obj('service_result_scalar', result => $res);
}
# rc and status are only updated from the payload; call this before storing
# the ticket whenever you change the payload's exception containers. This way,
# when you remove an exception (e.g., via a service interface), it has a
# direct effect on the ticket's rc and status.
#
# The ticket is passed to the payload method so it can pass it to the methods
# it calls; eventually the exception container will ask the ticket whether to
# ignore each exception it processes (cf. ignores_exception).
sub update_calculated_values {
my $self = shift;
$self->payload->update_transaction_stati($self);
$self->calculate_status; # calculates rc as well
}
sub calculate_rc {
my $self = shift;
$self->rc($self->payload->rc($self));
}
sub calculate_status {
my $self = shift;
$self->calculate_rc; # since status depends on the rc
my $status = sprintf "%s", $self->payload->status($self);
if ($self->stage eq $self->delegate->FINAL_TICKET_STAGE) {
$status =
$self->rc eq $self->delegate->RC_ERROR
? $self->delegate->TS_ERROR
: $self->delegate->TS_DONE;
}
$self->status($status);
}
sub set_default_rc {
my ($self, $rc) = @_;
assert_defined $rc, 'called without rc.';
$self->payload->common->default_rc($rc);
}
sub set_default_status {
my ($self, $status) = @_;
assert_defined $status, 'called without status.';
$self->payload->common->default_status($status);
}
sub reset_default_rc_and_status {
my $self = shift;
my $new_common = $self->delegate->make_obj('payload_common');
$self->payload->common->default_rc($new_common->default_rc);
$self->payload->common->default_status($new_common->default_status);
}
sub check {
my $self = shift;
$self->payload->check($self);
$self->facets->check($self);
}
sub filter_exceptions_by_rc {
my ($self, @filter) = @_;
$self->payload->filter_exceptions_by_rc($self, @filter);
}
sub filter_exceptions_by_status {
my ($self, @filter) = @_;
$self->payload->filter_exceptions_by_status($self, @filter);
}
sub delete {
my $self = shift;
( run in 0.822 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )