Skip to content

Commit

Permalink
issue #1708 merge with master and handle NPE when search param is fil…
Browse files Browse the repository at this point in the history
…tered out

Signed-off-by: Robin Arnold <robin.arnold23@ibm.com>
  • Loading branch information
punktilious committed Nov 20, 2020
2 parents 2d89c8a + 48c43d8 commit d8aca7d
Show file tree
Hide file tree
Showing 24 changed files with 1,669 additions and 308 deletions.
5 changes: 5 additions & 0 deletions build/release/docker-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

# Assumes that fhir-install has already been built
docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_TOKEN}

# Executes the build for the ibm-fhir-schematool
# This build runs first so that the FAILURE comes before and stops the subsequent builds/releases.
${WORKSPACE}/fhir-install/src/main/docker/ibm-fhir-schematool/build.sh

mvn dockerfile:build -f fhir-install -Dmaven.wagon.http.retryHandler.count=3
mvn dockerfile:tag@tag-version -f fhir-install -Dmaven.wagon.http.retryHandler.count=3
mvn dockerfile:push@push-version -f fhir-install -Dmaven.wagon.http.retryHandler.count=3
Expand Down
2 changes: 2 additions & 0 deletions docs/src/pages/guides/FHIRServerUsersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ It is also possible to configure a set of profiles, one or more of which a resou
* Validate that all profiles specified in the resource's `meta.profile` element are supported by the FHIR server
* Validate that the resource's data conforms to all profiles specified in the resource's `meta.profile` element
If a profile in the list specified by the configuration parameter contains a version, for example `http://ibm.com/fhir/profile/partner|1.0`, then a profile of the same name specified in the resource's `meta.profile` element will only be considered a match if it contains exactly the same version. However, if a profile in the list specified by the configuration parameter does not contain a version, for example `http://ibm.com/fhir/profile/partner`, then a profile of the same name specified in the resource's `meta.profile` element will be considered a match whether it contains a version or not.
If this configuration parameter is not set or is set to an empty list, then the FHIR server will perform its standard validation.
The IBM FHIR Server pre-packages all conformance resources from the core specification.
Expand Down
202 changes: 0 additions & 202 deletions fhir-install/licenses/LICENSE

This file was deleted.

1 change: 1 addition & 0 deletions fhir-install/licenses/LICENSE
3 changes: 3 additions & 0 deletions fhir-install/src/main/docker/ibm-fhir-schematool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
fhirschema.log
out.log
77 changes: 77 additions & 0 deletions fhir-install/src/main/docker/ibm-fhir-schematool/DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
layout: default
title: IBM FHIR Server - Schema Tool - Development
date: 2020-11-11
permalink: /ibm-fhir-server-schema-tool-development/
---

# **Design**

The IBM FHIR Schema Tool provides an Docker image that wraps the `fhir-persistence-schema` executable jar. The tool is state machine which take a single configuration to establish a current and running state of the IBM FHIR Server.

The design is such that it COULD, but does not support multiple input files at this time.

When the container is started, the container process one of two flows:

* Schema Onboarding - creates and updates a schema and apply grants
* Schema Offboarding - deletes a tenant (Db2) and removes data if there are no tenants left.

**Schema Onboarding Flow**

The schema onboarding flow setup add a new tenant or update the database to the latest schema levels.

1. Check if set to **skip**:
1. If `SKIP['true']`, stop and exit cleanly.
1. If `SKIP['false']`, proceed.
1. Check if **BEHAVIOR** set to ONBOARD:
1. If not `BEHAVIOR['ONBOARD']`, skip.
1. If `BEHAVIOR['ONBOARD']`, proceed.
1. Create the database configuration file
1. Check connectivity:
1. If connectivity fails, stop and exit in error.
1. If connectivity succeeds, proceed.
1. Create the schema
1. Update the Schema
1. Check if Db2:
1. If Db2, allocate tenant and save output.
1. If Db2, test the allocated tenant
1. If not Db2, proceed.
1. Grant permissions to the IBM FHIR Server database user

**Schema Offboarding Flow**

