Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2c7cda421 | |||
5cb48604c3 | |||
7bf5972250 |
0
orgas/.gitignore → by_json/.gitignore
vendored
0
orgas/.gitignore → by_json/.gitignore
vendored
14
by_json/Makefile
Normal file
14
by_json/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
all: orgas.svg policies.svg
|
||||
|
||||
# All .dot files are generated by gen_%.sh file (gen_orgas.sh for example)
|
||||
%.dot: gen_%.sh
|
||||
bash "$<" "$@"
|
||||
|
||||
%.svg: %.dot
|
||||
dot -Tsvg "$<" -o "$@"
|
||||
|
||||
clean:
|
||||
rm -f *.svg *.dot
|
||||
|
||||
# Keep temporary files (dot files) for debug
|
||||
.PRECIOUS: %.dot
|
@ -12,6 +12,14 @@ tmpl_gizmo="templates/gizmo.tmpl" # A colored polygon. Represents an entity.
|
||||
tmpl_link="templates/link.tmpl" # A link between two entities.
|
||||
tmpl_label="templates/label_default.tmpl" # Default label for entities.
|
||||
|
||||
# pastel colors (Cf. https://www.color-hex.com/color-palette/5361)
|
||||
COLOR1="#ffb3ba"
|
||||
COLOR2="#ffdfba"
|
||||
COLOR3="#ffffba"
|
||||
COLOR4="#baffc9"
|
||||
COLOR5="#bae1ff"
|
||||
COMP_COLOR4="#ffd8ba"
|
||||
|
||||
# Graph info
|
||||
rankdir="RL"
|
||||
title=""
|
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
|
||||
}
|
39
by_json/gen_orgas.sh
Executable file
39
by_json/gen_orgas.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate a dot file to create graph of RERO-ils data
|
||||
#
|
||||
|
||||
# Usage:
|
||||
# bash gen_orgas.sh output.dot
|
||||
# where `output.dot` is the output file that permit to generate a graph.
|
||||
# To generate the graph:
|
||||
# dot -Tsvg output.dot -o organisations.svg
|
||||
# where `output.dot` is the previous file. And `organisations.svg` the final schema you want to display.
|
||||
|
||||
# CONFIG
|
||||
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
||||
|
||||
# Load commons variables, functions and statements
|
||||
source commons.sh
|
||||
|
||||
# Graph header
|
||||
title="Link between organisations, libraries and users."
|
||||
save "templates/header.tmpl"
|
||||
|
||||
# ORGANISATIONS
|
||||
source process_orgas.sh
|
||||
|
||||
# LIBRARIES
|
||||
source process_lib.sh
|
||||
|
||||
# PATRON_TYPES
|
||||
source process_pt.sh
|
||||
|
||||
# USERS
|
||||
source process_users.sh
|
||||
|
||||
# Graph footer
|
||||
save "templates/footer.tmpl"
|
||||
|
||||
# END of program
|
||||
exit 0
|
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")
|
22
by_json/process_lib.sh
Normal file
22
by_json/process_lib.sh
Normal file
@ -0,0 +1,22 @@
|
||||
# DEPENDS ON: Organisations (process_orgas.sh)
|
||||
|
||||
# Colors
|
||||
LIB_COLOR="${COLOR2}" # libraries
|
||||
|
||||
# Main configuration
|
||||
shape="house"
|
||||
color="${LIB_COLOR}"
|
||||
while read -r lib
|
||||
do
|
||||
pid=$(echo $lib|jq -r .pid)
|
||||
name=$(echo $lib|jq -r .name)
|
||||
code=$(echo $lib|jq -r .code)
|
||||
orga=$(echo $lib|jq -r .organisation)
|
||||
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
||||
# write result in output
|
||||
identifier="Lib${pid}"
|
||||
label="$(render ${tmpl_label})"
|
||||
save "${tmpl_gizmo}"
|
||||
relation="Orga${orga_pid}"
|
||||
save "${tmpl_link}"
|
||||
done <<< $(parse_json "libraries")
|
19
by_json/process_orgas.sh
Normal file
19
by_json/process_orgas.sh
Normal file
@ -0,0 +1,19 @@
|
||||
# DEPENDS ON: None
|
||||
|
||||
# Colors
|
||||
ORGA_COLOR="${COLOR1}" # organisations
|
||||
|
||||
# Main configuration
|
||||
shape="box"
|
||||
color="${ORGA_COLOR}"
|
||||
while read -r orga
|
||||
do
|
||||
# take important info
|
||||
pid=$(echo $orga|jq -r .pid)
|
||||
code=$(echo $orga|jq -r .code)
|
||||
name=$(echo $orga|jq -r .name)
|
||||
# write result in output
|
||||
identifier="Orga${pid}"
|
||||
label="$(render ${tmpl_label})"
|
||||
save "${tmpl_gizmo}"
|
||||
done <<< $(parse_json "organisations")
|
26
by_json/process_pt.sh
Normal file
26
by_json/process_pt.sh
Normal file
@ -0,0 +1,26 @@
|
||||
# DEPENDS ON: Organisations (process_orgas.sh)
|
||||
|
||||
# Colors
|
||||
PT_COLOR="${COLOR3}" # patron_types
|
||||
|
||||
# Main configuration
|
||||
shape="polygon"
|
||||
color="${PT_COLOR}"
|
||||
additionals="sides=7"
|
||||
while read pt
|
||||
do
|
||||
pid=$(echo $pt|jq -r .pid)
|
||||
name=$(echo $pt|jq -r .name)
|
||||
orga=$(echo $pt|jq -r .organisation)
|
||||
# write result in output
|
||||
identifier="Type${pid}"
|
||||
label="$(render templates/label_patron_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 "patron_types")
|
55
by_json/process_users.sh
Normal file
55
by_json/process_users.sh
Normal file
@ -0,0 +1,55 @@
|
||||
# DEPENDS ON: Patron types (process_pt.sh), Library (process_lib.sh)
|
||||
|
||||
# Colors
|
||||
USER_COLOR="${COLOR5}" # users/patrons
|
||||
|
||||
# Main configuration
|
||||
shape="ellipse"
|
||||
additionals=''
|
||||
color="${USER_COLOR}"
|
||||
while read user
|
||||
do
|
||||
email=$(echo $user|jq -r .email)
|
||||
first_name=$(echo $user|jq -r .first_name)
|
||||
last_name=$(echo $user|jq -r .last_name)
|
||||
barcode=$(echo $user|jq -r .barcode)
|
||||
roles=$(echo $user|jq -r .roles[])
|
||||
library=$(echo $user|jq -r .library)
|
||||
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
||||
pt=$(echo $user|jq -r .pt)
|
||||
|
||||
# Prepare additional info
|
||||
if [[ "${roles}" != "null" ]]; then
|
||||
displayed_roles="roles: "
|
||||
for role in ${roles}; do
|
||||
displayed_roles="${displayed_roles}<font color='red' >${role}</font>, "
|
||||
done
|
||||
fi
|
||||
# Don't display barcode if no one
|
||||
info=""
|
||||
if [[ "${barcode}" != "null" ]]; then
|
||||
info="${info}<br/>${barcode}"
|
||||
fi
|
||||
# Same for roles
|
||||
if [[ -n "${displayed_roles}" ]]; then
|
||||
info="${info}<br/>${displayed_roles}"
|
||||
fi
|
||||
|
||||
# write result in output
|
||||
identifier="User_${email}"
|
||||
label="$(render templates/label_users.tmpl)"
|
||||
save "${tmpl_gizmo}"
|
||||
|
||||
# Display a link if library_pid is not null
|
||||
if [[ "${library_pid}" != "null" ]]; then
|
||||
relation="Lib${library_pid}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
|
||||
# Display a link if patron_type is not null
|
||||
if [[ "$pt" != "null" ]]; then
|
||||
pt_id=$(echo $pt|rev| cut -d "/" -f 1|rev)
|
||||
relation="Type${pt_id}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
done <<< $(parse_json "users")
|
1
by_json/templates/gizmo.tmpl
Normal file
1
by_json/templates/gizmo.tmpl
Normal file
@ -0,0 +1 @@
|
||||
\"${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}\"
|
@ -1,12 +0,0 @@
|
||||
all: organisations.svg
|
||||
|
||||
|
||||
graph.dot: gen.sh
|
||||
bash gen.sh graph.dot
|
||||
|
||||
|
||||
organisations.svg: graph.dot
|
||||
dot -Tsvg graph.dot -o organisations.svg
|
||||
|
||||
clean:
|
||||
rm -f organisations.svg graph.dot
|
145
orgas/gen.sh
145
orgas/gen.sh
@ -1,145 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate a dot file to create graph of RERO-ils data (orga, lib and users)
|
||||
#
|
||||
|
||||
# Usage:
|
||||
# bash gen.sh output.dot
|
||||
# where `output.dot` is the output file that permit to generate a graph.
|
||||
# To generate the graph:
|
||||
# dot -Tsvg output.dot -o organisations.svg
|
||||
# where `output.dot` is the previous file. And `organisations.svg` the final schema you want to display.
|
||||
|
||||
# CONFIG
|
||||
RERO_DIR="${HOME}/projets/rero/rero-ils"
|
||||
# pastel colors (Cf. https://www.color-hex.com/color-palette/5361)
|
||||
COLOR1="#ffb3ba"
|
||||
COLOR2="#ffdfba"
|
||||
COLOR3="#ffffba"
|
||||
COLOR4="#baffc9"
|
||||
COLOR5="#bae1ff"
|
||||
COMP_COLOR4="#ffd8ba"
|
||||
# colors you choose for different objects
|
||||
ORGA_COLOR="${COLOR1}" # organisations
|
||||
LIB_COLOR="${COLOR2}" # libraries
|
||||
PT_COLOR="${COLOR3}" # patron_types
|
||||
USER_COLOR="${COLOR5}" # users/patrons
|
||||
|
||||
# Load commons variables, functions and statements
|
||||
source commons.sh
|
||||
|
||||
# Graph header
|
||||
title="Link between organisations, libraries and users."
|
||||
save "templates/header.tmpl"
|
||||
|
||||
# ORGANISATIONS
|
||||
shape="box"
|
||||
color="${ORGA_COLOR}"
|
||||
while read -r orga
|
||||
do
|
||||
# take important info
|
||||
pid=$(echo $orga|jq -r .pid)
|
||||
code=$(echo $orga|jq -r .code)
|
||||
name=$(echo $orga|jq -r .name)
|
||||
# write result in output
|
||||
identifier="Orga${pid}"
|
||||
label="$(render ${tmpl_label})"
|
||||
save "${tmpl_gizmo}"
|
||||
done <<< $(parse_json "organisations")
|
||||
|
||||
# LIBRARIES
|
||||
shape="house"
|
||||
color="${LIB_COLOR}"
|
||||
while read -r lib
|
||||
do
|
||||
pid=$(echo $lib|jq -r .pid)
|
||||
name=$(echo $lib|jq -r .name)
|
||||
code=$(echo $lib|jq -r .code)
|
||||
orga=$(echo $lib|jq -r .organisation)
|
||||
orga_pid=$(echo $orga|rev|cut -d "/" -f 1|rev)
|
||||
# write result in output
|
||||
identifier="Lib${pid}"
|
||||
label="$(render ${tmpl_label})"
|
||||
save "${tmpl_gizmo}"
|
||||
relation="Orga${orga_pid}"
|
||||
save "${tmpl_link}"
|
||||
done <<< $(parse_json "libraries")
|
||||
|
||||
# PATRON_TYPES
|
||||
shape="polygon"
|
||||
color="${PT_COLOR}"
|
||||
additionals="sides=7"
|
||||
while read pt
|
||||
do
|
||||
pid=$(echo $pt|jq -r .pid)
|
||||
name=$(echo $pt|jq -r .name)
|
||||
orga=$(echo $pt|jq -r .organisation)
|
||||
# write result in output
|
||||
identifier="Type${pid}"
|
||||
label="$(render templates/label_patron_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 "patron_types")
|
||||
|
||||
# USERS
|
||||
shape="ellipse"
|
||||
additionals=''
|
||||
color="${USER_COLOR}"
|
||||
while read user
|
||||
do
|
||||
email=$(echo $user|jq -r .email)
|
||||
first_name=$(echo $user|jq -r .first_name)
|
||||
last_name=$(echo $user|jq -r .last_name)
|
||||
barcode=$(echo $user|jq -r .barcode)
|
||||
roles=$(echo $user|jq -r .roles[])
|
||||
library=$(echo $user|jq -r .library)
|
||||
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
|
||||
pt=$(echo $user|jq -r .pt)
|
||||
|
||||
# Prepare additional info
|
||||
if [[ "${roles}" != "null" ]]; then
|
||||
displayed_roles="roles: "
|
||||
for role in ${roles}; do
|
||||
displayed_roles="${displayed_roles}<font color='red' >${role}</font>, "
|
||||
done
|
||||
fi
|
||||
# Don't display barcode if no one
|
||||
info=""
|
||||
if [[ "${barcode}" != "null" ]]; then
|
||||
info="${info}<br/>${barcode}"
|
||||
fi
|
||||
# Same for roles
|
||||
if [[ -n "${displayed_roles}" ]]; then
|
||||
info="${info}<br/>${displayed_roles}"
|
||||
fi
|
||||
|
||||
# write result in output
|
||||
identifier="User_${email}"
|
||||
label="$(render templates/label_users.tmpl)"
|
||||
save "${tmpl_gizmo}"
|
||||
|
||||
# Display a link if library_pid is not null
|
||||
if [[ "${library_pid}" != "null" ]]; then
|
||||
relation="Lib${library_pid}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
|
||||
# Display a link if patron_type is not null
|
||||
if [[ "$pt" != "null" ]]; then
|
||||
pt_id=$(echo $pt|rev| cut -d "/" -f 1|rev)
|
||||
relation="Type${pt_id}"
|
||||
save "${tmpl_link}"
|
||||
fi
|
||||
done <<< $(parse_json "users")
|
||||
|
||||
# Graph footer
|
||||
save "templates/footer.tmpl"
|
||||
|
||||
# END of program
|
||||
exit 0
|
@ -1 +0,0 @@
|
||||
\"${identifier}\" [shape=${shape} color=\"transparent\" style=filled fillcolor=\"${color}\" label=${label} ${additionals}]
|
Reference in New Issue
Block a user