Add content to action triggers chapter.
[working/Evergreen.git] / 1.6 / admin / actiontriggers.xml
index 2ba9536..ff2ad72 100644 (file)
@@ -2,8 +2,320 @@
 <chapter xml:id="actiontriggers" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="EN"\r
     xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink">\r
     <info>\r
-        <title>Action Triggers</title>\r
-    </info>\r
-    \r
+        <title>Action Triggers</title>    \r
+       </info>\r
+       <para>Action Triggers were introduced to Evergreen in 1.6. They allow administrators the ability to set up actions for specific events. They are useful for notification events such as \r
+       hold notifications.</para>\r
+       \r
+                       \r
+       <para>To access the Action Triggers module, select\r
+               <menuchoice>\r
+                       <guimenu>Admin</guimenu>  \r
+                       <guisubmenu>Local Administration</guisubmenu>\r
+                       <guisubmenu>Notifications / Action triggers</guisubmenu>\r
+               </menuchoice>\r
+       </para>\r
+       <note><para>You must have Local Administrator permissions to access the Action Triggers module.</para></note>\r
+       <para>You will notice four tabs on this page: <guilabel><link linkend="eventdefinitions">Event Definitions</link></guilabel>, <guilabel><link linkend="Hooks">Hooks</link></guilabel>, \r
+       <guilabel><link linkend="Reactors">Reactors</link></guilabel> and <guilabel><link linkend="Validators">Validators</link></guilabel>.</para>\r
+               \r
+       <section xml:id="eventdefinitions">\r
+               <title>Event Definitions</title>\r
+               <para><guilabel>Event Definitions</guilabel> is the main tab and contains the key fields when working with action triggers. These fields include:</para>\r
+                       <table xml:id="eventdefinitionstable">\r
+                               <title>Action Trigger Event Definitions</title>\r
+                               <tgroup cols="2">\r
+                                       <colspec colnum="1" colname="col1" colwidth="1.0*"/>\r
+                                       <colspec colnum="2" colname="col2" colwidth="3.0*"/>\r
+                                       <thead>\r
+                                               <row>\r
+                                                       <entry>Field</entry>\r
+                                                       <entry>Description</entry>\r
+                                               </row>\r
+                                       </thead>\r
+                                       <tbody>\r
+                                               <row>\r
+                                                       <entry><guilabel>Owning library</guilabel></entry>\r
+                                                       <entry>The shortname of the library for which the action / trigger / hook is defined.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Name</guilabel></entry>\r
+                                                       <entry>The name of the trigger event, that links to a trigger event environment containing a set of fields  \r
+                                                       that will be returned to the <link linkend="Validators">Validators</link> / <link linkend="Reactors">Reactors</link> for processing.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel><link linkend="Hooks">Hooks</link></guilabel></entry>\r
+                                                       <entry>The name of the trigger for the trigger event. The underlying action_trigger.hook table defines the Fieldmapper \r
+                                                       class in the core_type column off of which the rest of the field definitions <quote>hang</quote>. </entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Enabled</guilabel></entry>\r
+                                                       <entry>Sets the given trigger as enabled or disabled. This must be set to enabled for the Action trigger to run.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Processing Delay</guilabel></entry>\r
+                                                       <entry>Defines how long after a given trigger / hook event has occurred before the associated action (<quote>Reactor</quote>) \r
+                                                       will be taken.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Processing Delay Field</guilabel></entry>\r
+                                                       <entry>Defines the field associated with the event on which the processing delay is calculated. For example, the processing delay \r
+                                                       context field on the hold.capture hook (which has a core_type of ahr) is <emphasis>capture_time</emphasis>.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Processing Group Context Field</guilabel></entry>\r
+                                                       <entry>Used to batch actions based on its associated group.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel><link linkend="Validators">Validators</link></guilabel></entry>\r
+                                                       <entry>The subroutines receive the trigger environment as an argument (see the linked <emphasis>Name</emphasis> for \r
+                                                       the environment definition) and returns either <emphasis>1</emphasis> if the validator is <emphasis>true</emphasis> or <emphasis>0</emphasis> \r
+                                                       if the validator returns <emphasis>false</emphasis>.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel><link linkend="Reactors">Reactors</link></guilabel></entry>\r
+                                                       <entry>Links the action trigger to the Reactor.</entry>\r
+                                               </row>\r
+                                               <row>\r
+                                                       <entry><guilabel>Max Event Validity Delay</guilabel></entry>\r
+                                                       <entry>Define the threshold for how far back the action_trigger_runner.pl script should reach to generate \r
+                                                       a batch of events.</entry>\r
+                                               </row>\r
+                                       </tbody>        \r
+                               </tgroup>\r
+                       </table>\r
+               \r
+               <procedure>\r
+               <title>Creating New Action Triggers</title>\r
+                       <step>\r
+                               <para>From the top menu, select\r
+                                       <menuchoice>\r
+                                               <guimenu>Admin</guimenu>  \r
+                                               <guisubmenu>Local Administration</guisubmenu>\r
+                                               <guisubmenu>Notifications / Action triggers</guisubmenu>\r
+                                       </menuchoice>\r
+                               </para>\r
+                       </step>\r
+                       <step><para>Click on the <guibutton>New</guibutton> button.</para></step>\r
+                       <step><para>Select an <guilabel>Owning Library</guilabel>.</para></step>\r
+                       <step><para>Create a unique <guilabel>Name</guilabel> for your new action trigger.</para></step>                                \r
+                       <step><para>Select the <guilabel>Hook</guilabel>.</para></step>\r
+                       <step><para>Check the <guilabel>Enabled</guilabel> check box.</para></step>\r
+               \r
+                       <step><para>Create a unique <guilabel>Name</guilabel> for your new action trigger.</para></step>\r
+                       <step><para>Set the <guilabel>Processing Delay</guilabel> in the appropriate format. Eg. <emphasis class="bold">7 days</emphasis> to run 7 days from the trigger event \r
+                       or <emphasis class="bold">00:01:00</emphasis> to run 1 hour after the <guilabel>Processing Delay Context Field</guilabel>.</para></step>\r
+                       <step><para>Set the <guilabel>Processing Delay Context Field</guilabel> and <guilabel>Processing Group Context Field</guilabel>.</para></step>  \r
+                       <step><para>Select the <guilabel>Validator</guilabel>, <guilabel>Reactor</guilabel>, <guilabel>Failure Cleanup</guilabel> and <guilabel>Success Cleanup</guilabel>.\r
+                       </para></step>  \r
+                       <step><para>Set the <guilabel>Processing Delay Context Field</guilabel> and <guilabel>Processing Group Context Field</guilabel>.</para></step>  \r
+                       <step preformance="optional"><para>Enter text in the <guilabel>Template</guilabel> text box if required. These are for email messages. Here is an sample \r
+                       template for sending 90 day overdue notices:</para>\r
+<programlisting><![CDATA[\r
+[%- USE date -%]\r
+[%- user = target.0.usr -%]\r
+To: robert.soulliere@mohawkcollege.ca\r
+From: robert.soulliere@mohawkcollege.ca\r
+Subject: Overdue Notification\r
+\r
+Dear [% user.family_name %], [% user.first_given_name %]\r
+Our records indicate the following items are overdue.\r
+\r
+[%- USE date -%]\r
+[%- user = target.0.usr -%]\r
+To: robert.soulliere@mohawkcollege.ca\r
+From: robert.soulliere@mohawkcollege.ca\r
+Subject: Overdue Items Marked Lost\r
+\r
+Dear [% user.family_name %], [% user.first_given_name %]\r
+The following items are 90 days overdue and have been marked LOST.\r
+[%- params.recipient_email || user.email %][%- params.sender_email || default_sender %]\r
+[% FOR circ IN target %]\r
+    Title: [% circ.target_copy.call_number.record.simple_record.title %] \r
+    Barcode: [% circ.target_copy.barcode %] \r
+    Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]\r
+    Item Cost: [% helpers.get_copy_price(circ.target_copy) %]\r
+    Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %]\r
+    Library: [% circ.circ_lib.name %]\r
+[% END %]\r
+\r
+\r
+[% FOR circ IN target %]\r
+    Title: [% circ.target_copy.call_number.record.simple_record.title %] \r
+    Barcode: [% circ.target_copy.barcode %] \r
+    Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]\r
+    Item Cost: [% helpers.get_copy_price(circ.target_copy) %]\r
+    Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %]\r
+    Library: [% circ.circ_lib.name %]\r
+[% END %]\r
+]]>\r
+</programlisting>      \r
+                       </step> \r
+                       <step><para>Once you are satisfied with your new event trigger , click the <guibutton>Save</guibutton>button located at the bottom of the \r
+                       form</para></step>\r
+               </procedure>\r
+               <tip><para>A quick and easy way to create new action triggers is to clone an existing action trigger.</para></tip>\r
+               <procedure>\r
+                       <title>Cloning Existing Action Triggers</title>\r
+                       <step>\r
+                               <para>Check the check box next to the action trigger you wish to clone</para>\r
+                       </step>\r
+                       <step>\r
+                               <para>Click the <guibutton>Clone Selected</guibutton> on the top left of the page.</para>\r
+                       </step>\r
+                       <step>\r
+                               <para>An editing window with open. Notice that the fields will be populated with content from the cloned action trigger. Edit as necessary and \r
+                       give the new action trigger a unique <guilabel>Name</guilabel>.</para>\r
+                       </step>\r
+                       <step>\r
+                               <para>Click <guilabel>Save</guilabel>.</para>\r
+                       </step>\r
+               </procedure>\r
+               <procedure>\r
+                       <title>Editing Action Triggers</title>\r
+                       <step>\r
+                               <para>Check the check box next to the action trigger you wish to delete</para>\r
+                       </step>\r
+                       <step>\r
+                               <para>Click the <guibutton>Delete Selected</guibutton> on the top left of the page.</para>\r
+                       </step>\r
+               </procedure>\r
+               \r
+               <note><para>Before deleting an action trigger, you should consider disabling it through the editing form. This way you can simply enable it if you decide that you would like to use \r
+               the action trigger in the future.</para></note>\r
+               <procedure>\r
+                       <title>Deleting Action Triggers</title>\r
+                       <step>\r
+                               <para>Check the check box next to the action trigger you wish to delete</para>\r
+                       </step>\r
+                       <step>\r
+                               <para>Click the <guibutton>Delete Selected</guibutton> on the top left of the page.</para>\r
+                       </step>\r
+               </procedure>\r
+       </section>\r
+       <section xml:id="Hooks">\r
+               <title>Hooks</title>\r
+               <para><guilabel>Hooks</guilabel> define the Fieldmapper class in the core_type column off of which the rest of the field definitions <quote>hang</quote>.</para>\r
+               <table xml:id="Hookstable">\r
+                       <title>Hooks</title>\r
+                       <tgroup cols="2">\r
+                               <colspec colnum="1" colname="col1" colwidth="1.0*"/>\r
+                               <colspec colnum="2" colname="col2" colwidth="3.0*"/>\r
+                               <thead>\r
+                                       <row>\r
+                                               <entry>Field</entry>\r
+                                               <entry>Description</entry>\r
+                                       </row>\r
+                               </thead>\r
+                               <tbody>\r
+                                       <row>\r
+                                               <entry><guilabel>Hook Key</guilabel></entry>\r
+                                               <entry>A unique name given to the hook.</entry>\r
+                                       </row>\r
+                                       <row>\r
+                                               <entry><guilabel>Core Type</guilabel></entry>\r
+                                               <entry>Used to link the action trigger to the IDL class in fm_IDL.xml</entry>\r
+                                       </row>\r
+                                       <row>\r
+                                               <entry><guilabel>Description</guilabel></entry>\r
+                                               <entry>Text to describe the purpose of the hook. </entry>\r
+                                       </row>\r
+                                       <row>\r
+                                               <entry><guilabel>Passive</guilabel></entry>\r
+                                               <entry>Indicates whether or not a hook requires the running of action_trigger_runner.pl with the <option>--process-hooks</option> option to \r
+                                               be processed. <quote>False</quote> means that the script is required for processing.</entry>\r
+                                       </row>\r
+                               </tbody>        \r
+                       </tgroup>\r
+               </table>\r
+               <para>You may also create, edit and delete Hooks but the <guilabel>Core Type</guilabel> must refer to an IDL class in the fm_IDL.xml file.</para>\r
+       </section>      \r
+       <section xml:id="Reactors">\r
+               <title>Reactors</title>\r
+               <para><guilabel>Reactors</guilabel> link the trigger definition to the action to be carried out.</para>\r
+               <table xml:id="Reactorstable">\r
+                       <title>Action Trigger Reactors</title>\r
+                       <tgroup cols="2">\r
+                               <colspec colnum="1" colname="col1" colwidth="1.0*"/>\r
+                               <colspec colnum="2" colname="col2" colwidth="3.0*"/>\r
+                               <thead>\r
+                                       <row>\r
+                                               <entry>Field</entry>\r
+                                               <entry>Description</entry>\r
+                                       </row>\r
+                               </thead>\r
+                               <tbody>\r
+                                       <row>\r
+                                               <entry><guilabel>Module Name</guilabel></entry>\r
+                                               <entry>The name of the Module to run if the action trigger is validated. It must be defined as a subroutine in \r
+                                               <filename>/openils/lib/perl5/OpenILS/Application/Trigger/Reactor.pm</filename> or as a module\r
+                                                in <filename>/openils/lib/perl5/OpenILS/Application/Trigger/Reactor/*.pm</filename>.</entry>\r
+                                       </row>\r
+                                       <row>\r
+                                               <entry><guilabel>Description</guilabel></entry>\r
+                                               <entry>Decription of the Action to be carried out.</entry>\r
+                                       </row>\r
+                               </tbody>        \r
+                       </tgroup>\r
+               </table>\r
+               <para>You may also create, edit and delete Reactors. Just remember that their must be an associated subroutine or module in the Reactor Perl module.</para>\r
+       </section>      \r
+       <section xml:id="Validators">\r
+               <title>Validators</title>\r
+               <para><guilabel>Validators</guilabel> set the validation test to be preformed to determine whether the action trigger is executed.</para>\r
+               <table xml:id="Validatorstable">\r
+                       <title>Action Trigger Validators</title>\r
+                       \r
+                       <tgroup cols="2">\r
+                               <colspec colnum="1" colname="col1" colwidth="1.0*"/>\r
+                               <colspec colnum="2" colname="col2" colwidth="3.0*"/>\r
+                               <thead>\r
+                                       <row>\r
+                                               <entry>Field</entry>\r
+                                               <entry>Description</entry>\r
+                                       </row>\r
+                               </thead>\r
+                               <tbody>\r
+                                       <row>\r
+                                               <entry><guilabel>Module Name</guilabel></entry>\r
+                                               <entry>The name of the subroutine in \r
+                                               <filename>/openils/lib/perl5/OpenILS/Application/Trigger/Reactor.pm</filename> to validate the action trigger.</entry>\r
+                                       </row>\r
+                                       <row>\r
+                                               <entry><guilabel>Description</guilabel></entry>\r
+                                               <entry>Decription of validation test to run.</entry>\r
+                                       </row>\r
+                               </tbody>        \r
+                       </tgroup>\r
+               </table>\r
+               <para>You may also create, edit and delete Validators. Just remember that their must be an associated subroutine in the <filename>Reactor.pm</filename> Perl module.</para>\r
+       </section>      \r
+       <section xml:id="ProcessingActionTriggers">     \r
+               <title>Processing Action Triggers</title>\r
+               <para>To run the action triggers, an Evergreen administrator will need to run the trigger processing script <command>/openils/bin/action_trigger_runner.pl \r
+               <option>--process-hooks</option> <option>--run-pending</option></command>. This should be set up as a cron job to run \r
+               periodically.</para> \r
+               <para>You will need to add some Hooks to the /openils/conf/action_trigger_filters.json file. Below is an example to add the <emphasis>password.reset_request</emphasis>, \r
+               <emphasis>hold.available</emphasis> and <emphasis>checkout.due</emphasis> hooks so that they will be processed by <command>action_trigger_runner.pl</command>.</para> \r
+                       \r
+<programlisting><![CDATA[\r
+{\r
+       "password.reset_request" : { },\r
+\r
+        "hold.available": {},\r
+\r
+       "checkout.due" :\r
+           { "context_org" : "circ_lib", "filter"      :\r
+                   { "checkin_time"  : null,\r
+                     "-or"           :\r
+                           [ { "stop_fines"  : ["MAXFINES", "LONGOVERDUE"] },\r
+                             { "stop_fines"  : null }\r
+                           ]\r
+                   }\r
+           }\r
+}\r
+]]>\r
+</programlisting>\r
+       </section>                                                                                                                                      \r
 </chapter>\r
 \r