backporting 15353 and 15354 from Dan Wells for vandelay fixing goodness
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 21 Jan 2010 16:46:59 +0000 (16:46 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 21 Jan 2010 16:46:59 +0000 (16:46 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@15355 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql [new file with mode: 0644]
Open-ILS/web/js/ui/default/vandelay/vandelay.js

index 0a96b06..e394e21 100644 (file)
@@ -133,7 +133,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </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"/>
@@ -227,9 +227,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <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>
index 8c0f974..644bf11 100644 (file)
@@ -36,6 +36,7 @@ sub create_bib_queue {
        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 @@ sub create_bib_queue {
        $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 @@ __PACKAGE__->register_method(
        api_name        => "open-ils.vandelay.bib_queue.create",
        method          => "create_bib_queue",
        api_level       => 1,
-       argc            => 3,
+       argc            => 4,
 );                      
 
 
index 1033b6b..3df652c 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0130'); -- senator
+INSERT INTO config.upgrade_log (version) VALUES ('0139'); -- Dan Wells via miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 47f5545..e1083fc 100644 (file)
@@ -432,61 +432,58 @@ $$ LANGUAGE PLPGSQL;
 
 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;
-
-    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;
+    SELECT item_attr_def INTO attr_def FROM vandelay.bib_queue WHERE id = NEW.queue;
+
+    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;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql b/Open-ILS/src/sql/Pg/upgrade/0139.schema.vandelay-item-import-fix.sql
new file mode 100644 (file)
index 0000000..15cae10
--- /dev/null
@@ -0,0 +1,66 @@
+
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0139'); -- Dan Wells via miker
+
+CREATE OR REPLACE FUNCTION vandelay.ingest_bib_items ( ) RETURNS TRIGGER AS $func$
+DECLARE
+    attr_def    BIGINT;
+    item_data   vandelay.import_item%ROWTYPE;
+BEGIN
+
+    SELECT item_attr_def INTO attr_def FROM vandelay.bib_queue WHERE id = NEW.queue;
+
+    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;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
index 262b4fc..cb0b2ff 100644 (file)
@@ -287,13 +287,13 @@ function uploadMARC(onload){
 /**
   * 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 @@ function batchUpload() {
         currentQueueId = vlUploadQueueSelector.getValue();
         uploadMARC(handleUploadMARC);
     } else {
-        createQueue(queueName, currentType, handleCreateQueue);
+        createQueue(queueName, currentType, handleCreateQueue, vlUploadQueueHoldingsImportProfile.attr('value'));
     }
 }