by_json: Generate circulation policies
* Generate a new circulation policies file: policies.svg * Parses Circulation policies * Parses Item Types
This commit is contained in:
parent
5cb48604c3
commit
d2c7cda421
@ -1,4 +1,4 @@
|
||||
all: orgas.svg
|
||||
all: orgas.svg policies.svg
|
||||
|
||||
# All .dot files are generated by gen_%.sh file (gen_orgas.sh for example)
|
||||
%.dot: gen_%.sh
|
||||
@ -9,3 +9,6 @@ all: orgas.svg
|
||||
|
||||
clean:
|
||||
rm -f *.svg *.dot
|
||||
|
||||
# Keep temporary files (dot files) for debug
|
||||
.PRECIOUS: %.dot
|
||||
|
12
by_json/filters/circulation_policies
Normal file
12
by_json/filters/circulation_policies
Normal file
@ -0,0 +1,12 @@
|
||||
.[] | {
|
||||
pid,
|
||||
name,
|
||||
description,
|
||||
organisation: .organisation."$ref",
|
||||
allow_checkout,
|
||||
checkout_duration,
|
||||
allow_requests,
|
||||
policy_library_level,
|
||||
libraries: [.libraries[]?],
|
||||
settings
|
||||
}
|
6
by_json/filters/item_types
Normal file
6
by_json/filters/item_types
Normal file
@ -0,0 +1,6 @@
|
||||
.[] | {
|
||||
pid,
|
||||
name,
|
||||
organisation: .organisation."$ref",
|
||||
type
|
||||
}
|
27
by_json/gen_policies.sh
Executable file
27
by_json/gen_policies.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate a dot file to create graph of RERO-ils data
|
||||
#
|
||||
|
||||
# CONFIG
|
||||
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
||||
|
||||
# Load commons variables, functions and statements
|
||||
source commons.sh
|
||||
|
||||
# Graph header
|
||||
title="Circulation policies details."
|
||||
save "templates/header.tmpl"
|
||||
|
||||
# ORGANISATIONS
|
||||
source process_orgas.sh
|
||||
# LIBRARIES
|
||||
source process_lib.sh
|
||||
# CIRCULATION POLICIES
|
||||
source process_cp.sh
|
||||
|
||||
# Graph footer
|
||||
save "templates/footer.tmpl"
|
||||
|
||||
# END of program
|
||||
exit 0
|
59
by_json/process_cp.sh
Normal file
59
by_json/process_cp.sh
Normal file
@ -0,0 +1,59 @@
|
||||
# DEPENDS ON: Organisations (process_orgas.sh), Libraries (process_lib.sh)
|
||||
|
||||
# Main configuration
|
||||
while read cp
|
||||
do
|
||||
# main info
|
||||
pid=$(echo $cp|jq -r .pid)
|
||||
name=$(echo $cp|jq -r .name)
|
||||
description=$(echo $cp|jq -r .description)
|
||||
orga=$(echo $cp|jq -r .organisation)
|
||||
|
||||
# Additional info
|
||||
checkout=$(echo $cp|jq -r .allow_checkout)
|
||||
duration=$(echo $cp|jq -r .checkout_duration)
|
||||
requests=$(echo $cp|jq -r .allow_requests)
|
||||
library_level=$(echo $cp|jq -r .policy_library_level)
|
||||
|
||||
# reset values (because settings overwrites them)
|
||||
shape="doubleoctagon"
|
||||
color="${COLOR5}"
|
||||
border_color="${COLOR5}"
|
||||
additionals=""
|
||||
# write result in output
|
||||
identifier="CP${pid}"
|
||||
label="$(render templates/label_circulation_policies.tmpl)"
|
||||
save "${tmpl_gizmo}"
|
||||
|
||||
# Make a link with organisation if present
|
||||
if [[ -n "${orga}" ]]; then
|
||||
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
||||
relation="Orga${orga_pid}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
|
||||
# Parse settings (if have content)
|
||||
settings=$(echo $cp|jq -r .settings)
|
||||
if [[ "${settings}" != "null" ]]; then
|
||||
for setting in $(echo $settings|jq -c '.[]')
|
||||
do
|
||||
pt_pid=$(echo $setting|jq -r '.patron_type."$ref"'|rev| cut -d"/" -f1 |rev)
|
||||
it_pid=$(echo $setting|jq -r '.item_type."$ref"'|rev|cut -d"/" -f1|rev)
|
||||
|
||||
# reset values
|
||||
shape="Mrecord"
|
||||
color="${COLOR4}"
|
||||
border_color="black"
|
||||
additionals=""
|
||||
# write result in output
|
||||
identifier="Setting${pid}${pt_pid}${it_pid}"
|
||||
label=$(render templates/label_settings.tmpl)
|
||||
save "${tmpl_gizmo}"
|
||||
|
||||
# Make a link between setting and Circulation Policy
|
||||
relation="CP${pid}"
|
||||
save "${tmpl_link}"
|
||||
done
|
||||
fi
|
||||
|
||||
done <<< $(parse_json "circulation_policies")
|
27
by_json/process_it.sh
Normal file
27
by_json/process_it.sh
Normal file
@ -0,0 +1,27 @@
|
||||
# DEPENDS ON: Organisations (process_orgas.sh)
|
||||
|
||||
# Colors
|
||||
IT_COLOR="${COLOR4}" # item_types
|
||||
|
||||
# Main configuration
|
||||
shape="polygon"
|
||||
color="${IT_COLOR}"
|
||||
additionals="sides=6"
|
||||
while read it
|
||||
do
|
||||
pid=$(echo $it|jq -r .pid)
|
||||
name=$(echo $it|jq -r .name)
|
||||
orga=$(echo $it|jq -r .organisation)
|
||||
itype="$(echo $it|jq -r '.type')"
|
||||
# write result in output
|
||||
identifier="IType${pid}"
|
||||
label="$(render templates/label_item_types.tmpl)"
|
||||
save "${tmpl_gizmo}"
|
||||
|
||||
# Make a link with organisation if present
|
||||
if [[ -n "${orga}" ]]; then
|
||||
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
||||
relation="Orga${orga_pid}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
done <<< $(parse_json "item_types")
|
@ -1 +1 @@
|
||||
\"${identifier}\" [shape=${shape} color=\"transparent\" style=filled fillcolor=\"${color}\" label=${label} ${additionals}]
|
||||
\"${identifier}\" [shape=${shape} color=\"${border_color:-transparent}\" style=filled fillcolor=\"${color}\" label=${label} ${additionals}]
|
||||
|
5
by_json/templates/label_circulation_policies.tmpl
Normal file
5
by_json/templates/label_circulation_policies.tmpl
Normal file
@ -0,0 +1,5 @@
|
||||
<${name}<br/>${description}<br/>
|
||||
Checkout: ${checkout} (duration: ${duration})<br/>
|
||||
Requests: ${requests}<br/>
|
||||
Policy library level: ${library_level}<br />
|
||||
PID: ${pid}>
|
1
by_json/templates/label_item_types.tmpl
Normal file
1
by_json/templates/label_item_types.tmpl
Normal file
@ -0,0 +1 @@
|
||||
<${name}<br/>(type: ${itype})<br/>PID: ${pid}>
|
1
by_json/templates/label_settings.tmpl
Normal file
1
by_json/templates/label_settings.tmpl
Normal file
@ -0,0 +1 @@
|
||||
\"Patron type PID: ${pt_pid} | Item type PID: ${it_pid}\"
|
Reference in New Issue
Block a user