[open-ils-commits] [GIT] Evergreen ILS branch master updated. 8881b239bc517d6847e84511f414e621d27282f4

Evergreen Git git at git.evergreen-ils.org
Mon Aug 17 12:54:07 EDT 2015


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  8881b239bc517d6847e84511f414e621d27282f4 (commit)
       via  1e4a0d81a18ca43610ddd9e5c09682ab15c1a3b5 (commit)
       via  4f4c29b9cfba445c5b0818b6f14245448b58f913 (commit)
      from  2714518fb9312b5ed366e353e537cf5477cc40f1 (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 8881b239bc517d6847e84511f414e621d27282f4
Author: Ben Shum <bshum at biblio.org>
Date:   Mon Aug 17 12:53:30 2015 -0400

    LP#1178377: Add release note for new bib source variable in catalog
    
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/new-bib-source-variable.txt b/docs/RELEASE_NOTES_NEXT/OPAC/new-bib-source-variable.txt
new file mode 100644
index 0000000..a93837c
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/OPAC/new-bib-source-variable.txt
@@ -0,0 +1,7 @@
+New bib source variable for catalog customization
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+For bibliographic records, there is a "bib source" that can be
+associated with every record. This source is now available as a
+variable that can be used behind the scenes when customizing
+the online catalog. The new bib source variables do not present
+themselves in the catalog display by default.

commit 1e4a0d81a18ca43610ddd9e5c09682ab15c1a3b5
Author: Doug Kyle <dkyle at grpl.org>
Date:   Mon Apr 14 12:31:11 2014 -0400

    LP#1178377: Make bib source optional element from unapi.bre
    
    also add cbs (config bib source) to flesh arg of get_records_and_facets
    
    Change the baseline schema file
    
    Signed-off-by: Doug Kyle <dkyle at grpl.org>
    Signed-off-by: Ben Shum <bshum at biblio.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 19f3a25..ccd8471 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -477,7 +477,7 @@ sub load_rresults {
     my ($facets, @data) = $self->get_records_and_facets(
         $fetch_recs, $results->{facet_key}, 
         {
-            flesh => '{holdings_xml,mra,acp,acnp,acns,bmp}',
+            flesh => '{holdings_xml,mra,acp,acnp,acns,bmp,cbs}',
             site => $site,
             metarecord => $is_meta,
             depth => $depth,
@@ -616,7 +616,7 @@ sub item_barcode_shortcut {
 
         $self->timelog("Calling get_records_and_facets() for item_barcode");
         my ($facets, @data) = $self->get_records_and_facets(
-            $rec_ids, undef, {flesh => "{holdings_xml,mra,acnp,acns,bmp}"}
+            $rec_ids, undef, {flesh => "{holdings_xml,mra,acnp,acns,bmp,cbs}"}
         );
         $self->timelog("Returned from calling get_records_and_facets() for item_barcode");
 
@@ -735,7 +735,7 @@ sub marc_expert_search {
     $self->timelog("Calling get_records_and_facets() for MARC expert");
     my ($facets, @data) = $self->get_records_and_facets(
         $self->ctx->{ids}, undef, {
-            flesh => "{holdings_xml,mra,acnp,acns}",
+            flesh => "{holdings_xml,mra,acnp,acns,cbs}",
             pref_lib => $self->ctx->{pref_ou},
         }
     );
diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
index 3fbf8bb..b4da6a0 100644
--- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql
+++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
@@ -435,7 +435,7 @@ BEGIN
     SELECT * INTO me FROM biblio.record_entry WHERE id = obj_id;
 
     -- grab bib_source, if any
-    IF me.source IS NOT NULL THEN
+    IF ('cbs' = ANY (includes) AND me.source IS NOT NULL) THEN
         source := unapi.cbs(me.source,NULL,NULL,NULL,NULL);
     ELSE
         source := NULL::XML;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql
index 20ab5ae..17a4512 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql
@@ -72,7 +72,7 @@ BEGIN
     SELECT * INTO me FROM biblio.record_entry WHERE id = obj_id;
 
     -- grab bib_source, if any
-    IF me.source IS NOT NULL THEN
+    IF ('cbs' = ANY (includes) AND me.source IS NOT NULL) THEN
         source := unapi.cbs(me.source,NULL,NULL,NULL,NULL);
     ELSE
         source := NULL::XML;

commit 4f4c29b9cfba445c5b0818b6f14245448b58f913
Author: Jeff Davis <jdavis at sitka.bclibraries.ca>
Date:   Thu May 9 12:03:58 2013 -0700

    LP#1178377: Expose bib source in TPAC
    
    - Add unapi.cbs database function to grab config.bib_source data, and
      include this in unapi.bre XML output.
    - Make bib_source.id and bib_source.source available as record
      attributes in TPAC.
    
    Signed-off-by: Jeff Davis <jdavis at sitka.bclibraries.ca>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
index 8ad2ec4..3fbf8bb 100644
--- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql
+++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
@@ -406,6 +406,7 @@ DECLARE
     output  XML;
     hxml    XML;
     axml    XML;
+    source  XML;
 BEGIN
 
     IF org = '-' OR org IS NULL THEN
@@ -433,6 +434,13 @@ BEGIN
 
     SELECT * INTO me FROM biblio.record_entry WHERE id = obj_id;
 
+    -- grab bib_source, if any
+    IF me.source IS NOT NULL THEN
+        source := unapi.cbs(me.source,NULL,NULL,NULL,NULL);
+    ELSE
+        source := NULL::XML;
+    END IF;
+
     -- grab SVF if we need them
     IF ('mra' = ANY (includes)) THEN 
         axml := unapi.mra(obj_id,NULL,NULL,NULL,NULL);
@@ -462,6 +470,10 @@ BEGIN
 
     top_el := REGEXP_REPLACE(tmp_xml, E'^.*?<((?:\\S+:)?' || layout.holdings_element || ').*$', E'\\1');
 
+    IF source IS NOT NULL THEN
+        tmp_xml := REGEXP_REPLACE(tmp_xml, '</' || top_el || '>(.*?)$', source || '</' || top_el || E'>\\1');
+    END IF;
+
     IF axml IS NOT NULL THEN 
         tmp_xml := REGEXP_REPLACE(tmp_xml, '</' || top_el || '>(.*?)$', axml || '</' || top_el || E'>\\1');
     END IF;
@@ -1205,6 +1217,22 @@ CREATE OR REPLACE FUNCTION unapi.auri ( obj_id BIGINT, format TEXT,  ename TEXT,
           GROUP BY uri.id, use_restriction, href, label;
 $F$ LANGUAGE SQL STABLE;
 
+CREATE OR REPLACE FUNCTION unapi.cbs ( 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 ) RETURNS XML AS $F$
+    SELECT  XMLELEMENT(
+                name bib_source,
+                XMLATTRIBUTES(
+                    NULL AS xmlns, -- TODO needs equivalent to http://open-ils.org/spec/holdings/v1
+                    id AS ident,
+                    quality,
+                    transcendant,
+                    can_have_copies
+                ),
+                source
+            )
+      FROM  config.bib_source
+      WHERE id = $1;
+$F$ LANGUAGE SQL STABLE;
+
 CREATE OR REPLACE FUNCTION unapi.mra (
     obj_id BIGINT,
     format TEXT,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql
new file mode 100644
index 0000000..20ab5ae
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_include_bib_source.sql
@@ -0,0 +1,144 @@
+-- Include bib source in XML returned by unapi.bre.
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION unapi.cbs ( 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 ) RETURNS XML AS $F$
+    SELECT  XMLELEMENT(
+                name bib_source,
+                XMLATTRIBUTES(
+                    NULL AS xmlns, -- TODO needs equivalent to http://open-ils.org/spec/holdings/v1
+                    id AS ident,
+                    quality,
+                    transcendant,
+                    can_have_copies
+                ),
+                source
+            )
+      FROM  config.bib_source
+      WHERE id = $1;
+$F$ LANGUAGE SQL STABLE;
+
+CREATE OR REPLACE FUNCTION unapi.bre (
+    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$
+DECLARE
+    me      biblio.record_entry%ROWTYPE;
+    layout  unapi.bre_output_layout%ROWTYPE;
+    xfrm    config.xml_transform%ROWTYPE;
+    ouid    INT;
+    tmp_xml TEXT;
+    top_el  TEXT;
+    output  XML;
+    hxml    XML;
+    axml    XML;
+    source  XML;
+BEGIN
+
+    IF org = '-' OR org IS NULL THEN
+        SELECT shortname INTO org FROM evergreen.org_top();
+    END IF;
+
+    SELECT id INTO ouid FROM actor.org_unit WHERE shortname = org;
+
+    IF ouid IS NULL THEN
+        RETURN NULL::XML;
+    END IF;
+
+    IF format = 'holdings_xml' THEN -- the special case
+        output := unapi.holdings_xml( obj_id, ouid, org, depth, includes, slimit, soffset, include_xmlns);
+        RETURN output;
+    END IF;
+
+    SELECT * INTO layout FROM unapi.bre_output_layout WHERE name = format;
+
+    IF layout.name IS NULL THEN
+        RETURN NULL::XML;
+    END IF;
+
+    SELECT * INTO xfrm FROM config.xml_transform WHERE name = layout.transform;
+
+    SELECT * INTO me FROM biblio.record_entry WHERE id = obj_id;
+
+    -- grab bib_source, if any
+    IF me.source IS NOT NULL THEN
+        source := unapi.cbs(me.source,NULL,NULL,NULL,NULL);
+    ELSE
+        source := NULL::XML;
+    END IF;
+
+    -- grab SVF if we need them
+    IF ('mra' = ANY (includes)) THEN 
+        axml := unapi.mra(obj_id,NULL,NULL,NULL,NULL);
+    ELSE
+        axml := NULL::XML;
+    END IF;
+
+    -- grab holdings if we need them
+    IF ('holdings_xml' = ANY (includes)) THEN 
+        hxml := unapi.holdings_xml(obj_id, ouid, org, depth, evergreen.array_remove_item_by_value(includes,'holdings_xml'), slimit, soffset, include_xmlns, pref_lib);
+    ELSE
+        hxml := NULL::XML;
+    END IF;
+
+
+    -- generate our item node
+
+
+    IF format = 'marcxml' THEN
+        tmp_xml := me.marc;
+        IF tmp_xml !~ E'<marc:' THEN -- If we're not using the prefixed namespace in this record, then remove all declarations of it
+           tmp_xml := REGEXP_REPLACE(tmp_xml, ' xmlns:marc="http://www.loc.gov/MARC21/slim"', '', 'g');
+        END IF; 
+    ELSE
+        tmp_xml := oils_xslt_process(me.marc, xfrm.xslt)::XML;
+    END IF;
+
+    top_el := REGEXP_REPLACE(tmp_xml, E'^.*?<((?:\\S+:)?' || layout.holdings_element || ').*$', E'\\1');
+
+    IF source IS NOT NULL THEN
+        tmp_xml := REGEXP_REPLACE(tmp_xml, '</' || top_el || '>(.*?)$', source || '</' || top_el || E'>\\1');
+    END IF;
+
+    IF axml IS NOT NULL THEN 
+        tmp_xml := REGEXP_REPLACE(tmp_xml, '</' || top_el || '>(.*?)$', axml || '</' || top_el || E'>\\1');
+    END IF;
+
+    IF hxml IS NOT NULL THEN -- XXX how do we configure the holdings position?
+        tmp_xml := REGEXP_REPLACE(tmp_xml, '</' || top_el || '>(.*?)$', hxml || '</' || top_el || E'>\\1');
+    END IF;
+
+    IF ('bre.unapi' = ANY (includes)) THEN 
+        output := REGEXP_REPLACE(
+            tmp_xml,
+            '</' || top_el || '>(.*?)',
+            XMLELEMENT(
+                name abbr,
+                XMLATTRIBUTES(
+                    'http://www.w3.org/1999/xhtml' AS xmlns,
+                    'unapi-id' AS class,
+                    'tag:open-ils.org:U2 at bre/' || obj_id || '/' || org AS title
+                )
+            )::TEXT || '</' || top_el || E'>\\1'
+        );
+    ELSE
+        output := tmp_xml;
+    END IF;
+
+    output := REGEXP_REPLACE(output::TEXT,E'>\\s+<','><','gs')::XML;
+    RETURN output;
+END;
+$F$ LANGUAGE PLPGSQL 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 0af121c..8edeab5 100644
--- a/Open-ILS/src/templates/opac/parts/misc_util.tt2
+++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2
@@ -449,6 +449,11 @@
 
         ou_hiding_disabled = ctx.org_hiding_disabled();
 
+        # explicitly grabbing the first bib_source node, though there should be only one anyway
+        bib_source = xml.findnodes('//*[local-name()="bib_source"][1]');
+        args.bib_source.id = bib_source.getAttribute('ident');
+        args.bib_source.source = bib_source.textContent;
+
         FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
 
             # Check volume visibility - could push this into XPath

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

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |    6 +-
 Open-ILS/src/sql/Pg/990.schema.unapi.sql           |   28 ++++++++
 ...ql => XXXX.schema.unapi_include_bib_source.sql} |   67 ++++++++++++++++---
 Open-ILS/src/templates/opac/parts/misc_util.tt2    |    5 ++
 .../OPAC/new-bib-source-variable.txt               |    7 ++
 5 files changed, 99 insertions(+), 14 deletions(-)
 copy Open-ILS/src/sql/Pg/upgrade/{0514.schema.unapi2-strip-whitespace.sql => XXXX.schema.unapi_include_bib_source.sql} (59%)
 create mode 100644 docs/RELEASE_NOTES_NEXT/OPAC/new-bib-source-variable.txt


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list