/
graphviz
executable file
·122 lines (108 loc) · 3.29 KB
/
graphviz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
EXE=$0
while [ -L "$EXE" ]; do
EXE=`readlink $EXE`
done
WORKDIR=`pwd`
cd `dirname $EXE`
function help() {
echo "Neo4j graphviz generator
USAGE: $0 neo4j/store/dir [--rebuild] [-o <file>] <jvm> <graphviz> <format>
WHERE
neo4j/store/dir is the path to where the neo4j graph store is located.
This is the only mandatory parameter, and must be first,
other options may be specified in any order.
Be sure to stop the Neo4j instance using this location.
--rebuild ensures that the program is compiled from scratch first.
--help display this message and exit.
<file> is the output file to generate (default is graph.dot).
The file ending determines the format of the generated file,
if the ending is anything other than 'dot', a <file>.dot file
will also be generated
<jvm> are the JVM command line options.
<graphviz> are the graphviz command line options.
<format> are graph output formatting configurations, these are structured
as: <optionParameter>=<value>[,<more>,<values>...]
Currently supported options are:
- nodeTitle=VAL
- relationshipTitle=VAL
Sets the title of a node/relationship. VAL is a string.
Placeholders for attributes can be used by prefixing the
attribute name with an @.
Example: relationshipTitle=\"@type [@id]\"
- nodePropertyFilter=FIELDS
FIELDS is a comma-separated list of the fields that should be
included in the result. E.g., nodePropertyFilter=id,name
"
}
MAINCLASS=org.neo4j.visualization.graphviz.Script
CLEAN=
OUTFILE=graph.dot
JVMOPTIONS=
ARGUMENTS=
DOTOPTIONS=
while [ $# -gt 0 ]; do
case "$1" in
--rebuild)
CLEAN=clean
;;
--help)
help
exit
;;
-o)
OUTFILE=$2
shift
;;
-o*)
OUTFILE=${1:2}
;;
-D* | -X* | -d* | -server | -client)
if [ -z "$JVMOPTIONS" ]; then
JVMOPTIONS="$1 "
else
JVMOPTIONS="$JVMOPTIONS$1 "
fi
;;
-v | -G* | -N* | -E* | -K* | -O | -q* | -s* | -y | -n* | -x | -L*)
DOTOPTIONS="$DOTOPTIONS $1"
;;
*)
ARGUMENTS="$ARGUMENTS $(echo $1|sed 's/ /\\ /g')"
;;
esac
shift
done
if [ -z "$OUTFILE" ]; then
echo Output file not specified
exit
fi
case "$OUTFILE" in
*.dot)
DOTFILE=$OUTFILE
;;
*)
DOTFILE=${OUTFILE}.dot
;;
esac
JVMOPTIONS="$JVMOPTIONS-Dgraphviz.out=$DOTFILE "
mvn $CLEAN compile exec:exec -Dexec.executable="java"\
-Dexec.workingdir="$WORKDIR"\
-Dexec.args="$JVMOPTIONS-cp %classpath $MAINCLASS$ARGUMENTS"\
|| exit
cd $WORKDIR
case "$OUTFILE" in
*.dot)
;;
*)
OUTFORMAT=$OUTFILE
while [ "$OLDFORMAT" != "$OUTFORMAT" ]; do
OLDFORMAT=$OUTFORMAT
OUTFORMAT=${OLDFORMAT#*.}
done
if [ "$OUTFORMAT" != "$OUTFILE" ]; then
OUTFORMAT=-T$OUTFORMAT
fi
dot $OUTFORMAT $DOTOPTIONS -o$OUTFILE $DOTFILE
;;
esac