From b56929fe58a805849c95beceda702761c1705fdc Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 24 Oct 2009 01:05:50 +0000 Subject: [PATCH] add passive event validator to stop events that are too far past the delay_field-based timeout; add BEGIN to a previous upgrade script for correctness git-svn-id: svn://svn.open-ils.org/ILS/trunk@14588 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Trigger/Validator.pm | 13 +++++++++++++ Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/400.schema.action_trigger.sql | 1 + .../0052.schema.asset_copy_location_order.sql | 2 ++ .../0053.data.max-passive-delay-validator.sql | 8 ++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0053.data.max-passive-delay-validator.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm index b3f2389e4f..f73cbffb58 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm @@ -16,6 +16,19 @@ sub CircIsOpen { return defined($env->{target}->checkin_time) ? 0 : 1; } +sub MaxPassiveDelayAge { + my $self = shift; + my $env = shift; + my $target = $env->{target}; + my $delay_field = $env->{event}->event_def->delay_field; + + my $delay_field_ts = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($target->$delay_field())); + $delay_field_ts->add( seconds => interval_to_seconds( $env->{params}->{max_delay_age} ) ); + + return 0 if $delay_field_ts > DateTime->now; + return 1; +} + sub CircIsOverdue { my $self = shift; my $env = shift; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 9f938ba416..643a70b3f1 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -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 ('0052'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0053'); -- miker CREATE TABLE config.bib_source ( diff --git a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql index df7fddc3b7..b5f71a9b2c 100644 --- a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql +++ b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql @@ -76,6 +76,7 @@ INSERT INTO action_trigger.validator (module,description) VALUES ('NOOP_False',' INSERT INTO action_trigger.validator (module,description) VALUES ('CircIsOpen','Check that the circulation is still open'); INSERT INTO action_trigger.validator (module,description) VALUES ('HoldIsAvailable','Check that an item is on the hold shelf'); INSERT INTO action_trigger.validator (module,description) VALUES ('CircIsOverdue','Check that the circulation is overdue'); +INSERT INTO action_trigger.validator (module,description) VALUES ('MaxPassiveDelayAge','Check that the event is not too far past the delay_field time -- requires a max_delay_age interval parameter'); -- After an event passes validation (action_trigger.validator), the reactor processes it. CREATE TABLE action_trigger.reactor ( diff --git a/Open-ILS/src/sql/Pg/upgrade/0052.schema.asset_copy_location_order.sql b/Open-ILS/src/sql/Pg/upgrade/0052.schema.asset_copy_location_order.sql index 2a037ee17f..0b998fbe17 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0052.schema.asset_copy_location_order.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0052.schema.asset_copy_location_order.sql @@ -1,3 +1,5 @@ +BEGIN; + INSERT INTO config.upgrade_log (version) VALUES ('0052'); CREATE TABLE asset.copy_location_order diff --git a/Open-ILS/src/sql/Pg/upgrade/0053.data.max-passive-delay-validator.sql b/Open-ILS/src/sql/Pg/upgrade/0053.data.max-passive-delay-validator.sql new file mode 100644 index 0000000000..36aaf77440 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0053.data.max-passive-delay-validator.sql @@ -0,0 +1,8 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0053'); + +INSERT INTO action_trigger.validator (module,description) VALUES ('MaxPassiveDelayAge','Check that the event is not too far past the delay_field time -- requires a max_delay_age interval parameter'); + +COMMIT; + -- 2.43.2