updated mods parser with new virtual_record fields
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Jul 2005 19:52:38 +0000 (19:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 1 Jul 2005 19:52:38 +0000 (19:52 +0000)
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

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Application/Auth.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/StatCat.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Survey.pm
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Open-ILS/src/perlmods/OpenILS/Utils/ModsParser.pm

index 74917ab..9f811c5 100644 (file)
@@ -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 ) = @_;
index 1902ae5..5f1bed2 100644 (file)
@@ -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;
        }
 }
index e512b61..d72ea65 100644 (file)
@@ -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";
index f238c66..de0fbc2 100644 (file)
@@ -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           => <<NOTE);
+Retrieves all the holds for the specified user id.  The login session
+is the requestor and if the requestor is different from the user, then
+the requestor must have VIEW_HOLDS permissions.
+NOTE
+
+sub retrieve_holds {
+       my($self, $client, $login_session, $user_id) = @_;
+       my $user = $apputils->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;
index 362678d..fe266cd 100644 (file)
@@ -1,3 +1,18 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2005  Georgia Public Library Service 
+# Bill Erickson <highfalutin@gmail.com>
+
+# 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;
index 882f488..dc4decf 100644 (file)
@@ -1,3 +1,18 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2005  Georgia Public Library Service 
+# Bill Erickson <highfalutin@gmail.com>
+
+# 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;
index 27e4649..0034030 100644 (file)
@@ -1,3 +1,18 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2005  Georgia Public Library Service 
+# Bill Erickson <highfalutin@gmail.com>
+
+# 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");
index 3fa5f9e..31c4cbe 100644 (file)
@@ -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;
index d400062..b86fc1d 100644 (file)
@@ -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']",