1 package OpenILS::Application::Storage::Publisher;
2 use base qw/OpenILS::Application::Storage/;
5 use OpenILS::Utils::Fieldmapper;
6 use OpenILS::Application::Storage::CDBI;
8 #use OpenILS::Application::Storage::CDBI::actor;
9 #use OpenILS::Application::Storage::CDBI::asset;
10 #use OpenILS::Application::Storage::CDBI::biblio;
11 #use OpenILS::Application::Storage::CDBI::config;
12 #use OpenILS::Application::Storage::CDBI::metabib;
14 use OpenILS::Application::Storage::Publisher::actor;
15 #use OpenILS::Application::Storage::Publisher::asset;
16 use OpenILS::Application::Storage::Publisher::biblio;
17 use OpenILS::Application::Storage::Publisher::config;
18 use OpenILS::Application::Storage::Publisher::metabib;
21 for my $fmclass ( Fieldmapper->classes ) {
22 (my $cdbi = $fmclass) =~ s/^Fieldmapper:://o;
23 (my $class = $cdbi) =~ s/::.*//o;
24 (my $api_class = $cdbi) =~ s/::/./go;
25 my $registration_class = __PACKAGE__ . "::$class";
26 my $api_prefix = 'open-ils.storage.'.$api_class;
28 warn "\tfmclass => $fmclass\n\tclass => $class\n\tregclass => $registration_class\n\tprefix => $api_prefix\n\tcdbi => $cdbi\n\n";
30 # Create the create method
31 unless ( __PACKAGE__->is_registered( $api_prefix.'.create' ) ) {
32 *{ $registration_class . '::create_node' } = sub {
39 my $rec = $cdbi->create($node);
47 $registration_class->register_method(
48 api_name => $api_prefix.'.create',
49 method => 'create_node',
54 # Create the batch create method
55 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.create' ) ) {
56 *{ $registration_class . '::create_node_batch' } = sub {
61 my $method = $self->method_lookup($api_prefix.'.create');
64 while ( my $node = shift(@nodes) ) {
65 my ($res) = $method->run( $node );
66 push(@success, 1) if ($res >= 0);
70 $insert_total += $_ for (@success);
74 $registration_class->register_method(
75 api_name => $api_prefix.'.batch.create',
76 method => 'create_node_batch',
81 # Create the update method
82 unless ( __PACKAGE__->is_registered( $api_prefix.'.update' ) ) {
83 *{ $registration_class . '::update_node' } = sub {
88 return $cdbi->update($node);
90 $registration_class->register_method(
91 api_name => $api_prefix.'.update',
92 method => 'update_node',
97 # Create the batch update method
98 unless ( __PACKAGE__->is_registered( $api_prefix.'.batch.update' ) ) {
99 *{ $registration_class . '::update_node_batch' } = sub {
104 my $method = $self->method_lookup($api_prefix.'.update');
107 while ( my $node = shift(@nodes) ) {
108 my ($res) = $method->run( $node );
109 push(@success, $res) if ($res >= 0);
112 my $insert_total = 0;
113 $insert_total += $_ for (@success);
115 return $insert_total;
117 $registration_class->register_method(
118 api_name => $api_prefix.'.batch.update',
119 method => 'update_node_batch',