[open-ils-commits] r17281 - in trunk/Open-ILS/src: perlmods/OpenILS/Application sql/Pg sql/Pg/upgrade (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Aug 20 09:22:32 EDT 2010


Author: dbs
Date: 2010-08-20 09:22:30 -0400 (Fri, 20 Aug 2010)
New Revision: 17281

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0376.data.merge_auth_perms.sql
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
Add the authority record merge middle-layer API (open-ils.cat.authority.records.merge)

Also add a pertinent permission (MERGE_AUTH_RECORDS)


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-08-20 11:25:40 UTC (rev 17280)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-08-20 13:22:30 UTC (rev 17281)
@@ -676,7 +676,45 @@
     return $count;
 }
 
+__PACKAGE__->register_method(
+    method    => 'in_db_auth_merge',
+    api_name  => 'open-ils.cat.authority.records.merge',
+    signature => q/
+        Merges a group of authority records
+        @param auth The login session key
+        @param master The id of the record all other records should be merged into
+        @param records Array of records to be merged into the master record
+        @return 1 on success, Event on error.
+    /
+);
 
+sub in_db_auth_merge {
+    my( $self, $conn, $auth, $master, $records ) = @_;
+
+    my $editor = new_editor( authtoken => $auth, xact => 1 );
+    return $editor->die_event unless $editor->checkauth;
+    return $editor->die_event unless $editor->allowed('MERGE_AUTH_RECORDS'); # TODO see below about record ownership
+
+    my $count = 0;
+    for my $source ( @$records ) {
+        $count += $editor->json_query({
+            select => {
+                are => [{
+                    alias => 'count',
+                    transform => 'authority.merge_records',
+                    column => 'id',
+                    params => [$source]
+                }]
+            },
+            from   => 'are',
+            where  => { id => $master }
+        })->[0]->{count}; # count of objects moved, of all types
+    }
+
+    $editor->commit;
+    return $count;
+}
+
 __PACKAGE__->register_method(
 	method	=> "fleshed_volume_update",
 	api_name	=> "open-ils.cat.asset.volume.fleshed.batch.update",);

Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-08-20 11:25:40 UTC (rev 17280)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2010-08-20 13:22:30 UTC (rev 17281)
@@ -68,7 +68,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0375'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0376'); -- dbs
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2010-08-20 11:25:40 UTC (rev 17280)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2010-08-20 13:22:30 UTC (rev 17281)
@@ -1258,7 +1258,7 @@
     (277,'UPDATE_VOLUME_NOTE', oils_i18n_gettext(277,'FIXME: Need description for UPDATE_VOLUME_NOTE', 'ppl', 'description')),
     (278,'UPDATE_VR_FORMAT', oils_i18n_gettext(278,'FIXME: Need description for UPDATE_VR_FORMAT', 'ppl', 'description')),
     (279,'UPDATE_XML_TRANSFORM', oils_i18n_gettext(279,'FIXME: Need description for UPDATE_XML_TRANSFORM', 'ppl', 'description')),
-    (280,'MERGE_BIB_RECORDS', oils_i18n_gettext(280,'FIXME: Need description for MERGE_BIB_RECORDS', 'ppl', 'description')),
+    (280,'MERGE_BIB_RECORDS', oils_i18n_gettext(280,'Allow a user to merge bibliographic records and associated assets', 'ppl', 'description')),
     (281,'UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', oils_i18n_gettext(281,'FIXME: Need description for UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', 'ppl', 'description')),
     (282,'CREATE_ACQ_FUNDING_SOURCE', oils_i18n_gettext(282,'FIXME: Need description for CREATE_ACQ_FUNDING_SOURCE', 'ppl', 'description')),
     (283,'CREATE_AUTHORITY_IMPORT_IMPORT_FIELD_DEF', oils_i18n_gettext(283,'FIXME: Need description for CREATE_AUTHORITY_IMPORT_IMPORT_FIELD_DEF', 'ppl', 'description')),
@@ -1379,6 +1379,7 @@
     (390, 'OVERRIDE_HOLD_HAS_LOCAL_COPY', oils_i18n_gettext( 390, 'Allow a user to override the circ.holds.hold_has_copy_at.block setting', 'ppl', 'description' ))
     ,(391, 'UPDATE_PICKUP_LIB_FROM_TRANSIT', oils_i18n_gettext( 391, 'Allow a user to change the pickup and transit destination for a captured hold item already in transit', 'ppl', 'description' ))
     ,(392, 'COPY_NEEDED_FOR_HOLD.override', oils_i18n_gettext( 392, 'Allow a user to force renewal of an item that could fulfill a hold request', 'ppl', 'description' ))
+    ,(393, 'MERGE_AUTH_RECORDS', oils_i18n_gettext( 393, 'Allow a user to merge authority records together', 'ppl', 'description' ))
 ;
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
@@ -1514,6 +1515,7 @@
 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (4, (SELECT id FROM permission.perm_list WHERE code = 'UPDATE_MFHD_RECORD'), 1, false);
 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (4, (SELECT id FROM permission.perm_list WHERE code = 'DELETE_MFHD_RECORD'), 1, false);
 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (4, (SELECT id FROM permission.perm_list WHERE code = 'UPDATE_RECORD'), 1, false);
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (4, (SELECT id FROM permission.perm_list WHERE code = 'MERGE_AUTH_RECORDS'), 1, false);
 
 -- Add basic circulation permissions to the Circulators group
 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (5, (SELECT id FROM permission.perm_list WHERE code = 'CREATE_TRANSACTION'), 0, false);

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0376.data.merge_auth_perms.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0376.data.merge_auth_perms.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0376.data.merge_auth_perms.sql	2010-08-20 13:22:30 UTC (rev 17281)
@@ -0,0 +1,6 @@
+INSERT INTO config.upgrade_log (version) VALUES ('0376'); -- dbs
+
+-- Permission for merging auth records may already be defined
+-- so we do it outside of a transaction
+INSERT INTO permission.perm_list (code, description) VALUES ('MERGE_AUTH_RECORDS', 'Allow a user to merge authority records together');
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (4, (SELECT id FROM permission.perm_list WHERE code = 'MERGE_AUTH_RECORDS'), 1, false);



More information about the open-ils-commits mailing list