Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: problems with busybox default shell on linux/amd64. #76

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions provisioning/resources/cx-ontology.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

@prefix cx: <https://w3id.org/catenax/ontology#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix json: <https://json-schema.org/draft/2020-12/schema#> .

json:Object a rdfs:Datatype.

cx:CxOntology a owl:Ontology ;
dc:creator "Catena-X Knowledge Agents Team" ;
dc:date "2022-11-29"^^xsd:date ;
dc:description "Catena-X Ontology for the Autmotive Industry." ;
dc:title "Catena-X Ontology" .
34 changes: 34 additions & 0 deletions provisioning/resources/cx-ontology.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>

<!--
* Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
-->

<rdf:RDF xmlns="https://w3id.org/catenax/ontology/#"
xml:base="https://w3id.org/catenax/ontology/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:json="https://json-schema.org/draft/2020-12/schema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="https://w3id.org/catenax/ontology/"/>
<rdf:Description rdf:about="https://json-schema.org/draft/2020-12/schema#Object">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Datatype"/>
</rdf:Description>
</rdf:RDF>
202 changes: 102 additions & 100 deletions provisioning/resources/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
#
Expand All @@ -21,106 +21,108 @@
# Entry script for provisioning agent/ontop with the ability to start multiple endpoints in lazy mode and disable CORS
#

# Reinterpret the environment vars as arrays
ONTOP_PORT=( ${ONTOP_PORT[*]} )
ONTOP_ONTOLOGY_FILE=( ${ONTOP_ONTOLOGY_FILE[*]} )
ONTOP_MAPPING_FILE=( ${ONTOP_MAPPING_FILE[*]} )
ONTOP_PROPERTIES_FILE=( ${ONTOP_PROPERTIES_FILE[*]} )
ONTOP_PORTAL_FILE=( ${ONTOP_PORTAL_FILE[*]} )
ONTOP_DEV_MODE=( ${ONTOP_DEV_MODE[*]} )
JAVA_TOOL_OPTIONS_ARRAY=( ${JAVA_TOOL_OPTIONS[*]} )

