16
How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

Embed Size (px)

Citation preview

Page 1: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

How to make a custom service run the X service for renew on a group of patrons

Yoel Kortick

Page 2: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

2

Introduction

• In addition to this file it is also recommended to the

following file on the Doc Portal:Aleph > Tree Search > How to from support >

Miscellaneous > How_to_make_custom-

services_19+.ppt

• It is also recommended to see the EL Commons section

on the X server, specifically for function “renew”

Page 3: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

3

Files involved

• There are four files involved

1. $aleph_proc/p-x-renew-01.template = the template of

the sql which retrieves the item barcodes and patron

IDs. It includes a variable for determining “number of

days from today” for item due date

2. $aleph_proc/p-x-renew-01 = the script run by the

custom service “p-x-renew-01”. It activates p-x-

renew-01.template and creates an sql statement

called “id_and_due_date.sql”, based on input

parameters entered by the user when running custom

service “p-x-renew-01”.

Page 4: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

4

Files involved

• There are four files involved

3. $aleph_root/pc_b_eng/p-x-renew-01.xml = the xml of

the service run in the GUI. It receives input parameters

used by $aleph_proc/p-x-renew-01 when the service

runs.

4. $aleph_root/pc_b_eng/menu-circ.xml = The services

menu in the circulation module. The new custom

service p-x-renew-01 has been added here.

Page 5: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

5

SQL

• The first step will be to build an SQL which will

retrieve all item barcodes and corresponding

patrons which will be renewed via the x server.

• At a later stage these barcodes and patrons will be

put into the proper URL format, for example:

http://library.edu:8995/X?

op=renew&item_barcode=2485635-

10&bor_id=313972002&library=usm50

Page 6: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

6

SQL

• Here is the SQL. The DAYS_TO_ADD will later be replaced by

an actual number entered in the custom service.

yoelk@il-aleph07(a20_3):...aleph/proc>cat $aleph_proc/p-x-renew-01.template

-- Get the z30_barcode and the z36_id for all items with due date less than

-- today plus DAYS_TO_ADD.

set head off

set pause off

spool bc_and_id

select z30_barcode,'|||',z36_id

from z30,z36

where z30_rec_key=z36_rec_key

and z36_due_date < to_char(sysdate+DAYS_TO_ADD,'YYYYMMDD');

spool off

exit

Page 7: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

7

The service script (part 1 of 3)

• Here is the script which is activated by the services.

It runs $aleph_proc/p-x-renew-01.template as an sql

using parameters entered in the serviceyoelk@il-aleph07(a20_3):...aleph/proc>cat $aleph_proc/p-x-renew-01

source $aleph_proc/def_local_env

start_p_generic_proc

set adm_library = `echo $p_active_library | aleph_tr -l`

set days_from_today = $p1

set log_file_name = $p2

echo "The adm library is: $adm_library"

echo "The days_from_today is: $days_from_today"

echo "log_file_name is: $log_file_name"

cd $aleph_proc

# make sql file

cat p-x-renew-01.template | sed "s/DAYS_TO_ADD/$days_from_today/" > \

id_and_due_date.sql

Here an sql is made based on the template using a parameter entered in the service

Page 8: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

8

The service script (part 2 of 3)

# run the sql file

# makes list of item barcode and borrower id separate by three pipes

sqlplus $adm_library/$adm_library @id_and_due_date

grep "rows selected" bc_and_id.lst

# begin manipulation of output file "bc_and_id.lst"

# remove the "rows selected" line

# remove the blank lines (select only lines with something)

grep -v "rows selected" bc_and_id.lst | grep ^. > bc_and_id.lst.tmp01

# begin to make it this syntax

# http://library.edu:8995/X?op=renew&item_barcode=2485635-10&bor_id=313972002&library=usm50

# change the three pipes to "$bor_id="

cat bc_and_id.lst.tmp01 | sed 's/|||/\&bor_id=/' > bc_and_id.lst.tmp02

source $alephe_root/www_server.conf

set httpx = `echo $server_httpd"/X/"`

cat bc_and_id.lst.tmp02 | sed 's/^/xserver_url/' | \

sed "s@xserver_url@$httpx?op=renew\&item_barcode=@" > bc_and_id.lst.tmp03

The URL is not hardcoded, it comes from a system parameter

Page 9: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

9

The service script (part 3 of 3)

# Now add &library=usm50 to end

