From 10f6e4335fe9f6bce1bfc330c992f1882b91407b Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 1 Apr 2010 21:00:12 +0000 Subject: [PATCH] Patch from Joe Atzberger: Last batch of method reg docs and perltidy. Note spellcheck now returns [] immediately if no term is given. No point initalizing and fetching stuff with no term. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16098 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Holds.pm | 44 +++++---- .../src/perlmods/OpenILS/Application/Circ/Money.pm | 28 +++--- .../perlmods/OpenILS/Application/Circ/NonCat.pm | 100 ++++++++++++--------- .../src/perlmods/OpenILS/Application/Search.pm | 32 ++++--- .../Application/Storage/Publisher/action.pm | 8 +- 5 files changed, 126 insertions(+), 86 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 4c51ba3b9d..2d831551d6 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -842,8 +842,19 @@ sub update_hold_if_frozen { } __PACKAGE__->register_method( - method => "hold_note_CUD", - api_name => "open-ils.circ.hold_request.note.cud" + method => "hold_note_CUD", + api_name => "open-ils.circ.hold_request.note.cud", + signature => { + desc => 'Create, update or delete a hold request note. If the operator (from Auth. token) ' + . 'is not the owner of the hold, the UPDATE_HOLD permission is required', + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'Hold note object', type => 'object' } + ], + return => { + desc => 'Returns the note ID, event on error' + }, + } ); sub hold_note_CUD { @@ -2277,27 +2288,24 @@ __PACKAGE__->register_method( method => 'hold_has_copy_at', api_name => 'open-ils.circ.hold.has_copy_at', signature => { - desc => q/ - Returns the ID of the found copy and name of the shelving location if there is - an available copy at the specified org unit. Returns empty hash otherwise. - The anticipated use for this method is to determine whether an item is - available at the library where the user is placing the hold (or, alternatively, - at the pickup library) to encourage bypassing the hold placement and just - checking out the item. - /, + desc => + 'Returns the ID of the found copy and name of the shelving location if there is ' . + 'an available copy at the specified org unit. Returns empty hash otherwise. ' . + 'The anticipated use for this method is to determine whether an item is ' . + 'available at the library where the user is placing the hold (or, alternatively, '. + 'at the pickup library) to encourage bypassing the hold placement and just ' . + 'checking out the item.' , params => { { desc => 'Authentication Token', type => 'string' }, - { desc => q/ - Method Arguments. Options include: - hold_type : the hold type code (T, V, C, M, ...) - hold_target : the identifier of the hold target object - org_unit : org unit ID - /, - type => 'object' + { desc => 'Method Arguments. Options include: hold_type, hold_target, org_unit. ' + . 'hold_type is the hold type code (T, V, C, M, ...). ' + . 'hold_target is the identifier of the hold target object. ' + . 'org_unit is org unit ID.', + type => 'object' }, }, return => { - desc => q/{ "copy" : copy_id, "location" : location_name }/, + desc => q/Result hash like { "copy" : copy_id, "location" : location_name }, empty hash on misses, event on error./, type => 'object' } } diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm index ae4dd35344..dbf9cdc699 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm @@ -447,7 +447,7 @@ sub fetch_reservation { } __PACKAGE__->register_method( - method => 'fetch_grocery', + method => 'fetch_grocery', api_name => 'open-ils.circ.money.grocery.retrieve' ); sub fetch_grocery { @@ -462,13 +462,21 @@ sub fetch_grocery { __PACKAGE__->register_method( - method => "billing_items", + method => "billing_items", + api_name => "open-ils.circ.money.billing.retrieve.all", authoritative => 1, - api_name => "open-ils.circ.money.billing.retrieve.all", - notes =><<" NOTE"); - Returns a list of billing items for the given transaction. - PARAMS( login, transaction_id ) - NOTE + signature => { + desc => 'Returns a list of billing items for the given transaction ID. ' . + 'If the operator is not the owner of the transaction, the VIEW_TRANSACTION permission is required.', + params => [ + { desc => 'Authentication token', type => 'string'}, + { desc => 'Transaction ID', type => 'number'} + ], + return => { + desc => 'Transaction object, event on error' + }, + } +); sub billing_items { my( $self, $client, $login, $transid ) = @_; @@ -491,9 +499,9 @@ sub billing_items { __PACKAGE__->register_method( - method => "billing_items_create", - api_name => "open-ils.circ.money.billing.create", - notes =><<" NOTE"); + method => "billing_items_create", + api_name => "open-ils.circ.money.billing.create", + notes => <<" NOTE"); Creates a new billing line item PARAMS( login, bill_object (mb) ) NOTE diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm index 1ddfb83c3b..fd35b19ed8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/NonCat.pm @@ -57,16 +57,17 @@ sub create_non_cat_circ { __PACKAGE__->register_method( - method => "create_noncat_type", - api_name => "open-ils.circ.non_cat_type.create", - notes => q/ + method => "create_noncat_type", + api_name => "open-ils.circ.non_cat_type.create", + notes => q/ Creates a new non cataloged item type @param authtoken The login session key @param name The name of the new type @param orgId The location where the type will live @return The type object on success and the corresponding event on failure - /); + / +); sub create_noncat_type { my( $self, $client, $authtoken, $name, $orgId, $interval, $inhouse ) = @_; @@ -97,17 +98,17 @@ sub create_noncat_type { } - __PACKAGE__->register_method( - method => "update_noncat_type", - api_name => "open-ils.circ.non_cat_type.update", - notes => q/ + method => "update_noncat_type", + api_name => "open-ils.circ.non_cat_type.update", + notes => q/ Updates a non-cataloged type object @param authtoken The login session key @param type The updated type object @return The result of the DB update call unless a preceeding event occurs, in which case the event will be returned - /); + / +); sub update_noncat_type { my( $self, $client, $authtoken, $type ) = @_; @@ -128,34 +129,46 @@ sub update_noncat_type { } __PACKAGE__->register_method( - method => "retrieve_noncat_types_all", - api_name => "open-ils.circ.non_cat_types.retrieve.all", - notes => q/ - Retrieves the non-cat types at the requested location as well - as those above and below the requested location in the org tree - @param orgId The base location at which to retrieve the type objects - @param depth Optional parameter to limit the depth of the tree - @return An array of non cat type objects or an event if an error occurs - /); + method => "retrieve_noncat_types_all", + api_name => "open-ils.circ.non_cat_types.retrieve.all", + signature => { + desc => 'Retrieves the non-cat types at the requested location as well ' + . 'as those above and below it in the org tree', + params => [ + { name => 'orgId', desc => 'Org unit ID of the base location', type => 'number' }, + { name => 'depth', desc => 'Depth limit of the tree (optional)', type => 'number' } + ], + return => { + desc => 'Array of non-cat objects, event on error' + }, + } +); sub retrieve_noncat_types_all { - my( $self, $client, $orgId, $depth ) = @_; - my $meth = 'open-ils.storage.ranged.config.non_cataloged_type.retrieve.atomic'; - my $svc = 'open-ils.storage'; - return $U->simplereq($svc, $meth, $orgId, $depth) if defined($depth); - return $U->simplereq($svc, $meth, $orgId); + my( $self, $client, $orgId, $depth ) = @_; + my $meth = 'open-ils.storage.ranged.config.non_cataloged_type.retrieve.atomic'; + my $svc = 'open-ils.storage'; + return $U->simplereq($svc, $meth, $orgId, $depth) if defined($depth); + return $U->simplereq($svc, $meth, $orgId); } - __PACKAGE__->register_method( - method => 'fetch_noncat', - api_name => 'open-ils.circ.non_cataloged_circulation.retrieve', - signature => q/ - / + method => 'fetch_noncat', + api_name => 'open-ils.circ.non_cataloged_circulation.retrieve', + signature => { + desc => 'Retrieve a circulation on a non cataloged item for a given Circ ID. If the operator is not the ' + . 'patron owner of the circ, the VIEW_CIRCULATIONS permission is required', + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'Circulation ID', type => 'number' } + ], + return => { + desc => 'Circulation object, event on error', + }, + } ); - sub fetch_noncat { my( $self, $conn, $auth, $circid ) = @_; my $e = new_editor( authtoken => $auth ); @@ -194,17 +207,21 @@ sub noncat_due_date { __PACKAGE__->register_method( - method => 'fetch_open_noncats', + method => 'fetch_open_noncats', authoritative => 1, - api_name => 'open-ils.circ.open_non_cataloged_circulation.user', - signature => q/ - Returns an id-list of non-cataloged circulations that are considered - open as of now. a circ is open if circ time + circ duration - (based on type) is > than now. - @param auth auth key - @param userid user to retrieve non-cat circs for - defaults to the session user - / + api_name => 'open-ils.circ.open_non_cataloged_circulation.user', + signature => { + desca => 'For a given user, returns an id-list of non-cataloged circulations that are considered open as of now. ' . + 'A circ is open if circ time + circ duration (based on type) is > than now. If trying to view the circs ' . + 'of another user, the VIEW_CIRCULATIONS permission is required', + params => [ + { desc => 'Authentication token', type => 'string' }, + { desc => 'UserID (optional: defaults to the session user)', type => 'number' } + ], + return => { + desc => 'Array of non-cataloged circ IDs, event on error' + }, + } ); sub fetch_open_noncats { @@ -221,8 +238,8 @@ sub fetch_open_noncats { __PACKAGE__->register_method( - method => 'delete_noncat', - api_name => 'open-ils.circ.non_cataloged_type.delete', + method => 'delete_noncat', + api_name => 'open-ils.circ.non_cataloged_type.delete', ); sub delete_noncat { my( $self, $conn, $auth, $typeid ) = @_; @@ -243,5 +260,4 @@ sub delete_noncat { } - 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm index 417649720e..6de6225a73 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm @@ -46,20 +46,27 @@ sub child_init { # ------------------------------------------------------------------ __PACKAGE__->register_method( - method => "spellcheck", - api_name => "open-ils.search.spellcheck", + method => "spellcheck", + api_name => "open-ils.search.spellcheck", signature => { - desc => 'Returns alternate spelling suggestions', - param => [ - {name => 'phrase', desc => 'Word or phrase to return alternate spelling suggestions for', type => 'string'}, - {name => 'Dictionary class', desc => 'Used to specify an alternate configured dictiony to use for suggestions', type => 'string'}, + desc => 'Returns alternate spelling suggestions', + param => [ + { + name => 'phrase', + desc => 'Word or phrase to return alternate spelling suggestions for', + type => 'string' + }, + { + name => 'Dictionary class', + desc => 'Alternate configured dictionary to use (optional)', + type => 'string' + }, ], return => { - desc => q/ - Suggestions for each word in the phrase. - [ { word : original_word, suggestions : [sug1, sug2, ...], found : 1 if the word was found in the dictionary, 0 otherwise }, ... ] - /, - type => 'array', + desc => 'Array with a suggestions hash for each word in the phrase, like: ' + . q# [{ word: original_word, suggestions: [sug1, sug2, ...], found: 1 }, ... ] # + . 'The "found" value will be 1 if the word was found in the dictionary, 0 otherwise.', + type => 'array', } } ); @@ -69,6 +76,8 @@ my $speller = Text::Aspell->new(); sub spellcheck { my( $self, $client, $phrase, $class ) = @_; + return [] unless $phrase; # nothing to check, abort. + my $conf = OpenSRF::Utils::SettingsClient->new; $class ||= 'default'; @@ -80,7 +89,6 @@ sub spellcheck { } my @resp; - return \@resp unless $phrase; for my $word (split(/\s+/,$phrase) ) { diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index a9fcaa24a5..c4785e0ff3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -40,10 +40,10 @@ sub open_noncat_circs { return action::non_cataloged_circulation->db_Main->selectcol_arrayref($sql, {}, $user); } __PACKAGE__->register_method( - api_name => 'open-ils.storage.action.open_non_cataloged_circulation.user', - api_level => 1, - argc => 1, - method => 'open_noncat_circs', + api_name => 'open-ils.storage.action.open_non_cataloged_circulation.user', + method => 'open_noncat_circs', + api_level => 1, + argc => 1, ); -- 2.11.0