[open-ils-commits] r15353 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application src/sql/Pg web/js/ui/default/vandelay (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 21 11:43:07 EST 2010


Author: miker
Date: 2010-01-21 11:43:04 -0500 (Thu, 21 Jan 2010)
New Revision: 15353

Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
   trunk/Open-ILS/web/js/ui/default/vandelay/vandelay.js
Log:
Patch from Dan Wells to address a thinko in the use of the queue ownership field for a Vandelay queue:

I have been doing a lot of experimenting with Vandelay the last few weeks and have traced many of my failures to one distinct bug.  I finally noticed yesterday why Item Import worked for the 'admin' user but for nobody else.  It turns out there is a bug in one of the database functions where it treats the queue 'owner' column as an org_unit ID when in fact it is a usr id.  Of course since 'admin' is ID 1 out of the box and there is an org_unit 1 as well, this bug is transparent to admin and easy to miss.

Well, I started by making a few changes to the function to address this, but soon realized that what we really wanted to do was base the import on the Import Def chosen by the user when the records are loaded, and it would be ideal if the Import Def was somehow associated with the queue at the time of import.  I started poking around in the schema, and lo and behold, the vandelay.bib_queue table already had an 'item_attr_def' linking column for this very purpose which was going unused!

So, the attached patch finally puts this column to use by doing the following:

1) Edits the create_bib_queue() sub in Vandelay.pm to accept the item import attribute definition ID as an argument and save it appropriately.

2) Edits the vandelay.js interface file to accept and send the import definition ID to create_bib_queue() when creating a queue.

3) Edits fm_IDL.xml to add the 'item_attr_def' field (and fix a small labeling error).

4) Edits 012.schema.vandelay.sql to replace the buggy function that started all this with a now simpler, working version.  The change is actually smaller than it looks due removing one nested loop and the resulting indentation change.

=============================================
Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
  have the right to submit it under the open source license
  indicated in the file; or

(b) The contribution is based upon previous work that, to the best
  of my knowledge, is covered under an appropriate open source
  license and I have the right under that license to submit that
  work with modifications, whether created in whole or in part
  by me, under the same open source license (unless I am
  permitted to submit under a different license), as indicated
  in the file; or

(c) The contribution was provided directly to me by some other
  person who certified (a), (b) or (c) and I have not modified
  it.

(d) I understand and agree that this project and the contribution
  are public and that a record of the contribution (including all
  personal information I submit with it, including my sign-off) is
  maintained indefinitely and may be redistributed consistent with
  this project or the open source license(s) involved.

Signed-off-by: Daniel B. Wells
=============================================



Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2010-01-21 02:18:40 UTC (rev 15352)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2010-01-21 16:43:04 UTC (rev 15353)
@@ -149,7 +149,7 @@
 		</permacrud>
 	</class>
 
-	<class id="vii" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="vandelay::import_item" oils_persist:tablename="vandelay.import_item" reporter:label="Import Item Attribute Definition">
+	<class id="vii" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="vandelay::import_item" oils_persist:tablename="vandelay.import_item" reporter:label="Import Item">
 		<fields oils_persist:primary="id" oils_persist:sequence="vandelay.import_item_id_seq">
 			<field reporter:label="Import Item ID" name="id" reporter:datatype="id"/>
 			<field reporter:label="Import Record" name="record" reporter:datatype="link"/>
@@ -243,9 +243,11 @@
 			<field reporter:label="Name" name="name" reporter:datatype="text" oils_persist:i18n="true"/>
 			<field reporter:label="Complete" name="complete" reporter:datatype="bool"/>
 			<field reporter:label="Type" name="queue_type" reporter:datatype="text"/>
+			<field reporter:label="Item Import Attribute Definition" name="item_attr_def" reporter:datatype="link"/>
 		</fields>
 		<links>
 			<link field="owner" reltype="has_a" key="id" map="" class="aou"/>
+			<link field="item_attr_def" reltype="has_a" key="id" map="" class="viiad"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
 			<actions>

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm	2010-01-21 02:18:40 UTC (rev 15352)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm	2010-01-21 16:43:04 UTC (rev 15353)
@@ -36,6 +36,7 @@
 	my $name = shift;
 	my $owner = shift;
 	my $type = shift;
+	my $import_def = shift;
 
 	my $e = new_editor(authtoken => $auth, xact => 1);
 
@@ -51,6 +52,7 @@
 	$queue->name( $name );
 	$queue->owner( $owner );
 	$queue->queue_type( $type ) if ($type);
+	$queue->item_attr_def( $import_def ) if ($import_def);
 
 	my $new_q = $e->create_vandelay_bib_queue( $queue );
 	return $e->die_event unless ($new_q);
@@ -62,7 +64,7 @@
 	api_name	=> "open-ils.vandelay.bib_queue.create",
 	method		=> "create_bib_queue",
 	api_level	=> 1,
