Let the onslaught continue...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 May 2005 13:51:09 +0000 (13:51 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 May 2005 13:51:09 +0000 (13:51 +0000)
changed recv to recv(timeout =>20) in gather

usual demo updates moving forward

git-svn-id: svn://svn.open-ils.org/ILS/trunk@679 dcc99617-32d9-48b4-a31d-7c20da2025e4

26 files changed:
Evergreen/circ_rules/circ_main.rules
Evergreen/css/opac/opac_main.css
Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/LocationTree.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/opac/Page.js
Open-ILS/src/javascript/opac/RecordResultPage.js
Open-ILS/src/javascript/opac/SearchBarFormChunk.js
Open-ILS/src/javascript/util/RemoteRequest.js
Open-ILS/src/javascript/util/ils_utils.js
Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Open-ILS/src/templates/html/body
Open-ILS/src/templates/opac/pages/advanced_search.ttk
Open-ILS/src/templates/opac/pages/chunks/adv_refined_keyword.ttk
Open-ILS/src/templates/opac/pages/chunks/init.ttk
Open-ILS/src/templates/opac/pages/chunks/org_tree.ttk
Open-ILS/src/templates/opac/pages/chunks/status_bar.ttk
Open-ILS/src/templates/opac/pages/login.ttk
Open-ILS/src/templates/opac/pages/main.ttk
Open-ILS/src/templates/opac/pages/my_opac.ttk
Open-ILS/src/templates/opac/pages/my_opac_secure.ttk
Open-ILS/src/templates/opac/pages/opac_start.ttk
OpenSRF/src/libtransport/generic_utils.c
OpenSRF/src/perlmods/OpenSRF/AppSession.pm

index d2cf9fe..cc2a145 100644 (file)
@@ -38,6 +38,7 @@
        COPY_NOCIRC                                     = 3;
        COPY_UNAVAIL                            = 4;
        COPY_LOCATION                           = 5;
+       NO_COPY                                         = 100; # used by container code
 
        PATRON_STANDING                 = 10;
        PATRON_FINE                                     = 11;
index d8d4ec4..5112d77 100644 (file)
@@ -100,3 +100,7 @@ table { border-collapse: collapse; }
        display: block;
 }
 
+
+.no_border_body {
+       border: none;
+}
index d1f8377..094836a 100644 (file)
@@ -89,7 +89,10 @@ AbstractRecordResultPage.prototype.gatherIDs = function(result) {
                        if(result.ids[i]==null || result.ids[i][0] == null) break;
                        var offset = parseInt(i) + parseInt(this.searchOffset);
                        this.recordIDs[offset] = result.ids[i][0];
-                       this.ranks[offset] = parseFloat(result.ids[i][1]);
+                       var rank = parseFloat(result.ids[i][1]);
+                       if(rank == 0)
+                               rank = 0.00000001; /* protect divide by 0 */
+                       this.ranks[offset] =  rank;
                        /*
                        debug("adding ranks[" + offset + "] = " + result.ids[i][1] + 
                                        "  \nrecordIDs["+offset+"], result.ids["+i+"][0]");
index 2fa7417..d81d3dd 100644 (file)
@@ -17,7 +17,9 @@ LocationTree.prototype.buildOrgTreeWidget = function(org_node) {
                item = new WebFXTreeItem(org_node.name());
        }
 
-       item.action = "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');";
+       item.action = 
+               "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');" +
+               "globalPage.locationTree.hide();";
 
        for( var index in org_node.children()) {
                var childorg = org_node.children()[index];
@@ -31,14 +33,15 @@ LocationTree.prototype.buildOrgTreeWidget = function(org_node) {
 
 
 LocationTree.prototype.hide = function() {
-       /*
+       this.treeContainerBox = getById("ot_nav_widget");
        if(this.treeContainerBox &&  
                        this.treeContainerBox.className.indexOf("nav_bar_visible") != -1 ) {
                swapClass( this.treeContainerBox, "nav_bar_hidden", "nav_bar_visible" );
        }
-       */
 }
 
