Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,26 @@ docs/node_modules/
docs/src/.vuepress/.cache/
docs/src/.vuepress/.temp/
docs/src/.vuepress/dist/
docs/yarn.lock
docs/yarn.lock
/temp-out/

# Ignore IDE specific files
.vscode/
.idea/
*.iml
.DS_Store
*.log
npm-debug.log*
yarn-error.log*
pnpm-debug.log*
.env
.env.local
.env.*.local
.cache/
.next/
out/
build/
dist/
coverage/
*.tsbuildinfo
.sass-cache/
14 changes: 14 additions & 0 deletions api-gen/gen-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail

if [ -z "${1:-}" ]; then
echo "Usage: $0 <version>" >&2
echo "Example: $0 2.0.0-RC2" >&2
exit 1
fi

VERSION="$1"
echo Generate API documentation
./gen-javadoc.sh "$VERSION"
./gen-maven-plugin-doc.sh
./gen-fhir-ig.sh
123 changes: 123 additions & 0 deletions api-gen/gen-fhir-ig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash
echo Generate FHIR IG

#!/bin/bash
set -euo pipefail

if [ -z "${1:-}" ]; then
echo "Usage: $0 <version> [api-list...]" >&2
echo "Example: $0 2.0.0-RC2" >&2
exit 1
fi

VERSION="$1"
shift


echo Download FHIR IG resources for version ${VERSION}

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

had_errors=0


ARTIFACT="dsf-fhir-validation"
JARNAME="${ARTIFACT}-${VERSION}.jar"
BASE_URL="https://repo1.maven.org/maven2/dev/dsf/${ARTIFACT}/${VERSION}"
URL="${BASE_URL}/${JARNAME}"
OUT_DIR="$WORKSPACE_ROOT/temp-out/dsf-fhir-validation"

echo "=== Processing (${ARTIFACT}) ==="
echo "Download: ${URL}"
mkdir -p "$OUT_DIR"

TMPFILE="$(mktemp -t "${ARTIFACT}.XXXXXX").jar"

if ! curl -sfSL --retry 3 -o "$TMPFILE" "$URL"; then
echo "Error: Download failed for ${api}: ${URL}" >&2
rm -f "$TMPFILE"
had_errors=1
continue
fi

echo "Extracting ${JARNAME} to ${OUT_DIR}"
# jar is a ZIP archive
if ! unzip -oq "$TMPFILE" -d "$OUT_DIR"; then
echo "Error: Extraction failed for ${api}" >&2
rm -f "$TMPFILE"
had_errors=1
continue
fi

rm -f "$TMPFILE"
echo "FHIR ressources extracted to ${OUT_DIR}"


if [ "$had_errors" -ne 0 ]; then
echo "One or more downloads/extractions failed." >&2
exit 2
fi

echo Generate implementation guide

# copy template/fhir-ig content to temp-out/fhir-ig-gen

TEMPLATE_DIR="$SCRIPT_DIR/template/fhir-ig"
IG_OUT_DIR="$WORKSPACE_ROOT/temp-out/fhir-ig-gen"

mkdir -p "$IG_OUT_DIR"
cp -R "$TEMPLATE_DIR/"* "$IG_OUT_DIR/"
echo "Copied IG template files to ${IG_OUT_DIR}"
# copy downloaded FHIR resources to temp-out/fhir-ig-gen/input/dsf-resources
RESOURCES_SRC_DIR="$WORKSPACE_ROOT/temp-out/dsf-fhir-validation/fhir"
RESOURCES_DEST_DIR="$IG_OUT_DIR/input/dsf-resources"

mkdir -p "$RESOURCES_DEST_DIR"
cp -R "$RESOURCES_SRC_DIR/"* "$RESOURCES_DEST_DIR/"
echo "Copied FHIR resources to ${RESOURCES_DEST_DIR}"

# remove all non-xml files from resources dest dir
find "$RESOURCES_DEST_DIR" -type f ! -name "*.xml" -delete
echo "Removed non-XML files from ${RESOURCES_DEST_DIR}"
#remove all xml files that do not start with dsf-
find "$RESOURCES_DEST_DIR" -type f -name "*.xml" ! -name "dsf-*" -delete
echo "Removed non-dsf XML files from ${RESOURCES_DEST_DIR}"

