From a280708fe305cfcb746ee91662e0173ebc946864 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Tue, 8 Jan 2013 18:54:10 -0500 Subject: [PATCH] Link checker: URL extraction bugfix and usability improvements 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 Signed-off-by: Mike Rylander --- Open-ILS/src/extras/ils_events.xml | 3 +++ .../lib/OpenILS/Application/URLVerify.pm | 7 ++++++ .../src/sql/Pg/076.functions.url_verify.sql | 7 ++++++ .../Pg/upgrade/YYYY.functions.url_verify.sql | 7 ++++++ .../templates/url_verify/create_session.tt2 | 25 ++++++++++--------- .../dojo/openils/URLVerify/CreateSession.js | 2 ++ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 1c458ad739..c37226beb7 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -776,6 +776,9 @@ The user you have attempted to delete cannot be deleted because it has open circulations and/or unpaid bills. + + You are trying to create an object with a unique identifier (such as a 'name' field) that is already in use. + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm index cbda9449e2..0d5e827700 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm @@ -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); diff --git a/Open-ILS/src/sql/Pg/076.functions.url_verify.sql b/Open-ILS/src/sql/Pg/076.functions.url_verify.sql index 5443d51930..dda7fbc8f8 100644 --- a/Open-ILS/src/sql/Pg/076.functions.url_verify.sql +++ b/Open-ILS/src/sql/Pg/076.functions.url_verify.sql @@ -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) diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql index bed0ae3db2..e80cb25542 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.functions.url_verify.sql @@ -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) diff --git a/Open-ILS/src/templates/url_verify/create_session.tt2 b/Open-ILS/src/templates/url_verify/create_session.tt2 index 5c575d0333..734b981d58 100644 --- a/Open-ILS/src/templates/url_verify/create_session.tt2 +++ b/Open-ILS/src/templates/url_verify/create_session.tt2 @@ -92,18 +92,6 @@ - - - - - - - - - - - [% l('Tags and subfields to search for URLs:') %] @@ -122,6 +110,19 @@ + + + + + + + + + + + +
diff --git a/Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js b/Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js index c17681caf9..7808f25d9c 100644 --- a/Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js +++ b/Open-ILS/web/js/dojo/openils/URLVerify/CreateSession.js @@ -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(); } } } -- 2.43.2