-
Notifications
You must be signed in to change notification settings - Fork 47
/
generate.sh
executable file
·69 lines (55 loc) · 2.35 KB
/
generate.sh
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
#! /bin/sh
#######################################################################
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This work is made available under the terms of the
# Creative Commons Attribution 4.0 International (CC-BY-4.0) license,
# which is available at
# https://creativecommons.org/licenses/by/4.0/legalcode.
#
# SPDX-License-Identifier: CC-BY-4.0
#######################################################################
# REMARKS:
# ========
# This script generates a set of artifacts for a given SAMM model in a ttl-file.
# Preconditiions:
# -internet connection to download specified SAMM CLI provided in $SAMMCLI folder and Catena-X CSS style
# Usage:
# Apply script to a single file
# ./generate.sh io.catenax.vehicle.product_description/2.0.0/ProductDescription.ttl
# To generate files for all models in repo
# find ./ -type f -name "*.ttl" -exec ./generate.sh "{}" \;
# Adjust if SAMM CLI version changes
JARNAME=bamm-cli-2.1.3.jar
SAMMFOLDER=.SAMMCLI/
SAMMCLI=$SAMMFOLDER$JARNAME
# Adjust if BAMM CLI version changes
SAMMCLIURL=https://github.com/eclipse-esmf/esmf-sdk/releases/download/v2.1.3/bamm-cli-2.1.3.jar
CATENAXCSS=$SAMMFOLDER/catena-template.css
CATENAXCUSTOMCSSURL=https://raw.githubusercontent.com/eclipse-tractusx/sldt-semantic-hub/main/backend/src/main/resources/catena-template.css
echo "Check availability of SAMM CLI"
if [ ! -f "$SAMMCLI" ]; then
echo "$SAMMCLI does not exist. Will download"
mkdir $SAMMFOLDER
cd $SAMMFOLDER && { curl -LJO $SAMMCLIURL ; cd -; }
fi
if [ ! -f "$CATENAXCSS" ]; then
echo "$CATENAXCSS does not exist. Will download"
mkdir $SAMMFOLDER
cd $SAMMFOLDER && { curl -LJO $CATENAXCUSTOMCSSURL ; cd -; }
fi
echo "Generate artifacts for $1"
MODELNAME="$(basename $1 .ttl)"
DIR="$(dirname "$1")"
PATHTEMPLATE=$DIR"/gen/"$MODELNAME
commands=(aas schema json openapi html)
endings=(-aas.json -aas-value-schema.json -aas-value.json .yml -aspectmodel.html)
toggles=("-f json" "" "" " -b=catenax.io" "-c $CATENAXCSS")
for i in ${!commands[@]}; do
echo "generate ${commands[$i]} into $PATHTEMPLATE${endings[$i]}"
java -jar $SAMMCLI aspect "$1" to ${commands[$i]} ${toggles[$i]} -o $PATHTEMPLATE${endings[$i]}
done