LP1813191: Add a Dewey Classification View to acn
authorJason Boyer <jboyer@library.in.gov>
Mon, 28 Jan 2019 15:22:01 +0000 (10:22 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 12 Aug 2021 19:46:54 +0000 (15:46 -0400)
The most-missed part of the Classic Item View in the
reporter are the dewey ranges and blocks. This branch
pulls those out into their own view and hangs it off
of a link from asset.call_number so they can be used
in reports from any path that connects to acn.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/reporter-schema.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dewey_ranges.sql [new file with mode: 0644]
docs/RELEASE_NOTES_NEXT/Reports/dewey_call_ranges.adoc [new file with mode: 0644]

index 0cc6925..32816d9 100644 (file)
@@ -3337,6 +3337,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Classification Scheme" name="label_class" reporter:datatype="link"/>
                        <field reporter:label="Prefix" name="prefix" reporter:datatype="link"/>
                        <field reporter:label="Suffix" name="suffix" reporter:datatype="link"/>
+                       <field reporter:label="Dewey Classification" name="dewey" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
@@ -3350,6 +3351,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="label_class" reltype="has_a" key="id" map="" class="acnc"/>
                        <link field="prefix" reltype="has_a" key="id" map="" class="acnp"/>
                        <link field="suffix" reltype="has_a" key="id" map="" class="acns"/>
+                       <link field="dewey" reltype="might_have" key="call_number" map="" class="racnd"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
@@ -3360,6 +3362,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             </actions>
         </permacrud>
        </class>
+       <class id="racnd" controller="open-ils.cstore open-ils.reporter-store open-ils.pcrud" oils_obj:fieldmapper="reporter::asset_call_number_dewey" oils_persist:tablename="reporter.asset_call_number_dewey" reporter:label="Dewey Classification">
+               <fields oils_persist:primary="call_number">
+                       <field reporter:label="Call Number" name="call_number" reporter:datatype="link" />
+                       <field reporter:label="Dewey Number" name="dewey" reporter:datatype="text"/>
+                       <field reporter:label="Dewey Range - Tens" name="dewey_range_tens" reporter:datatype="text"/>
+                       <field reporter:label="Dewey Range - Hundreds" name="dewey_range_hundreds" reporter:datatype="text"/>
+                       <field reporter:label="Dewey Block - Tens" name="dewey_block_tens" reporter:datatype="text"/>
+                       <field reporter:label="Dewey Block - Hundreds" name="dewey_block_hundreds" reporter:datatype="text"/>
+               </fields>
+               <links>
+                       <link field="call_number" reltype="has_a" key="id" map="" class="acn"/>
+               </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve/>
+            </actions>
+        </permacrud>
+       </class>
        <class id="auri" controller="open-ils.cstore" oils_obj:fieldmapper="asset::uri" oils_persist:tablename="asset.uri" reporter:label="Electronic Access URI">
                <fields oils_persist:primary="id" oils_persist:sequence="asset.uri_id_seq">
                        <field reporter:label="URI ID" name="id" reporter:datatype="id"/>
index 68b7cfc..fb427ca 100644 (file)
@@ -232,6 +232,30 @@ CREATE OR REPLACE FUNCTION reporter.refresh_materialized_simple_record () RETURN
     SELECT reporter.enable_materialized_simple_record_trigger();
 $$ LANGUAGE SQL;
 
+CREATE OR REPLACE VIEW reporter.asset_call_number_dewey AS
+  SELECT id AS call_number,
+    call_number_dewey(label) AS dewey,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9.]$'::text
+      THEN btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision), '000'::text))
+      ELSE NULL::text
+    END AS dewey_block_tens,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision), '000'::text))
+      ELSE NULL::text
+    END AS dewey_block_hundreds,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN (btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision), '000'::text)) || '-'::text)
+      || btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision) + 9::double precision, '000'::text))
+      ELSE NULL::text
+    END AS dewey_range_tens,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN (btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision), '000'::text)) || '-'::text)
+      || btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision) + 99::double precision, '000'::text))
+      ELSE NULL::text
+    END AS dewey_range_hundreds
+  FROM asset.call_number
+  WHERE call_number_dewey(label) ~ '^[0-9]'::text;
+
 CREATE OR REPLACE VIEW reporter.demographic AS
 SELECT u.id,
        u.dob,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dewey_ranges.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.dewey_ranges.sql
new file mode 100644 (file)
index 0000000..e877290
--- /dev/null
@@ -0,0 +1,29 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW reporter.asset_call_number_dewey AS
+  SELECT id AS call_number,
+    call_number_dewey(label) AS dewey,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9.]$'::text
+      THEN btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision), '000'::text))
+      ELSE NULL::text
+    END AS dewey_block_tens,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision), '000'::text))
+      ELSE NULL::text
+    END AS dewey_block_hundreds,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN (btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision), '000'::text)) || '-'::text)
+      || btrim(to_char(10::double precision * floor(call_number_dewey(label)::double precision / 10::double precision) + 9::double precision, '000'::text))
+      ELSE NULL::text
+    END AS dewey_range_tens,
+    CASE WHEN call_number_dewey(label) ~ '^[0-9]+.?[0-9]*$'::text
+      THEN (btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision), '000'::text)) || '-'::text)
+      || btrim(to_char(100::double precision * floor(call_number_dewey(label)::double precision / 100::double precision) + 99::double precision, '000'::text))
+      ELSE NULL::text
+    END AS dewey_range_hundreds
+  FROM asset.call_number
+  WHERE call_number_dewey(label) ~ '^[0-9]'::text;
+
+COMMIT;
diff --git a/docs/RELEASE_NOTES_NEXT/Reports/dewey_call_ranges.adoc b/docs/RELEASE_NOTES_NEXT/Reports/dewey_call_ranges.adoc
new file mode 100644 (file)
index 0000000..8897861
--- /dev/null
@@ -0,0 +1,7 @@
+Add Dewey Call Number Blocks and Ranges to Reports
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+A new view is added to the reporter with links from Call Number that
+will allow users to display or filter on the Dewey 10's or 100's block
+or range that a call number falls within. They can be accessed by
+following the "Dewey Classification" link from Call Number.
+