Add in-db unAPI support for multi-homed copies
authorMike Rylander <mrylander@gmail.com>
Mon, 14 Mar 2011 19:44:57 +0000 (15:44 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 14 Mar 2011 19:44:57 +0000 (15:44 -0400)
Open-ILS/src/sql/Pg/990.schema.unapi.sql

index e7abed5..0d100b8 100644 (file)
@@ -267,6 +267,17 @@ CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, d
                               WHERE record_entry = $1
                         )x)
                      )
+                 ELSE NULL END,
+                 CASE WHEN ('acp' = ANY $5) THEN 
+                     XMLELEMENT(
+                         name foreign_copies,
+                         (SELECT XMLAGG(acp) FROM (
+                            SELECT  unapi.acp(p.target_copy,'xml','copy','{}'::TEXT[], $3, $4, $6, $7)
+                              FROM  biblio.peer_bib_copy_map p
+                                    JOIN asset.copy c ON (p.target_copy = c.id)
+                              WHERE NOT c.deleted AND peer_bib = $1
+                        )x)
+                     )
                  ELSE NULL END
              );
 $F$ LANGUAGE SQL;
@@ -569,6 +580,14 @@ CREATE OR REPLACE FUNCTION unapi.acp ( obj_id BIGINT, format TEXT,  ename TEXT,
                             ELSE NULL
                         END
                     )
+                    XMLELEMENT( name foreign_records,
+                        CASE
+                            WHEN ('bre' = ANY ($4)) THEN
+                                XMLAGG((SELECT unapi.bre(peer_bib,'marcxml','record','{}'::TEXT[], $5, $6, $7, $8) FROM biblio.peer_bib_copy_map WHERE target_copy = cp.id))
+                            ELSE NULL
+                        END,
+
+                     )
                 )
           FROM  asset.copy cp
           WHERE id = $1