1 package NCIP::Handler::AcceptItem;
5 NCIP::Handler::AcceptItem
9 Not to be called directly, NCIP::Handler will pick the appropriate Handler
10 object, given a message type
20 our @ISA = qw(NCIP::Handler);
26 my $root = $xmldoc->documentElement();
27 my $xpc = $self->xpc();
28 my $itemid = $xpc->find( '//ns:ItemIdentifierValue', $root );
29 my ($action) = $xpc->findnodes( '//ns:RequestedActionType', $root );
30 my ($request) = $xpc->findnodes( '//ns:RequestId', $root );
31 my $requestagency = $xpc->find( 'ns:AgencyId', $request );
32 my $requestid = $xpc->find( '//ns:RequestIdentifierValue', $request );
33 my $borrowerid = $xpc->find( '//ns:UserIdentifierValue', $root );
36 $action = $action->textContent();
39 my $iteminfo = $xpc->find( '//ns:ItemOptionalFields', $root );
42 if ( $iteminfo->[0] ) {
44 # populate a hashref with bibliographic data, we need this to create an item
45 # (this could be moved up to Handler.pm eventually as CreateItem will need this also)
47 $xpc->find( '//ns:BibliographicDescription', $iteminfo->[0] );
48 my $title = $xpc->find( '//ns:Title', $bibliographic->[0] );
50 $itemdata->{title} = $title->[0]->textContent();
52 my $author = $xpc->find( '//ns:Author', $bibliographic->[0] );
54 $itemdata->{author} = $author->[0]->textContent();
57 $xpc->find( '//ns:PublicationDate', $bibliographic->[0] );
59 $itemdata->{publicationdate} = $date->[0]->textContent();
61 my $publisher = $xpc->find( '//ns:Publisher', $bibliographic->[0] );
62 if ( $publisher->[0] ) {
63 $itemdata->{publisher} = $publisher->[0]->textContent();
65 my $medium = $xpc->find( '//ns:Mediumtype', $bibliographic->[0] );
67 $itemdata->{mediumtype} = $medium->[0]->textContent();
73 my ( $from, $to ) = $self->get_agencies($xmldoc);
75 # Autographics workflow is for an accept item to create the item then do what is in $action
76 if ( $from->[0]->textContent() =~ /CPomAG/ ) {
80 $self->ils->acceptitem( $itemid, $borrowerid, $action, $create,
85 # we switch these for the templates
86 # because we are responding, to becomes from, from becomes to
87 $vars->{'fromagency'} = $to;
88 $vars->{'toagency'} = $from;
90 $vars->{'messagetype'} = 'AcceptItemResponse';
91 $vars->{'barcode'} = $itemid;
92 if ( !$accepted->{success} ) {
93 $vars->{'processingerror'} = 1;
94 $vars->{'processingerrortype'} = $accepted->{'messages'};
95 $vars->{'processingerrorelement'} = 'UniqueItemIdentifier';
96 $output = $self->render_output( 'problem.tt', $vars );
99 my $elements = $self->get_user_elements($xmldoc);
100 $vars->{'requestagency'} = $requestagency;
101 $vars->{'requestid'} = $requestid;
102 $vars->{'newbarcode'} = $accepted->{'newbarcode'} || $itemid;
103 $vars->{'elements'} = $elements;
104 $vars->{'accept'} = $accepted;
105 $output = $self->render_output( 'response.tt', $vars );