From 3406e4d5965672443e8ce5a0226fd039dab482e9 Mon Sep 17 00:00:00 2001 From: Olivier DOSSMANN Date: Thu, 6 Feb 2020 14:12:25 +0100 Subject: [PATCH] Orgas: cosmetics changes on result --- orgas/README.md | 10 +++++++++- orgas/gen.sh | 23 +++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/orgas/README.md b/orgas/README.md index f5e49e0..8b379ad 100644 --- a/orgas/README.md +++ b/orgas/README.md @@ -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). diff --git a/orgas/gen.sh b/orgas/gen.sh index d86533b..93e9cba 100755 --- a/orgas/gen.sh +++ b/orgas/gen.sh @@ -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}
(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}
(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}
${email}>]" >> "$output" echo "\"${u_id}\" -> Lib${library_pid}" >> "$output" done