]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
added a method lookup in child init to speed up the cat server.
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Cat.pm
1 use strict; use warnings;
2 package OpenILS::Application::Cat;
3 use OpenSRF::Application;
4 use OpenILS::Application::Cat::Utils;
5 use base qw/OpenSRF::Application/;
6 use Time::HiRes qw(time);
7 use JSON;
8 use OpenILS::Utils::Fieldmapper;
9
10 my $utils = "OpenILS::Application::Cat::Utils";
11
12
13 sub child_init {
14         OpenSRF::Application->method_lookup( "blah" );
15 }
16
17
18 __PACKAGE__->register_method(
19         method  => "biblio_record_tree_retrieve",
20         api_name        => "open-ils.cat.biblio.record.tree.retrieve",
21         argc            => 1, 
22         note            => "Returns the tree associated with the nodeset of the given doc id"
23 );
24
25 sub biblio_record_tree_retrieve {
26         my( $self, $client, $recordid ) = @_;
27
28         warn "Starting Retrieve: " . time() . "\n";
29         my $name = "open-ils.storage.biblio.record_entry.nodeset.retrieve";
30         my $method = $self->method_lookup($name);
31         warn "Looked Up Method: " . time() . "\n";
32
33         unless($method) {
34                 throw OpenSRF::EX::PANIC ("Could not lookup method $name");
35         }
36
37         my ($nodes) = $method->run($recordid);
38
39         if(UNIVERSAL::isa($nodes,"OpenSRF::EX")) {
40                 throw $nodes;
41         }
42
43         return undef unless $nodes;
44
45         warn "Starting Tree Builder: " . time() . "\n";
46         my $tree = $utils->nodeset2tree( $nodes );
47         warn "Returning Tree: " . time() . "\n";
48         return $tree;
49 }
50
51
52 __PACKAGE__->register_method(
53         method  => "biblio_record_tree_commit",
54         api_name        => "open-ils.cat.biblio.record.tree.commit",
55         argc            => 1, 
56         note            => "Walks the tree and commits any changed nodes " .
57                                         "adds any new nodes, and deletes any deleted nodes",
58 );
59
60 sub biblio_record_tree_commit {
61         my( $self, $client, $tree ) = @_;
62         my $nodeset = $utils->tree2nodeset($tree);
63         $utils->commit_nodeset( $nodeset );
64         return $nodeset;
65 }
66
67
68
69
70 1;