Skip to content

Commit c3ab1c9

Browse files
authored
Merge pull request #7 from maximilianiKIT/5-plugin-functionality
5 plugin functionality
2 parents 8b04b90 + 5229d3a commit c3ab1c9

File tree

72 files changed

+5765
-4217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+5765
-4217
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Java CI
77

88
on:
99
push:
10-
branches: [ main ]
10+
branches: [ main , dev]
1111
pull_request:
1212
branches: "*"
1313

@@ -28,13 +28,11 @@ jobs:
2828
run: sudo apt install -y python3 python3-setuptools python3-pip
2929
- name: Update pip
3030
run: pip3 install --upgrade pip
31-
- name: Install libraries via pip (xmltodict and wget)
32-
run: pip3 install xmltodict wget
3331
- name: Grant execute permission for gradlew
3432
run: chmod +x gradlew
3533
- name: Build with Gradle
3634
run: ./gradlew clean check jacocoTestReport
3735
- name: Codecov
3836
uses: codecov/codecov-action@v1
3937
with:
40-
files: ./build/reports/jacoco/test/jacocoTestReport.xml #optional
38+
files: ./build/reports/jacoco/test/jacocoTestReport.xml

.github/workflows/codeql-analysis.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
branches: [ "main", "dev" ]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ "main", "dev" ]
19+
branches: "*"
2020
schedule:
2121
- cron: '42 9 * * 4'
2222

@@ -40,11 +40,17 @@ jobs:
4040
- name: Checkout repository
4141
uses: actions/checkout@v3
4242

43+
- name: Set up OpenJDK
44+
uses: actions/setup-java@v1
45+
with:
46+
java-version: ${{ matrix.jdk }}
47+
4348
# Initializes the CodeQL tools for scanning.
4449
- name: Initialize CodeQL
4550
uses: github/codeql-action/init@v2
4651
with:
4752
languages: ${{ matrix.language }}
53+
java-version: 17
4854
# If you wish to specify custom queries, you can do so here or in a config file.
4955
# By default, queries listed here will override any specified in a config file.
5056
# Prefix the list here with "+" to use these queries and those in the config file.
@@ -57,16 +63,18 @@ jobs:
5763
# If this step fails, then you should remove it and run the build manually (see below)
5864
- name: Autobuild
5965
uses: github/codeql-action/autobuild@v2
66+
with:
67+
java-version: 17
6068

61-
# ℹ️ Command-line programs to run using the OS shell.
69+
# ℹ️ Command-line programs to run using the OS shell.
6270
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6371

6472
# If the Autobuild fails above, remove it and uncomment the following three lines.
6573
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
6674

67-
# - run: |
68-
# echo "Run, Build Application using script"
69-
# ./location_of_script_within_repo/buildscript.sh
75+
# # - run: |
76+
# echo "Run, Build Application using script"
77+
# ./location_of_script_within_repo/buildscript.sh
7078

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

.github/workflows/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,6 @@ gradle-app.setting
234234
# JDT-specific (Eclipse Java Development Tools)
235235
.classpath
236236

237-
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,java,macos,gradle,linux
237+
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,java,macos,gradle,linux
238+
lib/gemma
239+
!/plugins/gemma-plugin-0.1.0.jar

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
:warning:
88
Not fully tested yet!
9-
For mapping documents only Gemma is available currently!
109

