[open-ils-commits] [GIT] Evergreen ILS branch master updated. 32e32a379533faa0ec4d3ba73336b833cd7c2c5c

Evergreen Git git at git.evergreen-ils.org
Tue Feb 14 23:45:39 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  32e32a379533faa0ec4d3ba73336b833cd7c2c5c (commit)
       via  30e813fd9efaaccd6b76e556a6c76f4874915e9b (commit)
       via  0fa422e12f7ef76f299345ea307d861510fdcc23 (commit)
       via  dc8fb1f9a481131c8e1b55fc34d075e46640c29e (commit)
       via  3acb984032d5980fb17c697759112b278a11f621 (commit)
      from  5b653d705aee0718999720a64cedff0b93217eab (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 32e32a379533faa0ec4d3ba73336b833cd7c2c5c
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Tue Feb 14 23:42:59 2017 -0500

    LP#1629108: Stamping upgrade script for reroute metarecord constituent results
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 138d8b4..08fc5bc 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1013', :eg_version); -- csharp/miker/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1014', :eg_version); -- Bmagic/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql b/Open-ILS/src/sql/Pg/upgrade/1014.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
rename to Open-ILS/src/sql/Pg/upgrade/1014.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
index 3bdb151..14e9ebf 100755
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1014.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
@@ -1,7 +1,6 @@
-
 BEGIN;
 
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('1014', :eg_version);
 
 CREATE OR REPLACE FUNCTION unapi.mmr_mra (
     obj_id BIGINT,

commit 30e813fd9efaaccd6b76e556a6c76f4874915e9b
Author: blake <blake at mobiusconsortium.org>
Date:   Tue Feb 14 09:42:27 2017 -0600

    LP1629108 setup "Do_cache" bit on the function call for production use
    
    Flipped the do_cache bit from false to true.
    
    Signed-off-by: blake <blake at mobiusconsortium.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index ad057d3..40d63fb 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -516,7 +516,7 @@ sub load_rresults {
                 my $ses = OpenSRF::AppSession->create('open-ils.search');
                 $self->timelog("Firing off the multiclass query");
                 $args->{from_metarecord} = $rec_id;
-                my $req = $ses->request($method, $args, $query, 0);
+                my $req = $ses->request($method, $args, $query, 1);
                 $meta_results = $req->gather(1);
                 $self->timelog("Returned from the multiclass query");
 

commit 0fa422e12f7ef76f299345ea307d861510fdcc23
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Tue Feb 7 23:52:49 2017 -0500

    LP#1629108: Release notes for metarecord search improvements
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/metarecord_reroute.adoc b/docs/RELEASE_NOTES_NEXT/OPAC/metarecord_reroute.adoc
new file mode 100644
index 0000000..0a753de
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/OPAC/metarecord_reroute.adoc
@@ -0,0 +1,9 @@
+Metarecord Search Improvements
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+This release brings several improvement to the Group Formats and Editions
+search. 
+
+ * Limiters on the advanced search page can now be successfully applied to 
+Group Formats and Editions searches,
+ * Electronic resources are now retrievable through these searches,
+ * Paged navigation has improved.

commit dc8fb1f9a481131c8e1b55fc34d075e46640c29e
Author: blake <blake at mobiusconsortium.org>
Date:   Thu Feb 9 21:14:24 2017 -0600

    LP1629108 Finalizing Search.pm removing if block
    
    For ease of diffing, I left the old if block in place because removing it would
    cause all of the lines to show changes when in fact it was just spacing. This commit
    simply removes the if block and the spacing is the only change.
    
    Signed-off-by: blake <blake at mobiusconsortium.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 2d7a8d8..ad057d3 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -412,52 +412,41 @@ sub load_rresults {
     # the query string, not special args.
     my $args = {'limit' => $limit, 'offset' => $offset};
 
-    if (0) { #($metarecord) {
-        my $bre_ids = $self->recs_from_metarecord(
-            $metarecord, $ctx->{search_ou}, $depth);
-       
-        # force the metarecord result blob to match the format of regular search results
-        $results->{ids} = [map { [$_] } @$bre_ids];
-        $results->{count} = scalar(@{$results->{ids}});
+    return Apache2::Const::OK unless $query;
 
-    } else {
-
-        return Apache2::Const::OK unless $query;
-
-        if ($tag_circs) {
-            $args->{tag_circulated_records} = 1;
-            $args->{authtoken} = $self->editor->authtoken;
-        }
-        $args->{from_metarecord} = $metarecord if $metarecord;
+    if ($tag_circs) {
+        $args->{tag_circulated_records} = 1;
+        $args->{authtoken} = $self->editor->authtoken;
+    }
+    $args->{from_metarecord} = $metarecord if $metarecord;
 
-        # Stuff these into the TT context so that templates can use them in redrawing forms
-        $ctx->{user_query} = $user_query;
-        $ctx->{processed_search_query} = $query;
+    # Stuff these into the TT context so that templates can use them in redrawing forms
+    $ctx->{user_query} = $user_query;
+    $ctx->{processed_search_query} = $query;
 
-        $query = "$_ $query" for @facets;
+    $query = "$_ $query" for @facets;
 
-        my $ltag = $is_meta ? '[mmr search]' : '[bre search]';
-        $logger->activity("EGWeb: $ltag $query");
+    my $ltag = $is_meta ? '[mmr search]' : '[bre search]';
+    $logger->activity("EGWeb: $ltag $query");
 
-        try {
+    try {
 
-            my $method = 'open-ils.search.biblio.multiclass.query';
-            $method .= '.staff' if $ctx->{is_staff};
-            $method =~ s/biblio/metabib/ if $is_meta;
+        my $method = 'open-ils.search.biblio.multiclass.query';
+        $method .= '.staff' if $ctx->{is_staff};
+        $method =~ s/biblio/metabib/ if $is_meta;
 
-            my $ses = OpenSRF::AppSession->create('open-ils.search');
+        my $ses = OpenSRF::AppSession->create('open-ils.search');
 
-            $self->timelog("Firing off the multiclass query");
-            my $req = $ses->request($method, $args, $query, 1);
-            $results = $req->gather(1);
-            $self->timelog("Returned from the multiclass query");
+        $self->timelog("Firing off the multiclass query");
+        my $req = $ses->request($method, $args, $query, 1);
+        $results = $req->gather(1);
+        $self->timelog("Returned from the multiclass query");
 
-        } catch Error with {
-            my $err = shift;
-            $logger->error("multiclass search error: $err");
-            $results = {count => 0, ids => []};
-        };
-    }
+    } catch Error with {
+        my $err = shift;
+        $logger->error("multiclass search error: $err");
+        $results = {count => 0, ids => []};
+    };
 
     my $rec_ids = [map { $_->[0] } @{$results->{ids}}];
 

commit 3acb984032d5980fb17c697759112b278a11f621
Author: blake <blake at mobiusconsortium.org>
Date:   Mon Feb 13 15:19:45 2017 -0600

    LP1629108 metarecord_constituent_result_reroute
    
    This patch will route the metasearch logic through the "standard" search logic
    in order to leverage the heavy use of filters and other features.
    
    A column is introduced to unapi.mmr_mr to include the constituent bibs in the
    return. A tweak was required in the template toolkit code to take advantage of the
    new payload. This enables TT to decide which icons should be displayed when search
    results are filtered.
    
    Signed-off-by: blake <blake at mobiusconsortium.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
index 4c386e5..0f7c1f0 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
@@ -674,6 +674,7 @@ __PACKAGE__->add_search_filter( 'skip_check' );
 __PACKAGE__->add_search_filter( 'superpage' );
 __PACKAGE__->add_search_filter( 'superpage_size' );
 __PACKAGE__->add_search_filter( 'estimation_strategy' );
+__PACKAGE__->add_search_filter( 'from_metarecord' );
 __PACKAGE__->add_search_modifier( 'available' );
 __PACKAGE__->add_search_modifier( 'staff' );
 __PACKAGE__->add_search_modifier( 'deleted' );
@@ -1359,6 +1360,12 @@ sub flatten {
                            . join(',', map { $self->QueryParser->quote_value($_) } @{ $filter->args })
                            . "), false)";
                 }
+            } elsif ($filter->name eq 'from_metarecord') {
+                if (@{$filter->args} > 0) {
+                    my $key = 'm.metarecord';
+                    $where .= $joiner if $where ne '';
+                    $where .= "$key ${NOT}IN (" . join(',', map { $self->QueryParser->quote_value($_) } @{$filter->args}) . ')';
+                }
             }
         }
     }
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
index df5d03b..92ba04c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
@@ -3281,6 +3281,7 @@ sub query_parser_fts_wrapper {
     $query = "superpage($args{superpage}) $query" if ($args{superpage});
     $query = "offset($args{offset}) $query" if ($args{offset});
     $query = "#metarecord $query" if ($self->api_name =~ /metabib/);
+    $query = "from_metarecord($args{from_metarecord}) $query" if ($args{from_metarecord});
     $query = "#available $query" if ($args{available});
     $query = "#descending $query" if ($args{sort_dir} && $args{sort_dir} =~ /^d/i);
     $query = "#staff $query" if ($self->api_name =~ /staff/);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index c5a5307..2d7a8d8 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -408,8 +408,11 @@ sub load_rresults {
             $ctx->{saved_searches} = $list;
         }
     }