echo "FHIR IG generation setup completed. The IG source is in ${IG_OUT_DIR}."

UPDATE_PUBLISHER_SCRIPT="$IG_OUT_DIR/_updatePublisher.sh"
GENONCE_SCRIPT="$IG_OUT_DIR/_genonce.sh"

# Set Java options as in CI
export _JAVA_OPTIONS="-Xmx8g -Xms4g"
echo "Set _JAVA_OPTIONS=${_JAVA_OPTIONS}"

# Run updatePublisher if available (make executable and pass --yes)
if [ -f "$UPDATE_PUBLISHER_SCRIPT" ]; then
echo "Found $UPDATE_PUBLISHER_SCRIPT, making executable and running with --yes"
chmod +x "$UPDATE_PUBLISHER_SCRIPT"
(cd "$IG_OUT_DIR" && ./_updatePublisher.sh --yes)
echo "FHIR IG publisher update completed."
else
echo "No _updatePublisher.sh script found in ${IG_OUT_DIR}. Please update the IG publisher manually."
fi

# Run sushi if available
if command -v sushi >/dev/null 2>&1; then
echo "Running sushi in ${IG_OUT_DIR}"
(cd "$IG_OUT_DIR" && sushi .)
echo "sushi execution completed."
else
echo "sushi not found in PATH. Please install sushi to build the IG." >&2
fi

# Run genonce if available (make executable)
if [ -f "$GENONCE_SCRIPT" ]; then
echo "Found $GENONCE_SCRIPT, making executable and running"
chmod +x "$GENONCE_SCRIPT"
(cd "$IG_OUT_DIR" && ./_genonce.sh)
echo "FHIR IG generation completed."
else
echo "No _genonce.sh script found in ${IG_OUT_DIR}. Please run the IG generation manually."
fi
65 changes: 65 additions & 0 deletions api-gen/gen-javadoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
set -euo pipefail

if [ -z "${1:-}" ]; then
echo "Usage: $0 <version> [api-list...]" >&2
echo "Example: $0 2.0.0-RC2 # downloads api-v1 and api-v2" >&2
echo " $0 2.0.0-RC2 api-v1 # downloads only api-v1" >&2
exit 1
fi

VERSION="$1"
shift

# default APIs if none provided
if [ "$#" -eq 0 ]; then
APIS=("api-v1" "api-v2")
else
APIS=("$@")
fi

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

had_errors=0

for api in "${APIS[@]}"; do
# expect api names like "api-v1", "api-v2"
ARTIFACT="dsf-bpe-process-${api}"
JARNAME="${ARTIFACT}-${VERSION}-javadoc.jar"
BASE_URL="https://repo1.maven.org/maven2/dev/dsf/${ARTIFACT}/${VERSION}"
URL="${BASE_URL}/${JARNAME}"
OUT_DIR="$WORKSPACE_ROOT/temp-out/${api}"

echo "=== Processing ${api} (${ARTIFACT}) ==="
echo "Download: ${URL}"
mkdir -p "$OUT_DIR"

TMPFILE="$(mktemp -t "${ARTIFACT}.XXXXXX").jar"

if ! curl -sfSL --retry 3 -o "$TMPFILE" "$URL"; then
echo "Error: Download failed for ${api}: ${URL}" >&2
rm -f "$TMPFILE"
had_errors=1
continue
fi

echo "Extracting ${JARNAME} to ${OUT_DIR}"
# jar is a ZIP archive
if ! unzip -oq "$TMPFILE" -d "$OUT_DIR"; then
echo "Error: Extraction failed for ${api}" >&2
rm -f "$TMPFILE"
had_errors=1
continue
fi

rm -f "$TMPFILE"
echo "Javadoc for ${api} extracted to ${OUT_DIR}"
done

if [ "$had_errors" -ne 0 ]; then
echo "One or more downloads/extractions failed." >&2
exit 2
fi

echo "All selected Javadocs downloaded and extracted."
2 changes: 2 additions & 0 deletions api-gen/gen-maven-plugin-doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo Generate Maven Plugin Documentation
94 changes: 94 additions & 0 deletions api-gen/patch-sushi-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
set -euo pipefail