+
+
 LocationTree.prototype.toggle = function(button_div, offsetx, offsety) {
 
        this.treeContainerBox = getById("ot_nav_widget");
@@ -51,7 +54,7 @@ LocationTree.prototype.toggle = function(button_div, offsetx, offsety) {
                setTimeout("renderTree()", 5 );
        }
 
-       if( button_div && !offsetx && !offsety) {
+       if( button_div && offsetx == null && offsety == null ) {
                var x = findPosX(button_div);
                var y = findPosY(button_div);
                var height = getObjectHeight(button_div);
index 021e704..0728f2f 100644 (file)
@@ -143,7 +143,6 @@ MRResultPage.prototype.doSearch = function() {
                this.resetSearch();
        }
 
-
        this.searchDepth                = depth;
        this.searchLocation     = location;
        this.stype                              = stype;
index 0a18f71..3096f38 100644 (file)
@@ -19,16 +19,23 @@ Page.prototype.updateSelectedLocation = function(org) {
        if( typeof org == 'object' ) node = org;
        else node = getOrgById(org);
        globalSelectedLocation = node;
+       globalSearchDepth = findOrgType(node.ou_type()).depth();
        this.setLocDisplay();
 }
 
+Page.prototype.updateCurrentLocation = function(org) {
+       if( typeof org == 'object' ) node = org;
+       else node = getOrgById(orgid);
+       globalLocation = node;
+       this.setLocDisplay();
+}
+       
 
 /* tells the user where he is searching */
 Page.prototype.setLocDisplay = function(name) {
 
        debug("Setting loc display on the status bar");
        this.searchingCell = getById("now_searching_cell");
-       this.searchRange        = getById("search_range_select");
 
        if( this.searchingCell == null ) return;
        var name;
@@ -50,20 +57,78 @@ Page.prototype.setLocDisplay = function(name) {
                names.join("</span> / <span class='breadcrumb_label'>") + 
                "</span>";
 
-       /*
-       if(globalSearchBarFormChunk)
-               globalSearchBarFormChunk.resetPage();
-               */
+       this.resetRange();
 
 }
 
-Page.prototype.updateCurrentLocation = function(org) {
-       if( typeof org == 'object' ) node = org;
-       else node = getOrgById(orgid);
-       globalLocation = node;
-       this.setLocDisplay();
-}
-               
+Page.prototype.resetRange = function() {
+
+       this.searchRange                        = getById("search_range_select");
+
+       while( this.searchRange.options.length ) {
+               this.searchRange.options[0] = null;
+       }
+
+       var orgunit = globalSelectedLocation;
+       if(!orgunit)
+               orgunit = globalLocation;
 
+       debug("Reseting search range with search location " + orgunit);
+       debug("Resetting search range with search depth " + globalSearchDepth );
+
+       var selectedOption = null;
+
+       if(this.searchRange) {
+
+               for( var index in globalOrgTypes ) {
+                       var otype = globalOrgTypes[index];
+
+                       if( otype.depth() > findOrgType(orgunit.ou_type()).depth() )
+                               continue;
+
+                       var select =  new Option(otype.name(), otype.depth());
+
+                       this.searchRange.options[this.searchRange.options.length] = select;
+
+                       if( otype.depth() == globalSearchDepth ) {
+                               selectedOption = index;
+                       }
+               }
+       }
+
+       this.searchRange.selectedIndex = selectedOption;
+       this.searchRange.options[selectedOption].selected = true;
+
+       if(this.searchRange.options.length == 1 ) 
+               hideMe(this.searchRange.parentNode);
+       else  {
+               this.searchRange.parentNode.style.visibility = "visible";
+               this.searchRange.parentNode.style.display = "inline";
+       }
+
+       if( instanceOf(this, AbstractRecordResultPage) ) {
+
+               /* submit the search when the search range is selected */
+               var obj = this;
+
+               debug("Setting onclick for selector");
+               this.searchRange.onchange = function() {
+       
+                       var location = globalSelectedLocation;
+                       if(location == null) location = globalLocation.id();
+                       else location = location.id();
+                       globalSearchDepth = obj.searchRange.options[obj.searchRange.selectedIndex].value;       
+       
+                       url_redirect( [ 
+                                       "target",                                       "mr_result",
+                                       "mr_search_type",                       obj.stype,
+                                       "mr_search_query",              obj.string,
+                                       "mr_search_location",   location,
+                                       "mr_search_depth",              globalSearchDepth,      
+                                       "page",                                         0
+                                       ] );
+               }
+       }
+}
 
 
index db07016..bf5b9c5 100644 (file)
@@ -240,11 +240,6 @@ RecordResultPage.prototype.collectRecords = function() {
 
        var i = this.searchOffset;
 
-       var hcell = getById("hit_count_cell");
-       hcell.innerHTML = "Hits";
-       hcell.innerHTML += "&nbsp;&nbsp;";
-       hcell.innerHTML += this.hitCount;
-
        while( i < (this.searchOffset + this.hitsPerPage) ) {
                var id = this.recordIDs[i];
 
index 0fe30a5..6997426 100644 (file)
@@ -33,9 +33,26 @@ SearchBarFormChunk.prototype.resetPage = function() {
 
        try{ this.search_query.focus(); } catch(E) {}
 
+//     this.resetRange();
+
+}
+
+
+/*
+SearchBarFormChunk.prototype.resetRange = function() {
+
+       this.searchRange                        = getById("search_range_select");
+       var orgunit = globalSelectedLocation;
+       if(!orgunit)
+               orgunit = globalLocation;
+
        if(this.searchRange) {
                for( var index in globalOrgTypes ) {
-                       var otype = globalOrgTypes[index]
+                       var otype = globalOrgTypes[index];
+
+                       if( otype.depth() > orgunit.ou_type() )
+                               continue;
+
                        var select =  new Option(otype.name(), otype.depth());
        
                        debug("org depth " + otype.name() + " : " + otype.depth() );
@@ -43,20 +60,20 @@ SearchBarFormChunk.prototype.resetPage = function() {
                                debug("Building range selector with depth " 
                                                + globalSearchDepth  + " and name " + otype.name() );
                                select.selected = true;
-                               //this.searchRange.selectedIndex
                        }
        
                        this.searchRange.options[index] = select;
                }
        }
-
 }
-       
+*/
+
        
 function mrSearchSubmitForm() {
        var search_query                = getById("mr_search_query").value;
        var search_type         = getById("mr_search_type").value;
 
+
        var depth = globalSearchDepth;
        var location = globalSelectedLocation;
        if(location == null) 
index afe87ca..c1784dd 100644 (file)
@@ -1,6 +1,7 @@
 
 var XML_HTTP_GATEWAY = "gateway";
-var XML_HTTP_SERVER = "spacely.georgialibraries.org";
+//var XML_HTTP_SERVER = "spacely.georgialibraries.org";
+var XML_HTTP_SERVER = "gapines.org";
 var XML_HTTP_MAX_TRIES = 3;
 
 
index 8441cdf..be0d894 100644 (file)
@@ -64,7 +64,18 @@ function buildOrgTreeWidget(org_node) {
                item = new WebFXTreeItem(org_node.name());
        }
 
-       item.action = "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');";
+       item.action = 
+               "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');" +
+               "globalPage.locationTree.hide();";
+
+       /*
+       item.action = function() {
+               globalPage.updateSelectedLocation(org_node.id());
+               globalPage.globalMenuManager.hideAll();
+       }
+       */
+
+
        globalPage.treeWidgetElements[item.id] = org_node;
 
        for( var index in org_node.children()) {
index dcc9086..91dcd99 100644 (file)
@@ -235,8 +235,6 @@ sub _get_userid_by_id {
        return @users;
 }
 
-# open-ils.storage.direct.actor.user.search.usrid
-
 sub _get_id_by_userid {
 
        my @users = @_;
@@ -406,6 +404,7 @@ sub _build_volume_list {
 
 
 
+=head
 __PACKAGE__->register_method(
        method  => "generic_edit_copies_volumes",
        api_name        => "open-ils.cat.asset.volume.batch.update",
@@ -454,7 +453,136 @@ sub generic_edit_copies_volumes {
        return $result;
 }
 
+=cut
+
+
+
+# -----------------------------------------------------------------
+# Fleshed volume tree batch add/update.  This does everything a 
+# volume tree could want, add, update, delete
+# -----------------------------------------------------------------
+__PACKAGE__->register_method(
+       method  => "volume_tree_fleshed_update",
+       api_name        => "open-ils.cat.asset.volume_tree.fleshed.batch.update",
+);
+sub volume_tree_fleshed_update {
+
+       my( $self, $client, $user_session, $volumes ) = @_;
+       return undef unless $volumes;
+       my $user_obj = $apputils->check_user_session($user_session);
+
+       my $session = $apputils->start_db_session();
+       warn "Looping on volumes in fleshed volume tree update\n";
+
+       # cycle through the volumes provided and update/create/delete where necessary
+       for my $volume (@$volumes) {
+
+               warn "updating volume " . $volume->id . "\n";
+
+               my $update_copy_list = $volume->copies;
+
+               if( $volume->isnew ) {
+
+                       $volume->clear_id;
+                       $volume->editor($user_obj->id);
+                       $volume->creator($user_obj->id);
+                       $volume = _add_volume($session, $volume);
+
+               } elsif( $volume->ischanged ) {
+                       $volume->editor($user_obj->id);
+                       _update_volume($session, $volume);
+
+               } elsif( $volume->isdeleted) {
+                       return _delete_volume($session, $volume);
+               }
+
+               for my $copy (@{$update_copy_list}) {
+
+                       $copy->editor($user_obj->id);
+                       warn "updating copy for volume " . $volume->id . "\n";
+                       if( $copy->isnew ) {
+
+                               $copy->clear_id;
+                               $copy->call_number($volume->id);
+                               $copy->creator($user_obj->id);
+                               $copy = _fleshed_copy_update($session,$copy,$user_obj->id);
+
+                       } elsif( $copy->ischanged ) {
+                               $copy->call_number($volume->id);
+                               $copy = _fleshed_copy_update($session, $copy, $user_obj->id);
+
+                       } elsif( $copy->isdeleted ) {
+                               _fleshed_copy_update($session, $copy, $user_obj->id);
+                       }
+               }
+       }
+       $apputils->commit_db_session($session);
+       return scalar(@$volumes);
+}
+
+
+#XXX make me
+sub _delete_volume {
+       my( $session, $volume ) = @_;
+
+       $volume = _find_volume($session, $volume);
+
+#      my $copies = $session->request(
+#              "open-ils.storage.direct.asset.copy.search.call_number",
+#              $volume-id )->gather(1);
+#      if(@$copies) {
+#              throw OpenSRF::EX::ERROR 
+#                      ("Cannot remove volume with copies attached");
+#      }
+
+}
+
+=head
+sub _find_volume {
+       my( $session, $volume ) = @_;
+       my $cn_req = $session->request( 
+               'open-ils.storage.direct.asset.call_number.search' =>
+            {       owning_lib      => $volume->owning_lib,
+                    label           => $volume->label,
+                    record          => $volume->record,
+               }); 
+
+       return $cn_req->gather(1);
+}
+=cut
+
+sub _update_volume {
+       my($session, $volume) = @_;
+       my $req = $session->request(
+               "open-ils.storage.direct.asset.call_number.update",
+               $volume );
+       my $status = $req->gather(1);
+}
+
+sub _add_volume {
+
+       my($session, $volume) = @_;
 
+       my $request = $session->request( 
+               "open-ils.storage.direct.asset.call_number.create", $volume );
+
+       my $id = $request->gather(1);
+
+       if( $id == 0 ) {
+               OpenILS::Application::AppUtils->rollback_db_session($session);
+               throw OpenSRF::EX::ERROR (" * -> Error creating new volume");
+       }
+
+       $volume->id($id);
+       warn "received new volume id: $id\n";
+       return $volume;
+
+}
+
+
+
+
+=head
 __PACKAGE__->register_method(
        method  => "volume_tree_add",
        api_name        => "open-ils.cat.asset.volume.tree.batch.add",
@@ -478,120 +606,56 @@ sub volume_tree_add {
 
        for my $volume (@$volumes) {
 
-               new Fieldmapper::asset::call_number($volume);
-
                warn "Looping on volumes\n";
 
-
-
                my $new_copy_list = $volume->copies;
-               my $id;
 
                warn "Searching for volume with ".$volume->owning_lib . " " .
                        $volume->label . " " . $volume->record . "\n";
 
-               my $cn_req = $session->request( 
-                               'open-ils.storage.direct.asset.call_number.search' =>
-                     {       owning_lib      => $volume->owning_lib,
-                             label           => $volume->label,
-                             record          => $volume->record,
-                               }); 
+               my $cn = _find_volume($session, $volume);
 
-               $cn_req->wait_complete;
-               my $cn = $cn_req->recv();
                
-               if(!$cn_req->complete) {
-                       throw OpenSRF::EX::ERROR ("Error searching volumes on storage");
-               }
-
-               $cn_req->finish();
-
                if($cn) {
 
-                       if(UNIVERSAL::isa($cn,"Error")) {
-                               throw $cn ($cn->stringify);
-                       }
-
-                       $volume = $cn->content;
-                       $id = $volume->id;
+                       $volume = $cn;
                        $volume->editor( $user_obj->id );
 
                } else {
 
                        $volume->creator( $user_obj->id );
                        $volume->editor( $user_obj->id );
-
-                       warn "Attempting to create a new volume:\n";
-
-                       warn Dumper $volume;
-
-                       my $request = $session->request( 
-                               "open-ils.storage.direct.asset.call_number.create", $volume );
-
-                       my $response = $request->recv();
-
-                       if(!$request->complete) { 
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw OpenSRF::EX::ERROR 
-                                       ("No response from storage on call_number.create");
-                       }
-               
-                       if(UNIVERSAL::isa($response, "Error")) {
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw $response ($response->stringify);
-                       }
-
-                       $id = $response->content;
-
-                       if( $id == 0 ) {
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw OpenSRF::EX::ERROR (" * -> Error creating new volume");
-                       }
-
-                       $request->finish();
-       
-                       warn "received new volume id: $id\n";
+                       $volume = _add_volume($volume);
 
                }
 
-
                for my $copy (@{$new_copy_list}) {
 
-                       new Fieldmapper::asset::copy($copy);
-
                        warn "adding a copy for volume $id\n";
 
                        $copy->call_number($id);
-                       $copy->creator( $user_obj->id );
-                       $copy->editor( $user_obj->id );
+                       $copy->creator($user_obj->id);
+                       $copy->editor($user_obj->id);
 
                        warn Dumper $copy;
 
-                       my $req = $session->request(
-                                       "open-ils.storage.direct.asset.copy.create", $copy );
-                       my $resp = $req->recv();
+                       if( $copy->isnew() ) {
 
-                       if(!$resp || ! ref($resp) ) { 
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw OpenSRF::EX::ERROR 
-                                       ("No response from storage on call_number.create");
-                       }
+                               my $req = $session->request(
+                                               "open-ils.storage.direct.asset.copy.create", $copy );
+                               my $cid = $req->gather(1);
+
+                               if(!$cid) {
+                                       OpenILS::Application::AppUtils->rollback_db_session($session);
+                                       throw OpenSRF::EX::ERROR ("Error adding copy to volume $id" );
+                               }
        
-                       if(UNIVERSAL::isa($resp, "Error")) {
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw $resp ($resp->stringify);
-                       }
-                       
-                       my $cid = $resp->content;
+                               warn "got new copy id $cid\n";
 
-                       if(!$cid) {
-                               OpenILS::Application::AppUtils->rollback_db_session($session);
-                               throw OpenSRF::EX::ERROR ("Error adding copy to volume $id" );
-                       }
+                       } elsif( $copy->ischanged() ) {
 
-                       warn "got new copy id $cid\n";
+                       }
 
-                       $req->finish();
                }
 
                warn "completed adding copies for $id\n";
@@ -629,6 +693,7 @@ sub copy_update {
        return 1;
 }
 
+=cut
 
 
 __PACKAGE__->register_method(
@@ -639,86 +704,159 @@ __PACKAGE__->register_method(
 sub fleshed_copy_update {
        my($self, $client, $user_session, $copies) = @_;
 
-       my $user_obj = $apputils->check_user_session( $user_session ); #throws EX on error
-
+       my $user_obj = $apputils->check_user_session($user_session); 
        my $session = $apputils->start_db_session();
 
-       warn "Updating copies " . Dumper($copies) . "\n";
-       
        for my $copy (@$copies) {
+               _fleshed_copy_update($session, $copies, $user_obj->id);
+       }
 
-               warn "Gathering stat maps for copy " . $copy->id . "\n";
-               my $stat_maps = $session->request(
-                       "open-ils.storage.direct.asset.stat_cat_entry_copy_map.search.owning_copy",
-                       $copy->id )->gather(1);
+       $apputils->commit_db_session($session);
+       return 1;
+}
 
-               $copy->editor($user_obj->id);
 
-               for my $stat_entry (@{$copy->stat_cat_entries}){ 
-                       _copy_update_stat_cats( 
-                                       $session, $copy, $stat_maps, $stat_entry );
-               }
+sub _delete_copy {
+       my($session, $copy) = @_;
+       warn "Deleting copy " . $copy->id . "\n";
+       my $request = $session->request(
+               "open-ils.storage.direct.asset.copy.delete",
+               $copy );
+       return $request->gather(1);
+}
 
+sub _create_copy {
+       my($session, $copy) = @_;
 
-               # clean up stale stat maps for the copy
-               for my $map (@$stat_maps) {
-                       # if there is no stat cat entry on the copy who's id matches the
-                       # current map's id, remove the map from the database
-                       if(! grep { $_->id == $map->stat_cat_entry } 
-                                                                       @{$copy->stat_cat_entries} ) {
+       my $request = $session->request(
+               "open-ils.storage.direct.asset.copy.create",
+               $copy );
+       my $id = $request->gather(1);
 
-                               warn "Deleting copy stat map " . Dumper($map) . "\n";
-                               my $req = $session->request(
-                                       "open-ils.storage.direct.asset.stat_cat_entry_copy_map.delete",
-                                       $map );
-                               $req->gather(1);
-                       }
-               }
+       if($id < 1) {
+               throw OpenSRF::EX::ERROR
+                       ("Unable to create new copy " . Dumper($copy));
+       }
+       $copy->id($id);
+       warn "Created copy " . $copy->id . "\n";
 
+       return $copy;
 
-               # if we're fleshed, change back to id's
-               if(ref($copy->status)) {
-                       $copy->status( $copy->status->id ); }
+}
 
-               if(ref($copy->location)) {
-                       $copy->location( $copy->location->id ); }
+sub _update_copy {
+       my($session, $copy) = @_;
+       my $request = $session->request(
+               "open-ils.storage.asset.copy.update",
+               $copy );
+       warn "Updated copy " . $copy->id . "\n";
+       return $request->gather(1);
+}
 
 
-               my $req = $session->request(
-                       "open-ils.storage.direct.asset.copy.update",
-                       $copy );
-               my $status = $req->gather(1);
+# -----------------------------------------------------------------
+# Creates/Updates/Deletes a fleshed asset.copy.  
+# adds/deletes copy stat_cat maps where necessary
+# -----------------------------------------------------------------
+sub _fleshed_copy_update {
+       my($session, $copy, $editor) = @_;
+
+       my $stat_cat_entries = $copy->stat_cat_entries;
+       $copy->editor($editor);
+       
+       # in case we're fleshed
+       if(ref($copy->status))          {$copy->status( $copy->status->id ); }
+       if(ref($copy->location))        {$copy->location( $copy->location->id ); }
+       if(ref($copy->circ_lib))        {$copy->circ_lib( $copy->circ_lib->id ); }
+
+
+       if( $copy->isdeleted ) { 
+               return _delete_copy($session, $copy);
+       } elsif( $copy->isnew ) {
+               $copy = _create_copy($session, $copy);
+       } elsif( $copy->ischanged ) {
+               _update_copy($session, $copy);
        }
 
+       warn "Updating copy " . Dumper($copy) . "\n";
+       
+       if(!@$stat_cat_entries) { return 1; }
 
-       $apputils->commit_db_session($session);
+       my $stat_maps = $session->request(
+               "open-ils.storage.direct.asset.stat_cat_entry_copy_map.search.owning_copy",
+               $copy->id )->gather(1);
+
+       if( ! $copy->isnew ) { _delete_stale_maps($session, $copy); }
+       
+       # go through the stat cat update/create process
+       for my $stat_entry (@{$stat_cat_entries}){ 
+               _copy_update_stat_cats( $session, $copy, $stat_maps, $stat_entry );
+       }
+       
        return 1;
 }
 
+
+# -----------------------------------------------------------------
+# Deletes stat maps attached to this copy in the database that
+# are no longer attached to the current copy
+# -----------------------------------------------------------------
+sub _delete_stale_maps {
+       my( $session, $stat_maps, $copy) = @_;
+
+       warn "Deleting stale stat maps for copy " . $copy->id . "\n";
+       for my $map (@$stat_maps) {
+       # if there is no stat cat entry on the copy who's id matches the
+       # current map's id, remove the map from the database
+       if(! grep { $_->id == $map->stat_cat_entry } @{$copy->stat_cat_entries} ) {
+               my $req = $session->request(
+                       "open-ils.storage.direct.asset.stat_cat_entry_copy_map.delete", $map );
+               $req->gather(1);
+               }
+       }
+
+       return $stat_maps;
+}
+
+
+# -----------------------------------------------------------------
+# Searches the stat maps to see if '$entry' already exists on
+# the given copy.  If it does not, a new stat map is created
+# for the given entry and copy
+# -----------------------------------------------------------------
 sub _copy_update_stat_cats {
        my ( $session, $copy, $stat_maps, $entry ) = @_;
 
+       warn "Updating stat maps for copy " . $copy->id . "\n";
+
        # see if this map already exists
        for my $map (@$stat_maps) {
-               if( $map->stat_cat_entry == $entry->id ) {
-                       return;
-               }
+               if( $map->stat_cat_entry == $entry->id ) {return;}
        }
 
        warn "Creating new stat map for stat  " . 
                $entry->stat_cat . " and copy " . $copy->id . "\n";
 
        # if not, create it
-       $entry->clear_id;
+       my $new_map = Fieldmapper::asset::stat_cat_entry_copy_map->new();
+
+       $new_map->stat_cat( $entry->stat_cat );
+       $new_map->stat_cat_entry( $entry->id );
+       $new_map->owning_copy( $copy->id );
+
+       warn "New map is " . Dumper($new_map) . "\n";
+
        my $request = $session->request(
                "open-ils.storage.direct.asset.stat_cat_entry_copy_map.create",
-               $entry );
+               $new_map );
        my $status = $request->gather(1);
+       warn "created new map with id $status\n";
 
 }
 
 
 
+=head
 __PACKAGE__->register_method(
        method  => "volume_tree_delete",
        api_name        => "open-ils.cat.asset.volume.tree.batch.delete",
@@ -726,7 +864,6 @@ __PACKAGE__->register_method(
 
 sub volume_tree_delete {
 
-
        my( $self, $client, $user_session, $volumes ) = @_;
        return undef unless $volumes;
 
@@ -798,6 +935,7 @@ sub volume_tree_delete {
 }
 
 
+=cut
 
 
 
index b9071a7..f12e118 100644 (file)
@@ -44,6 +44,8 @@ my $stash;
 my $cache_handle;
 
 
+use constant NO_COPY => 100;
+
 sub initialize {
        my $self = shift;
        my $conf = OpenSRF::Utils::SettingsClient->new;
@@ -129,6 +131,8 @@ sub gather_circ_objects {
                $patron_id );
 
        my $copy = $copy_req->gather(1)->[0];
+       if(!$copy) { return NO_COPY; }
+
        $copy->status( $copy->status->name );
        $circ_objects->{copy} = $copy;
 
@@ -194,7 +198,16 @@ sub permit_circ {
        my $session     = OpenSRF::AppSession->create("open-ils.storage");
        
        # collect items necessary for circ calculation
-       gather_circ_objects( $session, $barcode, $user_id );
+       my $status = gather_circ_objects( $session, $barcode, $user_id );
+
+       if( $status == NO_COPY ) {
+               return { record => undef, 
+                       status => NO_COPY, 
+                       text => "No copy available with barcode $barcode"
+               };
+       }
+
+
        
        $stash->set("run_block", $permission_script);
 
index f5a2141..d45c53b 100644 (file)
@@ -234,25 +234,18 @@ sub biblio_search_tcn {
        my $session = OpenSRF::AppSession->create( "open-ils.storage" );
        my $request = $session->request( 
                        "open-ils.storage.direct.biblio.record_entry.search.tcn_value", $tcn );
-       my $response = $request->recv();
+       my $record_entry = $request->gather(1);
 
-
-       unless ($response) { return []; }
-
-       if(UNIVERSAL::isa($response,"OpenSRF::EX")) {
-               warn "Received exception for tcn search\n";
-               throw $response ($response->stringify);
-       }
-
-       my $record_entry = $response->content;
        my @ids;
        for my $record (@$record_entry) {
                push @ids, $record->id;
        }
 
-       warn "received ID's for tcn search @ids\n";
+       $session->disconnect();
 
+       warn "received ID's for tcn search @ids\n";
        my $size = @ids;
+
        return { count => $size, ids => \@ids };
 
 }
@@ -616,20 +609,13 @@ sub biblio_search_class {
                        org_unit => $org_id, 
                        depth =>$org_type );
 
-       my $response = $request->recv();
-
-       if(UNIVERSAL::isa($response, "OpenSRF::EX")) {
-               throw $response ($response->stringify);
-       }
-
-       my $count = $response->content;
+       my $count = $request->gather(1);
        warn "Received count $count\n";
        # XXX check count size and respond accordingly
 
-       $request->finish();
        $request = $session->request(   
+               "open-ils.storage.metabib.$class.search_fts.metarecord.atomic",
                #"open-ils.storage.cachable.metabib.$class.search_fts.metarecord.atomic",
-               "open-ils.storage.cachable.metabib.$class.search_fts.metarecord.atomic",
                term            => $string, 
                org_unit => $org_id, 
                depth           => $org_type, 
@@ -641,7 +627,7 @@ sub biblio_search_class {
        my @all_ids;
 
        use Data::Dumper;
-       warn Dumper $records;
+       warn "Received from class search " . Dumper($records);
 
        # if we just get one, it won't be wrapped in an array
        if(!ref($records->[0])) {
index c691e23..9593f6d 100644 (file)
@@ -12,6 +12,8 @@
 
        IF onload; " onload='$onload'"; END;
        IF onclick; " onclick='$onclick'"; END;
+       IF style; " style='$style'"; END;
+       IF class; " class='$class'"; END;
        IF id; " id='$id'"; END;
 
        ">";
index 8917a12..1efcfbe 100644 (file)
                        INCLUDE opac/pages/chunks/body_header.ttk;
 
                        lines(1);
+                       "<center>";
+                       box(content = "ADV search evolves from here...");
+                       "</center>";
+
                        box(id='adv_search_main_header', content="Advanced Search");
                        lines(1);
 
index 2baeff5..fbe119e 100644 (file)
@@ -38,7 +38,7 @@
                                WRAPPER html/row;
                                        WRAPPER html/cell colspan='4';
                                                WRAPPER html/center;
-                                                       input( type='submit', value='Search', onclick='alert("hi");');
+                                                       input( type='submit', value='Search', onclick='alert("Not Implemented, try the left search bar");');
                                                END;
                                        END;
                                END;
index 5dfcf80..3ab1b01 100644 (file)
@@ -14,7 +14,8 @@
        WRAPPER html/js;
                'parent.paramObj = new Object();';
                FOR pname IN cgi.param();
-                       'parent.paramObj["__' _  pname _ '"] = decodeURIComponent("'; cgi.param(pname); '");'; "\n";
+                       param = cgi.param(pname).replace("\"","\\\"");
+                       'parent.paramObj["__' _  pname _ '"] = decodeURIComponent("'; param; '");'; "\n";
                END;
        END;
 
index 0cd6332..182ecb3 100644 (file)
                                
                                anchor(text="Expand All", onclick="globalPage.locationTree.widget.expandAll();");
                                space(3);
-                               anchor(text="Collapse All", onclick="globalPage.locationTree.widget.collapseAll();");
+                               anchor(text="Collapse All", 
+                                               onclick="
+                                                       globalPage.locationTree.widget.collapseAll();
+                                                       globalPage.locationTree.widget.expand();
+                                                       ");
                                space(3);
 
                        END;
index dbfec96..10c2456 100644 (file)
@@ -5,6 +5,19 @@
 
                WRAPPER html/cell class='search_range_cell' nowrap='nowrap';
        
+                       
+                       WRAPPER html/span;
+                               space(3);
+                               "Expand search to ";
+                               space(1);
+       
+                               WRAPPER html/select 
+                                       name='search_range_select' 
+                                       id='search_range_select'
+                                       onchange='logicNode.globalSearchDepth = this.options[this.selectedIndex].value;';
+                               END;
+                       END;
+
                        input( type='submit', value="Location", id='location_select_button' 
                                onclick='
                                var evt = event;
                                        globalPage.locationTree.toggle(target);'
                        ); 
 
-                       space(3);
-                       "Search Range";
-                       space(1);
-
-                       WRAPPER html/select 
-                               name='search_range_select' 
-                               id='search_range_select'
-                               onchange='logicNode.globalSearchDepth = this.options[this.selectedIndex].value;';
-                       END;
        
                END;
 
index 4de084e..3c930a8 100644 (file)
@@ -26,7 +26,7 @@
 
 
                                        WRAPPER html/row;
-                                               cell(width='42%', align='right', content = tm.username);
+                                               cell(width='42%', align='right', content = "Username");
                                                cell(width='3%');
                                                cell(width='55%', align='left',
                                                                content = input( type='textarea', id='login_username', name='username', size='16' ));
@@ -35,7 +35,7 @@
                                        row(content = cell(colspan='3', content = lines(2)));
 
                                        WRAPPER html/row;
-                                               cell(width='42%', align='right', content = tm.password);
+                                               cell(width='42%', align='right', content = "Password");
                                                cell( width='3%');
                                                cell(width='55%', align='left',
                                                                content = input( type='password', id='login_password', name='password', size='16' ));
index 581cef8..6d64e0b 100644 (file)
@@ -93,7 +93,7 @@
                <frameset cols='100%'>
 
                        <frame
-                               style                   = "border:none; border:0px;" 
+                               style                   = "border:0px;" 
                                frameborder     = '0' 
                                height          = '100%'
                                width                   = '100%' 
index 0e10bf9..c458ae0 100644 (file)
@@ -12,9 +12,9 @@
                        INCLUDE opac/pages/chunks/body_header.ttk;
 
                                WRAPPER html/iframe
-                                       style       = "border:none; border:0px;"
+                                       style       = "border:none;"
                frameborder = '0'
-               height      = '100%'
+                                       #height     = '100%'
                width       = '100%'
                name        = 'my_oac_iframe'
                id          = 'my_opac_iframe'
index 2bc08e5..4530dc7 100644 (file)
@@ -6,9 +6,11 @@
                        js( src='/js/opac/MyOPACSPage.js' );
                        js( src='/js/util/RemoteRequest.js' );
                        js( src='/js/util/webutils.js' );
+
+                       '<style type="text/css"> body { border:0; } </style>'; 
                END;
 
-               WRAPPER html/body onload='';
+               WRAPPER html/body class='no_border_body' onload='';
                        "my secure opac page";
                
                END; # - body
index d71cd3c..90997c2 100644 (file)
@@ -14,7 +14,6 @@
                                lines(4);
                                PROCESS front_search; 
                        END;
-
                        INCLUDE opac/pages/chunks/org_tree.ttk;
 
                END; 
        # search range
        # ---------------------------------------------------------------------------
        BLOCK search_range;
-               "Search Range";
-               space(2);
-               WRAPPER html/select 
-                       name='search_range_select' 
-                       id='search_range_select'
-                       onchange='logicNode.globalSearchDepth = this.options[this.selectedIndex].value;';
+               WRAPPER html/span;
+                       "Expand search to ";
+                       space(2);
+                       WRAPPER html/select 
+                               name='search_range_select' 
+                               id='search_range_select'
+                               onchange='logicNode.globalSearchDepth = this.options[this.selectedIndex].value;';
+                       END;
                END;
        END;
 
                evt = (evt) ? evt : ((window.event) ? event : null);
                var target = (evt.target) ? evt.target : evt.srcElement;
                if(evt)
-                       globalPage.locationTree.toggle(target);
+                       globalPage.locationTree.toggle(target, 0, 0);
        }
 </script>
 
index 67d196b..6183954 100644 (file)
@@ -16,6 +16,7 @@ void get_timestamp( char buf_36chars[]) {
        strcat(buf_36chars,mil);
        free(localtime);
 }
+
 double get_timestamp_millis() {
        struct timeb t;
        ftime(&t);
index da3f4d6..4f408ff 100644 (file)
@@ -807,6 +807,7 @@ sub send {
 
 sub finish {
        my $self = shift;
+       return unless $self->session;
        $self->session->remove_app_request($self);
        delete($$self{$_}) for (keys %$self);
 }
@@ -942,7 +943,7 @@ sub gather {
        my $self = shift;
        my $finish = shift;
        $self->wait_complete;
-       my $resp = $self->recv;
+       my $resp = $self->recv( timeout => 20 );
        if( $self->failed() ) { 
                throw OpenSRF::EX::ERROR
                        ($self->failed()->stringify());