The schema offboarding flow offboards the current schema, while preserving the schema for multiple tenants (if supported by the database type).

1. Check if set to **SKIP**:
1. If `SKIP['true']`, stop and exit cleanly.
1. If `SKIP['false']`, proceed.
1. Check if **BEHAVIOR** set to OFFBOARD:
1. If not `BEHAVIOR['OFFBOARD']`, skip.
1. If `BEHAVIOR['OFFBOARD']`, proceed.
1. Check if Db2:
1. If Db2, then deallocate tenant
1. If not Db2, then proceed.
1. If (Db2 and no more tenants) or Postgres, then proceed:
1. Drop FHIR Schema
1. Drop Java Batch
1. Drop OAuth

# **Implementation Details**

## Configuration

The configuration is drived primarily from a working directory, and in alternative circumstances backed by an Environment variable with the input.

The configuration data is mounted to `/ibm-fhir-schematool/workarea/input`.

## Logging
1. Logging - The logging is to standard error and standard out.
- The logs data is put into the `/ibm-fhir-schematool/workarea/output` folder.
2. Must Gather Flow - Each execution generates a new set of log files to the `/ibm-fhir-schematool/workarea/output` folder.

## Docker
The design is to use as few layers as possible starting with `adoptopenjdk/openjdk11-openj9:ubi-minimal-jre`.

The build uses multiple layers to avoid a bloated image after the necessary updates. Using a single image results in a 500M image (per docker history ibm-fhir-schematool), versus 167M.

The DockerHub repository is at `ibmcom/ibm-fhir-schematool` and the team that manages it is the IBM FHIR Server team (Docker team: fhir).
80 changes: 80 additions & 0 deletions fhir-install/src/main/docker/ibm-fhir-schematool/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
layout: default
title: IBM FHIR Server - Schema Tool - Development
date: 2020-11-11
permalink: /ibm-fhir-server-schema-tool-development/
---

# Development

The document helps developers setup the development environment for the IBM FHIR Server Schema Tool.

1. Build the `fhir-examples` and `fhir-parent`

``` shell
export WORKSPACE=`pwd`
cd fhir-install/src/main/docker/ibm-fhir-schematool
mvn clean install -DskipTests -f ${WORKSPACE}/fhir-examples/
mvn clean install -DskipTests -f ${WORKSPACE}/fhir-parent/
```

2. Change to the `fhir-install/src/main/docker/ibm-fhir-schematool` directory

3. Prep the contents

``` shell
mkdir -p target
cp ${WORKSPACE}/fhir-persistence-schema/target/fhir-persistence-schema-*-cli.jar target/
cp ${WORKSPACE}/LICENSE target/LICENSE
```

4. Build the schema tool.

``` shell
docker build --tag ibm-fhir-schematool:latest .
```

or

``` shell
docker build --build-arg FHIR_VERSION=4.5.0 -t ibm-fhir-schematool:4.5.0 .
```

5. For Db2, change run. (You may have to edit the corresponding examples)

* onboard
``` shell
time docker run --env ENV_TOOL_INPUT=`cat examples/db2/persistence-offboard-example.json |base64` ibm-fhir-schematool:latest | tee out.log
```

* offboard
``` shell
time docker run --env ENV_TOOL_INPUT=`cat examples/db2/persistence-onboard-example.json |base64` ibm-fhir-schematool:latest | tee out.log
```

6. For Postgres, run. (You may have to edit the corresponding examples)

* onboard
``` shell
time docker run --env ENV_TOOL_INPUT=`cat examples/postgres/persistence-offboard-example.json |base64` ibm-fhir-schematool:latest | tee out.log
```

* offboard
``` shell
time docker run --env ENV_TOOL_INPUT=`cat examples/postgres/persistence-onboard-example.json |base64` ibm-fhir-schematool:latest | tee out.log
```

7. Confirm you see your changes work, and the Deployment works.

* Schema is created, or deleted
* No Error Logs (at least unexpected)
* Output is as expected

# Run a Shell Check

Sanity check of the Shell Script

```
brew install shellcheck
shellcheck run.sh
```
Loading

0 comments on commit d8aca7d

Please sign in to comment.