1110
The mapping service allows multiple schemas to be uploaded and managed and documents to be mapped over one of them at a time accordingly.
1211
Therefore, the service is extensible to other mappers, although currently only Gemma, a service that can only map JSON files, is available.
@@ -17,28 +16,24 @@ The REST API is documented at the following link: [http://localhost:8095/swagger
1716
Dependencies that are needed to build and are not being downloaded via gradle:
1817

1918
- OpenJDK 17
19+
- Python 3
2020

2121
`./gradlew -Pclean-release build`
2222

2323
## How to start
2424

25-
> TODO This section is a placeholder. It still needs to be written properly.
25+
`./gradlew bootRun`
2626

2727
### Prerequisites
28-
29-
You might want to take a look at testbed4inf, which should make it easy to satisfy those.
30-
31-
- Gemma
32-
- Python
33-
34-
### Install Python and Gemma
35-
```
36-
sudo apt install -y python3 python3-pip
37-
pip3 install xmltodict wget
38-
```
39-
40-
41-
## More information
28+
Please make sure the application.properties file is configured correctly.
29+
Espacially the following properties (at the end of the file) are important:
30+
- `mapping-service.pythonLocation=file:///opt/homebrew/bin/python3` \
31+
Enter the loacation of your python3 installation. You can determine it by typing `which python3` in your terminal.
32+
- `mapping-service.mappingsLocation:file:///tmp/mapping-service/` \
33+
Enter the location where you want to store your mappings. This folder will be created if it does not exist yet.
34+
35+
You might want to add a plugin to make the service working. Normally, there should be a gemma-plugin-x.x.x.jar in the plugins folder.
36+
If not, you can find its source code [here](https://github.com/maximilianiKIT/gemma-plugin).
4237

4338
## License
4439

build.gradle

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ plugins {
1010

1111
description = 'Generic mapping service supporting different mapping implementations.'
1212
group = 'edu.kit.datamanager'
13-
version = '1.0.0'
1413

14+
println "Running gradle version: $gradle.gradleVersion"
1515
println "Building ${name} version: ${version}"
16+
println "JDK version: ${JavaVersion.current()}"
17+
1618

1719
configurations {
1820
asciidoctorExt
@@ -31,43 +33,45 @@ ext {
3133
}
3234

3335
dependencies {
34-
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.5'
35-
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.5'
36-
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.5'
37-
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.5'
38-
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.6.6'
39-
implementation 'org.springdoc:springdoc-openapi-ui:1.6.6'
40-
implementation 'org.springdoc:springdoc-openapi-data-rest:1.6.6'
41-
implementation 'org.springdoc:springdoc-openapi-webmvc-core:1.6.6'
42-
implementation 'org.javers:javers-spring-boot-starter-sql:6.6.3'
36+
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r'
37+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.3'
38+
implementation 'org.springframework.boot:spring-boot-starter-security:2.7.3'
39+
implementation 'org.springframework.boot:spring-boot-starter-validation:2.7.3'
40+
implementation 'org.springframework.boot:spring-boot-starter-web:2.7.3'
41+
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.7.3'
42+
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
43+
implementation 'org.springdoc:springdoc-openapi-data-rest:1.6.11'
44+
implementation 'org.springdoc:springdoc-openapi-webmvc-core:1.6.11'
45+
implementation 'org.javers:javers-spring-boot-starter-sql:6.6.5'
4346
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
4447
implementation 'org.apache.commons:commons-collections4:4.4'
4548
implementation 'org.json:json:20220320'
4649
implementation 'com.github.jknack:handlebars:4.3.0'
4750
implementation 'com.google.guava:guava:31.1-jre'
4851
implementation 'commons-io:commons-io:2.11.0'
4952
implementation 'javax.validation:validation-api:2.0.1.Final'
50-
implementation 'edu.kit.datamanager:service-base:1.0.1'
53+
implementation 'edu.kit.datamanager:service-base:1.0.4'
5154

52-
testImplementation(platform('org.junit:junit-bom:5.8.2'))
53-
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
54-
testImplementation 'org.junit.jupiter:junit-jupiter-migrationsupport:5.8.2'
55-
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.5'
55+
testImplementation platform('org.junit:junit-bom:5.9.0')
56+
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
57+
testImplementation 'org.junit.jupiter:junit-jupiter-migrationsupport:5.9.0'
58+
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.3'
5659
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc:2.0.6.RELEASE'
57-
testImplementation 'org.springframework.security:spring-security-test:5.6.2'
58-
testImplementation 'org.springframework:spring-test:5.3.17'
59-
testImplementation 'org.mockito:mockito-core:4.3.1'
60+
testImplementation 'org.springframework.security:spring-security-test:5.7.3'
61+
testImplementation 'org.springframework:spring-test:5.3.22'
62+
testImplementation 'org.mockito:mockito-core:4.8.0'
6063
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
6164
testImplementation 'org.powermock:powermock-api-mockito2:2.0.9'
62-
testImplementation 'org.junit.vintage:junit-vintage-engine:5.8.2'
65+
testImplementation 'net.bytebuddy:byte-buddy:1.12.16'
66+
testImplementation 'org.junit.vintage:junit-vintage-engine:5.9.0'
6367

64-
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:2.6.5'
65-
annotationProcessor 'org.projectlombok:lombok:1.18.22'
68+
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:2.7.3'
69+
annotationProcessor 'org.projectlombok:lombok:1.18.24'
6670

67-
compileOnly 'org.projectlombok:lombok:1.18.22'
71+
compileOnly 'org.projectlombok:lombok:1.18.24'
6872

69-
runtimeOnly 'com.h2database:h2:2.1.210'
70-
runtimeOnly 'org.postgresql:postgresql:42.3.3'
73+
runtimeOnly 'com.h2database:h2:2.1.214'
74+
runtimeOnly 'org.postgresql:postgresql:42.5.0'
7175
runtimeOnly 'org.apache.httpcomponents:httpclient:4.5.13'
7276

7377
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor:2.0.6.RELEASE'
@@ -97,9 +101,20 @@ asciidoctor {
97101
dependsOn test
98102
}
99103

104+
jar {
105+
manifest {
106+
attributes 'Main-Class': 'edu.kit.datamanager.mapping-service.MappingServiceApplication'
107+
}
108+
}
109+
100110
bootJar {
101111
dependsOn asciidoctor
102112
from ("${asciidoctor.outputDir}/html5") {
103113
into 'static/docs'
104114
}
115+
launchScript()
116+
}
117+
118+
release {
119+
tagTemplate = 'v${version}'
105120
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ distributionPath=wrapper/dists
33
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
7+
version=1.0.1-SNAPSHOT
Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,23 @@
11
package edu.kit.datamanager.mappingservice;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import com.fasterxml.jackson.databind.SerializationFeature;
6-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
73
import edu.kit.datamanager.mappingservice.configuration.ApplicationProperties;
4+
import edu.kit.datamanager.mappingservice.plugins.PluginManager;
5+
import edu.kit.datamanager.mappingservice.util.PythonRunnerUtil;
86
import org.slf4j.Logger;
97
import org.slf4j.LoggerFactory;
10-
import org.springframework.beans.factory.InjectionPoint;
118
import org.springframework.boot.SpringApplication;
129
import org.springframework.boot.autoconfigure.SpringBootApplication;
1310
import org.springframework.boot.autoconfigure.domain.EntityScan;
1411
import org.springframework.boot.context.properties.ConfigurationProperties;
1512
import org.springframework.context.annotation.Bean;
16-
import org.springframework.context.annotation.ComponentScan;
17-
import org.springframework.context.annotation.Scope;
18-
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
19-
import org.springframework.scheduling.annotation.EnableScheduling;
13+
import org.springframework.context.annotation.Configuration;
2014

2115
@SpringBootApplication
22-
@EnableScheduling
23-
@ComponentScan({"edu.kit.datamanager.mappingservice", "edu.kit.datamanager.configuration"})
2416
@EntityScan("edu.kit.datamanager")
17+
@Configuration
2518
public class MappingServiceApplication {
2619

27-
@Bean
28-
@Scope("prototype")
29-
public Logger logger(InjectionPoint injectionPoint) {
30-
Class<?> targetClass = injectionPoint.getMember().getDeclaringClass();
31-
return LoggerFactory.getLogger(targetClass.getCanonicalName());
32-
}
33-
34-
@Bean(name = "OBJECT_MAPPER_BEAN")
35-
public ObjectMapper jsonObjectMapper() {
36-
return Jackson2ObjectMapperBuilder.json()
37-
.serializationInclusion(JsonInclude.Include.NON_EMPTY) // Don’t include null values
38-
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) //ISODate
39-
.modules(new JavaTimeModule())
40-
.build();
41-
}
20+
private static final Logger LOG = LoggerFactory.getLogger(MappingServiceApplication.class);
4221

4322
@Bean
4423
@ConfigurationProperties("repo")
@@ -48,6 +27,10 @@ public ApplicationProperties applicationProperties() {
4827

4928
public static void main(String[] args) {
5029
SpringApplication.run(MappingServiceApplication.class, args);
51-
System.out.println("Mapping service is running!");
30+
31+
PluginManager.soleInstance().getListOfAvailableValidators().forEach((value) -> LOG.info("Found validator: " + value));
32+
PythonRunnerUtil.printPythonVersion();
33+
34+
System.out.println("Mapping service is running! Access it at http://localhost:8095");
5235
}
5336
}

src/main/java/edu/kit/datamanager/mappingservice/configuration/ApplicationProperties.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 Karlsruhe Institute of Technology.
2+
* Copyright 2022 Karlsruhe Institute of Technology.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,10 @@
2626
import java.net.URL;
2727

2828
/**
29+
* This class is used to configure the application.
30+
* It reads the values from the application.properties file.
2931
*
32+
* @author maximilianiKIT
3033
*/
3134
@ConfigurationProperties(prefix = "mapping-service")
3235
@Component
@@ -38,20 +41,13 @@ public class ApplicationProperties extends GenericPluginProperties {
3841
* The absolute path to the python interpreter.
3942
*/
4043
@edu.kit.datamanager.annotations.ExecutableFileURL
41-
@Value("${mapping-service.gemma.pythonLocation}")
44+
@Value("${mapping-service.pythonLocation}")
4245
private URL pythonLocation;
4346

44-
/**
45-
* The path to the gemma mapping script 'mapping_single.py'
46-
*/
47-
@edu.kit.datamanager.annotations.LocalFileURL
48-
@Value("${mapping-service.gemma.gemmaLocation}")
49-
private URL gemmaLocation;
50-
5147
/**
5248
* The absolute path where the mappings are stored.
5349
*/
5450
@edu.kit.datamanager.annotations.LocalFolderURL
55-
@Value("${mapping-service.mappingsLocation}")
51+
@Value("${mapping-service.mappingSchemasLocation}")
5652
private URL mappingsLocation;
5753
}

src/main/java/edu/kit/datamanager/mappingservice/configuration/JPAPersistenceConfig.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)