#! /bin/sh

#
# Generate ULO.java from the OWL ontology.
# The generated file is printed to stdout.
#

set -eu

# print first argument to stderr
report() {
    echo "$0: $1" 1>&2
}

# $workdir is the directory where we put all temp files,
# $target_file the path for the file to generate
workdir="$(mktemp -d)"
target_file="$workdir/ULO.java"

(
    cd "$workdir"

    report "cloning repositories..."

    git clone --quiet https://github.com/ansell/rdf4j-schema-generator.git
    git clone --quiet https://gl.mathhub.info/ulo/ulo.git ulo

    report "generating $target_file..."

    rdf4j-schema-generator/rdf4j-schema-generator \
	-f application/xml -name ULO \
	ulo/ulo.owl "$target_file" >/dev/null
)

cat "$target_file"
