1 package OpenILS::Application::Storage::Publisher;
2 use base qw/OpenILS::Application::Storage/;
5 use OpenSRF::EX qw/:try/;;
6 use OpenSRF::Utils::Logger;
7 my $log = 'OpenSRF::Utils::Logger';
9 use OpenILS::Utils::Fieldmapper;
10 use OpenILS::Application::Storage::CDBI;
12 #use OpenILS::Application::Storage::CDBI::actor;
13 #use OpenILS::Application::Storage::CDBI::asset;
14 #use OpenILS::Application::Storage::CDBI::biblio;
15 #use OpenILS::Application::Storage::CDBI::config;
16 #use OpenILS::Application::Storage::CDBI::metabib;
18 use OpenILS::Application::Storage::Publisher::actor;
19 #use OpenILS::Application::Storage::Publisher::asset;
20 use OpenILS::Application::Storage::Publisher::biblio;
21 use OpenILS::Application::Storage::Publisher::config;
22 use OpenILS::Application::Storage::Publisher::metabib;
29 my $cdbi = $self->{cdbi};
34 my ($rec) = $cdbi->fast_fieldmapper($id);
35 $client->respond( $rec ) if ($rec);
37 last if ($self->api_name !~ /list/o);
48 my $cdbi = $self->{cdbi};
52 my $rec = $cdbi->create($node);
53 $success = $rec->id if ($rec);
66 my $cdbi = $self->{cdbi};
68 return $cdbi->update($node);
76 my $cdbi = $self->{cdbi};
80 $success = $cdbi->delete($node);
92 my $cdbi = $self->{cdbi};
93 my $api_name = $self->api_name;
94 (my $single_call_api_name = $api_name) =~ s/batch\.//o;
96 $log->debug("Default $api_name looking up $single_call_api_name...",INTERNAL);
97 my $method = $self->method_lookup($single_call_api_name);
100 while ( my $node = shift(@nodes) ) {
101 my ($res) = $method->run( $node );
102 push(@success, 1) if ($res >= 0);
105 my $insert_total = 0;
106 $insert_total += $_ for (@success);
108 return $insert_total;
111 for my $fmclass ( Fieldmapper->classes ) {
112 (my $cdbi = $fmclass) =~ s/^Fieldmapper:://o;
113 (my $class = $cdbi) =~ s/::.*//o;
114 (my $api_class = $cdbi) =~ s/::/./go;
115 my $registration_class = __PACKAGE__ . "::$class";
116 my $api_prefix = 'open-ils.storage.'.$api_class;
118 # Create the retrieve method
119 unless ( __PACKAGE__->is_registered( $api_prefix.'.retrieve' ) ) {
120 __PACKAGE__->register_method(
121 api_name => $api_prefix.'.retrieve',
122 method => 'retrieve_node',
128 # Create the batch retrieve method
129 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.retrieve' ) ) {
130 __PACKAGE__->register_method(
131 api_name => $api_prefix.'.batch.retrieve',
132 method => 'batch_call',
138 # Create the create method
139 unless ( __PACKAGE__->is_registered( $api_prefix.'.create' ) ) {
140 __PACKAGE__->register_method(
141 api_name => $api_prefix.'.create',
142 method => 'create_node',
148 # Create the batch create method
149 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.create' ) ) {
150 __PACKAGE__->register_method(
151 api_name => $api_prefix.'.batch.create',
152 method => 'batch_call',
158 # Create the update method
159 unless ( __PACKAGE__->is_registered( $api_prefix.'.update' ) ) {
160 __PACKAGE__->register_method(
161 api_name => $api_prefix.'.update',
162 method => 'update_node',
168 # Create the batch update method
169 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.update' ) ) {
170 __PACKAGE__->register_method(
171 api_name => $api_prefix.'.batch.update',
172 method => 'batch_call',
178 # Create the delete method
179 unless ( __PACKAGE__->is_registered( $api_prefix.'.delete' ) ) {
180 __PACKAGE__->register_method(
181 api_name => $api_prefix.'.delete',
182 method => 'delete_node',
188 # Create the batch delete method
189 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.delete' ) ) {
190 __PACKAGE__->register_method(
191 api_name => $api_prefix.'.batch.delete',
192 method => 'batch_call',