cat bc_and_id.lst.tmp03 | sed 's/$/\&library=/' | \

sed "s/library=/library=$adm_library/" > bc_and_id.lst.tmp04

# Pack spaces

cat bc_and_id.lst.tmp04 | sed 's/ //g' > x_server_file

wget -O $alephe_scratch/$log_file_name.log.`date +%Y%m%d_%H%M` -i x_server_file

# Remove temporary files

mv x_server_file $alephe_scratch/x_server_file.`date +%Y%m%d_%H%M`

rm bc_and_id.*

rm id_and_due_date.sql

exit:

end_p_proc

exit

The full file of x server URLs for renew is run, and then all temporary files are removed

Page 10: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

10

The xml of the customer of serviceyoelk@il-aleph07(a20_3):...aleph/pc_b_eng>cat p-x-renew-01.xml

<?xml version = "1.0"?><!DOCTYPE dialog SYSTEM "dialog.dtd"><dialog><title>The X server renew service (p-x-renew-01.xml)</title><proc>p-x-renew-01</proc>

<control> <edit> <argname>F01</argname> <label>Days from today for due date</label> <size>3</size> </edit></control>

<control> <edit> <argname>F02</argname> <label>alephe_scratch log file name (maximum 10 characters)</label> <size>10</size> </edit></control>

<permission>p_priv_01</permission>

</dialog>

This is later used as a variable in the sql

A separate alephe_scratch file is saved with the x server response messages

Page 11: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

11

The services menu for circulation

yoelk@il-aleph07(a20_3):...aleph/proc>pcb

yoelk@il-aleph07(a20_3):...aleph/pc_b_eng>cat menu-circ.xml

<?xml version = "1.0"?>

<!DOCTYPE menu SYSTEM "menu.dtd">

<menu>

<sub>

<sub_main>Circ</sub_main>

<sub_menu>

<group_caption>Notices to Patrons</group_caption>

<item>

<display>Courtesy Notices (cir-10)</display>

<file>p-cir-10</file>

</item>

<item>

<display>Renew Loans with X server (p-x-renew-01)</display>

<file>p-x-renew-01</file>

</item>

Calls and runsp-x-renew-01.xml

Page 12: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

12

Run the service

All loans due within 8 days (including overdue) will be included

A messages log file called “x_renew_01” will be created

Page 13: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

13

The messages log file

• Here is an example of part of the messages log

file in $alephe_scratch

yoelk@il-aleph07(a20_3) USM50> more $alephe_scratch/x_renew_01.log.20101025_0812

<?xml version = "1.0" encoding = "UTF-8"?>

<renew>

<reply>ok</reply>

<due-date>20101027</due-date>

<due-hour>2200</due-hour>

<session-id>85HRARBQFFKQD5YES9ARUD9QK4YQ2X7A18MP67RS8NI9VB4JT3</session-id>

</renew>

<?xml version = "1.0" encoding = "UTF-8"?>

<renew>

<error-code-1>0221</error-code-1>

<error-text-1>Loan has been declared lost.</error-text-1>

<session-id>3G9GLRQ5FBQBFXBHQ2M7GB9T24E6Y4UF8F5N65H95CYI8JRAER</session-id>

</renew>

Page 14: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

14

The file with URLs which is run

• Here is an example of part of the file containing

the “renew” x server URLs which is created and

run by the service

yoelk@il-aleph07(a20_3) USM50> cat x_server_file.20101025_0825

http://il-aleph07.corp.exlibrisgroup.com:8993/X/?op=renew&item_barcode=32044005026661&bor_id=00238154&library=usm50

http://http://il-aleph07.corp.exlibrisgroup.com:8993/X/?op=renew&item_barcode=32044025805375&bor_id=00004317&library=usm50

http://il-aleph07.corp.exlibrisgroup.com:8993/X/?op=renew&item_barcode=32044035608835&bor_id=00004317&library=usm50

Page 15: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

15

The renewal is made

• Here is an example where the renewal is made by

the x server from the custom service, and a cash

transaction ois created

yoelk@il-aleph07(a20_3) USM50> grep 32044010678266 x_server_file.20101025_0825

http://il-aleph07.corp.exlibrisgroup.com:8993/X/?op=renew&item_barcode=32044010678266&bor_id=00338133&library=usm50

Page 16: How to make a custom service run the X service for renew on a group of patrons Yoel Kortick

Thank You!Yoel Kortick