add configurable string joiner instead of hardcoding a space Open-ILS/web/js/dojo...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 May 2009 00:52:14 +0000 (00:52 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 May 2009 00:52:14 +0000 (00:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13038 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/web/js/dojo/openils/BibTemplate.js

index 4a5d878..2a483e3 100644 (file)
@@ -1516,6 +1516,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Owning Library" name="owning_lib" oils_obj:array_position="11" oils_persist:virtual="false"  reporter:datatype="org_unit"/>
                        <field reporter:label="Bib Record" name="record" oils_obj:array_position="12" oils_persist:virtual="false" reporter:datatype="link"/>
                        <field reporter:label="Notes" name="notes" oils_obj:array_position="13" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="URI Maps" name="uri_maps" oils_obj:array_position="14" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="URIs" name="uris" oils_obj:array_position="15" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
@@ -1524,6 +1526,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
                        <link field="notes" reltype="has_many" key="call_number" map="" class="acnn"/>
                        <link field="copies" reltype="has_many" key="call_number" map="" class="acp"/>
+                       <link field="uris" reltype="has_many" key="call_number" map="uri" class="auricnm"/>
+                       <link field="uri_maps" reltype="has_many" key="call_number" map="" class="auricnm"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
@@ -1544,8 +1548,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Label" name="label" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="text"/>
                        <field reporter:label="Use Information" name="use_restriction" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="text"/>
                        <field reporter:label="Active" name="active" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="bool"/>
+                       <field reporter:label="Call Number Maps" name="call_number_maps" oils_obj:array_position="8" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Call Numbers" name="call_numbers" oils_obj:array_position="9" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
-               <links/>
+               <links>
+                       <link field="call_numbers" reltype="has_many" key="uri" map="call_number" class="auricnm"/>
+                       <link field="call_number_maps" reltype="has_many" key="uri" map="" class="auricnm"/>
+        </links>
        </class>
        <class id="auricnm" controller="open-ils.cstore" oils_obj:fieldmapper="asset::uri_call_number_map" oils_persist:tablename="asset.uri_call_number_map" reporter:label="Electronic Access URI to Call Number Map">
                <fields oils_persist:primary="id" oils_persist:sequence="asset.uri_call_number_map_id_seq">
index cf7c189..7ed9187 100644 (file)
@@ -267,7 +267,7 @@ sub cn_browse {
        my $orgs = $_storage->request(
                "open-ils.cstore.direct.actor.org_unit.search",
                $o_search,
-               { flesh         => 3,
+               { flesh         => 100,
                  flesh_fields  => { aou        => [qw/children/] }
                }
        )->gather(1);
@@ -362,7 +362,7 @@ sub new_books_by_item {
                my $orgs = $_storage->request(
                        "open-ils.cstore.direct.actor.org_unit.search",
                        { shortname => $ou },
-                       { flesh         => 10,
+                       { flesh         => 100,
                          flesh_fields  => { aou        => [qw/children/] }
                        }
                )->gather(1);
@@ -533,7 +533,7 @@ sub tag_sf_browse {
                my $orgs = $_storage->request(
                        "open-ils.cstore.direct.actor.org_unit.search",
                        { shortname => $ou },
-                       { flesh         => 10,
+                       { flesh         => 100,
                          flesh_fields  => { aou        => [qw/children/] }
                        }
                )->gather(1);
@@ -651,9 +651,53 @@ sub holding_data_formats {
 }
 __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acn.formats', api_level => 1 );
 __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acp.formats', api_level => 1 );
+__PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.auri.formats', api_level => 1 );
 
 
 __PACKAGE__->register_method(
+       method    => 'retrieve_uri',
+       api_name  => 'open-ils.supercat.auri.marcxml.retrieve',
+       api_level => 1,
+       argc      => 1,
+       signature =>
+               { desc     => <<"                 DESC",
+Returns a fleshed call number object
+                 DESC
+                 params   =>
+                       [
+                               { name => 'uri_id',
+                                 desc => 'An OpenILS asset::uri id',
+                                 type => 'number' },
+                       ],
+                 'return' =>
+                       { desc => 'fleshed uri',
+                         type => 'object' }
+               }
+);
+sub retrieve_uri {
+       my $self = shift;
+       my $client = shift;
+       my $cpid = shift;
+       my $args = shift;
+
+    return OpenILS::Application::SuperCat::unAPI
+        ->new(OpenSRF::AppSession
+            ->create( 'open-ils.cstore' )
+            ->request(
+               "open-ils.cstore.direct.asset.uri.retrieve",
+                   $cpid,
+                   { flesh             => 10,
+                         flesh_fields  => {
+                                               auri    => [qw/call_number_maps/],
+                                               acn         => [qw/owning_lib record/],
+                                               auricnm => [qw/uri/],
+                               }
+                   })
+            ->gather(1))
+        ->as_xml($args);
+}
+
+__PACKAGE__->register_method(
        method    => 'retrieve_copy',
        api_name  => 'open-ils.supercat.acp.marcxml.retrieve',
        api_level => 1,
@@ -728,9 +772,10 @@ sub retrieve_callnumber {
             ->request(
                "open-ils.cstore.direct.asset.call_number.retrieve",
                    $cnid,
-                   { flesh             => 2,
+                   { flesh             => 5,
                          flesh_fields  => {
-                                               acn     => [qw/owning_lib record copies/],
+                                               acn     => [qw/owning_lib record copies uri_maps/],
+                                               auricnm => [qw/uri/],
                                                acp     => [qw/location status circ_lib stat_cat_entries notes/],
                                }
                    })
@@ -792,7 +837,7 @@ sub basic_record_holdings {
        my $orgs = $_storage->request(
                "open-ils.cstore.direct.actor.org_unit.search",
                $o_search,
-               { flesh         => 3,
+               { flesh         => 100,
                  flesh_fields  => { aou        => [qw/children/] }
                }
        )->gather(1);
@@ -871,7 +916,8 @@ sub new_record_holdings {
                { flesh         => 5,
                  flesh_fields  => {
                                        bre     => [qw/call_numbers/],
-                                       acn     => [qw/copies owning_lib/],
+                                       acn     => [qw/copies owning_lib uri_maps/],
+                                       auricnm => [qw/uri/],
                                        acp     => [qw/location status circ_lib stat_cat_entries notes/],
                                        asce    => [qw/stat_cat/],
                                }
@@ -886,7 +932,7 @@ sub new_record_holdings {
        my $orgs = $_storage->request(
                "open-ils.cstore.direct.actor.org_unit.search",
                $o_search,
-               { flesh         => 3,
+               { flesh         => 100,
                  flesh_fields  => { aou        => [qw/children/] }
                }
        )->gather(1);
@@ -911,6 +957,10 @@ sub new_record_holdings {
                        $found = 1;
                        last;
                }
+
+        if (!$found && ref($cn->uri_maps) && @{$cn->uri_maps}) {
+               $found = 1 if (grep {$cn->owning_lib->id == $_} @ou_ids);
+        }
                next unless $found;
 
         $client->respond(
@@ -1604,6 +1654,38 @@ sub obj {
     return $self->{obj};
 }
 
+package OpenILS::Application::SuperCat::unAPI::auri;
+use base qw/OpenILS::Application::SuperCat::unAPI/;
+
+sub as_xml {
+    my $self = shift;
+    my $args = shift;
+
+    my $xml = '<uri xmlns="http://open-ils.org/spec/holdings/v1" ';
+    $xml .= 'id="tag:open-ils.org:asset-uri/' . $self->obj->id . '" ';
+    $xml .= 'use_restriction="' . $self->escape( $self->obj->use_restriction ) . '" ';
+    $xml .= 'label="' . $self->escape( $self->obj->label ) . '" ';
+    $xml .= 'href="' . $self->escape( $self->obj->href ) . '">';
+
+    if (!$args->{no_volumes} && ref($self->obj->call_number_maps) && @{ $self->obj->call_number_maps }) {
+        $xml .= '<volumes>' . join(
+            '',
+            map {
+                OpenILS::Application::SuperCat::unAPI
+                    ->new( $_->call_number )
+                    ->as_xml({ %$args, no_uris=>1, no_copies=>1 })
+            } @{ $self->obj->call_number_maps }
+        ) . '</volumes>';
+
+    } else {
+        $xml .= '<volumes/>';
+    }
+
+    $xml .= '</uri>';
+
+    return $xml;
+}
+
 package OpenILS::Application::SuperCat::unAPI::acn;
 use base qw/OpenILS::Application::SuperCat::unAPI/;
 
@@ -1631,6 +1713,20 @@ sub as_xml {
         $xml .= '<copies/>';
     }
 
+    if (!$args->{no_uris} && ref($self->obj->uri_maps) && @{ $self->obj->uri_maps }) {
+        $xml .= '<uris>' . join(
+            '',
+            map {
+                OpenILS::Application::SuperCat::unAPI
+                    ->new( $_->uri )
+                    ->as_xml({ %$args, no_volumes=>1 })
+            } @{ $self->obj->uri_maps }
+        ) . '</uris>';
+
+    } else {
+        $xml .= '<uris/>';
+    }
+
 
     $xml .= '<owning_lib xmlns="http://open-ils.org/spec/actors/v1" ';
     $xml .= 'id="tag:open-ils.org:actor-org_unit/' . $self->obj->owning_lib->id . '" ';
@@ -1664,11 +1760,12 @@ sub as_xml {
 
     $xml .= '<status>' . $self->escape( $self->obj->status->name  ) . '</status>';
     $xml .= '<location>' . $self->escape( $self->obj->location->name  ) . '</location>';
+    $xml .= '<circlib>' . $self->escape( $self->obj->circ_lib->name  ) . '</circlib>';
 
-    $xml .= '<circlib xmlns="http://open-ils.org/spec/actors/v1" ';
+    $xml .= '<circ_lib xmlns="http://open-ils.org/spec/actors/v1" ';
     $xml .= 'id="tag:open-ils.org:actor-org_unit/' . $self->obj->circ_lib->id . '" ';
     $xml .= 'shortname="'.$self->escape( $self->obj->circ_lib->shortname ) .'" ';
-    $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'">' . $self->escape( $self->obj->circ_lib->name  ) . '</circlib>';
+    $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'"/>';
 
        $xml .= "<copy_notes>";
        if (ref($self->obj->notes) && $self->obj->notes) {
index 7d60d16..097c71d 100644 (file)
@@ -352,6 +352,7 @@ sub unapi {
                $type = 'call_number' if ($1 =~ /^call_number/o);
                $type = 'acp' if ($1 =~ /^asset-copy/o);
                $type = 'acn' if ($1 =~ /^asset-call_number/o);
+               $type = 'auri' if ($1 =~ /^asset-uri/o);
                $command = 'retrieve';
                $command = 'browse' if ($type eq 'call_number');
        }
@@ -424,7 +425,7 @@ sub unapi {
                print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id&l=$lib_id&d=$lib_depth\n\n"
                        if ($type eq 'record');
                return 302;
-       } elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format) && ($type ne 'acn' && $type ne 'acp')) {
+       } elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format) && ($type ne 'acn' && $type ne 'acp' && $type ne 'auri')) {
                my $feed = create_record_feed(
                        $type,
                        $format => [ $id ],
index 5483986..3eb3e38 100644 (file)
@@ -28,7 +28,6 @@ if(!dojo._hasResource["openils.BibTemplate"]) {
 
         render : function() {
             var all_slots = dojo.query('*[type^=opac/slot-data]', this.root);
-            var rec = location.href.split('?')[1];
         
             var slots = {};
             dojo.forEach(all_slots, function(s){
@@ -51,6 +50,8 @@ if(!dojo._hasResource["openils.BibTemplate"]) {
                         load: function (bib) {
 
                             dojo.forEach(slot_list, function (slot) {
+                                var joiner = slot.getAttribute('join') || ' ';
+
                                 var slot_handler = dojo.query(
                                     'script[type=opac/slot-format]',
                                     slot
@@ -65,7 +66,7 @@ if(!dojo._hasResource["openils.BibTemplate"]) {
                                 slot.innerHTML = dojo.query(
                                     slot.getAttribute('query'),
                                     bib
-                                ).map(slot_handler).join(' ');
+                                ).map(slot_handler).join(joiner);
                 
                                 delete(slot_handler);