Skip to content

berick/evergreen-xml-notices

Repository files navigation

evergreen-xml-notices

Important

The documtation below still holds, but the latest version of the code running at KCLS (as of 2024-09-12, where this code originated) lives at https://github.com/kcls/evergreen-pub/tree/release/3.11/KCLS/utility-scripts/xml-notices

XML Notice File Generator For Evergreen

Generate and send XML files for Evergreen Action/Trigger event definitions. Files are sent to configured 3rd party for generating print/email/phone/etc. notices.

How-To

Create an Action/Trigger Event Definition

  • Use the NOOP_True reactor.
    • The purpose of the event definition is only to collect target (e.g. circulation ID) information.
  • No template is nececessary
  • It should NOT have a group_field value.
    • Grouping is done by the script.
  • Give it a unique granularity
  • No environment data will be needed, unless one of the other modules (e.g. validator) requires it.

For Example (Hold Shelf Expire Email)

    INSERT INTO action_trigger.event_definition (
        id, owner, active, name, hook, validator, reactor, delay, max_delay,
        usr_field, opt_in_setting, delay_field, granularity, retention_interval
    ) VALUES (
        500, 
        1,
        TRUE,
        'Hold Expired On Hold Shelf Email Notice (UMS)',
        'hold_request.cancel.expire_holds_shelf',
        'HoldIsCancelled',
        'NOOP_True',
        '00:00:30',                         -- delay
        NULL,                               -- max delay
        'usr',                              -- usr field
        'notification.hold.cancel.email',   -- opt in
        NULL,                               -- delay field
        'Hold-Shelf-Expire-Email',          -- granularity
        '1 year'
    );

Edit generate-notices.sh

  1. Set the required value for the SCP_DEST variable.
  2. Comment-out the KCLS notifications configured within the "case $GRANULARITY in" block. I left the KCLS notices for reference, since Different notice types use different options.
  3. Add your new notice to the file to the same block
case $GRANULARITY in

    'Hold-Shelf-Expire-Email')                                                 
        export FOR_EMAIL="--for-email"                                         
        export EVENT_DEF=500
        export NOTICE_TAG=hold-shelf-expire                                    
        export NOTICE_TYPE="hold shelf expire email"                           
        ;; 

    # Other notices here...

esac
  1. Create the XML file output directory
sudo -u opensrf mkdir -p /openils/var/data/xml-notices

Generate and Send the XML File

Example 1

  • Remove --send-email to generate the XML file without sending it.
./generate-notices.sh --granularity Hold-Shelf-Expire-Email --send-xml

Example 2

By default, the script processes events whose run_time occurred yesterday, but this can be modified via the --end-date and --window variables.

This example would be executed hourly to process events whose run time fell within the previous hour.

./generate-notices.sh --send-xml --window "1 hour" \
    --end-date "$(date +'%FT%H:00:00')" --granularity Hold-Ready-Locker-Phone

About

XML Notice File Generator For Evergreen

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published