base materialized simple record on old super_simple_record
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 26 Apr 2008 16:49:25 +0000 (16:49 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 26 Apr 2008 16:49:25 +0000 (16:49 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9458 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/reporter-schema.sql
Open-ILS/src/sql/Pg/upgrade_simple_record.sql

index 642395f..aa31d33 100644 (file)
@@ -1080,7 +1080,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                <links>
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
                        <link field="creator" reltype="has_a" key="id" map="" class="au"/>
-                       <link field="simple_record" reltype="might_have" key="id" map="" class="rssr"/>
+                       <link field="simple_record" reltype="might_have" key="id" map="" class="rmsr"/>
                        <link field="metarecord" reltype="might_have" key="source" map="metarecord" class="mmrsm"/>
                        <link field="call_numbers" reltype="has_many" key="record" map="" class="acn"/>
                        <link field="keyword_field_entries" reltype="has_many" key="source" map="" class="mkfe"/>
@@ -3231,6 +3231,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="folder" reltype="has_a" key="id" map="" class="rof"/>
                </links>
        </class>
+       <class id="rmsr" controller="open-ils.reporter-store" oils_obj:fieldmapper="reporter::materialized_simple_record" oils_persist:tablename="reporter.materialized_simple_record" reporter:label="Fast Simple Record Extracts">
+               <fields oils_persist:primary="id">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field reporter:label="Record ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id" />
+                       <field reporter:label="Fingerprint" name="fingerprint" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Overall Record Quality" name="quality" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="int"/>
+                       <field reporter:label="TCN Source" name="tcn_source" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="TCN Value" name="tcn_value" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Title Proper (normalized)" name="title" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Author (normalized)" name="author" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Publisher (normalized)" name="publisher" oils_obj:array_position="10" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Publication Year (normalized)" name="pubdate" oils_obj:array_position="11" oils_persist:virtual="false" reporter:datatype="int"/>
+                       <field reporter:label="ISBN" name="isbn" oils_obj:array_position="12" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="ISSN" name="issn" oils_obj:array_position="13" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Full Bibliographic record" name="biblio_record" oils_obj:array_position="14" oils_persist:virtual="true" reporter:datatype="link"/>
+               </fields>
+               <links>
+                       <link field="biblio_record" reltype="might_have" key="id" map="" class="bre"/>
+               </links>
+       </class>
        <class id="rssr" controller="open-ils.reporter-store" oils_obj:fieldmapper="reporter::super_simple_record" oils_persist:tablename="reporter.super_simple_record" reporter:label="Simple Record Extracts">
                <fields oils_persist:primary="id">
                        <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
index 74662ba..d7f6332 100644 (file)
@@ -132,7 +132,7 @@ SELECT      r.id,
   WHERE        r.deleted IS FALSE
   GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14;
 
-CREATE OR REPLACE VIEW reporter.super_simple_record AS
+CREATE OR REPLACE VIEW reporter.old_super_simple_record AS
 SELECT r.id,
        r.fingerprint,
        r.quality,
@@ -154,8 +154,9 @@ SELECT      r.id,
   WHERE        r.deleted IS FALSE
   GROUP BY 1,2,3,4,5,6,8,9;
 
-CREATE TABLE reporter.materialized_simple_record AS SELECT * FROM reporter.simple_record WHERE 1=0;
+CREATE TABLE reporter.materialized_simple_record AS SELECT * FROM reporter.old_super_simple_record WHERE 1=0;
 ALTER TABLE reporter.materialized_simple_record ADD PRIMARY KEY (id);
+CREATE VIEW reporter.super_simple_record AS SELECT * FROM reporter.materialized_simple_record;
 
 CREATE OR REPLACE FUNCTION reporter.simple_rec_sync () RETURNS TRIGGER AS $$
 BEGIN
@@ -164,7 +165,7 @@ BEGIN
     END IF;
 
     IF TG_OP IN ('INSERT','UPDATE') AND NOT NEW.deleted THEN
-        INSERT INTO reporter.materialized_simple_record SELECT * FROM reporter.simple_record WHERE id = NEW.record;
+        INSERT INTO reporter.materialized_simple_record SELECT * FROM reporter.old_super_simple_record WHERE id = NEW.record;
     END IF;
 
 END;
index a328f00..b0ceb3c 100644 (file)
@@ -1,7 +1,7 @@
 
 BEGIN;
 
-CREATE TABLE reporter.materialized_simple_record AS SELECT * FROM reporter.simple_record WHERE 1=0;
+CREATE TABLE reporter.materialized_simple_record AS SELECT * FROM reporter.super_simple_record WHERE 1=0;
 
 INSERT INTO reporter.materialized_simple_record
     (id,fingerprint,quality,tcn_source,tcn_value,title,author,publisher,pubdate,isbn,issn)
@@ -9,6 +9,30 @@ INSERT INTO reporter.materialized_simple_record
 
 ALTER TABLE reporter.materialized_simple_record ADD PRIMARY KEY (id);
 
+CREATE OR REPLACE VIEW reporter.super_simple_record AS SELECT * FROM reporter.materialized_simple_record;
+
+CREATE OR REPLACE VIEW reporter.old_super_simple_record AS
+SELECT  r.id,
+    r.fingerprint,
+    r.quality,
+    r.tcn_source,
+    r.tcn_value,
+    title.value AS title,
+    FIRST(author.value) AS author,
+    publisher.value AS publisher,
+    SUBSTRING(pubdate.value FROM $$\d+$$) AS pubdate,
+    ARRAY_ACCUM( SUBSTRING(isbn.value FROM $$^\S+$$) ) AS isbn,
+    ARRAY_ACCUM( SUBSTRING(issn.value FROM $$^\S+$$) ) AS issn
+  FROM  biblio.record_entry r
+    LEFT JOIN metabib.full_rec title ON (r.id = title.record AND title.tag = '245' AND title.subfield = 'a')
+    LEFT JOIN metabib.full_rec author ON (r.id = author.record AND author.tag IN ('100','110','111') AND author.subfield = 'a')
+    LEFT JOIN metabib.full_rec publisher ON (r.id = publisher.record AND publisher.tag = '260' AND publisher.subfield = 'b')
+    LEFT JOIN metabib.full_rec pubdate ON (r.id = pubdate.record AND pubdate.tag = '260' AND pubdate.subfield = 'c')
+    LEFT JOIN metabib.full_rec isbn ON (r.id = isbn.record AND isbn.tag IN ('024', '020') AND isbn.subfield IN ('a','z'))
+    LEFT JOIN metabib.full_rec issn ON (r.id = issn.record AND issn.tag = '022' AND issn.subfield = 'a')
+  WHERE r.deleted IS FALSE
+  GROUP BY 1,2,3,4,5,6,8,9;
+
 CREATE OR REPLACE FUNCTION reporter.simple_rec_sync () RETURNS TRIGGER AS $$
 BEGIN
     IF TG_OP IN ('UPDATE','DELETE') THEN
@@ -16,7 +40,7 @@ BEGIN
     END IF;
 
     IF TG_OP IN ('INSERT','UPDATE') AND NOT NEW.deleted THEN
-        INSERT INTO reporter.materialized_simple_record SELECT * FROM reporter.simple_record WHERE id = NEW.record;
+        INSERT INTO reporter.materialized_simple_record SELECT * FROM reporter.old_super_simple_record WHERE id = NEW.record;
     END IF;
 
 END;