Archived
1
0

Orgas: cosmetics changes on result

This commit is contained in:
Olivier DOSSMANN 2020-02-06 14:12:25 +01:00
parent 7f0b1cca4f
commit 3406e4d596
2 changed files with 24 additions and 9 deletions

View File

@ -2,10 +2,18 @@
*datagraph_generator* 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: **datagraph.svg** file (can be open with Gimp for example).
Result: **organisations.svg** file (can be open with Gimp for example).

View File

@ -1,15 +1,20 @@
#!/usr/bin/env bash
#
# Generate a dot file to create graph of RERO-ils data (orga, lib and users)
#
# Generate a dot file to create digraph of RERO-ils data
RERO_DIR="${HOME}/projets/rero/rero-ils"
output="$1"
source="/home/od/projets/rero/rero-ils/data/"
SRC_DIR="${RERO_DIR}/data/"
# start of file
echo "digraph {" > "$output"
echo "rankdir = RL;" >> "$output"
echo "label = \"Link between organisations, libraries and users.\";" >> "$output"
# ORGANISATIONS
orga_file="${source}organisations.json"
orga_file="${SRC_DIR}organisations.json"
cat "${orga_file}"|jq -c '.[] | {
name,
pid,
@ -20,28 +25,30 @@ do
code=$(echo $orga|jq -r .code)
name=$(echo $orga|jq -r .name)
# write result in output
echo "Orga${pid} [label=\"${name}\"]" >> "$output"
echo "Orga${pid} [shape=box color=\"transparent\" style=filled fillcolor=\"#bcafff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
done
# LIBRARIES
lib_file="${source}libraries.json"
lib_file="${SRC_DIR}libraries.json"
cat "${lib_file}"|jq -c '.[] | {
name,
pid,
code,
organisation: .organisation."$ref"}'|while read 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
l_id="Lib${pid}"
echo "${l_id} [label=\"${name}\"]" >> "$output"
echo "${l_id} [shape=house color=transparent style=filled fillcolor=\"#49afff\" label=<${name}<br/>(code: ${code})>]" >> "$output"
echo "${l_id} -> Orga${orga_pid}" >> "$output"
done
# USERS
user_file="${source}users.json"
user_file="${SRC_DIR}users.json"
cat "${user_file}"|jq -c '.[] | {
email,
first_name,
@ -55,7 +62,7 @@ do
library_pid=$(echo $library|rev|cut -d "/" -f 1|rev)
# write result in output
u_id="User_${email}"
echo "\"${u_id}\" [label=\"${first_name} ${last_name}\"]" >> "$output"
echo "\"${u_id}\" [label=<${first_name} ${last_name}<br/>${email}>]" >> "$output"
echo "\"${u_id}\" -> Lib${library_pid}" >> "$output"
done