+    # Limit and offset will stay here. Everything else should be part of
+    # the query string, not special args.
+    my $args = {'limit' => $limit, 'offset' => $offset};
 
-    if ($metarecord) {
+    if (0) { #($metarecord) {
         my $bre_ids = $self->recs_from_metarecord(
             $metarecord, $ctx->{search_ou}, $depth);
        
@@ -421,14 +424,11 @@ sub load_rresults {
 
         return Apache2::Const::OK unless $query;
 
-        # Limit and offset will stay here. Everything else should be part of
-        # the query string, not special args.
-        my $args = {'limit' => $limit, 'offset' => $offset};
-
         if ($tag_circs) {
             $args->{tag_circulated_records} = 1;
             $args->{authtoken} = $self->editor->authtoken;
         }
+        $args->{from_metarecord} = $metarecord if $metarecord;
 
         # Stuff these into the TT context so that templates can use them in redrawing forms
         $ctx->{user_query} = $user_query;
@@ -520,10 +520,25 @@ sub load_rresults {
         push(@{$ctx->{records}}, $rec);
 
         if ($is_meta) {
-            # collect filtered, constituent records count for each MR
-            my $bre_ids = $self->recs_from_metarecord(
-                $rec_id, $ctx->{search_ou}, $depth);
-            $rec->{mr_constituent_count} = scalar(@$bre_ids);
+            my $meta_results;
+            try {
+                my $method = 'open-ils.search.biblio.multiclass.query';
+                $method .= '.staff' if $ctx->{is_staff};
+                my $ses = OpenSRF::AppSession->create('open-ils.search');
+                $self->timelog("Firing off the multiclass query");
+                $args->{from_metarecord} = $rec_id;
+                my $req = $ses->request($method, $args, $query, 0);
+                $meta_results = $req->gather(1);
+                $self->timelog("Returned from the multiclass query");
+
+            } catch Error with {
+                my $err = shift;
+                $logger->error("multiclass search error: $err");
+                $meta_results = {count => 0, ids => []};
+            };
+            my $meta_rec_ids = [map { $_->[0] } @{$meta_results->{ids}}];
+            $rec->{mr_constituent_count} = $meta_results->{count};
+            $rec->{mr_constituent_ids} = $meta_rec_ids;
         }
     }
 
diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
index c7014ce..154c284 100644
--- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql
+++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
@@ -1387,12 +1387,13 @@ CREATE OR REPLACE FUNCTION unapi.mmr_mra (
                             rad.composite,
                             rad.multi,
                             rad.filter,
-                            rad.sorter
+                            rad.sorter,
+                            cmra.source_list
                         ),
                         cmra.value
                     )
               FROM  (
-                SELECT DISTINCT aid, attr, value
+                SELECT DISTINCT aid, attr, value, STRING_AGG(x.id::TEXT, ',') AS source_list
                   FROM (
                     SELECT  v.source AS id,
                             c.id AS aid,
@@ -1402,6 +1403,7 @@ CREATE OR REPLACE FUNCTION unapi.mmr_mra (
                             JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) )
                     ) AS x
                     JOIN sourcelist ON (x.id = sourcelist.source)
+                    GROUP BY 1, 2, 3
                 ) AS cmra
                 JOIN config.record_attr_definition rad ON (cmra.attr = rad.name)
                 UNION ALL
diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1629108_metarecord_constituent_result_reroute.pg b/Open-ILS/src/sql/Pg/t/regress/lp1629108_metarecord_constituent_result_reroute.pg
new file mode 100755
index 0000000..2a86875
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/regress/lp1629108_metarecord_constituent_result_reroute.pg
@@ -0,0 +1,131 @@
+-- Format the output for nice TAP.
+\pset format unaligned
+\pset tuples_only true
+\pset pager
+
+-- Revert all changes on failure.
+\set ON_ERROR_ROLLBACK 1
+\set ON_ERROR_STOP true
+\set QUIET 1
+
+-- Load the TAP functions.
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(2);
+
+-- Replace the function
+CREATE OR REPLACE FUNCTION unapi.mmr_mra (
+    obj_id BIGINT,
+    format TEXT,
+    ename TEXT,
+    includes TEXT[],
+    org TEXT,
+    depth INT DEFAULT NULL,
+    slimit HSTORE DEFAULT NULL,
+    soffset HSTORE DEFAULT NULL,
+    include_xmlns BOOL DEFAULT TRUE,
+    pref_lib INT DEFAULT NULL
+) RETURNS XML AS $F$
+    SELECT  XMLELEMENT(
+        name attributes,
+        XMLATTRIBUTES(
+            CASE WHEN $9 THEN 'http://open-ils.org/spec/indexing/v1' ELSE NULL END AS xmlns,
+            'tag:open-ils.org:U2 at mmr/' || $1 AS metarecord
+        ),
+        (SELECT XMLAGG(foo.y)
+          FROM (
+            WITH sourcelist AS (
+                WITH aou AS (SELECT COALESCE(id, (evergreen.org_top()).id) AS id
+                    FROM actor.org_unit WHERE shortname = $5 LIMIT 1)
+                SELECT source
+                FROM metabib.metarecord_source_map, aou
+                WHERE metarecord = $1 AND (
+                    EXISTS (
+                        SELECT 1 FROM asset.opac_visible_copies
+                        WHERE record = source AND circ_lib IN (
+                            SELECT id FROM actor.org_unit_descendants(aou.id, $6))
+                        LIMIT 1
+                    )
+                    OR EXISTS (SELECT 1 FROM located_uris(source, aou.id, $10) LIMIT 1)
+                )
+            )
+            SELECT  cmra.aid,
+                    XMLELEMENT(
+                        name field,
+                        XMLATTRIBUTES(
+                            cmra.attr AS name,
+                            cmra.value AS "coded-value",
+                            cmra.aid AS "cvmid",
+                            rad.composite,
+                            rad.multi,
+                            rad.filter,
+                            rad.sorter,
+                            cmra.source_list
+                        ),
+                        cmra.value
+                    )
+              FROM  (
+                SELECT DISTINCT aid, attr, value, STRING_AGG(x.id::TEXT, ',') AS source_list
+                  FROM (
+                    SELECT  v.source AS id,
+                            c.id AS aid,
+                            c.ctype AS attr,
+                            c.code AS value
+                      FROM  metabib.record_attr_vector_list v
+                            JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) )
+                    ) AS x
+                    JOIN sourcelist ON (x.id = sourcelist.source)
+                    GROUP BY 1, 2, 3 
+                ) AS cmra
+                JOIN config.record_attr_definition rad ON (cmra.attr = rad.name)
+                UNION ALL
+            SELECT  umra.aid,
+                    XMLELEMENT(
+                        name field,
+                        XMLATTRIBUTES(
+                            umra.attr AS name,
+                            rad.composite,
+                            rad.multi,
+                            rad.filter,
+                            rad.sorter
+                        ),
+                        umra.value
+                    )
+              FROM  (
+                SELECT DISTINCT aid, attr, value
+                  FROM (
+                    SELECT  v.source AS id,
+                            m.id AS aid,
+                            m.attr AS attr,
+                            m.value AS value
+                      FROM  metabib.record_attr_vector_list v
+                            JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+                    ) AS x
+                    JOIN sourcelist ON (x.id = sourcelist.source)
+                ) AS umra
+                JOIN config.record_attr_definition rad ON (umra.attr = rad.name)
+                ORDER BY 1
+
+            )foo(id,y)
+        )
+    )
+$F$ LANGUAGE SQL STABLE;
+
+-- Now make sure that the a query against it doesn't break
+PREPARE thrower AS select mmr_mra::varchar from unapi.mmr_mra
+(15,'','',null::text[],'CONS',0,null::HSTORE,null::HSTORE,true,1);
+
+SELECT performs_ok( 'thrower',250,'Generic check for unapi.mmr_mra breakage' ); 
+
+-- Make sure that the function returns the new XML property source_list
+SELECT is(  
+(
+select mmr_mra::varchar ~ 'source_list="15,16,17"' from unapi.mmr_mra
+(15,'','',null::text[],'CONS',0,null::HSTORE,null::HSTORE,true,1)
+), true, 'unapi.mmr_mra results have source_list="15,16,17sfaf"' );
+
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;
\ No newline at end of file
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
new file mode 100755
index 0000000..3bdb151
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.metarecord_constituents_search_result_page_should_use_standard_search_code.sql
@@ -0,0 +1,104 @@
+
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION unapi.mmr_mra (
+    obj_id BIGINT,
+    format TEXT,
+    ename TEXT,
+    includes TEXT[],
+    org TEXT,
+    depth INT DEFAULT NULL,
+    slimit HSTORE DEFAULT NULL,
+    soffset HSTORE DEFAULT NULL,
+    include_xmlns BOOL DEFAULT TRUE,
+    pref_lib INT DEFAULT NULL
+) RETURNS XML AS $F$
+    SELECT  XMLELEMENT(
+        name attributes,
+        XMLATTRIBUTES(
+            CASE WHEN $9 THEN 'http://open-ils.org/spec/indexing/v1' ELSE NULL END AS xmlns,
+            'tag:open-ils.org:U2 at mmr/' || $1 AS metarecord
+        ),
+        (SELECT XMLAGG(foo.y)
+          FROM (
+            WITH sourcelist AS (
+                WITH aou AS (SELECT COALESCE(id, (evergreen.org_top()).id) AS id
+                    FROM actor.org_unit WHERE shortname = $5 LIMIT 1)
+                SELECT source
+                FROM metabib.metarecord_source_map, aou
+                WHERE metarecord = $1 AND (
+                    EXISTS (
+                        SELECT 1 FROM asset.opac_visible_copies
+                        WHERE record = source AND circ_lib IN (
+                            SELECT id FROM actor.org_unit_descendants(aou.id, $6))
+                        LIMIT 1
+                    )
+                    OR EXISTS (SELECT 1 FROM located_uris(source, aou.id, $10) LIMIT 1)
+                )
+            )
+            SELECT  cmra.aid,
+                    XMLELEMENT(
+                        name field,
+                        XMLATTRIBUTES(
+                            cmra.attr AS name,
+                            cmra.value AS "coded-value",
+                            cmra.aid AS "cvmid",
+                            rad.composite,
+                            rad.multi,
+                            rad.filter,
+                            rad.sorter,
+                            cmra.source_list
+                        ),
+                        cmra.value
+                    )
+              FROM  (
+                SELECT DISTINCT aid, attr, value, STRING_AGG(x.id::TEXT, ',') AS source_list
+                  FROM (
+                    SELECT  v.source AS id,
+                            c.id AS aid,
+                            c.ctype AS attr,
+                            c.code AS value
+                      FROM  metabib.record_attr_vector_list v
+                            JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) )
+                    ) AS x
+                    JOIN sourcelist ON (x.id = sourcelist.source)
+                    GROUP BY 1, 2, 3
+                ) AS cmra
+                JOIN config.record_attr_definition rad ON (cmra.attr = rad.name)
+                UNION ALL
+            SELECT  umra.aid,
+                    XMLELEMENT(
+                        name field,
+                        XMLATTRIBUTES(
+                            umra.attr AS name,
+                            rad.composite,
+                            rad.multi,
+                            rad.filter,
+                            rad.sorter
+                        ),
+                        umra.value
+                    )
+              FROM  (
+                SELECT DISTINCT aid, attr, value
+                  FROM (
+                    SELECT  v.source AS id,
+                            m.id AS aid,
+                            m.attr AS attr,
+                            m.value AS value
+                      FROM  metabib.record_attr_vector_list v
+                            JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+                    ) AS x
+                    JOIN sourcelist ON (x.id = sourcelist.source)
+                ) AS umra
+                JOIN config.record_attr_definition rad ON (umra.attr = rad.name)
+                ORDER BY 1
+
+            )foo(id,y)
+        )
+    )
+$F$ LANGUAGE SQL STABLE;
+  
+COMMIT;
+
diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2
index 50611fc..a01ac50 100644
--- a/Open-ILS/src/templates/opac/parts/misc_util.tt2
+++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2
@@ -602,18 +602,36 @@
                 NEXT IF ccvm.opac_visible == 'f';
 
                 format = {};
