towards using fielder in openils.AuthorityControlSet
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 28 Jun 2011 15:49:17 +0000 (11:49 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 11 Jul 2011 17:48:30 +0000 (13:48 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/web/js/dojo/openils/AuthorityControlSet.js
Open-ILS/web/opac/skin/default/js/authbrowse.js

index e89d46e..5816331 100644 (file)
@@ -1758,7 +1758,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </links>
        </class>
 
-       <class id="acs" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set" oils_persist:tablename="authority.control_set" reporter:label="Authority Control Set">
+       <class id="acs" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set" oils_persist:tablename="authority.control_set" reporter:label="Authority Control Set" oils_persist:field_safe="true">
                <fields oils_persist:primary="id" oils_persist:sequence="authority.control_set_id_seq">
                        <field reporter:label="Control Set ID" name="id" reporter:datatype="id" reporter:selector="name"/>
                        <field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true" oils_obj:required="true" />
@@ -1780,7 +1780,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
-       <class id="acsaf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set_authority_field" oils_persist:tablename="authority.control_set_authority_field" reporter:label="Authority Control Set Authority Field">
+       <class id="acsaf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set_authority_field" oils_persist:tablename="authority.control_set_authority_field" reporter:label="Authority Control Set Authority Field" oils_persist:field_safe="true">
                <fields oils_persist:primary="id" oils_persist:sequence="authority.control_set_authority_field_id_seq">
                        <field reporter:label="Control Set Authority Field ID" name="id" reporter:datatype="id" reporter:selector="name"/>
                        <field reporter:label="Main Entry" name="main_entry" reporter:datatype="link"/>
@@ -1812,7 +1812,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
-       <class id="acsbf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set_bib_field" oils_persist:tablename="authority.control_set_bib_field" reporter:label="Authority Control Set Bib Field">
+       <class id="acsbf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::control_set_bib_field" oils_persist:tablename="authority.control_set_bib_field" reporter:label="Authority Control Set Bib Field" oils_persist:field_safe="true">
                <fields oils_persist:primary="id" oils_persist:sequence="authority.control_set_bib_field_id_seq">
                        <field reporter:label="Controlled Bib Field ID" name="id" reporter:datatype="id" reporter:selector="name"/>
                        <field reporter:label="Controlling Authority Field" name="authority_field" reporter:datatype="link"/>
@@ -1831,7 +1831,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
-       <class id="at" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::thesaurus" oils_persist:tablename="authority.thesaurus" reporter:label="Authority Thesaurus">
+       <class id="at" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::thesaurus" oils_persist:tablename="authority.thesaurus" reporter:label="Authority Thesaurus" oils_persist:field_safe="true">
                <fields oils_persist:primary="code">
                        <field reporter:label="Thesaurus Code" name="code" reporter:datatype="id" reporter:selector="name"/>
                        <field reporter:label="Control Set" name="control_set" reporter:datatype="link"/>
@@ -1851,7 +1851,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
-       <class id="aba" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::browse_axis" oils_persist:tablename="authority.browse_axis" reporter:label="Authority Browse Axis">
+       <class id="aba" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::browse_axis" oils_persist:tablename="authority.browse_axis" reporter:label="Authority Browse Axis" oils_persist:field_safe="true">
                <fields oils_persist:primary="code">
                        <field reporter:label="Code" name="code" reporter:datatype="id" reporter:selector="name" oils_obj:validate="^\S+$"/>
                        <field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true" oils_obj:required="true"/>
@@ -1873,7 +1873,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
-    <class id="abaafm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::browse_axis_authority_field_map" oils_persist:tablename="authority.browse_axis_authority_field_map" reporter:label="Authority Browse Axis Field Map">
+    <class id="abaafm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::browse_axis_authority_field_map" oils_persist:tablename="authority.browse_axis_authority_field_map" reporter:label="Authority Browse Axis Field Map" oils_persist:field_safe="true">
         <fields oils_persist:primary="id" oils_persist:sequence="authority.browse_axis_authority_field_map_id_seq">
             <field reporter:label="Axis Authority Field Map ID" name="id" reporter:datatype="id"/>
             <field reporter:label="Authority Field" name="field" oils_obj:required="true" reporter:datatype="link"/>
index ae650af..9284094 100644 (file)
@@ -16,8 +16,6 @@
  */
 
 if(!dojo._hasResource["openils.AuthorityControlSet"]) {
-
-    dojo.require('openils.PermaCrud');
     dojo.require('MARC.FixedFields');
 
     dojo._hasResource["openils.AuthorityControlSet"] = true;
@@ -34,15 +32,15 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) {
 
                 // TODO -- push the raw tree into the oils cache for later reuse
 
-                var pcrud = new openils.PermaCrud({authtoken : ses()});
-
                 // fetch everything up front...
-                openils.AuthorityControlSet._control_set_list = pcrud.retrieveAll('acs');
-                openils.AuthorityControlSet._thesaurus_list = pcrud.retrieveAll('at');
-                openils.AuthorityControlSet._authority_field_list = pcrud.retrieveAll('acsaf');
-                openils.AuthorityControlSet._bib_field_list = pcrud.retrieveAll('acsbf');
-                openils.AuthorityControlSet._browse_axis_list = pcrud.retrieveAll('aba');
-                openils.AuthorityControlSet._browse_field_map_list = pcrud.retrieveAll('abaafm');
+                this._preFetchWithFielder({
+                    "acs": "_control_set_list",
+                    "at": "_thesaurus_list",
+                    "acsaf": "_authority_field_list",
+                    "acsbf": "_bib_field_list",
+                    "aba": "_browse_axis_list",
+                    "abaafm": "_browse_field_map_list"
+                });
 
                 openils.AuthorityControlSet._browse_axis_by_name = {};
                 dojo.forEach( openils.AuthorityControlSet._browse_axis_list, function (ba) {
@@ -164,6 +162,10 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) {
             }
         },
 
+        _preFetchWithFielder: function(map) {
+            // TODO get pkeys from fieldmapper but use fielder to get everything
+        },
+
         controlSetId: function (x) {
             if (x) this._controlset = ''+x;
             return this._controlset;
@@ -174,10 +176,12 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) {
         },
 
         controlSetByThesaurusCode: function (x) {
+            console.log("1");
             var thes = dojo.filter(
                 openils.AuthorityControlSet._thesaurus_list,
                 function (at) { return at.code() == x }
             )[0];
+            console.log("2");
 
             return this.controlSet(thes.controlSet());
         },
index 69dc516..3aa8f2f 100644 (file)
@@ -24,6 +24,7 @@ function doAuthorityBrowse(axis, term, page, per_page) {
         + '/' + page
         + '/' + per_page
     ;
+    console.log("doAuthorityBrowse 3: " + url);
     dojo.xhrGet({
         "url": url,
         "handleAs": "xml",
@@ -35,14 +36,20 @@ function doAuthorityBrowse(axis, term, page, per_page) {
 
 function displayAuthorityRecords(doc) {
     console.log("displayAuthorityRecords");
+    var acs_helper = new openils.AuthorityControlSet();
+    console.log("got acs_helper");
     dojo.query("record", doc).forEach(
         function(record) {
             console.log("record");
             var m = new MARC.Record({"xml": record});
+            console.log("got m");
+            var s = m.extractFixedField("Subj");
+            console.log("got s");
+            var cs = acs_helper.controlSetByThesaurusCode(s);
+            console.log("got cs");
             dojo.create(
                 "div", {
-                    "innerHTML": "record here, Subj is " +
-                        m.extractFixedField("Subj")
+                    "innerHTML": "record here, control set is " + cs
                 }, "test-holder"
             );
         }