Skip to content

Commit

Permalink
Merge pull request medizininformatik-initiative#272 from medizininfor…
Browse files Browse the repository at this point in the history
…matik-initiative/release/v5.0.0-alpha.1

Release v5.0.0 alpha.1
  • Loading branch information
michael-82 authored Apr 3, 2024
2 parents 7487cbc + 21d9d3a commit d96691a
Show file tree
Hide file tree
Showing 35 changed files with 1,147 additions and 408 deletions.
2 changes: 1 addition & 1 deletion .github/integration-test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ services:
- "blaze-data:/app/data"

flare:
image: ghcr.io/medizininformatik-initiative/flare:2.0.0-rc2
image: ghcr.io/medizininformatik-initiative/flare:2.1.1
ports:
- "8092:8080"
environment:
Expand Down
52 changes: 27 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Cache Local Maven Repo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: tests-maven-${{ hashFiles('pom.xml') }}

- uses: s4u/maven-settings-action@v2.8.0
- uses: s4u/maven-settings-action@v3.0.0
with:
servers: |
[{"id": "mii", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}]
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: java
queries: security-and-quality
Expand All @@ -44,53 +44,55 @@ jobs:
run: mvn -Pdownload-ontology -B verify

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3

- name: Upload Feasibility Backend Jar
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: backend-jar
path: target/feasibilityBackend.jar

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and Export to Docker
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
tags: backend:latest
outputs: type=docker,dest=/tmp/feasibilityBackend.tar

- name: Upload Feasibility Backend Image
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: backend-image
path: /tmp/feasibilityBackend.tar

security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Cache Local Maven Repo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: security-scan-maven-${{ hashFiles('pom.xml') }}

- uses: s4u/maven-settings-action@v2.8.0
- uses: s4u/maven-settings-action@v3.0.0
with:
servers: |
[{"id": "mii", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}]
Expand All @@ -99,7 +101,7 @@ jobs:
run: mvn -Pdownload-ontology -B -DskipTests package

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
tags: security-scan-build:latest
Expand All @@ -115,7 +117,7 @@ jobs:
timeout: '15m0s'

- name: Upload Trivy Scan Results to GitHub Security Tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif

Expand All @@ -125,10 +127,10 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download Feasibility Backend Image
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: backend-image
path: /tmp
Expand Down Expand Up @@ -181,21 +183,21 @@ jobs:
- security-scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Cache Local Maven Repo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: release-maven-${{ hashFiles('pom.xml') }}

- uses: s4u/maven-settings-action@v2.8.0
- uses: s4u/maven-settings-action@v3.0.0
with:
servers: |
[{"id": "mii", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}]
Expand All @@ -220,10 +222,10 @@ jobs:
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [5.0.0-alpha.1] - 2024-04-03

