Link checker: URL extraction bugfix and usability improvements
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 8 Jan 2013 23:54:10 +0000 (18:54 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 14 Feb 2013 19:19:17 +0000 (14:19 -0500)
The database procedure for URL extraction did not correctly handle
URLs in repeating subfields in the same tag.  Now fixed.

You now get a hint if you try to create a session with a name you have
used before.

Some UI elements on the create session interface have been reordered to
be more logical.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm
Open-ILS/src/sql/Pg/076.functions.url_verify.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql
Open-ILS/src/templates/url_verify/create_session.tt2
Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js

index 1c458ad..c37226b 100644 (file)
         <event code='2004' textcode='ACTOR_USER_DELETE_OPEN_XACTS'>
                 <desc xml:lang="en-US">The user you have attempted to delete cannot be deleted because it has open circulations and/or unpaid bills.</desc>
         </event>
+       <event code='2005' textcode='OBJECT_UNIQUE_IDENTIFIER_USED'>
+               <desc xml:lang="en-US">You are trying to create an object with a unique identifier (such as a 'name' field) that is already in use.</desc>
+       </event>
 
     <!-- CREDIT EVENTS -->
        <event code='4001' textcode='CREDIT_PROCESSOR_NOT_ENABLED'>
index cbda944..0d5e827 100644 (file)
@@ -658,6 +658,13 @@ sub create_session {
     $owning_lib ||= $e->requestor->ws_ou;
     return $e->die_event unless $e->allowed("URL_VERIFY", $owning_lib);
 
+    $name .= "";
+    my $name_test = $e->search_url_verify_session({name => $name});
+    return $e->die_event unless $name_test; # db error
+    return $e->die_event(
+        new OpenILS::Event("OBJECT_UNIQUE_IDENTIFIER_USED", note => "name"),
+    ) if @$name_test;   # already existing sessions with that name
+
     my $session = Fieldmapper::url_verify::session->new;
     $session->name($name);
     $session->owning_lib($owning_lib);
index 5443d51..dda7fbc 100644 (file)
@@ -62,6 +62,7 @@ CREATE TRIGGER ingest_url_tgr
 
 CREATE OR REPLACE FUNCTION url_verify.extract_urls ( session_id INT, item_id INT ) RETURNS INT AS $$
 DECLARE
+    last_seen_tag TEXT;
     current_tag TEXT;
     current_sf TEXT;
     current_url TEXT;
@@ -86,6 +87,12 @@ BEGIN
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
               WHERE c.id = item_id;
 
+            IF current_tag IS NULL THEN
+                current_tag := last_seen_tag;
+            ELSE
+                last_seen_tag := current_tag;
+            END IF;
+
             SELECT  (XPATH(current_selector.xpath || '/@code', b.marc::XML))[current_url_pos]::TEXT INTO current_sf
               FROM  biblio.record_entry b
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
index bed0ae3..e80cb25 100644 (file)
@@ -46,6 +46,7 @@ CREATE TRIGGER ingest_url_tgr
 
 CREATE OR REPLACE FUNCTION url_verify.extract_urls ( session_id INT, item_id INT ) RETURNS INT AS $$
 DECLARE
+    last_seen_tag TEXT;
     current_tag TEXT;
     current_sf TEXT;
     current_url TEXT;
@@ -70,6 +71,12 @@ BEGIN
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
               WHERE c.id = item_id;
 
+            IF current_tag IS NULL THEN
+                current_tag := last_seen_tag;
+            ELSE
+                last_seen_tag := current_tag;
+            END IF;
+
             SELECT  (XPATH(current_selector.xpath || '/@code', b.marc::XML))[current_url_pos]::TEXT INTO current_sf
               FROM  biblio.record_entry b
                     JOIN container.biblio_record_entry_bucket_item c ON (c.target_biblio_record_entry = b.id)
index 5c575d0..734b981 100644 (file)
 
             <tr>
                 <th>
-                    <label for="no-url-selection">[% l('Process immediately?') %]</label>
-                </th>
-                <td>
-                    <input dojoType="dijit.form.CheckBox" id="no-url-selection"
-                        jsId="no_url_selection" />
-                </td>
-                <td class="note">
-                </td>
-            </tr>
-
-            <tr>
-                <th>
                     [% l('Tags and subfields to search for URLs:') %]
                 </th>
                 <td>
                 <td class="note">
                 </td>
             </tr>
+
+            <tr>
+                <th>
+                    <label for="no-url-selection">[% l('Process immediately?') %]</label>
+                </th>
+                <td>
+                    <input dojoType="dijit.form.CheckBox" id="no-url-selection"
+                        jsId="no_url_selection" />
+                </td>
+                <td class="note">
+                </td>
+            </tr>
+
         </table>
 
         <div>
index c17681c..7808f25 100644 (file)
@@ -83,6 +83,8 @@ if (!dojo._hasResource["openils.URLVerify.CreateSession"]) {
                         /* I think we're modal enough to get away with this. */
                         module.session_id = r;
                         module.save_tags();
+                    } else {
+                        module.progress_dialog.hide();
                     }
                 }
             }