Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HolgerReiseVSys committed May 7, 2024
1 parent 5c37c3b commit 61bab85
Show file tree
Hide file tree
Showing 451 changed files with 84,312 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
73 changes: 73 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and push

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '21' ]

steps:
# Install the migration tool in the local repo
- name: Checkout Migration Tool
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ehrbase/migration-tool
ref: develop
# This will be used by git in all further steps
# We need a PERSONAL ACCESS TOKEN so pushes trigger other github actions
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Install Migration Tool
run: mvn install

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to GitLab
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Spotless
run: mvn spotless:check
- name: install migration tool main
run: mvn install -Dmaven.test.skip=true


- name: Build with Maven
run: mvn clean verify spring-boot:build-image

- name: Build and push
if: ${{ github.ref == 'ref/head/develop' }} || ${{ github.ref == 'ref/head/master' }} || ${{ github.ref == 'ref/head/main' }}
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
docker push ehrbase/migration-tool:${VERSION}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 vitasystems GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
208 changes: 208 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/>
</parent>

<groupId>org.ehrbase.migration</groupId>
<artifactId>migration-application</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>EHRbase Migration Tool Application</name>

<properties>
<image.name>dockerhub.io/ehrbase/migration-tool</image.name>
<image.tag>${project.version}</image.tag>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.ehrbase.migration</groupId>
<artifactId>migration-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>

<dependency>
<groupId>org.ehrbase.migration</groupId>
<artifactId>migration-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>
</dependencies>

<build>
<finalName>migration-tool</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<toggleOffOn>
<off>@format:off</off>
<on>@format:on</on>
</toggleOffOn>
<palantirJavaFormat>
<version>2.40.0</version>
</palantirJavaFormat>
<licenseHeader>
<file>../spotless-lic-header</file>
</licenseHeader>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.ehrbase.migration.application.MigrationTool</mainClass>
<image>
<name>${image.name}:${image.tag}</name>
<env>
<BP_DEBUG_ENABLED>true</BP_DEBUG_ENABLED>
</env>
</image>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<!-- SET ARG LINE PROPERTY FOR SUREFIRE -->
<execution>
<id>agent for unit tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!-- SET ARG LINE PROPERTY FOR FAILSAFE -->
<execution>
<id>agent for integration tests</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- SETS THE VM ARGUMENT LINE USED WHEN UNIT TESTS ARE RUN. -->
<argLine>@{surefireArgLine}</argLine>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<phase>verify</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- SETS THE VM ARGUMENT LINE USED WHEN INTEGRATION TESTS ARE RUN. -->
<argLine>@{failsafeArgLine}</argLine>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2023 vitasystems GmbH
*
* This file is part of project EHRbase Migration Tool
*
* 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.migration.application;

import org.ehrbase.migration.service.ProcessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication(scanBasePackages = "org.ehrbase.migration")
public class MigrationTool implements CommandLineRunner {

public enum MigrationMode {
DB2DB,
IMPORT,
EXPORT,
NONE
}

@Value("${mode}")
private MigrationMode mode;

@Value("${terminate:true}")
private boolean terminate;

private static Logger LOG = LoggerFactory.getLogger(MigrationTool.class);

private final ConfigurableApplicationContext context;

private final ProcessService processService;

public MigrationTool(ProcessService processService, ConfigurableApplicationContext context) {
this.processService = processService;
this.context = context;
}

public static void main(String[] args) {
LOG.info("STARTING THE APPLICATION");
new SpringApplicationBuilder(MigrationTool.class)
.web(WebApplicationType.NONE)
.run(args);
}

@Override
public void run(String... args) {

switch (mode) {
case DB2DB -> processService.db2db();
case IMPORT -> processService.importFromFile();
case EXPORT -> processService.exportToFile();
case NONE -> LOG.info("Migration mode NONE: Skipping");
}
if (terminate) {
LOG.debug("Shutting down");
int exitCode = SpringApplication.exit(context);
LOG.info("APPLICATION FINISHED");
System.exit(exitCode);
}
}
}
Loading

0 comments on commit 61bab85

Please sign in to comment.