From: miker Date: Wed, 28 Jan 2009 02:17:38 +0000 (+0000) Subject: example validators; adding noop modules to the schema creation script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d6d7a5d43848bc5d1c873303d10d3da8306a9a9a;p=evergreen%2Ftadl.git example validators; adding noop modules to the schema creation script git-svn-id: svn://svn.open-ils.org/ILS/trunk@12006 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm index f9a001d62f..d97b911fb6 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm @@ -2,4 +2,28 @@ package OpenILS::Application::Trigger::Validator; sub fourty_two { return 42 } sub NOOP_True { return 1 } sub NOOP_False { return 0 } + +sub CircIsOpen { + my $self = shift; + my $env = shift; + + return defined($env->{target}->checkin_time) ? 0 : 1; +} + +sub HoldIsAvailable { + my $self = shift; + my $env = shift; + + my $t = $env->{target}->transit; + + die "Transit object exists, but is not fleshed. Add 'transit' to the environment in order to use this Validator." + if ($t && !ref($t)); + + if ($t) { + return (defined($env->{target}->capture_time) && defined($t->dest_recv_time)) ? 1 : 0; + } + + return defined($env->{target}->capture_time) ? 1 : 0; +} + 1; 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 06007fb466..8911ed9566 100644 --- a/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql +++ b/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql @@ -49,13 +49,17 @@ CREATE TABLE action_trigger.collector ( module TEXT PRIMARY KEY, -- All live under the OpenILS::Trigger::Collector:: namespace description TEXT ); -INSERT INTO action_trigger.collector (module,description) VALUES ('CircCountsByCircMod','Count of Circulations for a User, broken down by circulation modifier'); +INSERT INTO action_trigger.collector (module,description) VALUES ('fourty_two','Returns the answer to life, the universe and everything'); +--INSERT INTO action_trigger.collector (module,description) VALUES ('CircCountsByCircMod','Count of Circulations for a User, broken down by circulation modifier'); -- Simple tests on an FM object from hook.core_type to test for "should we still do this." CREATE TABLE action_trigger.validator ( module TEXT PRIMARY KEY, -- All live under the OpenILS::Trigger::Validator:: namespace description TEXT ); +INSERT INTO action_trigger.validator (module,description) VALUES ('fourty_two','Returns the answer to life, the universe and everything'); +INSERT INTO action_trigger.validator (module,description) VALUES ('NOOP_True','Always returns true -- validation always passes'); +INSERT INTO action_trigger.validator (module,description) VALUES ('NOOP_False','Always returns false -- validation always fails'); 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'); @@ -64,6 +68,9 @@ CREATE TABLE action_trigger.reactor ( module TEXT PRIMARY KEY, -- All live under the OpenILS::Trigger::Reactor:: namespace description TEXT ); +INSERT INTO action_trigger.reactor (module,description) VALUES ('fourty_two','Returns the answer to life, the universe and everything'); +INSERT INTO action_trigger.reactor (module,description) VALUES ('NOOP_True','Always returns true -- reaction always passes'); +INSERT INTO action_trigger.reactor (module,description) VALUES ('NOOP_False','Always returns false -- reaction always fails'); INSERT INTO action_trigger.reactor (module,description) VALUES ('SendEmail','Send an email based on a user-defined template'); INSERT INTO action_trigger.reactor (module,description) VALUES ('GenerateBatchOverduePDF','Output a batch PDF of overdue notices for printing'); @@ -72,6 +79,9 @@ CREATE TABLE action_trigger.cleanup ( module TEXT PRIMARY KEY, -- All live under the OpenILS::Trigger::Cleanup:: namespace description TEXT ); +INSERT INTO action_trigger.cleanup (module,description) VALUES ('fourty_two','Returns the answer to life, the universe and everything'); +INSERT INTO action_trigger.cleanup (module,description) VALUES ('NOOP_True','Always returns true -- cleanup always passes'); +INSERT INTO action_trigger.cleanup (module,description) VALUES ('NOOP_False','Always returns false -- cleanup always fails'); INSERT INTO action_trigger.cleanup (module,description) VALUES ('ClearAllPending','Remove all future, pending notifications for this target'); CREATE TABLE action_trigger.event_definition (