[open-ils-commits] [GIT] Evergreen ILS branch master updated. 258c8c7b5e23c8b7fdb21d8c62920cd97840ccf1

Evergreen Git git at git.evergreen-ils.org
Thu Feb 18 11:08:53 EST 2016


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  258c8c7b5e23c8b7fdb21d8c62920cd97840ccf1 (commit)
       via  b3b433df95222a45e130eaf2b7617d7d1daa8594 (commit)
       via  8e60e0adc17ac6eb8b93a782b71106385bb509e8 (commit)
       via  f0ac3dab0206e5fafca8ed1d1cb491f8f2034406 (commit)
       via  b1892a6a34fb1b4b973b04cbdbd84ef50b3e845a (commit)
       via  4fbeac6d22deeeeb9d5998f072df8662f7ed2c68 (commit)
      from  fb65ec1881afc5c4d217b3a0502ad288b063f8db (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 258c8c7b5e23c8b7fdb21d8c62920cd97840ccf1
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Thu Feb 18 11:06:36 2016 -0500

    LP#1367926 Release notes addition
    
    Adding a bullet point to the release notes to further clarify the format that
    the URL should take.
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc b/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc
index f5ad26f..f4cc7c8 100644
--- a/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc
+++ b/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc
@@ -59,3 +59,6 @@ following form:
      to be a copy barcode rather than a copy ID; for example, in
      +tag::U2 at acp/ACQ140{acn,bre,mra}/-/0/barcode+, +ACQ140+ is
      meant to be a copy barcode.
+   * followed, optionally, by +&format=+ and the format in which the record
+     should be retrieved. If this part is omitted, the list of available 
+     formats will be retrieved. 

commit b3b433df95222a45e130eaf2b7617d7d1daa8594
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue Feb 16 14:20:06 2016 -0500

    LP#1367926: release notes
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc b/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc
new file mode 100644
index 0000000..f5ad26f
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc
@@ -0,0 +1,61 @@
+Expand unAPI API
+^^^^^^^^^^^^^^^^
+Evergreen's unAPI support now includes access to many more
+record types. For example, the following URL would fetch
+bib 267 in MODS32 along with holdings, volume, copy,
+and record attribute information:
+
+https://example.org/opac/extras/unapi?id=tag::U2@bre/267{holdings_xml,acn,acp,mra}&format=mods32
+
+To access the new unAPI features, the unAPI ID should have the
+following form:
+
+  * +tag::U2 at +
+  * followed by class name, which may be
+    * +bre+ (bibs)
+    * +biblio_record_entry_feed+ (multiple bibs)
+    * +acl+ (copy locations)
+    * +acn+ (volumes)
+    * +acnp+ (call number prefixes)
+    * +acns+ (call number suffixes)
+    * +acp+ (copies)
+    * +acpn+ (copy notes)
+    * +aou+ (org units)
+    * +ascecm+ (copy stat cat entries)
+    * +auri+ (located URIs)
+    * +bmp+ (monographic parts)
+    * +cbs+ (bib sources)
+    * +ccs+ (copy statuses)
+    * +circ+ (loan checkout and due dates)
+    * +holdings_xml+ (holdings)
+    * +mmr+ (metarecords)
+    * +mmr_holdings_xml+ (metarecords with holdings)
+    * +mmr_mra+ (metarecords with record attributes)
+    * +mra+ (record attributes)
+    * +sbsum+ (serial basic summaries)
+    * +sdist+ (serial distributions)
+    * +siss+ (serial issues)
+    * +sisum+ (serial index summaries)
+    * +sitem+ (serial items)
+    * +sssum+ (serial supplement summaries)
+    * +sstr+ (serial streams)
+    * +ssub+ (serial subscriptions)
+    * +sunit+ (serial units)
+  * followed by +/+
+  * followed by a record identifier (or in the case of
+    the +biblio_record_entry_feed+ class, multiple IDs separated
+    by commas)
+  * followed, optionally, by limit and offset in square brackets
+  * followed, optionally, by a comma-separated list of "includes"
+    enclosed in curly brackets.  The list list of includes is
+    the same as the list of classes with the following addition:
+    * +bre.extern+ (information from the non-MARC parts of a bib
+      record)
+   * followed, optionally, by +/+ and org unit; "-" signifies
+     the top of the org unit tree
+   * followed, optionally, by +/+ and org unit depth
+   * followed, optionally, by +/+ and a path. If the path
+     is +barcode+ and the class is +acp+, the record ID is taken
+     to be a copy barcode rather than a copy ID; for example, in
+     +tag::U2 at acp/ACQ140{acn,bre,mra}/-/0/barcode+, +ACQ140+ is
+     meant to be a copy barcode.

commit 8e60e0adc17ac6eb8b93a782b71106385bb509e8
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue Feb 16 13:28:27 2016 -0500

    LP#1367926: add some unit tests
    
    - a pgTAP test of the new 'bre.extern' include option
      for unapi.bre()
    - tests for OpenILS::WWW::SuperCat::unapi2_formats and
      OpenILS::Utils::TagURI
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t b/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t
index ffffba6..39fae1c 100644
--- a/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t
+++ b/Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t
@@ -1,8 +1,33 @@
 #!perl -T
 
-use Test::More tests => 2;
+use Test::More tests => 10;
+use Test::Output;
 
 BEGIN {
 	use_ok( 'OpenILS::WWW::SuperCat' );
 }
 use_ok( 'OpenILS::WWW::SuperCat::Feed' );
+use_ok( 'OpenILS::Utils::TagURI' );
+
+my $tag = 'tag::U2 at bre/454{holdings_xml}';
+my $u = OpenILS::Utils::TagURI->new($tag);
+is( $u->id,        454,   'parsed correct ID' );
+is( $u->classname, 'bre', 'parsed correct class name' );
+is( $u->toURI,     $tag,  'can reconstruct unAPI ID' );
+
+my $apache_stub;
+stdout_like { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u) }
+            qr/marcxml/,
+            'U2 formats list for bre includes marcxml';
+
+stdout_unlike { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u) }
+              qr/name="xml"/,
+              'U2 formats list for bre does not include xml';
+
+my $u2 = OpenILS::Utils::TagURI->new('tag::U2 at acn/4');
+stdout_like { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u2) }
+            qr/name="xml"/,
+            'U2 formats list for acn does includes xml';
+stdout_unlike { OpenILS::WWW::SuperCat::unapi2_formats($apache_stub, $u2) }
+              qr/name="marcxml"/,
+              'U2 formats list for acn does not includes marcxml';
diff --git a/Open-ILS/src/sql/Pg/t/unapi.pg b/Open-ILS/src/sql/Pg/t/unapi.pg
new file mode 100644
index 0000000..15b1919
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/unapi.pg
@@ -0,0 +1,12 @@
+BEGIN;
+
+SELECT plan(1);
+
+SELECT matches(
+    (SELECT unapi.bre(-1, 'marcxml', 'bre', '{bre.extern}', '-')::TEXT),
+    '<extern xmlns="http://open-ils.org/spec/biblio/v1"',
+    'bre.extern include for unapi.bre supplies <extern> element'
+);
+    
+SELECT * FROM finish();
+ROLLBACK;