### Added
- Added an endpoint to validate uploaded structured queries. ([#258](https://github.com/medizininformatik-initiative/feasibility-backend/issues/258))
### Changed
- Validation for structured queries has been reworked. ([#260](https://github.com/medizininformatik-initiative/feasibility-backend/issues/260)), ([#266](https://github.com/medizininformatik-initiative/feasibility-backend/issues/266))
### Deprecated
### Removed
### Fixed
### Security
- Updated spring boot to 3.2.4 ([#262](https://github.com/medizininformatik-initiative/feasibility-backend/issues/262))

The full changelog can be found [here](https://github.com/medizininformatik-initiative/feasibility-backend/milestone/9?closed=1).

## [4.3.0] - 2024-02-02

### Added
Expand Down
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<version>3.2.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>de.medizininformatik-initiative</groupId>
<artifactId>FeasibilityGuiBackend</artifactId>
<version>4.3.0</version>
<version>5.0.0-alpha.1</version>

<name>FeasibilityGuiBackend</name>
<description>Backend of the Feasibility GUI</description>
Expand Down Expand Up @@ -236,7 +236,15 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.17.6</version>
<version>1.19.7</version>
<scope>test</scope>
</dependency>

<!-- Remove when testcontainers uses a version > 1.24 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.1</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.numcodex.feasibility_gui_backend.query.api.AttributeFilter;
import de.numcodex.feasibility_gui_backend.query.api.TimeRestriction;
import de.numcodex.feasibility_gui_backend.query.api.ValueFilter;
import de.numcodex.feasibility_gui_backend.query.api.status.ValidationIssue;
import lombok.Builder;

import java.util.List;
Expand All @@ -17,7 +18,17 @@ public record Criterion (
@JsonProperty("termCodes") List<TermCode> termCodes,
@JsonProperty("attributeFilters") List<AttributeFilter> attributeFilters,
@JsonProperty("valueFilter") ValueFilter valueFilter,
@JsonProperty("timeRestriction") TimeRestriction timeRestriction
@JsonProperty("timeRestriction") TimeRestriction timeRestriction,
@JsonProperty("issues") List<ValidationIssue> validationIssues
) {

public static Criterion createImmutableCriterion(MutableCriterion mutableCriterion) {
return Criterion.builder()
.termCodes(mutableCriterion.termCodes)
.context(mutableCriterion.context)
.attributeFilters(mutableCriterion.attributeFilters)
.valueFilter(mutableCriterion.valueFilter)
.timeRestriction(mutableCriterion.timeRestriction)
.validationIssues(mutableCriterion.validationIssues)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.numcodex.feasibility_gui_backend.common.api;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.numcodex.feasibility_gui_backend.query.api.AttributeFilter;
import de.numcodex.feasibility_gui_backend.query.api.TimeRestriction;
import de.numcodex.feasibility_gui_backend.query.api.ValueFilter;
import de.numcodex.feasibility_gui_backend.query.api.status.ValidationIssue;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@JsonInclude(Include.NON_NULL)
@Builder
@Data
public class MutableCriterion {
@JsonProperty("context") TermCode context;
@JsonProperty("termCodes") List<TermCode> termCodes;
@JsonProperty("attributeFilters") List<AttributeFilter> attributeFilters;
@JsonProperty("valueFilter") ValueFilter valueFilter;
@JsonProperty("timeRestriction") TimeRestriction timeRestriction;
@JsonProperty("issues") List<ValidationIssue> validationIssues;

public static MutableCriterion createMutableCriterion (Criterion criterion) {
return MutableCriterion.builder()
.termCodes(criterion.termCodes())
.context(criterion.context())
.attributeFilters(criterion.attributeFilters())
.valueFilter(criterion.valueFilter())
.timeRestriction(criterion.timeRestriction())
.validationIssues(criterion.validationIssues())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.numcodex.feasibility_gui_backend.query.result.ResultService;
import de.numcodex.feasibility_gui_backend.query.templates.QueryTemplateException;
import de.numcodex.feasibility_gui_backend.query.templates.QueryTemplateHandler;
import de.numcodex.feasibility_gui_backend.terminology.validation.StructuredQueryValidation;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException;
Expand Down Expand Up @@ -58,6 +59,9 @@ public enum ResultDetail {
@NonNull
private final SavedQueryRepository savedQueryRepository;

@NonNull
private final StructuredQueryValidation structuredQueryValidation;

@NonNull
private ObjectMapper jsonUtil;

Expand Down Expand Up @@ -235,28 +239,61 @@ public String getAuthorId(Long queryId) throws QueryNotFoundException {
return queryRepository.getAuthor(queryId).orElseThrow(QueryNotFoundException::new);
}

public List<QueryListEntry> convertQueriesToQueryListEntries(List<de.numcodex.feasibility_gui_backend.query.persistence.Query> queryList) {
var ret = new ArrayList<QueryListEntry>();
public QueryListEntry convertQueryToQueryListEntry(de.numcodex.feasibility_gui_backend.query.persistence.Query query,
boolean skipValidation) {
boolean isValid = true;
if (!skipValidation) {
try {
var sq = jsonUtil.readValue(query.getQueryContent().getQueryContent(), StructuredQuery.class);
isValid = structuredQueryValidation.isValid(sq);
} catch (JsonProcessingException e) {
isValid = false;
}
}

queryList.forEach(q -> {
if (q.getSavedQuery() != null) {
ret.add(
QueryListEntry.builder()
.id(q.getId())
.label(q.getSavedQuery().getLabel())
.comment(q.getSavedQuery().getComment())
.totalNumberOfPatients(q.getSavedQuery().getResultSize())
.createdAt(q.getCreatedAt())
.build());
if (query.getSavedQuery() != null) {
if (skipValidation) {
return
QueryListEntry.builder()
.id(query.getId())
.label(query.getSavedQuery().getLabel())
.comment(query.getSavedQuery().getComment())
.totalNumberOfPatients(query.getSavedQuery().getResultSize())
.createdAt(query.getCreatedAt())
.build();
} else {
ret.add(
QueryListEntry.builder()
.id(q.getId())
.createdAt(q.getCreatedAt())
.build());
return
QueryListEntry.builder()
.id(query.getId())
.label(query.getSavedQuery().getLabel())
.comment(query.getSavedQuery().getComment())
.totalNumberOfPatients(query.getSavedQuery().getResultSize())
.createdAt(query.getCreatedAt())
.isValid(isValid)
.build();
}
});
} else {
if (skipValidation) {
return
QueryListEntry.builder()
.id(query.getId())
.createdAt(query.getCreatedAt())
.build();
} else {
return
QueryListEntry.builder()
.id(query.getId())
.createdAt(query.getCreatedAt())
.isValid(isValid)
.build();
}
}
}

public List<QueryListEntry> convertQueriesToQueryListEntries(List<de.numcodex.feasibility_gui_backend.query.persistence.Query> queryList,
boolean skipValidation) {
var ret = new ArrayList<QueryListEntry>();
queryList.forEach(q -> ret.add(convertQueryToQueryListEntry(q, skipValidation)));
return ret;
}

Expand Down
Loading

0 comments on commit d96691a

Please sign in to comment.