From: erickson Date: Fri, 1 Jul 2005 19:52:38 +0000 (+0000) Subject: updated mods parser with new virtual_record fields X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6bd4f6a38ab2644954c95fd5359b0e87127c7cd7;p=Evergreen.git updated mods parser with new virtual_record fields done much work on creating and retrieving holds small utility methods abound git-svn-id: svn://svn.open-ils.org/ILS/trunk@1025 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 74917ab847..9f811c5a13 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -113,10 +113,9 @@ sub flesh_user { $kill = 1; } - # grab the user with the given card + # grab the user with the given id my $ureq = $session->request( - "open-ils.storage.direct.actor.user.retrieve", - $id); + "open-ils.storage.direct.actor.user.retrieve", $id); my $user = $ureq->gather(1); # grab the cards @@ -125,11 +124,32 @@ sub flesh_user { $user->id() ); $user->cards( $cards_req->gather(1) ); + for my $c(@{$user->cards}) { + if($c->id == $user->card || $c->id eq $user->card ) { + warn "Setting my card to " . $c->id . "\n"; + $user->card($c); + } + } + my $add_req = $session->request( "open-ils.storage.direct.actor.user_address.search.usr", $user->id() ); $user->addresses( $add_req->gather(1) ); + for my $c(@{$user->addresses}) { + if($c->id == $user->billing_address || $c->id eq $user->billing_address ) { + warn "Setting my address to " . $c->id . "\n"; + $user->billing_address($c); + } + } + + for my $c(@{$user->addresses}) { + if($c->id == $user->mailing_address || $c->id eq $user->mailing_address ) { + warn "Setting my address to " . $c->id . "\n"; + $user->mailing_address($c); + } + } + my $stat_req = $session->request( "open-ils.storage.direct.actor.stat_cat_entry_user_map.search.target_usr", $user->id() ); @@ -578,13 +598,15 @@ sub get_org_unit { my( $self, $client, $user_session, $org_id ) = @_; - my $user_obj = - OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error - - if(!$org_id) { - $org_id = $user_obj->home_ou; + if(defined($user_session) && !defined($org_id)) { + my $user_obj = + OpenILS::Application::AppUtils->check_user_session( $user_session ); #throws EX on error + if(!defined($org_id)) { + $org_id = $user_obj->home_ou; + } } + my $home_ou = OpenILS::Application::AppUtils->simple_scalar_request( "open-ils.storage", "open-ils.storage.direct.actor.org_unit.retrieve", @@ -779,8 +801,8 @@ __PACKAGE__->register_method( sub update_password { my( $self, $client, $user_session, $new_value, $current_password ) = @_; - my $user_obj = $apputils->check_user_session($user_session); warn "Updating user with method " .$self->api_name . "\n"; + my $user_obj = $apputils->check_user_session($user_session); if($self->api_name =~ /password/) { @@ -796,6 +818,7 @@ sub update_password { } elsif($self->api_name =~ /email/) { + warn "Updating email to $new_value\n"; $user_obj->email($new_value); } @@ -813,7 +836,7 @@ sub update_password { __PACKAGE__->register_method( method => "check_user_perms", - api_name => "open-ils.actor.user.email.update"); + api_name => "open-ils.actor.user.perm.check"); sub check_user_perms { my( $self, $client, $user_id, $org_id, @perm_types ) = @_; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm b/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm index 1902ae53fd..5f1bed200c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Auth.pm @@ -104,6 +104,9 @@ sub complete_authenticate { my $name = "open-ils.storage.direct.actor.user.search.usrname"; + warn "Completing Authentication\n"; + + warn "Retrieving user from storage..\n"; my $user_list = OpenILS::Application::AppUtils->simple_scalar_request( "open-ils.storage", $name, $username ); @@ -112,6 +115,8 @@ sub complete_authenticate { ("No user info returned from storage for $username"); } + warn "We have the user from storage with usrname $username\n"; + my $user = $user_list->[0]; @@ -120,14 +125,19 @@ sub complete_authenticate { } my $password = $user->passwd(); + warn "user passwd is $password\n"; if(!$password) { throw OpenSRF::EX::ERROR ("No password exists for $username", ERROR); } + warn "we have a password\n"; + my $current_seed = $cache_handle->get_cache("_open-ils_seed_$username"); $cache_handle->delete_cache( "_open-ils_seed_$username" ); + warn "Removed tmp data from cache\n"; + unless($current_seed) { throw OpenSRF::EX::User ("User must call open-ils.auth.init_authenticate first (or respond faster)"); @@ -154,6 +164,7 @@ sub complete_authenticate { } else { + warn "User password is incorrect...\n"; # send exception return 0; } } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index e512b618a4..d72ea65729 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -5,7 +5,7 @@ use strict; use warnings; use OpenILS::Application::Circ::Rules; use OpenILS::Application::Circ::Survey; use OpenILS::Application::Circ::StatCat; -#use OpenILS::Application::Circ::Actor; +use OpenILS::Application::Circ::Holds; use OpenILS::Application::AppUtils; my $apputils = "OpenILS::Application::AppUtils"; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index f238c667d4..de0fbc27c0 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -104,6 +104,7 @@ sub create_hold { my $req = $session->request( $method, $hold ); my $resp = $req->gather(1); + $session->disconnect(); if(!$resp) { return OpenILS::EX->new("UNKNOWN")->ex(); } # $apputils->commit_db_session($session); } @@ -158,4 +159,35 @@ sub _check_request_holds_override { } +__PACKAGE__->register_method( + method => "retrieve_holds", + api_name => "open-ils.circ.holds.retrieve", + notes => <check_user_session($login_session); + + if($user->id ne $user_id) { + if($apputils->check_user_perms($user_id, $user->home_ou, "VIEW_HOLDS")) { + return OpenILS::Perm->new("VIEW_HOLDS"); + } + } + + my $session = OpenSRF::AppSession->create("open-ils.storage"); + my $req = $session->request( + "open-ils.storage.direct.action.hold_request.search.usr", + $user_id ); + my $h = $req->gather(1); + $session->disconnect(); + return $h; +} + + + + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm index 362678dded..fe266cdb23 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm @@ -1,3 +1,18 @@ +# --------------------------------------------------------------- +# Copyright (C) 2005 Georgia Public Library Service +# Bill Erickson + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# --------------------------------------------------------------- + package OpenILS::Application::Circ::Rules; use base qw/OpenSRF::Application/; use strict; use warnings; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm index 882f488a55..dc4decf4a7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm @@ -1,3 +1,18 @@ +# --------------------------------------------------------------- +# Copyright (C) 2005 Georgia Public Library Service +# Bill Erickson + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# --------------------------------------------------------------- + package OpenILS::Application::Circ::StatCat; use base qw/OpenSRF::Application/; use strict; use warnings; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm index 27e4649f82..003403082c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm @@ -1,3 +1,18 @@ +# --------------------------------------------------------------- +# Copyright (C) 2005 Georgia Public Library Service +# Bill Erickson + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# --------------------------------------------------------------- + package OpenILS::Application::Circ::Survey; use base qw/OpenSRF::Application/; use strict; use warnings; @@ -8,14 +23,8 @@ use Time::HiRes qw(time); my $apputils = "OpenILS::Application::AppUtils"; -#open-ils.storage.direct.action.survey.search.* - - - - # - creates a new survey # expects a survey complete with questions and answers - __PACKAGE__->register_method( method => "add_survey", api_name => "open-ils.circ.survey.create"); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 3fa5f9e11b..31c4cbe03c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -341,12 +341,11 @@ sub biblio_id_to_copy { __PACKAGE__->register_method( - method => "fleshed_copy_retrieve", + method => "fleshed_copy_retrieve_batch", api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve", ); -# turns a barcode into a copy object -sub fleshed_copy_retrieve { +sub fleshed_copy_retrieve_batch { my( $self, $client, $ids ) = @_; throw OpenSRF::EX::InvalidArg @@ -362,6 +361,22 @@ sub fleshed_copy_retrieve { return $copy; } +__PACKAGE__->register_method( + method => "fleshed_copy_retrieve", + api_name => "open-ils.search.asset.copy.fleshed.retrieve", +); + +sub fleshed_copy_retrieve_batch { + my( $self, $client, $id ) = @_; + + return undef unless defined $id; + warn "copy retrieve for id $id\n"; + return OpenILS::Application::AppUtils->simple_scalar_request( + "open-ils.storage", + "open-ils.storage.fleshed.asset.copy.retrieve.atomic", + $id ); +} + __PACKAGE__->register_method( @@ -877,17 +892,21 @@ sub biblio_mrid_to_record_ids { warn "Searching for record for MR $mrid\n"; - my $mrmaps = OpenILS::Application::AppUtils->simple_scalar_request( "open-ils.storage", - "open-ils.storage.direct.metabib.metarecord_source_map.search.metarecord", $mrid ); + my $mrmaps = OpenILS::Application::AppUtils->simple_scalar_request( + "open-ils.storage", + #"open-ils.storage.direct.metabib.metarecord_source_map.search.metarecord", $mrid ); + "open-ils.storage.ordered.metabib.metarecord.records.atomic", + $mrid ); - my @ids; - for my $map (@$mrmaps) { push @ids, $map->source(); } - warn "Recovered id's [@ids] for mr $mrid\n"; + #my @ids; + #for my $map (@$mrmaps) { push @ids, $map->source(); } + #warn "Recovered id's [@ids] for mr $mrid\n"; + #my $size = @ids; - my $size = @ids; + my $size = @$mrmaps; - return { count => $size, ids => \@ids }; + return { count => $size, ids => $mrmaps }; } @@ -962,5 +981,21 @@ sub retrieve_all_copy_statuses { } +__PACKAGE__->register_method( + method => "copy_counts_per_org", + api_name => "open-ils.search.biblio.copy_counts.retrieve"); + +sub copy_counts_per_org { + my( $self, $client, $record_id ) = @_; + my $counts = $apputils->simple_scalar_request( + "open-ils.storage", + "open-ils.storage.biblio.record_entry.global_copy_count.atomic", + $record_id ); + $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ]; + return $counts; +} + + + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/ModsParser.pm b/Open-ILS/src/perlmods/OpenILS/Utils/ModsParser.pm index d400062944..b86fc1d133 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/ModsParser.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/ModsParser.pm @@ -58,7 +58,7 @@ my $xpathset = { subject => { topic => - "//mods:mods/*[local-name()='subject']", + "//mods:mods/mods:subject/*[local-name()!='geographicCode']/parent::mods:subject", # geographic => # "//mods:mods/*[local-name()='subject']/*[local-name()='geographic']",