commit f0ac3dab0206e5fafca8ed1d1cb491f8f2034406
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue Feb 16 11:31:34 2016 -0500

    LP#1367926: various improvements and bugfixes
    
    - use entityize() so that non-ASCII characters don't break
      XML well-formedness
    - when a U2 identifier is given, the list of supported formats
      returned is now accurate
    - biblio_record_entry_feed now works; for example,
    
    /opac/extras/unapi?id=tag::U2 at biblio_record_entry_feed/1608,454{holdings_xml}&format=mods32
    
    returns a modsCollection of bibs 1608 and 454.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
index 26f2372..3a8aebe 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
@@ -748,18 +748,22 @@ sub u2 {
         $u2->id( $copy->id );
     }
 
+    if ($u2->classname eq 'biblio_record_entry_feed') {
+        $u2->id( '{' . $u2->id . '}' );
+    }
+    my $args = [
+        'unapi.' . $u2->classname,
+        $u2->id,
+        $format,
+    ];
+    push @$args, $u2->classname unless $u2->classname eq 'biblio_record_entry_feed';
+    push @$args, '{' . ( $u2->includes ? join( ',', keys %{ $u2->includes } ) : '' ) . '}';
+    push @$args, ($u2->location || undef);
+    push @$args, ($u2->depth || undef);
+
     return OpenSRF::AppSession->create('open-ils.cstore')->request(
         "open-ils.cstore.json_query.atomic",
-        { from =>
-            [   'unapi.' . $u2->classname,
-                $u2->id,
-                $format,
-                $u2->classname,
-                '{' . ( $u2->includes ? join( ',', keys %{ $u2->includes } ) : '' ) . '}',
-                $u2->location || undef,
-                $u2->depth || undef
-            ]
-        }
+        { from => $args }
     )->gather(1)->[0]{'unapi.'. $u2->classname};
 }
 __PACKAGE__->register_method(
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
index 83274ac..06e43e1 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
@@ -458,9 +458,39 @@ sub unapi2 {
 
     print "Content-type: $ctype; charset=utf-8\n\n";
     print "<?xml version='1.0' encoding='UTF-8' ?>\n";
-    print $supercat
-        ->request("open-ils.supercat.u2", $u2->toURI, $format)
-        ->gather(1);
+    print $U->entityize(
+         $supercat->request("open-ils.supercat.u2", $u2->toURI, $format)
+        ->gather(1)
+    );
+
+    return Apache2::Const::OK;
+}
+
+sub unapi2_formats {
+    my $apache = shift;
+    my $u2 = shift;
+
+    print "Content-type: application/xml; charset=utf-8\n\n";
+    print "<?xml version='1.0' encoding='UTF-8' ?>\n";
+    my $id = $u2->toURI;
+    if ($u2->classname =~ /^(?:bre|biblio_record_entry_feed)$/) {
+        # TODO: if/when unapi.bre_output_layout becomes something
+        # that actually changes, the hard-coding here should be
+        # replaced
+        print <<FORMATS;
+<formats id='$id'>
+<format name="holdings_xml" type="application/xml"/>
+<format name="marcxml" type="application/xml" namespace_uri="http://www.loc.gov/MARC21/slim" docs="http://www.loc.gov/marcxml/" schema_location="http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"/>
+<format name="mods32" type="application/xml" namespace_uri="http://www.loc.gov/mods/v3" docs="http://www.loc.gov/mods/" schema_location="http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"/>
+</formats>
+FORMATS
+    } else {
+        print <<FORMATS;
+<formats id='$id'>
+<format name="xml" type="application/xml"/>
+</formats>
+FORMATS
+    }
 
     return Apache2::Const::OK;
 }
@@ -490,8 +520,12 @@ sub unapi {
     my $format = $cgi->param('format') || '';
     (my $base_format = $format) =~ s/(-full|-uris)$//o;
     my $u2uri = OpenILS::Utils::TagURI->new($uri);
-    if ($format and $u2uri->version > 1) {
-        return unapi2($apache, $u2uri, $format);
+    if ($u2uri->version > 1) {
+        if ($format) {
+            return unapi2($apache, $u2uri, $format);
+        } else {
+            return unapi2_formats($apache, $u2uri);
+        }
     }
 
     my $host = $cgi->virtual_host || $cgi->server_name;

commit b1892a6a34fb1b4b973b04cbdbd84ef50b3e845a
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Dec 8 10:08:41 2015 -0500

    LP#1367926: Expose non-MARC bre data via U2
    
    Many use cases for the new unAPI implemetation depend on being able to run
    recurring processes on new, updated, or deleted objects.  For most objects,
    this is simple because they carry timestamps as fields.  However, the bre
    class, as exposed by unAPI, does not provide access to many non-MARC fields.
    
    So, here we add an 'includes' options to expose the non-MARC fields of use
    to external processes.  The option is spelled "bre.extern", as in the tag
    URI:
    
      tag::U2 at bre/267{bre.extern}
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
index fcc96e4..eaa743a 100644
--- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql
+++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
@@ -522,6 +522,33 @@ BEGIN
         output := tmp_xml;
     END IF;
 
+    IF ('bre.extern' = ANY (includes)) THEN 
+        output := REGEXP_REPLACE(
+            tmp_xml,
+            '</' || top_el || '>(.*?)',
+            XMLELEMENT(
+                name extern,
+                XMLATTRIBUTES(
+                    'http://open-ils.org/spec/biblio/v1' AS xmlns,
+                    me.creator AS creator,
+                    me.editor AS editor,
+                    me.create_date AS create_date,
+                    me.edit_date AS edit_date,
+                    me.quality AS quality,
+                    me.fingerprint AS fingerprint,
+                    me.tcn_source AS tcn_source,
+                    me.tcn_value AS tcn_value,
+                    me.owner AS owner,
+                    me.share_depth AS share_depth,
+                    me.active AS active,
+                    me.deleted AS deleted
+                )
+            )::TEXT || '</' || top_el || E'>\\1'
+        );
+    ELSE
+        output := tmp_xml;
+    END IF;
+
     output := REGEXP_REPLACE(output::TEXT,E'>\\s+<','><','gs')::XML;
     RETURN output;
 END;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.unapi-bre.external-includes.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.unapi-bre.external-includes.sql
new file mode 100644
index 0000000..e1d6fad
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.unapi-bre.external-includes.sql
@@ -0,0 +1,153 @@
+
+BEGIN;
+
+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 ('cbs' = ANY (includes) AND 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;
+
+    IF ('bre.extern' = ANY (includes)) THEN 
+        output := REGEXP_REPLACE(
+            tmp_xml,
+            '</' || top_el || '>(.*?)',
+            XMLELEMENT(
+                name extern,
+                XMLATTRIBUTES(
+                    'http://open-ils.org/spec/biblio/v1' AS xmlns,
+                    me.creator AS creator,
+                    me.editor AS editor,
+                    me.create_date AS create_date,
+                    me.edit_date AS edit_date,
+                    me.quality AS quality,
+                    me.fingerprint AS fingerprint,
+                    me.tcn_source AS tcn_source,
+                    me.tcn_value AS tcn_value,
+                    me.owner AS owner,
+                    me.share_depth AS share_depth,
+                    me.active AS active,
+                    me.deleted AS deleted
+                )
+            )::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;
+

commit 4fbeac6d22deeeeb9d5998f072df8662f7ed2c68
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Sep 10 12:22:44 2014 -0400

    LP#1367926: Add support for (nearly) direct access to the full unapi backend
    
    Some parts of Evergreen (notably the TPAC), and various 3rd party services,
    would benefit from full and direct access to the power of the backend (read:
    faster, more complete, more API-stable) unAPI (um) API. Related, many moons
    ago, I built a perl module (OpenILS::Utils::TagURI) to make parsing of tag
    URIs systematic for use in OpenSearch and unAPI contexts. This branch uses
    O::U::TagURI and a simple shim inside open-ils.supercat to expose the power
    of that backend unAPI functionality.
    
    By way of example, here is the tag URI to look up a copy, by barcode, and
    request the call number, bib and bib attributes at the same time.  The
    barcode in this example is "ACQ140":
    
     tag::U2 at acp/ACQ140{acn,bre,mra}/-/0/barcode
    
    The full example URL would be something like:
    
     http://example.com/opac/extras/unapi?id=tag::U2@acp/ACQ140{acn,bre,mra}/-/0/barcode&format=xml
    
    Here is retrieving a bib in MODS 3.2 with holdings embedded:
    
     tag::U2 at bre/267{holdings_xml,acn,acp,mra}
    
    And the URL:
    
     http://example.com/opac/extras/unapi?tag::U2@bre/267{holdings_xml,acn,acp,mra}&format=mods32
    
    To test:
    
    Try the example URLs, varying record ID, classes, and includes. Some
    classes and includes available are:
    
    * bre (bibs)
    * acn (volumes)
    * acp (copies)
    * biblio_record_entry_feed (multiple bibs)
    * holdings_xml
    * cbs (bib source)
    * circ (circulation checkout and due dates)
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
index 1d94ef3..26f2372 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
@@ -37,6 +37,7 @@ use OpenSRF::Utils::Logger qw($logger);
 use OpenILS::Utils::Fieldmapper;
 
 use OpenILS::Utils::CStoreEditor q/:funcs/;
+use OpenILS::Utils::TagURI;
 
 
 our (
@@ -731,6 +732,60 @@ Returns the XML representation of the requested bibliographic record's holdings
         }
 );
 
+sub u2 {
+    my $self = shift;
+    my $client = shift;
+
+    my $u2 = shift;
+    my $format = shift || 'xml';
+
+    $u2 = OpenILS::Utils::TagURI->new($u2);
+    return '' unless $u2;
+
+    # Use pathinfo on acp as a lookup type specifier.
+    if ($u2->classname eq 'acp' and $u2->pathinfo =~ /\bbarcode\b/) {
+        my( $copy, $evt ) = $U->fetch_copy_by_barcode( $u2->id );
+        $u2->id( $copy->id );
+    }
+
+    return OpenSRF::AppSession->create('open-ils.cstore')->request(
+        "open-ils.cstore.json_query.atomic",
+        { from =>
+            [   'unapi.' . $u2->classname,
+                $u2->id,
+                $format,
+                $u2->classname,
+                '{' . ( $u2->includes ? join( ',', keys %{ $u2->includes } ) : '' ) . '}',
+                $u2->location || undef,
+                $u2->depth || undef
+            ]
+        }
+    )->gather(1)->[0]{'unapi.'. $u2->classname};
+}
+__PACKAGE__->register_method(
+    method    => 'u2',
+    api_name  => 'open-ils.supercat.u2',
+    api_level => 1,
+    argc      => 2,
+    signature =>
+        { desc     => <<"          DESC",
+Returns the XML representation of the requested object
+          DESC
+          params   =>
+            [
+                { name => 'u2',
+                  desc => 'The U2 Tag URI (OpenILS::Utils::TagURI)',
+                  type => 'object' },
+                { name => 'format',
+                  desc => 'For bre and bre feeds, the xml transform format',
+                  type => 'string' }
+            ],
+          'return' =>
+            { desc => 'XML (or transformed) object data',
+              type => 'string' }
+        }
+);
+
 
 sub general_browse {
     my $self = shift;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/TagURI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/TagURI.pm
index a6679f4..7e2adf8 100755
--- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/TagURI.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/TagURI.pm
@@ -90,8 +90,8 @@ sub parse {
     
         $self->classname($classname);
         $self->id($id);
-        $self->paging(($paging ? [ map { s/^\s*//; s/\s*$//; $_ } split(',', $paging) ] : []));
-        $self->includes(($inc ? { map { /:/ ? split(':') : ($_,undef) } map { s/^\s*//; s/\s*$//; $_ } split(',', $inc) } : {}));
+        $self->paging(($paging ? [ map { s/^\s*//; s/\s*$//; $_ } split(',', $paging) ] : undef));
+        $self->includes(($inc ? { map { /:/ ? split(':') : ($_,undef) } map { s/^\s*//; s/\s*$//; $_ } split(',', $inc) } : undef));
         $self->location($loc);
         $self->depth($depth);
         $self->pathinfo($mods);
@@ -122,7 +122,7 @@ sub toURI {
     $tag .= 'U2@' if ($self->version == 2);
     $tag .= $self->classname . '/' . $self->id;
     $tag .= '['. join(',', @{ $self->paging }) . ']' if defined($self->paging);
-    $tag .= '{'. join(',', map { $_ . ':' . $self->includes->{$_} } keys %{ $self->includes }) . '}' if defined($self->includes);
+    $tag .= '{'. join(',', map { $self->includes->{$_} ? ($_ . ':' . $self->includes->{$_}) : ($_) } keys %{ $self->includes }) . '}' if defined($self->includes);
     $tag .= '/' . $self->location if defined($self->location);
     $tag .= '/' . $self->depth if defined($self->depth);
     $tag .= '/' . $self->pathinfo if defined($self->pathinfo);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
index ce5effe..83274ac 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
@@ -26,6 +26,7 @@ use OpenILS::Utils::Fieldmapper;
 use OpenILS::WWW::SuperCat::Feed;
 use OpenSRF::Utils::Logger qw/$logger/;
 use OpenILS::Application::AppUtils;
+use OpenILS::Utils::TagURI;
 
 use MARC::Record;
 use MARC::File::XML ( BinaryEncoding => 'UTF-8' );
@@ -444,6 +445,26 @@ sub oisbn {
     return Apache2::Const::OK;
 }
 
+sub unapi2 {
+    my $apache = shift;
+    my $u2 = shift;
+    my $format = shift;
+
+    my $ctype = 'application/xml';
+    # Only bre and biblio_record_entry_feed have tranforms, but we'll ignore that for now
+    if ($u2->classname =~ /^(?:bre|biblio_record_entry_feed)$/ and $format ne 'xml') {
+        # XXX set $ctype to something else
+    }
+
+    print "Content-type: $ctype; charset=utf-8\n\n";
+    print "<?xml version='1.0' encoding='UTF-8' ?>\n";
+    print $supercat
+        ->request("open-ils.supercat.u2", $u2->toURI, $format)
+        ->gather(1);
+
+    return Apache2::Const::OK;
+}
+
 sub unapi {
 
     my $apache = shift;
@@ -465,6 +486,14 @@ sub unapi {
 
 
     my $uri = $cgi->param('id') || '';
+
+    my $format = $cgi->param('format') || '';
+    (my $base_format = $format) =~ s/(-full|-uris)$//o;
+    my $u2uri = OpenILS::Utils::TagURI->new($uri);
+    if ($format and $u2uri->version > 1) {
+        return unapi2($apache, $u2uri, $format);
+    }
+
     my $host = $cgi->virtual_host || $cgi->server_name;
 
     my $skin = $cgi->param('skin') || 'default';
@@ -473,7 +502,6 @@ sub unapi {
     # Enable localized results of copy status, etc
     $supercat->session_locale($locale);
 
-    my $format = $cgi->param('format') || '';
     my $flesh_feed = parse_feed_type($format);
     (my $base_format = $format) =~ s/(-full|-uris)$//o;
     my ($id,$type,$command,$lib,$depth,$paging) = ('','record','');

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

Summary of changes:
 .../perlmods/lib/OpenILS/Application/SuperCat.pm   |   59 ++++++++++++++++++
 Open-ILS/src/perlmods/lib/OpenILS/Utils/TagURI.pm  |    6 +-
 Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm  |   64 +++++++++++++++++++-
 Open-ILS/src/perlmods/t/18-OpenILS-WWW-SuperCat.t  |   27 ++++++++-
 Open-ILS/src/sql/Pg/990.schema.unapi.sql           |   27 ++++++++
 Open-ILS/src/sql/Pg/t/unapi.pg                     |   12 ++++
 ... XXXX.function.unapi-bre.external-includes.sql} |   49 +++++++++------
 docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc     |   64 ++++++++++++++++++++
 8 files changed, 283 insertions(+), 25 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/unapi.pg
 copy Open-ILS/src/sql/Pg/upgrade/{0923.schema.unapi_include_bib_source.sql => XXXX.function.unapi-bre.external-includes.sql} (80%)
 create mode 100644 docs/RELEASE_NOTES_NEXT/OPAC/Expand_unAPI.adoc


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list