-	argc		=> 3,
+	argc		=> 4,
 );                      
 
 

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-01-21 02:18:40 UTC (rev 15352)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-01-21 16:43:04 UTC (rev 15353)
@@ -51,7 +51,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0138'); -- dbs
+INSERT INTO config.upgrade_log (version) VALUES ('0139'); -- Dan Wells via miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql	2010-01-21 02:18:40 UTC (rev 15352)
+++ trunk/Open-ILS/src/sql/Pg/012.schema.vandelay.sql	2010-01-21 16:43:04 UTC (rev 15353)
@@ -432,61 +432,58 @@
 
 CREATE OR REPLACE FUNCTION vandelay.ingest_bib_items ( ) RETURNS TRIGGER AS $func$
 DECLARE
-    queue_rec   RECORD;
-    item_rule   RECORD;
+    attr_def    BIGINT;
     item_data   vandelay.import_item%ROWTYPE;
 BEGIN
 
-    SELECT * INTO queue_rec FROM vandelay.bib_queue WHERE id = NEW.queue;
+    SELECT item_attr_def INTO attr_def FROM vandelay.bib_queue WHERE id = NEW.queue;
 
-    FOR item_rule IN SELECT r.* FROM actor.org_unit_ancestors( queue_rec.owner ) o JOIN vandelay.import_item_attr_definition r ON ( r.owner = o.id ) LOOP
-        FOR item_data IN SELECT * FROM vandelay.ingest_items( NEW.id::BIGINT, item_rule.id::BIGINT ) LOOP
-            INSERT INTO vandelay.import_item (
-		record,
-                definition,
-                owning_lib,
-                circ_lib,
-                call_number,
-                copy_number,
-                status,
-                location,
-                circulate,
-                deposit,
-                deposit_amount,
-                ref,
-                holdable,
-                price,
-                barcode,
-                circ_modifier,
-                circ_as_type,
-                alert_message,
-                pub_note,
-                priv_note,
-                opac_visible
-            ) VALUES (
-		NEW.id,
-                item_data.definition,
-                item_data.owning_lib,
-                item_data.circ_lib,
-                item_data.call_number,
-                item_data.copy_number,
-                item_data.status,
-                item_data.location,
-                item_data.circulate,
-                item_data.deposit,
-                item_data.deposit_amount,
-                item_data.ref,
-                item_data.holdable,
-                item_data.price,
-                item_data.barcode,
-                item_data.circ_modifier,
-                item_data.circ_as_type,
-                item_data.alert_message,
-                item_data.pub_note,
-                item_data.priv_note,
-                item_data.opac_visible
-            );
-        END LOOP;
+    FOR item_data IN SELECT * FROM vandelay.ingest_items( NEW.id::BIGINT, attr_def ) LOOP
+        INSERT INTO vandelay.import_item (
+            record,
+            definition,
+            owning_lib,
+            circ_lib,
+            call_number,
+            copy_number,
+            status,
+            location,
+            circulate,
+            deposit,
+            deposit_amount,
+            ref,
+            holdable,
+            price,
+            barcode,
+            circ_modifier,
+            circ_as_type,
+            alert_message,
+            pub_note,
+            priv_note,
+            opac_visible
+        ) VALUES (
+            NEW.id,
+            item_data.definition,
+            item_data.owning_lib,
+            item_data.circ_lib,
+            item_data.call_number,
+            item_data.copy_number,
+            item_data.status,
+            item_data.location,
+            item_data.circulate,
+            item_data.deposit,
+            item_data.deposit_amount,
+            item_data.ref,
+            item_data.holdable,
+            item_data.price,
+            item_data.barcode,
+            item_data.circ_modifier,
+            item_data.circ_as_type,
+            item_data.alert_message,
+            item_data.pub_note,
+            item_data.priv_note,
+            item_data.opac_visible
+        );
     END LOOP;
 
     RETURN NULL;

Modified: trunk/Open-ILS/web/js/ui/default/vandelay/vandelay.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/vandelay/vandelay.js	2010-01-21 02:18:40 UTC (rev 15352)
+++ trunk/Open-ILS/web/js/ui/default/vandelay/vandelay.js	2010-01-21 16:43:04 UTC (rev 15353)
@@ -287,13 +287,13 @@
 /**
   * Creates a new vandelay queue
   */
-function createQueue(queueName, type, onload) {
+function createQueue(queueName, type, onload, importDefId) {
     var name = (type=='bib') ? 'bib' : 'authority';
     var method = 'open-ils.vandelay.'+ name +'_queue.create'
     fieldmapper.standardRequest(
         ['open-ils.vandelay', method],
         {   async: true,
-            params: [authtoken, queueName, null, name],
+            params: [authtoken, queueName, null, name, importDefId],
             oncomplete : function(r) {
                 var queue = r.recv().content();
                 if(e = openils.Event.parse(queue)) 
@@ -899,7 +899,7 @@
         currentQueueId = vlUploadQueueSelector.getValue();
         uploadMARC(handleUploadMARC);
     } else {
-        createQueue(queueName, currentType, handleCreateQueue);
+        createQueue(queueName, currentType, handleCreateQueue, vlUploadQueueHoldingsImportProfile.attr('value'));
     }
 }
 



More information about the open-ils-commits mailing list