Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
|
@ -1,16 +0,0 @@
|
|||
DATE := $(shell date +'%Y%m%d')
|
||||
|
||||
all: $(DATE)-orgas.svg $(DATE)-policies.svg
|
||||
|
||||
# All .dot files are generated by gen_%.sh file (gen_orgas.sh for example)
|
||||
%.dot: gen_%.sh
|
||||
bash "$<" "$@"
|
||||
|
||||
$(DATE)-%.svg: %.dot
|
||||
dot -Tsvg "$<" -o "$@"
|
||||
|
||||
clean:
|
||||
rm -f *.svg *.dot
|
||||
|
||||
# Keep temporary files (dot files) for debug
|
||||
.PRECIOUS: %.dot
|
|
@ -1,20 +0,0 @@
|
|||
# Presentation
|
||||
|
||||
*gen_orgas.sh* generates a diagram with **graphviz** with the link between organisations, libraries and users in *rero-ils* project.
|
||||
|
||||
*gen_policies.sh* do the same with link between organisations, libraries, circulation policies and patron\_type/item\_type couples.
|
||||
|
||||
# Requirements
|
||||
|
||||
* graphviz
|
||||
* [jq](https://stedolan.github.io/jq/)
|
||||
|
||||
# Usage
|
||||
|
||||
* change **RERO\_DIR** variable to point your **rero-ils directory**
|
||||
|
||||
```
|
||||
make clean && RERO_DIR="/home/moi/rero/rero-ils" make
|
||||
```
|
||||
|
||||
Result: **2 files (orgas.svg and policies.svg)** file (can be open with Gimp for example).
|
|
@ -1,12 +0,0 @@
|
|||
.[] | {
|
||||
pid,
|
||||
name,
|
||||
description,
|
||||
organisation: .organisation."$ref",
|
||||
allow_checkout,
|
||||
checkout_duration,
|
||||
allow_requests,
|
||||
policy_library_level,
|
||||
libraries: [.libraries[]?],
|
||||
settings
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
.[] | {
|
||||
pid,
|
||||
name,
|
||||
organisation: .organisation."$ref",
|
||||
type
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#!/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.
|
||||
|
||||
# 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
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate a dot file to create graph of RERO-ils data
|
||||
#
|
||||
|
||||
# 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
|
|
@ -1,59 +0,0 @@
|
|||
# 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")
|
|
@ -1,27 +0,0 @@
|
|||
# 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,22 +0,0 @@
|
|||
# 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")
|
|
@ -1,19 +0,0 @@
|
|||
# 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")
|
|
@ -1,29 +0,0 @@
|
|||
# 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)
|
||||
# fix problems with '<' and '>' in descriptions
|
||||
description=$(echo $pt|jq -r .description|sed -e 's/</\</g ; s/>/\>/g')
|
||||
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")
|
|
@ -1,55 +0,0 @@
|
|||
# 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 +0,0 @@
|
|||
\"${identifier}\" [shape=${shape} color=\"${border_color:-transparent}\" style=filled fillcolor=\"${color}\" label=${label} ${additionals}];
|
|
@ -1,5 +0,0 @@
|
|||
<${name}<br/>${description}<br/>
|
||||
Checkout: ${checkout} (duration: ${duration})<br/>
|
||||
Requests: ${requests}<br/>
|
||||
Policy library level: ${library_level}<br />
|
||||
PID: ${pid}>
|
|
@ -1 +0,0 @@
|
|||
<${name}<br/>(type: ${itype})<br/>PID: ${pid}>
|
|
@ -1,2 +0,0 @@
|
|||
<${name}<br/>${description}<br/>
|
||||
PID: ${pid}>
|
|
@ -1 +0,0 @@
|
|||
\"Patron type PID: ${pt_pid} | Item type PID: ${it_pid}\"
|
|
@ -1 +0,0 @@
|
|||
\"${identifier}\" -> \"${relation}\";
|
|
@ -0,0 +1,12 @@
|
|||
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
|
|
@ -0,0 +1,19 @@
|
|||
# Presentation
|
||||
|
||||
*gen.sh* generates a diagram with **graphviz** with the link between organisations, libraries and users in *rero-ils* project.
|
||||
|
||||
# Requirements
|
||||
|
||||
* graphviz
|
||||
* [jq](https://stedolan.github.io/jq/)
|
||||
|
||||
# Usage
|
||||
|
||||
* Open **gen.sh** file
|
||||
* change **RERO\_DIR** variable to point your **rero-ils directory**
|
||||
|
||||
```
|
||||
make clean && make
|
||||
```
|
||||
|
||||
Result: **organisations.svg** file (can be open with Gimp for example).
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
# Built variables
|
||||
outputfile="$1"
|
||||
RERO_DIR="${RERO_DIR:-${HOME}/projets/rero/rero-ils}"
|
||||
SRC_DIR="${RERO_DIR}/data/"
|
||||
|
||||
# Templates
|
||||
|
@ -13,14 +12,6 @@ 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=""
|
||||
|
@ -33,14 +24,6 @@ elif [[ -f "${outputfile}" ]]; then
|
|||
echo "File already exists!"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "${RERO_DIR}" ]]; then
|
||||
echo "Source directory doesn't exist: ${RERO_DIR}. Did you set RERO_DIR variable?"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "${SRC_DIR}" ]]; then
|
||||
echo "No data directory found in ${RERO_DIR}. Did you set RERO_DIR variable correctly?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# FUNCTIONS
|
||||
# WRITE first argument in output file
|
|
@ -1,6 +1,5 @@
|
|||
.[] | {
|
||||
pid,
|
||||
name,
|
||||
description,
|
||||
organisation: .organisation."$ref"
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
#!/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
|
|
@ -0,0 +1 @@
|
|||
\"${identifier}\" [shape=${shape} color=\"transparent\" style=filled fillcolor=\"${color}\" label=${label} ${additionals}]
|
|
@ -0,0 +1 @@
|
|||
<${name}<br/>PID: ${pid}>
|
|
@ -0,0 +1 @@
|
|||
\"${identifier}\" -> \"${relation}\"
|
Reference in New Issue