-                type = ccvm.code.remove('-'); # blu-ray to bluray
-                format.label = ccvm.search_label || ccvm.value;
-                format.icon = PROCESS get_ccvm_icon ccvm=ccvm;
-                format.itemtype = schema_typemap.$type || 'CreativeWork';
-
-                args.all_formats.push(format); # metarecords want all formats
-
-                IF !args.format_label;
-                    # use the first format as the default
-                    args.format_label = format.label; 
-                    args.schema.itemtype = format.itemtype;
-                    args.format_icon = format.icon;
+                this_icon_source = node.getAttribute('source_list');
+                including = 'F';
+                # Just display everything if we don't have the data
+                IF NOT args.mr_constituent_ids OR NOT this_icon_source;
+                    including = 'T';
+                # We have an array of search-included bib IDs and we have the bib ID that this icon belongs to
+                ELSE;
+                    FOR mr_constituent_id IN args.mr_constituent_ids;
+                        IF this_icon_source.split(',').grep('^' _ mr_constituent_id _ '$' ).size;
+                            # This bib appears to be in the array of filtered bibs
+                            including = 'T';
+                        END;
+                    END;
+                END;
+                IF including == 'T';
+                    type = ccvm.code.remove('-'); # blu-ray to bluray
+                    format.label = ccvm.search_label || ccvm.value;
+                    format.icon = PROCESS get_ccvm_icon ccvm=ccvm;
+                    format.itemtype = schema_typemap.$type || 'CreativeWork';
+                    format.search_format = ccvm.code;
+                    format.source_bibs = this_icon_source.split(',');
+
+                    args.all_formats.push(format); # metarecords want all formats
+
+                    IF !args.format_label;
+                        # use the first format as the default
+                        args.format_label = format.label;
+                        args.schema.itemtype = format.itemtype;
+                        args.format_icon = format.icon;
+                    END;
                 END;
             END;
         END;
diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2
index f4ff94a..8f59022 100644
--- a/Open-ILS/src/templates/opac/parts/result/table.tt2
+++ b/Open-ILS/src/templates/opac/parts/result/table.tt2
@@ -66,7 +66,12 @@
                     </thead>
                     <tbody id="result_table">
                     [%  FOR rec IN ctx.records;
-                            attrs = {marc_xml => rec.marc_xml};
+                            attrs = {};
+                            attrs.marc_xml = rec.marc_xml;
+                            attrs.mr_constituent_ids = [];
+                            FOREACH mr_constituent_id IN rec.mr_constituent_ids;
+                                attrs.mr_constituent_ids.push(mr_constituent_id);
+                            END;
                             PROCESS get_marc_attrs args=attrs;
                             IF show_detail_view;
                                 attrs.title = attrs.title_extended;

-----------------------------------------------------------------------

Summary of changes:
 .../Application/Storage/Driver/Pg/QueryParser.pm   |    7 ++
 .../Application/Storage/Publisher/metabib.pm       |    1 +
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |   92 ++++++++++---------
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/990.schema.unapi.sql           |    6 +-
 ...29108_metarecord_constituent_result_reroute.pg} |   38 +++++++-
 ...esult_page_should_use_standard_search_code.sql} |   10 ++-
 Open-ILS/src/templates/opac/parts/misc_util.tt2    |   42 +++++++---
 Open-ILS/src/templates/opac/parts/result/table.tt2 |    7 ++-
 .../OPAC/metarecord_reroute.adoc                   |    9 ++
 10 files changed, 146 insertions(+), 68 deletions(-)
 copy Open-ILS/src/sql/Pg/{upgrade/0898.unique_mr_attrs.sql => t/regress/lp1629108_metarecord_constituent_result_reroute.pg} (76%)
 mode change 100644 => 100755
 copy Open-ILS/src/sql/Pg/upgrade/{0898.unique_mr_attrs.sql => 1014.metarecord_constituents_search_result_page_should_use_standard_search_code.sql} (92%)
 mode change 100644 => 100755
 create mode 100644 docs/RELEASE_NOTES_NEXT/OPAC/metarecord_reroute.adoc


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list