Preparing the Application Generator Script

The Application Generator tool of the Platform is provided as a Docker image named db-gene/generator, which is accessible from the DecisionBrain registries. However, to ease its use, a Bash script that executes the Generator tool is provided.

The text of this script can be found below. You should copy it into a file named generator.sh, which you will typically put in the same directory as the entities.jdl file that you created. For more details, please refer to Chapter Defining the Data Model.

#!/usr/bin/env bash

# put the default version you want to use here. You can change it using the "-v VERSION" option if needed.
VERSION=4.4.0-SNAPSHOT

function Usage {
  echo "Usage: $(basename "$0") [-v VERSION]" 1>&2
  echo "Generate an application within the current folder." 1>&2
  echo "The JDL or DBM file used to generate the application must be located in the current folder." 1>&2
  echo "    [-v VERSION] if provided, VERSION must represent the Platform generator version (e.g. $VERSION)" 1>&2
  echo "" 1>&2
  echo "Examples:" 1>&2
  echo "     $ $(basename "$0")                       # calls generator $VERSION" 1>&2
  echo "     $ $(basename "$0") -v X.Y.Z              # calls generator X.Y.Z" 1>&2
  exit 1
}

if [ "$1" == "--help" ]
then Usage
fi

if [ "$1" == "-v" ]
then
  shift
  VERSION="$1"
  shift
fi

# mount current folder on '/tmp' and run the generator
TARGET_FOLDER=$(pwd)
if [ "$OSTYPE" == "msys" ]
then
    TARGET_FOLDER=$(cmd //c cd)
fi

echo Mounting $TARGET_FOLDER as generation folder
docker run --rm -it -v "$TARGET_FOLDER":/tmp product-dbgene-prod-docker-group.decisionbrain.cloud/db-gene/generator:$VERSION @gene/gene "$@"