(click to expand)
+EHRbase is an [openEHR](https://www.openehr.org/) Clinical Data Repository, providing a standard-based backend for
+interoperable clinical applications. It implements the latest version of the openEHR Reference Model (RM 1.1.0) and
+version 1.4 of the Archetype Definition Language (ADL). Applications can use the capabilities of EHRbase through the
+latest version of the [openEHR REST API](https://specifications.openehr.org/releases/ITS-REST/latest/) and model-based
+queries using the [Archetype Query Language](https://specifications.openehr.org/releases/QUERY/latest/AQL.html).
-Please check the [CHANGELOG](https://github.com/ehrbase/ehrbase/blob/develop/CHANGELOG.md) and/or [EHRbase Documentation](https://ehrbase.readthedocs.io/en/latest/) for more details.
-
-##### WIP: 2021, XYZ 00
-v?.?.? - (...)
+----
-**Important:** Please note that this release introduces [Archie's](https://github.com/openEHR/archie) new strict invariant checks. Depending on existing data and clients this might be a breaking change. Please carefully check the EHRbase output and update your input data if EHRbase rejects it. The strict validation can also be deactivated via configuration, but caution in advised!
+## Release notes
-##### 2021, Sep 9
-v0.17.2 - **beta** release. Bug fixes, enhancements, automatic Docker Hub deployments via Github Actions.
+Please check the [CHANGELOG](https://github.com/ehrbase/ehrbase/blob/develop/CHANGELOG.md)
-##### 2021, Aug 12
-v0.17.1 - **beta** release. Default handling for audit metadata, bug fixes and SDK version update.
-
-##### 2021, Aug 04
-v0.17.0 - fifth **beta** release. validation using an external terminology server, Attribute-based Access Control, AQL fixes and other enhancements
-
-##### 2021, March 30
-v0.16.0 - fourth **beta** release. New endpoints for versioned Compositions, ATNA Logging, AQL fixes and other enhancements.
-
-##### 2021, February 25
-v0.15.0 - third **beta** release. New admin API endpoints for EHRs, Compositions and Contributions. Fixes and other enhancements.
-
-##### 2020, October 1
-v0.14.0 - second **beta** release.
-
-##### 2020, May 14
-This release of EHRbase (v0.13.0) is the first **beta** release.
-
-
-
-Please check the [CHANGELOG](https://github.com/ehrbase/ehrbase/blob/develop/CHANGELOG.md) and/or [EHRbase Documentation](https://ehrbase.readthedocs.io/en/latest/) for more details.
+## Documentation
+Check out the documentation at https://docs.ehrbase.org
+## Quick Start: Run EHRbase with Docker
-## 📝 Documentation
-[EHRbase Documentation](https://ehrbase.readthedocs.io/en/latest/) is build with Sphinx and hosted on [Read the Docs](https://readthedocs.org/).
+> [!TIP]
+> The fastest way to get started with EHRbase and openEHR is the **EHRbase Sandbox** available at https://sandkiste.ehrbase.org/.
+>
+> For a deployment on premise read below.
-## Quick Start: Run EHRbase with Docker
-See our [Run EHRbase + DB with Docker-Compose](https://ehrbase.readthedocs.io/en/latest/03_development/04_docker_images/01_ehrbase/02_use_image/index.html#run-ehrbase-db-with-docker-compose) documentation page for a quick start.
+Check out the Installation guide at https://docs.ehrbase.org/docs/EHRbase/installation
## Building and Installing EHRbase
-These instructions will get you a copy of the project up and running on your local machine **for development and testing purposes**. Please read these instructions carefully. See [deployment](#deployment) for notes on how to deploy the project on a live system.
+
+These instructions will get you a copy of the project up and running on your local machine **for development and testing
+purposes**. Please read these instructions carefully. See [deployment](#deployment) for notes on how to deploy the
+project on a live system.
### Prerequisites
-You will need Java JDK/JRE 11 (preferably openJDK: e.g. from https://adoptopenjdk.net/)
-
-You will need a Postgres Database (Docker image or local installation). We recommend the Docker image to get started quickly.
-
-When installing locally, the Postgres Database (at least Version 10.4) needs the following extensions:
- * [temporal tables](https://github.com/arkhipov/temporal_tables)
- ```bash
- git clone https://github.com/arkhipov/temporal_tables.git
- make
- sudo make install
- make installcheck
- ```
- * [jsquery](https://github.com/postgrespro/jsquery)
- ```bash
- git clone https://github.com/postgrespro/jsquery.git
- cd jsquery
- make USE_PGXS=1
- sudo make USE_PGXS=1 install
- make USE_PGXS=1 installcheck
- ```
+You will need Java JDK/JRE 21 (preferably openJDK: e.g. from https://adoptopenjdk.net/)
+
+You will need a Postgres Database (at least Version 15 or higher, Version 16 recommended) (Docker image or local installation).
+We recommend the Docker image to get started quickly.
### Installing
#### 1. Setup database
-> NOTE: Building EHRbase requires a properly set up and running DB for the following steps.
+> NOTE: Building EHRbase requires a properly set-up and running DB for the following steps.
-Run `./db-setup/createdb.sql` as `postgres` User.
+Run `./createdb.sql` as `postgres` User.
You can also use this Docker image which is a preconfigured Postgres database:
+
```shell
docker network create ehrbase-net
- docker run --name ehrdb --network ehrbase-net -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 ehrbase/ehrbase-postgres:latest
+ docker run --name ehrdb --network ehrbase-net -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 ehrbase/ehrbase-v2-postgres:16.2
```
-(For a preconfigured EHRbase application Docker image and its usage see the [documentation](https://ehrbase.readthedocs.io/en/latest/03_development/04_docker_images/index.html))
+(For a preconfigured EHRbase application Docker image and its usage see the [Installation](https://docs.ehrbase.org/docs/EHRbase/installation) guide.
+
#### 2. Setup Maven environment
Edit the database properties in `./pom.xml` if necessary
#### 3. Build EHRbase
+
Run `mvn package`
#### 4. Run EHRbase
-Replace the * with the current version, e.g. `application/target/application-0.9.0.jar`
+Replace the * with the current version, e.g. `application/target/ehrbase-2.0.0.jar`
-`java -jar application/target/application-*.jar`
+`java -jar application/target/ehrbase-*.jar`
### Authentication Types
@@ -117,7 +90,7 @@ Currently we have support one user with password which can be set via environmen
and can be overridden by environment values. Alternatively you can set them inside the corresponding application.yml
file.
-The same applies to the *admin* user, via `SECURITY_AUTHADMINUSER`, `SECURITY_AUTHADMINPASSWORD`
+The same applies to the *admin* user, via `SECURITY_AUTHADMINUSER`, `SECURITY_AUTHADMINPASSWORD`
and their default values of `ehrbase-admin` and `EvenMoreSecretPassword`.
#### 2. OAuth2
@@ -127,53 +100,89 @@ Environment variable `SECURITY_AUTHTYPE=OAUTH` is enabling OAuth2 authentication
Additionally, setting the following variable to point to the existing OAuth2 server and realm is necessary:
`SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI=http://localhost:8081/auth/realms/ehrbase`
-
Two roles are available: a user role, and admin role. By default, these roles are expected to be named `USER` and
`ADMIN`. The names of these roles can be customised through the `SECURITY_OAUTH2USERROLE` and `SECURITY_OAUTH2ADMINROLE`
environment variables. Users should have their roles assigned accordingly, either in the `realm_access.roles` or `scope`
claim of the JWT used for authentication.
-## Running the tests
+## Contributing
-This command will run all tests from `tests/robot` folder.
-DB and server application will be started/stopped by the tests accordingly. You *must not* start them by hand.
+### Codestyle/Formatting
-> NOTE: Make sure you meet the PREREQUISITES mentioned in tests/README.md prior to test execution.
->
-> Please Check the README in `tests` folder for more details.
+EHRbase java sourcecode is using [palantir-java-format](https://github.com/palantir/palantir-java-format) codestyle.
+The formatting is checked and applied using
+the [spotless-maven-plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven).
+To apply the codestyle run the `com.diffplug.spotless:spotless-maven-plugin:apply` maven goal in the root directory of
+the project.
+To check if the code conforms to the codestyle run the `com.diffplug.spotless:spotless-maven-plugin:check` maven goal in
+the root directory of the project.
+These maven goals can also be run for a single module by running them in the modules' subdirectory.
-```bash
-cd tests
-./run_local_tests.sh
+To make sure all code conforms to the codestyle, the "check-codestyle" check is run on all pull requests.
+Pull requests not passing this check shall not be merged.
+
+If you wish to automatically apply the formatting on commit for *.java files, a simple pre-commit hook script "
+pre-commit.sh" is available in the root directory of this repository.
+To enable the hook you can either copy the script to or create a symlink for it at `.git/hooks/pre-commit`.
+The git hook will run the "apply" goal for the whole project, but formatting changes will only be staged for already
+staged files, to avoid including unrelated changes.
+
+In case there is a section of code that you carefully formatted in a special way the formatting can be turned off for
+that section like this:
+
+```
+everything here will be reformatted..
+
+// @formatter:off
+
+ This is not affected by spotless-plugin reformatting...
+ And will stay as is it is!
+
+// @formatter:on
+
+everything here will be reformatted..
```
+Please be aware that `@formatter:off/on` should only be used on rare occasions to increase readability of complex code and shall be looked at critically when reviewing merge requests.
+
+## Running the tests
+
+For integration tests please refer to the [integration-test](https://github.com/ehrbase/integration-tests) repository
## Deployment
- 1. `java -jar application/target/application-*.jar` You can override the application properties (like database settings) using the normal spring boot mechanism: [Command-Line Arguments in Spring Boot](https://www.baeldung.com/spring-boot-command-line-arguments)
+ 1. `java -jar application/target/ehrbase-*.jar` You can override the application properties (like database settings) using the normal spring boot mechanism: [Command-Line Arguments in Spring Boot](https://www.baeldung.com/spring-boot-command-line-arguments)
2. Browse to Swagger UI --> http://localhost:8080/ehrbase/swagger-ui.html
+## Updating
+Before updating to a new version of EHRBase check [UPDATING.md](UPDATING.md) for any backwards-incompatible changes and additional
+steps needed in EHRBase. New Releases may introduce DB changes. It is thus recommend to make a DB backup before
+updating.
## Built With
* [Maven](https://maven.apache.org/) - Dependency Management
+----
+## Acknowledgments
-## License
-
-EHRbase uses the Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
+EHRbase contains code and derived code from EtherCIS (ethercis.org) which has been developed by Christian Chevalley (
+ADOC Software Development Co.,Ltd).
+Dr. Tony Shannon and Phil Berret of the [Ripple Foundation CIC Ltd, UK](https://ripple.foundation/) and Dr. Ian
+McNicoll (FreshEHR Ltd.) greatly contributed to EtherCIS.
-## Acknowledgments
+EHRbase heavily relies on the openEHR Reference Model implementation ([Archie](https://github.com/openEHR/archie)) made
+by Nedap. Many thanks to Pieter Bos and his team for their work!
-EHRbase contains code and derived code from EtherCIS (ethercis.org) which has been developed by Christian Chevalley (ADOC Software Development Co.,Ltd).
-Dr. Tony Shannon and Phil Berret of the [Ripple Foundation CIC Ltd, UK](https://ripple.foundation/) and Dr. Ian McNicoll (FreshEHR Ltd.) greatly contributed to EtherCIS.
+EHRbase is jointly developed by [Vitasystems GmbH](https://www.vitagroup.ag/de_DE/Ueber-uns/vitasystems)
+and [Peter L. Reichertz Institute for Medical Informatics of TU Braunschweig and Hannover Medical School](https://www.plri.de/)
-EHRbase heavily relies on the openEHR Reference Model implementation ([Archie](https://github.com/openEHR/archie)) made by Nedap. Many thanks to Pieter Bos and his team for their work!
-EHRbase is jointly developed by [Vitasystems GmbH](https://www.vitagroup.ag/de_DE/Ueber-uns/vitasystems) and [Peter L. Reichertz Institute for Medical Informatics of TU Braunschweig and Hannover Medical School](plri.de)
+## License
+EHRbase uses the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
## Stargazers over time
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000000..e4ae0ac5e7
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,27 @@
+# Responsible disclosure of security issues
+
+## Report a vulnerability
+
+We're extremely grateful for users that identify and report vulnerabilities to the EHRbase community. All reports are thoroughly investigated, confirmed and patched as soon as possible.
+
+Given that EHRbase is used to handle sensitive, medical data, we would like to ask you to submit the vulnerability to [ehrbase-security@vitagroup.ag](mailto:ehrbase-security@vitagroup.ag), to allow triaging and handling of the vulnerability with standardized processes and response times.
+
+Reporting vulnerabilities according to [regular responsible disclosure policies](https://www.bugcrowd.com/resource/what-is-responsible-disclosure/) allows us to confirm and provide a patch based on your report before a full disclosure, preventing in-the-wild exploitation of the vulnerability.
+
+## When should I report a vulnerability?
+
+- You think you discovered a potential security vulnerability in EHRbase
+- You are unsure how a vulnerability affects EHRbase
+
+## When should I **not** report a vulnerability?
+
+- You need support in securely deploying/operating EHRbase
+- You need support for additional environment-dependent security measures
+- You need support in security related updates
+- Your issue is not related to security
+
+## Security vulnerability response
+
+Each report is acknowledged, analyzed and responded to by the team as soon as possible.
+
+We will notify you as soon as the issue is triaged and we identify a fix and a release date, and create a full disclosure after a patch is released.
\ No newline at end of file
diff --git a/UPDATING.md b/UPDATING.md
index fea8e9f9ca..521034ca64 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -1,14 +1,70 @@
# Updating EHRbase
-This file documents any backwards-incompatible changes in EHRBase deployment and
-assists users migrating to a new version.
-
-## EHRbase 1.0.0
-### Database Configuration
-The creation of the DB must ensure that SQL interval type is ISO-8601 compliant. This is required to ensure proper
-formatting of the resultset.
-Scripts provided ensure this encoding is done properly (see `base/db-setup`) with the following statement:
-```
--- ensure INTERVAL is ISO8601 encoded
-alter database ehrbase SET intervalstyle = 'iso_8601';
-```
\ No newline at end of file
+This file documents any backwards-incompatible changes in EHRBase and assists users migrating to a new version.
+
+## EHRbase 2.0.0
+
+### Migrating data
+
+EHRbase 2.0.0 comes with a completely overhauled data structure that is not automatically migrated when deploying this
+new version over an older data structure.
+
+To support the migrating of data from systems `pre-2.0.0` to `2.0.0`, a migration tool and instructions are provided
+at https://github.com/ehrbase/migration-tool.
+
+
+## EHRbase 2.7.0
+
+### EHR_STATUS and FOLDER consistency check
+
+Updating an `EHR_STATUS` or `FOLDER` did not check the `If-Match header` against the DB. This allowed to pass in an
+invalid identifier that does not match the existing in the DB. This may have lead to inconsistent data in some systems.
+
+To check if any `EHR_STATUS` or `FOLDER` is affected run [ehrbase_2.7.0_check_ehr_status_and_folder_void](db_scripts/ehrbase_2.7.0_check_ehr_status_and_folder_void.sql).
+In case you see an output like:
+```text
+Inconsistent EHR_STATUS found
+Inconsistent FOLDER found
+```
+Please open an issue so that a fix can be provided.
+
+## EHRbase 2.10.0
+
+Starting from version 2.0.0 the ehrscape API was deprecated.
+With the release of version 2.10.0, the API is now disabled by default,
+but can still be enabled by setting the configuration property or environment variable `ehrbase.rest.ehrscape.enabled` to `true`.
+
+A validation that compositions only contain nodes that are defined by the template has been added.
+This behavior can be disabled by setting the configuration property or environment variable `ehrbase.validation.checkForExtraNodes` to `false`.
+
+## EHRbase 2.11.0
+
+The new data model for FOLDER items requires a full migration of the ehr_folder_data table, which may take a while.
+As only local VERSIONED_COMPOSITION references are supported, existing data is rewritten accordingly.
+If entries of FOLDER.items.id.value exist that do not comply with the UUID format, the migration will fail.
+These entries will have to be fixed manually.
+
+## EHRbase 2.13.0
+
+The openEHR terminology has been update to version 2.4.0.
+As the code for the composition category 'episodic' has changed from 435 to 451, existing templates and compositions may be inconsistent.
+For smaller systems this can be checked via AQL:
+`SELECT c/archetype_details/template_id/value, count(*) FROM COMPOSITION c WHERE c/category/code/value = '435'`.
+Please open an issue on github in case you need instructions on correcting the data.
+
+## EHRbase 2.21.0
+
+In AQL queries CONTAINS expressions with a node predicate now exclude results from nested archetypes.
+
+Example:
+```
+SELECT el
+FROM OBSERVATION[openEHR-EHR-OBSERVATION.blood_pressure.v2] CONTAINS ELEMENT el[at0004]
+```
+will be no longer contain from ELEMENTs returned by
+```
+SELECT el
+FROM OBSERVATION[openEHR-EHR-OBSERVATION.blood_pressure.v2] CONTAINS CLUSTER c[openEHR-EHR-CLUSTER.device.v1] CONTAINS ELEMENT el[at0004]
+```
+
+To restore the previous behaviour set `ehrbase.aql.archetype-local-node-predicates = false`
diff --git a/api/pom.xml b/api/pom.xml
index 3ef80a53ae..73d7ba4ac3 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -1,7 +1,7 @@
-
+4.0.0org.ehrbase.openehrserver
- 0.20.0-SNAPSHOT
+ 2.23.0-SNAPSHOTapi
+ EHRbase Internal API
+
+ org.aspectj
+ aspectjweaver
+
+
com.fasterxml.jackson.datatypejackson-datatype-jsr310
@@ -62,15 +66,20 @@
com.nedap.healthcare.archieopenehr-rm
+
org.assertjassertj-core
+ test
- junit
- junit
+ org.junit.jupiter
+ junit-jupitertest
+
-
\ No newline at end of file
+
+
+
diff --git a/api/src/main/java/org/ehrbase/api/annotations/EhrbaseSecurity.java b/api/src/main/java/org/ehrbase/api/annotations/EhrbaseSecurity.java
new file mode 100644
index 0000000000..b616e380f1
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/annotations/EhrbaseSecurity.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.annotations;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(ElementType.METHOD)
+public @interface EhrbaseSecurity {}
diff --git a/api/src/main/java/org/ehrbase/api/aspect/AnnotationAspect.java b/api/src/main/java/org/ehrbase/api/aspect/AnnotationAspect.java
new file mode 100644
index 0000000000..f116c068b2
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/aspect/AnnotationAspect.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.aspect;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+import org.aspectj.lang.ProceedingJoinPoint;
+
+public interface AnnotationAspect {
+ public List> matchAnnotations();
+
+ public Object action(ProceedingJoinPoint pjp, List annotations) throws Throwable;
+}
diff --git a/api/src/main/java/org/ehrbase/api/aspect/AuthorizationAspect.java b/api/src/main/java/org/ehrbase/api/aspect/AuthorizationAspect.java
new file mode 100644
index 0000000000..fc3048866f
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/aspect/AuthorizationAspect.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.aspect;
+
+public interface AuthorizationAspect extends AnnotationAspect {}
diff --git a/api/src/main/java/org/ehrbase/api/definitions/OperationalTemplateFormat.java b/api/src/main/java/org/ehrbase/api/definitions/OperationalTemplateFormat.java
index e4674a9870..a8b8392560 100644
--- a/api/src/main/java/org/ehrbase/api/definitions/OperationalTemplateFormat.java
+++ b/api/src/main/java/org/ehrbase/api/definitions/OperationalTemplateFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,9 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.definitions;
public enum OperationalTemplateFormat {
- XML, JSON
+ XML,
+ JSON
}
diff --git a/api/src/main/java/org/ehrbase/api/definitions/QueryMode.java b/api/src/main/java/org/ehrbase/api/definitions/QueryMode.java
deleted file mode 100644
index 131350b2b1..0000000000
--- a/api/src/main/java/org/ehrbase/api/definitions/QueryMode.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2019 Vitasystems GmbH and Hannover Medical School.
- *
- * This file is part of project EHRbase
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://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.
- */
-
-package org.ehrbase.api.definitions;
-
-public enum QueryMode {
- SQL("sql"), AQL("aql");
-
- private final String code;
-
- QueryMode(String code) {
- this.code = code;
- }
-
- public String getCode() {
- return code;
- }
-}
diff --git a/api/src/main/java/org/ehrbase/api/definitions/ServerConfig.java b/api/src/main/java/org/ehrbase/api/definitions/ServerConfig.java
deleted file mode 100644
index c07d243d43..0000000000
--- a/api/src/main/java/org/ehrbase/api/definitions/ServerConfig.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.ehrbase.api.definitions;
-
-public interface ServerConfig {
-
- int getPort();
-
- void setPort(int port);
-
- String getNodename();
-
- void setNodename(String nodename);
-
- String getAqlIterationSkipList();
-
- Integer getAqlDepth();
-
- Boolean getUseJsQuery();
-
- void setUseJsQuery(boolean b);
-
- public boolean isDisableStrictValidation();
-}
diff --git a/api/src/main/java/org/ehrbase/api/dto/AqlQueryContext.java b/api/src/main/java/org/ehrbase/api/dto/AqlQueryContext.java
new file mode 100644
index 0000000000..ce2a27a80d
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/AqlQueryContext.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import java.net.URI;
+import org.ehrbase.openehr.sdk.response.dto.MetaData;
+
+public interface AqlQueryContext {
+
+ String BEAN_NAME = "scopedAqlQueryContext";
+
+ interface MetaProperty {
+ String propertyName();
+ }
+
+ enum EhrbaseMetaProperty implements MetaProperty {
+ OFFSET("offset"),
+ FETCH("fetch"),
+ DEFAULT_LIMIT("default-limit"),
+ MAX_LIMIT("max-limit"),
+ MAX_FETCH("max-fetch"),
+ RESULT_SIZE("resultsize"),
+ DRY_RUN("dry_run"),
+ EXECUTED_SQL("executed_sql"),
+ QUERY_PLAN("query_plan");
+
+ private final String propertyName;
+
+ EhrbaseMetaProperty(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ @Override
+ public String propertyName() {
+ return propertyName;
+ }
+ }
+
+ String OPENEHR_REST_API_VERSION = "1.0.3";
+
+ MetaData createMetaData(URI location);
+
+ boolean showExecutedAql();
+
+ boolean isDryRun();
+
+ boolean showExecutedSql();
+
+ boolean showQueryPlan();
+
+ boolean isPathSkipping();
+
+ boolean isArchetypeLocalNodePredicates();
+
+ void setExecutedAql(String executedAql);
+
+ void setMetaProperty(MetaProperty property, Object value);
+}
diff --git a/api/src/main/java/org/ehrbase/api/dto/AqlQueryRequest.java b/api/src/main/java/org/ehrbase/api/dto/AqlQueryRequest.java
new file mode 100644
index 0000000000..03c880bb5c
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/AqlQueryRequest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import java.util.Map;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.ehrbase.api.exception.IllegalAqlException;
+import org.ehrbase.api.service.AqlQueryService;
+import org.ehrbase.openehr.sdk.aql.dto.AqlQuery;
+import org.ehrbase.openehr.sdk.aql.parser.AqlParseException;
+import org.ehrbase.openehr.sdk.aql.parser.AqlQueryParser;
+
+/**
+ * The requested AQL to be executed by {@link AqlQueryService#query(AqlQueryRequest)}.
+ *
+ * @param aqlQuery the actual aql query
+ * @param parameters additional query parameters
+ * @param fetch query limit to apply
+ * @param offset query offset to apply
+ */
+public record AqlQueryRequest(
+ @Nonnull AqlQuery aqlQuery,
+ @Nullable Map parameters,
+ @Nullable Long fetch,
+ @Nullable Long offset) {
+
+ /**
+ * Create a new {@link AqlQueryRequest} by parsing the given AQL queryString.
+ *
+ * @see AqlQueryRequest
+ */
+ public static AqlQueryRequest prepare(
+ @Nonnull String queryString,
+ @Nullable Map parameters,
+ @Nullable Long fetch,
+ @Nullable Long offset) {
+ try {
+ AqlQuery aqlQuery = AqlQueryParser.parse(queryString);
+ return new AqlQueryRequest(aqlQuery, parameters, fetch, offset);
+ } catch (AqlParseException e) {
+ throw new IllegalAqlException(
+ "Could not parse AQL query: "
+ + Optional.of(e).map(Throwable::getCause).orElse(e).getMessage(),
+ e);
+ }
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/dto/EhrDto.java b/api/src/main/java/org/ehrbase/api/dto/EhrDto.java
new file mode 100644
index 0000000000..3e53ce5c0d
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/EhrDto.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime;
+import com.nedap.archie.rm.support.identification.HierObjectId;
+import java.util.List;
+import org.ehrbase.openehr.sdk.response.dto.ehrscape.CompositionDto;
+import org.ehrbase.openehr.sdk.response.dto.ehrscape.ContributionDto;
+
+/**
+ * Basic set of response data regarding EHR_STATUS. operations. Used as default or when PREFER
+ * header requests minimal response.
+ */
+@JsonRootName(value = "EHR")
+@JacksonXmlRootElement(localName = "ehr")
+public record EhrDto(
+ @JsonProperty(value = "system_id") HierObjectId systemId,
+ @JsonProperty(value = "ehr_id") HierObjectId ehrId,
+ @JsonProperty(value = "ehr_status") EhrStatusDto ehrStatus,
+ @JsonProperty(value = "time_created") DvDateTime timeCreated,
+ @JsonProperty(value = "compositions") List compositions,
+ @JsonProperty(value = "contributions") List contributions) {}
diff --git a/api/src/main/java/org/ehrbase/api/dto/EhrStatusDto.java b/api/src/main/java/org/ehrbase/api/dto/EhrStatusDto.java
new file mode 100644
index 0000000000..555ecb2968
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/EhrStatusDto.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2019-2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.nedap.archie.rm.archetyped.Archetyped;
+import com.nedap.archie.rm.archetyped.FeederAudit;
+import com.nedap.archie.rm.datastructures.ItemStructure;
+import com.nedap.archie.rm.datavalues.DvText;
+import com.nedap.archie.rm.generic.PartySelf;
+import com.nedap.archie.rm.support.identification.UIDBasedId;
+import javax.annotation.Nullable;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Request/Response data of an EHR_STATUS.
+ */
+@JsonRootName(value = "EHR_STATUS")
+@JacksonXmlRootElement(localName = "ehr_status")
+@XmlType(name = "EHR_STATUS")
+public record EhrStatusDto(
+ @JsonProperty(value = "uid") @XmlElement UIDBasedId uid,
+ @JsonProperty(value = "archetype_node_id", required = true) @XmlAttribute(name = "archetype_node_id")
+ String archetypeNodeId,
+ @JsonProperty(value = "name") @XmlElement DvText name,
+ @JsonProperty(value = "archetype_details") @XmlElement(name = "archetype_details") @Nullable
+ Archetyped archetypeDetails,
+ @JsonProperty(value = "feeder_audit") @XmlElement(name = "feeder_audit") @Nullable FeederAudit feederAudit,
+ @JsonProperty(value = "subject") @XmlElement PartySelf subject,
+ @JsonProperty(value = "is_queryable") @XmlElement(name = "is_queryable") Boolean isQueryable,
+ @JsonProperty(value = "is_modifiable") @XmlElement(name = "is_modifiable") Boolean isModifiable,
+ @JsonProperty(value = "other_details") @XmlElement(name = "other_details") @Nullable
+ ItemStructure otherDetails) {
+
+ @JsonProperty(value = "_type", required = true)
+ @XmlElement(name = "_type")
+ public String type() {
+ return "EHR_STATUS";
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/dto/FolderDto.java b/api/src/main/java/org/ehrbase/api/dto/FolderDto.java
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/api/src/main/java/org/ehrbase/api/dto/VersionedCompositionDto.java b/api/src/main/java/org/ehrbase/api/dto/VersionedCompositionDto.java
new file mode 100644
index 0000000000..c33960cea5
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/VersionedCompositionDto.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019-2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.nedap.archie.rm.support.identification.HierObjectId;
+import com.nedap.archie.rm.support.identification.ObjectId;
+import com.nedap.archie.rm.support.identification.ObjectRef;
+
+/**
+ * Response data of a VERSIONED_COMPOSITION.
+ */
+@JsonRootName(value = "VERSIONED_COMPOSITION")
+@JacksonXmlRootElement(localName = "versioned_composition")
+public record VersionedCompositionDto(
+ @JsonProperty(value = "uid") HierObjectId uid,
+ @JsonProperty(value = "owner_id") ObjectRef extends ObjectId> ownerId,
+ @JsonProperty(value = "time_created") String timeCreated) {
+
+ @JsonProperty(value = "_type")
+ public String type() {
+ return "VERSIONED_COMPOSITION";
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/dto/VersionedEhrStatusDto.java b/api/src/main/java/org/ehrbase/api/dto/VersionedEhrStatusDto.java
new file mode 100644
index 0000000000..b9d24292a4
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/VersionedEhrStatusDto.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019-2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.nedap.archie.rm.support.identification.HierObjectId;
+import com.nedap.archie.rm.support.identification.ObjectId;
+import com.nedap.archie.rm.support.identification.ObjectRef;
+
+/**
+ * Response data of a VERSIONED_EHR_STATUS.
+ */
+@JsonRootName(value = "VERSIONED_EHR_STATUS")
+@JacksonXmlRootElement(localName = "versioned_ehr_status")
+public record VersionedEhrStatusDto(
+ @JsonProperty(value = "uid") HierObjectId uid,
+ @JsonProperty(value = "owner_id") ObjectRef extends ObjectId> ownerId,
+ @JsonProperty(value = "time_created") String timeCreated) {
+
+ @JsonProperty(value = "_type")
+ public String type() {
+ return "VERSIONED_EHR_STATUS";
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/dto/experimental/ItemTagDto.java b/api/src/main/java/org/ehrbase/api/dto/experimental/ItemTagDto.java
new file mode 100644
index 0000000000..7d7705aac9
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/dto/experimental/ItemTagDto.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2019-2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.dto.experimental;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
+import java.util.UUID;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public final class ItemTagDto {
+ private UUID id;
+ private UUID ownerId;
+ private UUID target;
+ private ItemTagRMType targetType;
+ private String targetPath;
+ private String key;
+ private String value;
+
+ public ItemTagDto() {
+ // NOOP - For Jackson
+ }
+
+ /**
+ * @param id Identifier of the tag
+ * @param ownerId Identifier of owner object, such as EHR.
+ * @param target Identifier of target, which may be a VERSIONED_OBJECT<T> or a VERSION<T>.
+ * @param targetType RM type of the tag
+ * @param targetPath Optional archetype (i.e. AQL) or RM path within target, used to tag a fine-grained element.
+ * @param key The tag key. May not be empty or contain leading or trailing whitespace.
+ * @param value The value. If set, may not be empty.
+ */
+ public ItemTagDto(
+ UUID id,
+ UUID ownerId, // obtained by path for PUT
+ UUID target, // obtained by path for PUT
+ ItemTagRMType targetType, // obtained by path for PUT
+ String targetPath,
+ String key,
+ String value) {
+ this.id = id;
+ this.ownerId = ownerId;
+ this.target = target;
+ this.targetType = targetType;
+ this.targetPath = targetPath;
+ this.key = key;
+ this.value = value;
+ }
+
+ @Nullable
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(@Nullable final UUID id) {
+ this.id = id;
+ }
+
+ @JsonProperty(value = "owner_id")
+ @Nullable
+ public UUID getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(@Nullable final UUID ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ @Nullable
+ public UUID getTarget() {
+ return target;
+ }
+
+ public void setTarget(@Nullable final UUID target) {
+ this.target = target;
+ }
+
+ @JsonProperty(value = "target_type")
+ @Nullable
+ public ItemTagRMType getTargetType() {
+ return targetType;
+ }
+
+ public void setTargetType(@Nullable final ItemTagRMType targetType) {
+ this.targetType = targetType;
+ }
+
+ @JsonProperty(value = "target_path")
+ @Nullable
+ public String getTargetPath() {
+ return targetPath;
+ }
+
+ public void setTargetPath(@Nullable final String targetPath) {
+ this.targetPath = targetPath;
+ }
+
+ @Nonnull
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(@Nonnull final String key) {
+ this.key = key;
+ }
+
+ @Nullable
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(@Nullable final String value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+ if (obj == null || obj.getClass() != this.getClass()) return false;
+ var that = (ItemTagDto) obj;
+ return Objects.equals(this.id, that.id)
+ && Objects.equals(this.ownerId, that.ownerId)
+ && Objects.equals(this.target, that.target)
+ && Objects.equals(this.targetType, that.targetType)
+ && Objects.equals(this.targetPath, that.targetPath)
+ && Objects.equals(this.key, that.key)
+ && Objects.equals(this.value, that.value);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, ownerId, target, targetType, targetPath, key, value);
+ }
+
+ @Override
+ public String toString() {
+ return "ItemTagDto[" + "id="
+ + id + ", " + "ownerId="
+ + ownerId + ", " + "target="
+ + target + ", " + "targetType="
+ + targetType + ", " + "targetPath="
+ + targetPath + ", " + "key="
+ + key + ", " + "value="
+ + value + ']';
+ }
+
+ public enum ItemTagRMType {
+ EHR_STATUS,
+ COMPOSITION
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/AqlFeatureNotImplementedException.java b/api/src/main/java/org/ehrbase/api/exception/AqlFeatureNotImplementedException.java
new file mode 100644
index 0000000000..f4fdb4bbad
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/exception/AqlFeatureNotImplementedException.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.exception;
+
+public class AqlFeatureNotImplementedException extends AqlRuntimeException {
+ public AqlFeatureNotImplementedException(String message) {
+ super("Not implemented: %s".formatted(message));
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/AqlRuntimeException.java b/api/src/main/java/org/ehrbase/api/exception/AqlRuntimeException.java
new file mode 100644
index 0000000000..83d8ee2930
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/exception/AqlRuntimeException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.exception;
+
+public abstract class AqlRuntimeException extends RuntimeException {
+
+ public AqlRuntimeException(String s) {
+ super(s);
+ }
+
+ public AqlRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AqlRuntimeException(Throwable cause) {
+ super(cause.getMessage(), cause);
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/BadGatewayException.java b/api/src/main/java/org/ehrbase/api/exception/BadGatewayException.java
index 8dff1e63ae..27a49f961a 100644
--- a/api/src/main/java/org/ehrbase/api/exception/BadGatewayException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/BadGatewayException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -23,7 +22,7 @@
* status 502 "Bad gateway" or whatever is appropriate.
* Proxied connection failed, e.g. the server could not contact the clustered note that processes the specified query (EhrScape API example).
*/
-public class BadGatewayException extends RuntimeException{
+public class BadGatewayException extends RuntimeException {
public BadGatewayException(String message) {
super(message);
diff --git a/api/src/main/java/org/ehrbase/api/exception/DuplicateObjectException.java b/api/src/main/java/org/ehrbase/api/exception/DuplicateObjectException.java
deleted file mode 100644
index 38d00b10a2..0000000000
--- a/api/src/main/java/org/ehrbase/api/exception/DuplicateObjectException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2019 Vitasystems GmbH and Hannover Medical School.
- *
- * This file is part of project EHRbase
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://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.
- */
-
-package org.ehrbase.api.exception;
-
-public class DuplicateObjectException extends RuntimeException {
-
- private String type;
-
- public DuplicateObjectException(String type, String message) {
- super(message);
- this.type = type;
- }
-
- public DuplicateObjectException(String type, String message, Throwable cause) {
- super(message, cause);
- this.type = type;
- }
-
- public String getType() {
- return type;
- }
-}
diff --git a/api/src/main/java/org/ehrbase/api/exception/GeneralRequestProcessingException.java b/api/src/main/java/org/ehrbase/api/exception/GeneralRequestProcessingException.java
index 02300e3021..3cbcfaec01 100644
--- a/api/src/main/java/org/ehrbase/api/exception/GeneralRequestProcessingException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/GeneralRequestProcessingException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -23,7 +22,7 @@
* status 400 "Bad Request" or whatever is appropriate.
* To be thrown in all cases where part of the request leads to problems, like malformed queries or non-existent referenced objects.
*/
-public class GeneralRequestProcessingException extends RuntimeException {
+public class GeneralRequestProcessingException extends RuntimeException {
public GeneralRequestProcessingException(String message) {
super(message);
diff --git a/api/src/main/java/org/ehrbase/api/exception/IllegalAqlException.java b/api/src/main/java/org/ehrbase/api/exception/IllegalAqlException.java
new file mode 100644
index 0000000000..a004d9ef3d
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/exception/IllegalAqlException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.exception;
+
+public class IllegalAqlException extends AqlRuntimeException {
+ public IllegalAqlException(String message) {
+ super(message);
+ }
+
+ public IllegalAqlException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IllegalAqlException(Throwable cause) {
+ super(cause.getMessage(), cause);
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/InternalServerException.java b/api/src/main/java/org/ehrbase/api/exception/InternalServerException.java
index 2dd28bc87c..07a9bf6f11 100644
--- a/api/src/main/java/org/ehrbase/api/exception/InternalServerException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/InternalServerException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -29,11 +28,11 @@ public InternalServerException(String message) {
super(message);
}
- public InternalServerException(String message, Exception cause) {
+ public InternalServerException(String message, Throwable cause) {
super(message, cause);
}
- public InternalServerException(Exception cause) {
- super(cause);
+ public InternalServerException(Throwable cause) {
+ super(cause.getMessage(), cause);
}
}
diff --git a/api/src/main/java/org/ehrbase/api/exception/InvalidApiParameterException.java b/api/src/main/java/org/ehrbase/api/exception/InvalidApiParameterException.java
index 4371f3d6b1..9e65c6dd66 100644
--- a/api/src/main/java/org/ehrbase/api/exception/InvalidApiParameterException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/InvalidApiParameterException.java
@@ -1,11 +1,13 @@
/*
- * Copyright 2019-2022 vitasystems GmbH and Hannover Medical School.
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -13,16 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
public class InvalidApiParameterException extends RuntimeException {
- public InvalidApiParameterException(String message) {
- super(message);
- }
+ public InvalidApiParameterException(String message) {
+ super(message);
+ }
- public InvalidApiParameterException(String message, Throwable cause) {
- super(message, cause);
- }
+ public InvalidApiParameterException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/api/src/main/java/org/ehrbase/api/exception/NotAcceptableException.java b/api/src/main/java/org/ehrbase/api/exception/NotAcceptableException.java
index 3ce803bc98..99a9f42f2b 100644
--- a/api/src/main/java/org/ehrbase/api/exception/NotAcceptableException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/NotAcceptableException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
public class NotAcceptableException extends RuntimeException {
diff --git a/api/src/main/java/org/ehrbase/api/exception/ObjectNotFoundException.java b/api/src/main/java/org/ehrbase/api/exception/ObjectNotFoundException.java
index 1fda474069..28b286e061 100644
--- a/api/src/main/java/org/ehrbase/api/exception/ObjectNotFoundException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/ObjectNotFoundException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -25,7 +24,7 @@
*/
public class ObjectNotFoundException extends RuntimeException {
- private String type;
+ private final String type;
public ObjectNotFoundException(String type, String message) {
super(message);
diff --git a/api/src/main/java/org/ehrbase/api/exception/PreconditionFailedException.java b/api/src/main/java/org/ehrbase/api/exception/PreconditionFailedException.java
index 8e583eca36..5cc4a0ea75 100644
--- a/api/src/main/java/org/ehrbase/api/exception/PreconditionFailedException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/PreconditionFailedException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -23,7 +22,7 @@
* status 412 "Precondition Failed" or whatever is appropriate.
* To be thrown in all cases where part of the request leads to problems, like malformed queries or non-existent referenced objects.
*/
-public class PreconditionFailedException extends RuntimeException {
+public class PreconditionFailedException extends RuntimeException {
private final String currentVersionUid;
private final String url;
@@ -56,4 +55,4 @@ public String getCurrentVersionUid() {
public String getUrl() {
return url;
}
-}
\ No newline at end of file
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/StateConflictException.java b/api/src/main/java/org/ehrbase/api/exception/StateConflictException.java
index 715afb1052..5b92d265e4 100644
--- a/api/src/main/java/org/ehrbase/api/exception/StateConflictException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/StateConflictException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -23,7 +22,7 @@
* status 409 "Conflict" or whatever is appropriate.
* Request is in conflict with current state, e.g. referenced version of object is not the last version.
*/
-public class StateConflictException extends RuntimeException{
+public class StateConflictException extends RuntimeException {
public StateConflictException(String message) {
super(message);
diff --git a/api/src/main/java/org/ehrbase/api/exception/UnexpectedSwitchCaseException.java b/api/src/main/java/org/ehrbase/api/exception/UnexpectedSwitchCaseException.java
index 761961c9fb..be48a4f875 100644
--- a/api/src/main/java/org/ehrbase/api/exception/UnexpectedSwitchCaseException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/UnexpectedSwitchCaseException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Hannover Medical School.
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,38 +15,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
import org.apache.commons.lang3.StringUtils;
/**
*
- * Diese Exception wird geworfen, wenn in einem Switch-Block ein Case eingetreten ist, der nicht korrekt behandelt werden kann. Eigentlich
- * sollte dieser Fall nicht auftreten (außer man ignoriert die Eclipse-Warning zum unvollständigen Switch).
+ * This exception is thrown when a case has occurred in a switch block that cannot be handled correctly.
*
*
- * Typische Verwendungen in einer Switch-Definition:
+ * Typical uses in a switch statement:
*
- *
Im unerwarteten default-Case
- *
Im explizit nicht sinnvoll behandelbaren Case
- *
Im unerwarteten default-Case eines Switch mit Fall-Through von nicht sinnvoll behandelbaren Cases (Kombination aus 1. und 2.)
+ *
unexpected default case
+ *
explicitly not sensibly treatable case
+ *
unexpected default case with fall-through of not sensibly treatable case (combination of 1. and 2.)
*
- * @author Jan Falkenstern, Stefan Kock
*/
public class UnexpectedSwitchCaseException extends RuntimeException {
private static final long serialVersionUID = 5695009820197756438L;
/**
- * Erzeugt aus dem übergebenen enumValue eine message.
- * Ausgegeben in der Exception-Message wird enumValue.name(),
- * damit z.B. bei lokalisierten Enums immer denselbe Wert ausgegeben wird.
+ * Creates a message from the enumValue parameter.
+ * The message is based on enumValue.name(),
+ * so that the format is stable, e.g. in case of i18n.
*
* @param enumValue must not be null
*/
@@ -55,9 +48,9 @@ public UnexpectedSwitchCaseException(Enum> enumValue) {
}
/**
- * Erzeugt aus dem übergebenen enumValue eine message.
- * Ausgegeben in der Exception-Message wird enumValue.name(),
- * damit z.B. bei lokalisierten Enums immer denselbe Wert ausgegeben wird.
+ * Creates a message from the enumValue parameter.
+ * The message is based on enumValue.name(),
+ * so that the format is stable, e.g. in case of i18n.
*
* @param enumValue must not be null
* @param additionalMessage additional text for generated message
@@ -67,7 +60,7 @@ public UnexpectedSwitchCaseException(Enum> enumValue, String additionalMessage
}
/**
- * Erzeugt aus dem übergebenen intValue eine message.
+ * Creates a message from the intValue parameter
*
* @param intValue
*/
@@ -76,7 +69,7 @@ public UnexpectedSwitchCaseException(Integer intValue) {
}
/**
- * Erzeugt aus dem übergebenen intValue eine message.
+ * Creates a message from the intValue parameter
*
* @param intValue
* @param additionalMessage additional text for generated message
@@ -86,13 +79,7 @@ public UnexpectedSwitchCaseException(Integer intValue, String additionalMessage)
}
/**
- * Erzeugt aus dem übergebenen stringValue eine message.
- *
- *
- *
Achtung: Breaking Change!
- *
Mit Version 0.1.3-SNAPSHOT hat sich die Bedeutung des Konstruktors geändert!
- * Statt der Meldung wird jetzt nur der Wert angegeben!
- *
+ * Creates a message from the stringValue parameter
*
* @param stringValue
*/
@@ -101,7 +88,7 @@ public UnexpectedSwitchCaseException(String stringValue) {
}
/**
- * Erzeugt aus dem übergebenen stringValue eine message.
+ * Creates a message from the stringValue parameter
*
* @param stringValue
* @param additionalMessage additional text for generated message
@@ -111,10 +98,9 @@ public UnexpectedSwitchCaseException(String stringValue, String additionalMessag
}
/**
- * Erzeugt die Message der {@link UnexpectedSwitchCaseException} anhand der übergebenen Parameter mit Ausgabe von
- * enumValue.getClass().getSimpleName().
- * Ausgegeben in der Exception-Message wird enumValue.name(),
- * damit z.B. bei lokalisierten Enums immer denselbe Wert ausgegeben wird.
+ * Creates the message of a {@link UnexpectedSwitchCaseException} containing the simple class name of the enumValue parameter.
+ * The message is based on enumValue.name(),
+ * so that the format is stable, e.g. in case of i18n.
*
* @param enumValue must not be null
* @param additionalMessage additional text for generated message (optional)
@@ -126,7 +112,7 @@ public static String formatMessage(Enum> enumValue, String additionalMessage)
}
/**
- * Erzeugt die Message der {@link UnexpectedSwitchCaseException} anhand der übergebenen Parameter.
+ * Creates the message of a {@link UnexpectedSwitchCaseException} based on the given parameters.
*
* @param value
* @param additionalMessage additional text for generated message (optional)
@@ -138,7 +124,7 @@ public static String formatMessage(Object value, String additionalMessage) {
}
/**
- * Erzeugt die Message der {@link UnexpectedSwitchCaseException} anhand der übergebenen Parameter.
+ * Creates the message of a {@link UnexpectedSwitchCaseException} based on the given parameters.
*
* @param type e.g. enumValue.getClass().getSimpleName()
* @param value unsupported value in switch
@@ -166,4 +152,4 @@ public static String formatMessage(String type, Object value, String additionalM
return sb.toString();
}
-}
\ No newline at end of file
+}
diff --git a/api/src/main/java/org/ehrbase/api/exception/UnprocessableEntityException.java b/api/src/main/java/org/ehrbase/api/exception/UnprocessableEntityException.java
index d8da677be5..05ae453c58 100644
--- a/api/src/main/java/org/ehrbase/api/exception/UnprocessableEntityException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/UnprocessableEntityException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Jake Smolka (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -27,4 +26,8 @@ public class UnprocessableEntityException extends RuntimeException {
public UnprocessableEntityException(String message) {
super(message);
}
+
+ public UnprocessableEntityException(String message, Throwable e) {
+ super(message, e);
+ }
}
diff --git a/api/src/main/java/org/ehrbase/api/exception/UnsupportedMediaTypeException.java b/api/src/main/java/org/ehrbase/api/exception/UnsupportedMediaTypeException.java
index 6f013b262e..11d7e3b26f 100644
--- a/api/src/main/java/org/ehrbase/api/exception/UnsupportedMediaTypeException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/UnsupportedMediaTypeException.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
package org.ehrbase.api.exception;
/**
@@ -14,6 +31,7 @@ public class UnsupportedMediaTypeException extends RuntimeException {
public UnsupportedMediaTypeException(String message) {
super(message);
}
+
public UnsupportedMediaTypeException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/api/src/main/java/org/ehrbase/api/exception/ValidationException.java b/api/src/main/java/org/ehrbase/api/exception/ValidationException.java
index ccfced4fb3..af5a4d9838 100644
--- a/api/src/main/java/org/ehrbase/api/exception/ValidationException.java
+++ b/api/src/main/java/org/ehrbase/api/exception/ValidationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Vitasystems GmbH and Christian Chevalley (Hannover Medical School).
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.exception;
/**
@@ -23,7 +22,7 @@
* status 400 "Bad Request" or whatever is appropriate.
* To be thrown in all cases where part of the request leads to problems, like malformed queries or non-existent referenced objects.
*/
-public class ValidationException extends RuntimeException {
+public class ValidationException extends RuntimeException {
public ValidationException(String message) {
super(message);
@@ -33,7 +32,7 @@ public ValidationException(String message, Throwable cause) {
super(message, cause);
}
- public ValidationException(Exception otherException){
- super(otherException);
+ public ValidationException(Exception cause) {
+ super(cause.getMessage(), cause);
}
}
diff --git a/api/src/main/java/org/ehrbase/api/knowledge/KnowledgeCacheService.java b/api/src/main/java/org/ehrbase/api/knowledge/KnowledgeCacheService.java
new file mode 100644
index 0000000000..96c4852294
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/knowledge/KnowledgeCacheService.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.knowledge;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplate;
+import org.openehr.schemas.v1.OPERATIONALTEMPLATE;
+
+public interface KnowledgeCacheService {
+
+ String addOperationalTemplate(OPERATIONALTEMPLATE template);
+
+ List listAllOperationalTemplates();
+
+ Map findAllTemplateIds();
+
+ /**
+ * retrieve an operational template document instance
+ *
+ * @param key the name of the operational template
+ * @return an OPERATIONALTEMPLATE document instance or null
+ * @see org.openehr.schemas.v1.OPERATIONALTEMPLATE
+ */
+ Optional retrieveOperationalTemplate(String key);
+
+ WebTemplate getInternalTemplate(String templateId);
+
+ /**
+ * Deletes a given operational template physically from cache and from template storage and from cache. Should only
+ * be executed if the template is no longer referenced by any Composition. Make sure you check for references before
+ * deleting a template otherwise this causes inconsistencies and no longer deliverable Composition entries.
+ *
+ * @param template - The template instance to delete
+ */
+ void deleteOperationalTemplate(OPERATIONALTEMPLATE template);
+
+ Optional findTemplateIdByUuid(UUID uuid);
+
+ Optional findUuidByTemplateId(String templateId);
+
+ String adminUpdateOperationalTemplate(InputStream content);
+
+ int deleteAllOperationalTemplates();
+}
diff --git a/api/src/main/java/org/ehrbase/api/knowledge/TemplateMetaData.java b/api/src/main/java/org/ehrbase/api/knowledge/TemplateMetaData.java
new file mode 100644
index 0000000000..f420c25064
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/knowledge/TemplateMetaData.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.knowledge;
+
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import org.openehr.schemas.v1.OPERATIONALTEMPLATE;
+
+public class TemplateMetaData {
+ private OPERATIONALTEMPLATE operationaltemplate;
+ private OffsetDateTime createdOn;
+
+ private UUID internalId;
+
+ private List errorList;
+
+ public OPERATIONALTEMPLATE getOperationaltemplate() {
+ return operationaltemplate;
+ }
+
+ public void setOperationalTemplate(OPERATIONALTEMPLATE operationaltemplate) {
+ this.operationaltemplate = operationaltemplate;
+ }
+
+ public OffsetDateTime getCreatedOn() {
+ return createdOn;
+ }
+
+ public void setCreatedOn(OffsetDateTime createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public void setInternalId(UUID internalId) {
+ this.internalId = internalId;
+ }
+
+ public UUID getInternalId() {
+ return internalId;
+ }
+
+ public List getErrorList() {
+ if (this.errorList == null) {
+ this.errorList = new ArrayList<>();
+ }
+ return errorList;
+ }
+
+ public void addError(String error) {
+ if (this.errorList == null) {
+ this.errorList = new ArrayList<>();
+ }
+ this.errorList.add(error);
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/mapper/StructuredStringJSonSerializer.java b/api/src/main/java/org/ehrbase/api/mapper/StructuredStringJSonSerializer.java
index b258e96523..22a88f39ad 100644
--- a/api/src/main/java/org/ehrbase/api/mapper/StructuredStringJSonSerializer.java
+++ b/api/src/main/java/org/ehrbase/api/mapper/StructuredStringJSonSerializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Stefan Spiska (Vitasystems GmbH) and Hannover Medical School.
+ * Copyright (c) 2024 vitasystems GmbH.
*
* This file is part of project EHRbase
*
@@ -7,7 +7,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -15,17 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.ehrbase.api.mapper;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
-import org.ehrbase.api.exception.UnexpectedSwitchCaseException;
-import org.ehrbase.response.ehrscape.StructuredString;
-
import java.io.IOException;
+import org.ehrbase.api.exception.UnexpectedSwitchCaseException;
+import org.ehrbase.openehr.sdk.response.dto.ehrscape.StructuredString;
public class StructuredStringJSonSerializer extends JsonSerializer {
@Override
@@ -55,5 +53,3 @@ public void serialize(StructuredString value, JsonGenerator jgen, SerializerProv
}
}
}
-
-
diff --git a/api/src/main/java/org/ehrbase/api/repository/KeyValuePair.java b/api/src/main/java/org/ehrbase/api/repository/KeyValuePair.java
new file mode 100644
index 0000000000..58e21db89e
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/repository/KeyValuePair.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.repository;
+
+import java.util.UUID;
+
+public interface KeyValuePair {
+
+ public static KeyValuePair of(String pluginId, String key, String value) {
+ return KeyValuePair.of(UUID.randomUUID(), pluginId, key, value);
+ }
+
+ public static KeyValuePair of(UUID id, String pluginId, String key, String value) {
+ return new KeyValueEntry(id, pluginId, key, value);
+ }
+
+ public UUID getId();
+
+ public String getContext();
+
+ public String getKey();
+
+ public String getValue();
+}
+
+class KeyValueEntry implements KeyValuePair {
+
+ private final UUID id;
+ private final String context;
+ private final String key;
+ private final String value;
+
+ KeyValueEntry(UUID id, String pluginId, String key, String value) {
+ this.id = id;
+ this.context = pluginId;
+ this.key = key;
+ this.value = value;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/api/src/main/java/org/ehrbase/api/repository/KeyValuePairRepository.java b/api/src/main/java/org/ehrbase/api/repository/KeyValuePairRepository.java
new file mode 100644
index 0000000000..e654330f01
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/repository/KeyValuePairRepository.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.repository;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+public interface KeyValuePairRepository {
+
+ public List findAllBy(String context);
+
+ public Optional findBy(String context, String key);
+
+ public Optional findBy(UUID uid);
+
+ public KeyValuePair save(KeyValuePair kve);
+
+ public boolean deleteBy(UUID uid);
+}
diff --git a/api/src/main/java/org/ehrbase/api/rest/EHRbaseHeader.java b/api/src/main/java/org/ehrbase/api/rest/EHRbaseHeader.java
new file mode 100644
index 0000000000..afcef5a77a
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/rest/EHRbaseHeader.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.rest;
+
+/**
+ * EHRbase specific HTTP headers that are not part of the openEHR standard.
+ */
+public final class EHRbaseHeader {
+
+ private EHRbaseHeader() {}
+
+ public static final String TEMPLATE_ID = "EHRBase-Template-ID";
+
+ /**
+ * Used by the /query endpoint to perform only a dry run query.
+ */
+ public static final String AQL_DRY_RUN = "EHRbase-AQL-Dry-Run";
+
+ /**
+ * Used by the /query endpoint to provide the executed SQL statement in the return metadata.
+ */
+ public static final String AQL_EXECUTED_SQL = "EHRbase-AQL-Executed-SQL";
+
+ /**
+ * Used by the /query endpoint to provide the database query plan in the return metadata.
+ */
+ public static final String AQL_QUERY_PLAN = "EHRbase-AQL-Query-Plan";
+
+ /**
+ * In AQL queries with paths containing consecutive node predicates: Skip nodes implied by the archetype definitions
+ */
+ public static final String AQL_PATH_SKIPPING = "EHRbase-AQL-Path-Skipping";
+
+ /**
+ * In AQL queries CONTAINS expressions with a node predicate: Exclude results from nested archetypes
+ */
+ public static final String AQL_ARCHETYPE_LOCAL_NODE_PREDICATES = "EHRbase-AQL-Archetype-Local-Node-Predicates";
+}
diff --git a/api/src/main/java/org/ehrbase/api/rest/HttpRestContext.java b/api/src/main/java/org/ehrbase/api/rest/HttpRestContext.java
new file mode 100644
index 0000000000..da0311a1ad
--- /dev/null
+++ b/api/src/main/java/org/ehrbase/api/rest/HttpRestContext.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2024 vitasystems GmbH.
+ *
+ * This file is part of project EHRbase
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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.
+ */
+package org.ehrbase.api.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+public class HttpRestContext {
+
+ public interface HttpCtx {
+ T get(CtxAttr attr);
+ }
+
+ public static final class CtxAttr {}
+
+ public static final CtxAttr QUERY = new CtxAttr<>();
+ public static final CtxAttr QUERY_ID = new CtxAttr<>();
+ public static final CtxAttr LOCATION = new CtxAttr<>();
+ public static final CtxAttr VERSION = new CtxAttr<>();
+ public static final CtxAttr EHR_ID = new CtxAttr<>();
+ public static final CtxAttr TEMPLATE_ID = new CtxAttr<>();
+ public static final CtxAttr COMPOSITION_ID = new CtxAttr<>();
+ public static final CtxAttr DIRECTORY_ID = new CtxAttr<>();
+ public static final CtxAttr CONTRIBUTION_ID = new CtxAttr<>();
+ public static final CtxAttr> REMOVED_PATIENTS = new CtxAttr<>();
+ public static final CtxAttr QUERY_EXECUTE_ENDPOINT = new CtxAttr<>();
+
+ private static final ThreadLocal