ENDPOINT_LENGTH=${#ONTOP_PORT[@]}
if [[ ${ENDPOINT_LENGTH} -gt 0 ]]; then
echo "Found ${ENDPOINT_LENGTH} endpoints to provision.";
else
echo "Incorrect port specification: ${ONTOP_PORT[*]}";
exit 1;
fi

((ENDPOINT_LENGTH--))

# for matching the definitions
NUMBER='^[0-9]+$'
TOML='^.*toml$'
ONTOLOGY='^.*(ttl|xml)$'
MAPPING='^.*(obda)$'
PROPERTIES='^.*(properties)$'
CORS="--cors-allowed-origins=${ONTOP_CORS_ALLOWED_ORIGINS}"
CORS=""
LAZY="--lazy"
ENDPOINT_LENGTH=0
ONTOP_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS

# Loop over the endpoints driven by the ports
for ENDPOINT_NUMBER in "${!ONTOP_PORT[@]}"
do
# check port number
if [[ "${ONTOP_PORT[${ENDPOINT_NUMBER}]}" =~ ${NUMBER} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on port ${ONTOP_PORT[${ENDPOINT_NUMBER}]}";
PORT="--port=${ONTOP_PORT[${ENDPOINT_NUMBER}]}";

# check ontology
if [[ "${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}" =~ ${ONTOLOGY} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on ontology ${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";
ONTOLOGY_FILE="--ontology=${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";

# check mapping
if [[ "${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}" =~ ${MAPPING} ]]; then

echo "Providing endpoint ${ENDPOINT_NUMBER} on mapping ${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";
MAPPING_FILE="--mapping=${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";

# check properties
if [[ "${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}" =~ ${PROPERTIES} ]]; then

echo "Providing endpoint ${ENDPOINT_NUMBER} on properties ${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";
PROPERTIES_FILE="--properties=${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";

# check developer mode
if [ "${ONTOP_DEV_MODE[${ENDPOINT_NUMBER}]}" == "true" ]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} in developer mode";
DEV_MODE="--dev"
else
DEV_MODE=""
fi

# check portal activation
if [[ "${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}" =~ ${TOML} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on portal ${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}";
PORTAL_FILE="--portal=${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}"
else
PORTAL_FILE=""
fi

JAVA_TOOL_OPTIONS=${JAVA_TOOL_OPTIONS_ARRAY[${ENDPOINT_NUMBER}]};

echo "Arguments: ${ONTOLOGY_FILE} ${MAPPING_FILE} ${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${JAVA_TOOL_OPTIONS}";

if [[ "${ENDPOINT_NUMBER}" == "${ENDPOINT_LENGTH}" ]]; then
echo "Invoking last process";
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${LAZY};
else
echo "Invoking intermediate process";
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${LAZY}&
fi

else
# Incorrect properties
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect properties given: ${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect mapping
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect mapping given: ${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect ontology
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect ontology given: ${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect port number
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect port number given: ${ONTOP_PORT[${ENDPOINT_NUMBER}]}";
fi
for ENDPOINT in $ONTOP_PORT ; do # NOTE: do not double-quote $services here.
ENDPOINT_LENGTH=$((ENDPOINT_INDEX+1))
done

if [ "$ONTOP_CORS_ALLOWED_ORIGINS" != "" ]; then
CORS="--cors-allowed-origins=${ONTOP_CORS_ALLOWED_ORIGINS}"
fi

echo "Found $ENDPOINT_LENGTH endpoints to provide under $CORS $LAZY."

ENDPOINT_INDEX=0
for ENDPOINT in $ONTOP_PORT ; do # NOTE: do not double-quote $services here.
ENDPOINT_INDEX=$((ENDPOINT_INDEX+1))

ONTOLOGY="/opt/ontop/ontology.ttl"
ONTOLOGY_INDEX=0
for ONTOLOGY_FILE in $ONTOP_ONTOLOGY_FILE ; do
ONTOLOGY_INDEX=$((ONTOLOGY_INDEX+1))

if [ $ENDPOINT_INDEX -ge $ONTOLOGY_INDEX ]; then
ONTOLOGY=$ONTOLOGY_FILE
fi
done

MAPPING="/opt/ontop/input/mapping.obda"
MAPPING_INDEX=0
for MAPPING_FILE in $ONTOP_MAPPING_FILE ; do
MAPPING_INDEX=$((MAPPING_INDEX+1))

if [ $ENDPOINT_INDEX -ge $MAPPING_INDEX ]; then
MAPPING=$MAPPING_FILE
fi
done

PROPERTIES="/opt/ontop/input/settings.properties"
PROPERTIES_INDEX=0
for PROPERTIES_FILE in $ONTOP_PROPERTIES_FILE ; do
PROPERTIES_INDEX=$((PROPERTIES_INDEX+1))

if [ $ENDPOINT_INDEX -ge $PROPERTIES_INDEX ]; then
PROPERTIES=$PROPERTIES_FILE
fi
done

DEV="false"
DEV_INDEX=0
for DEV_MODE in $ONTOP_DEV_MODE ; do
DEV_INDEX=$((DEV_INDEX+1))

if [ $ENDPOINT_INDEX -ge $DEV_INDEX ]; then
DEV=$DEV_MODE
fi
done

JAVA_TOOL_OPTIONS=""
TOOL_INDEX=0
for TOOL_OPTIONS in $ONTOP_TOOL_OPTIONS ; do
TOOL_INDEX=$((TOOL_INDEX+1))

if [ $ENDPOINT_INDEX -ge $TOOL_INDEX ]; then
JAVA_TOOL_OPTIONS=$TOOL_OPTIONS
fi
done

PORTAL="/opt/ontop/portal.toml"
PORTAL_INDEX=0
for PORTAL_FILE in $ONTOP_PORTAL_FILES ; do
PORTAL_INDEX=$((PORTAL_INDEX+1))

if [ $ENDPOINT_INDEX -ge $PORTAL_INDEX ]; then
PORTAL=$PORTAL_FILE
fi
done

echo "Providing endpoint $ENDPOINT_INDEX on port $ENDPOINT with ontology $ONTOLOGY mapping $MAPPING properties $PROPERTIES portal $PORTAL dev mode $DEV and tool options $JAVA_TOOL_OPTIONS"

ENDPOINT="--port=$ENDPOINT"
ONTOLOGY="--ontology=$ONTOLOGY"
MAPPING="--mapping=$MAPPING"
PROPERTIES="--properties=$PROPERTIES"
if [ "$DEV" == "true" ]; then
DEV="--dev"
else
DEV=""
fi
PORTAL="--portal=$PORTAL"

if [ $ENDPOINT_INDEX -eq $ENDPOINT_LENGTH ]; then
echo "Invoking last process";
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY} ${MAPPING} \
${PROPERTIES} ${PORTAL} ${DEV} ${ENDPOINT} ${CORS} ${LAZY};
else
echo "Invoking intermediate process";
JAVA_TOOL_OPTIONS=TOOL
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES} ${PORTAL} ${DEV} ${ENDPOINT} ${CORS} ${LAZY}&
fi
done
55 changes: 55 additions & 0 deletions provisioning/resources/portal.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

title="Catena-X Agent Provisioning Demo"

[[tabGroups]]

name="Example Queries"

[[tabGroups.tabs]]

name="Diagnosis Skill"
query="""
PREFIX cx: <https://w3id.org/catenax/ontology#>
PREFIX cx-diag: <https://w3id.org/catenax/ontology/diagnosis#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?reason ?code ?description ?version ?partend ?partcat ?partclass WHERE {
# Select Business Partner
?Oem cx:BPNL "BPNL00000003COJN".

# Search for Trouble Codes of the Business Partner
# related to a cause in the "Kabelbaum"
?Dtc rdf:type cx-diag:DTC.
?Dtc cx:provisionedBy ?Oem.
?Dtc cx-diag:PossibleCauses ?reason.
FILTER contains(?reason,"Kabelbaum").
?Dtc cx-diag:Code ?code.
?Dtc cx-diag:Description ?description.
?Dtc cx-diag:Version ?version.

# Navigate to the affected parts
# and show only parts with a classification "Powertrain"
?Dtc cx-diag:affects ?Part.
?Part cx-diag:Category ?partcat.
?Part cx-diag:EnDenomination ?partend.
?Part cx-diag:Classification ?partclass.
FILTER contains(?partclass,'Powertrain').

} LIMIT 40
"""
3 changes: 3 additions & 0 deletions provisioning/resources/settings.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Setup In-Memory Database with the trouble codes
jdbc.url=jdbc:h2:file:/opt/ontop/database/db;INIT=RUNSCRIPT FROM '/opt/ontop/data/dtc.sql'
jdbc.driver=org.h2.Driver
5 changes: 4 additions & 1 deletion provisioning/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ COPY --from=build /opt/ontop/lib/*.jar /opt/ontop/lib/
COPY --from=build /opt/ontop/jdbc/*.jar /opt/ontop/jdbc/

# run with docker --build-arg sqlFiles=initial_sql to establish a different sql file
ARG sqlFiles=resources/dtc.sql
ARG sqlFiles="resources/dtc.sql"
COPY ${sqlFiles} /opt/ontop/data/.

COPY resources/cx-ontology.ttl resources/cx-ontology.xml resources/settings.properties /opt/ontop/input/
COPY resources/portal.toml /opt/ontop/

# Additional Java debugging options
ARG JAVA_TOOL_OPTIONS ""

Expand Down
Loading