# Defaults
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
CONFIG="${1:-$WORKSPACE_ROOT/temp-out/fhir-ig-gen/sushi-config.yaml}"
RES_DIR="${2:-$WORKSPACE_ROOT/temp-out/fhir-ig-gen/input/dsf-resources}"

if [ ! -f "$CONFIG" ]; then
echo "Error: sushi-config.yaml not found at $CONFIG" >&2
exit 1
fi
if [ ! -d "$RES_DIR" ]; then
echo "Error: resources dir not found at $RES_DIR" >&2
exit 1
fi

# portable mktemp: try simple mktemp, fallback to -t form (macOS)
TMP_ENTRIES="$(mktemp 2>/dev/null || mktemp -t patch-sushi-entries)"
TMP_OUT="$(mktemp 2>/dev/null || mktemp -t patch-sushi-out)"
trap 'rm -f "$TMP_ENTRIES" "$TMP_OUT"' EXIT

# ensure file exists
: > "$TMP_ENTRIES"

# iterate xml files, use parent dir as ResourceType and filename as id
while IFS= read -r -d '' file; do
parent="$(basename "$(dirname "$file")")"
# skip Subscription resources entirely
if [ "$parent" = "Subscription" ]; then
continue
fi

fname="$(basename "$file" .xml)"

# For NamingSystem do NOT remove dsf- prefix; for others remove leading dsf- if present
if [ "$parent" = "NamingSystem" ]; then
name="$fname"
else
name="${fname#dsf-}"
fi

# remove trailing version segment if it starts with a digit, e.g. -2.0.0 or -2.0.0-RC1
if [[ "$name" =~ ^(.+)-[0-9].*$ ]]; then
name="${BASH_REMATCH[1]}"
fi

key="${parent}/${name}"
# append only if not already present (preserve first occurrence)
if ! grep -q "^ ${key}:" "$TMP_ENTRIES"; then
printf " %s:\n exampleBoolean: false\n\n" "$key" >> "$TMP_ENTRIES"
fi
done < <(find "$RES_DIR" -type f -name "*.xml" -print0)

# If no entries found, ensure resources: is removed or left unchanged
if [ ! -s "$TMP_ENTRIES" ]; then
echo "No XML resources found in $RES_DIR. No changes made to $CONFIG."
exit 0
fi

# replace existing resources: block in config with generated entries
awk -v insfile="$TMP_ENTRIES" '
BEGIN { in_resources=0; inserted=0 }
# match a top-level "resources:" line (allow leading spaces)
/^[[:space:]]*resources:[[:space:]]*$/ {
print;
# insert generated entries
while((getline line < insfile) > 0) print line;
close(insfile);
inserted=1;
in_resources=1;
next
}
{
if(in_resources){
# skip indented lines (old resources block) and blank/comment lines that belong to it
if($0 ~ /^[[:space:]]/ || $0 ~ /^#/ || $0 == "") next
else in_resources=0
}
print
}
END {
# if no resources: found, append one at end
if(!inserted){
print ""
print "resources:"
while((getline line < insfile) > 0) print line;
close(insfile);
}
}
' "$CONFIG" > "$TMP_OUT" && mv "$TMP_OUT" "$CONFIG"

echo "Updated $CONFIG with resource entries from $RES_DIR"
7 changes: 7 additions & 0 deletions api-gen/template/fhir-ig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
Thumbs.db
/fsh-generated
/input-cache
/output
/temp
/template
34 changes: 34 additions & 0 deletions api-gen/template/fhir-ig/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
stages:
- setup
- build
- deploy

build:
stage: build
image:
name: registry.it.hs-heilbronn.de/dsf/ig-builder
entrypoint: [""]
before_script:
- export _JAVA_OPTIONS="-Xmx8g -Xms4g"
script:
- chmod +x _updatePublisher.sh
- ./_updatePublisher.sh --yes
- sushi .
- chmod +x _genonce.sh
- ./_genonce.sh
artifacts:
name: "$CI_PROJECT_NAME"
paths:
- output/
# tags:
# - docker

pages:
stage: deploy
script:
- mkdir public
- cp -r output/* public
- cp public/index.html public/404.html
artifacts:
paths:
- public
Loading