Skip to content

Commit f970b62

Browse files
authored
Merge pull request #21 from kit-data-manager/development
PR for next release
2 parents accd683 + 427b572 commit f970b62

Some content is hidden

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

45 files changed

+1480
-639
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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: "gradle" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
target-branch: "dev"
11+
schedule:
12+
interval: "weekly"

.github/issue-branch.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Automatically close issue after a pull request merge
2+
autoCloseIssue: true
3+
4+
# Override the source branch
5+
defaultBranch: 'development'
6+
7+
#Skip branch creation based on issue label 'question'
8+
branches:
9+
- label: question
10+
skip: true
11+
12+
# Automatically open a Pull Request
13+
openPR: true
14+
15+
# Copy attributes from issue
16+
copyIssueDescriptionToPR: true
17+
copyIssueLabelsToPR: true
18+
copyIssueAssigneeToPR: true
19+
copyIssueMilestoneToPR: true

.github/workflows/branch_on_issue.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Branch on Issue
2+
3+
on:
4+
issues:
5+
types: [ assigned ]
6+
pull_request:
7+
types: [ closed ]
8+
9+
jobs:
10+
create_issue_branch_job:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Create Issue Branch
14+
uses: robvanderleek/create-issue-branch@main
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
#!gradle/wrapper/gradle-wrapper.jar
55
#!**/src/main/**/build/
66
#!**/src/test/**/build/
7+
lib/
78
#
89
#### Spring boot ###
9-
#**/application.properties
10+
**/application.properties
1011
#
1112
#### Gemma/python ###
1213
#/gemma
1314
#**/__pycache__
15+
**/output
1416
#
1517
#### STS ###
1618
#.apt_generated
@@ -129,6 +131,7 @@ fabric.properties
129131
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
130132

131133
.idea/
134+
.fleet
132135

133136
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
134137

README.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,61 @@ Dependencies that are needed to build and are not being downloaded via gradle:
2121

2222
- OpenJDK 17
2323
- Python 3
24+
- pip (runtime only)
2425

2526
`./gradlew -Pclean-release build`
2627

27-
## How to start
28+
### Python Location
29+
30+
Currently, mapping-service requires Python to be installed in order to build and to run. At runtime, the Python executable is configured in
31+
`application.properties`(see below). For building the mapping-service Python executable is set to `/usr/bin/python3` by default. In case you want to build
32+
the mapping-service on a machine on which the Python installation is located elsewhere, e.g., under Windows, you can provide the Python location
33+
used at compile time externally, i.e.:
2834

29-
`./gradlew bootRun`
35+
```
36+
.\gradlew -Pclean-release "-DpythonExecutable=file:///C:/Python310/python.exe" build
37+
```
38+
39+
## How to start
3040

31-
### Prerequisites
32-
Please make sure the application.properties file is configured correctly.
33-
Espacially the following properties (at the end of the file) are important:
34-
- `mapping-service.pythonLocation=file:///opt/homebrew/bin/python3` \
35-
Enter the loacation of your python3 installation. You can determine it by typing `which python3` in your terminal.
41+
Before you can start the mapping-service, you first have to create an `application.properties` file in the source folder. As an example you may use `config/application.default.properties`
42+
and modify it according to your needs. Espacially the following properties (at the end of the file) are important:
43+
- `spring.datasource.url=jdbc:h2:file:/tmp/mapping-service/database`
44+
The path points to the location of the database in which your configured mappings are stored.
45+
- `mapping-service.pythonExecutable=${pythonExecutable:'file:///usr/bin/python3'}` \
46+
If no pythonExecutable is provided externally (see above) the default `/usr/bin/python3` is used.
47+
- `mapping-service.pluginLocation=file:///tmp/mapping-service/plugins` \
48+
The local folder where available plugins are located.
3649
- `mapping-service.mappingsLocation:file:///tmp/mapping-service/` \
3750
Enter the location where you want to store your mappings. This folder will be created if it does not exist yet.
3851

39-
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.
40-
If not, you can find its source code [here](https://github.com/maximilianiKIT/gemma-plugin).
52+
In order to provide the mapping-service with mapping functionality, there are already some pre-compiled plugins available under in the `plugins` folder of this repository.
53+
Copy them to your configured `mapping-service.pluginLocation` to make them available to the mapping-service.
54+
The source code of the gemma-plugin can be found [here](https://github.com/maximilianiKIT/gemma-plugin). The plugin shows how to integrate Python mappings easily.
55+
56+
There is also the possibility to add new plugins directly at the source tree and create a pluggable Jar out of them. Therefor, check
57+
`src/main/java/edu/kit/datamanager/mappingservice/plugins/impl`. Just add your new plugin, e.g., based on the `TestPlugin` example.
58+
In order to make the plugin usable by the mapping service, you then have to build a plugin Jar out of it. In order to do that, just call:
59+
60+
```
61+
./gradlew buildPluginJar
62+
```
63+
64+
This task creates a file `default-plugins-<VERSION>` at `build/libs` which has to be copied to `mapping-service.pluginLocation` to make it available.
65+
66+
After doing this, the mapping-service is ready for the first start. This can be achieved by executing:
67+
68+
`java -jar build/lib/mapping-service-<VERSION>.jar`
69+
70+
This assumes, that the command is called from the source folder and that your `application.properties` is located in the same folder.
71+
Otherwise, you may use:
72+
73+
`java -jar build/lib/mapping-service-<VERSION>.jar --spring.config.location=/tmp/application.properties`
74+
75+
Ideally, for production use, you place everything (`mapping-service-<VERSION>.jar`, `application.properties`, `mapping-service.pluginLocation`, `mapping-service.mappingsLocation`,
76+
and `spring.datasource.url`) in a separate folder from where you then call the mapping-service via:
77+
78+
`java -jar mapping-service-<VERSION>.jar`
4179

4280
## License
4381

build.gradle

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id "org.asciidoctor.jvm.convert" version "3.3.0"
55
id "org.owasp.dependencycheck" version "7.0.4.1"
66
id 'net.researchgate.release' version '2.8.1'
7+
id "com.gorylenko.gradle-git-properties" version "2.4.1"
78
id 'java'
89
id 'jacoco'
910
}
@@ -24,14 +25,19 @@ configurations {
2425
}
2526
}
2627

28+
sourceCompatibility = 1.17
29+
targetCompatibility = 1.17
30+
2731
repositories {
2832
mavenLocal()
2933
mavenCentral()
3034
}
3135

3236
ext {
3337
set('snippetsDir', file('build/generated-snippets'))
34-
applicationProperties = System.getProperty('applicationProperties', 'src/main/resources/application.properties')
38+
applicationProperties = System.getProperty('applicationProperties', './src/test/resources/test-config/application-test.properties')
39+
pythonExecutable = System.getProperty('pythonExecutable', 'file:///usr/bin/python3')
40+
userDir = System.getProperty('user.dir')
3541
}
3642

3743
dependencies {
@@ -53,6 +59,8 @@ dependencies {
5359
implementation 'commons-io:commons-io:2.11.0'
5460
implementation 'javax.validation:validation-api:2.0.1.Final'
5561
implementation 'edu.kit.datamanager:service-base:1.0.4'
62+
// apache
63+
implementation "org.apache.tika:tika-core:2.7.0"
5664

5765
testImplementation platform('org.junit:junit-bom:5.9.0')
5866
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
@@ -82,10 +90,13 @@ dependencies {
8290
test {
8391
outputs.dir snippetsDir
8492
finalizedBy jacocoTestReport
85-
print("Running tests with configuration: ${applicationProperties}")
93+
println("Running tests with configuration: ${applicationProperties}")
94+
println("Running tests with python: ${pythonExecutable}")
95+
println("Running tests in directory: ${userDir}")
8696
environment 'spring.config.location', applicationProperties
87-
// environment 'spring.config.location', 'classpath:/test-config/'
97+
environment 'pythonExecutable', pythonExecutable
8898
useJUnitPlatform()
99+
testLogging.showStandardStreams = true
89100
}
90101

91102
jacoco {
@@ -112,6 +123,15 @@ jar {
112123
}
113124
}
114125

126+
springBoot {
127+
buildInfo()
128+
}
129+
130+
bootRun {
131+
systemProperty "spring.config.location", "file:$projectDir/"
132+
systemProperty "pythonLocation", pythonExecutable
133+
}
134+
115135
bootJar {
116136
dependsOn asciidoctor
117137
from ("${asciidoctor.outputDir}/html5") {
@@ -122,4 +142,11 @@ bootJar {
122142

123143
release {
124144
tagTemplate = 'v${version}'
125-
}
145+
}
146+
147+
task buildPluginJar(type: Jar) {
148+
description = 'Bundeling only plugin classes'
149+
archiveFileName.set("default-plugins-${version}.jar")
150+
from sourceSets.main.output
151+
include '**/plugins/impl/*.class'
152+
}

src/main/resources/application.properties renamed to config/application.default.properties

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ server.port=8095
66
# The properties max-file-size and max-request-size define the maximum size of files
77
# transferred to and from the repository. Setting them to -1 removes all limits.
88
server.compression.enabled=false
9+
10+
# Max sizes of requests and uploaded files. This value may has to be increased for
11+
# bigger mapping inputs, e.g., while extracting information for a zipped dataset.
912
spring.servlet.multipart.max-file-size=100MB
1013
spring.servlet.multipart.max-request-size=100MB
1114
# Logging settings
@@ -24,16 +27,17 @@ management.endpoints.web.exposure.include=*
2427
# Database
2528
##################################################
2629
spring.datasource.driver-class-name=org.h2.Driver
27-
spring.datasource.url=jdbc:h2:file:///tmp/mapping-service/database
30+
spring.datasource.url=jdbc:h2:file:e:/tmp/mapping-service/database
2831
spring.datasource.username=user
2932
spring.datasource.password=password
3033
spring.jpa.hibernate.ddl-auto=update
3134

3235
##################################################
3336
# Mapping-Service specific settings
3437
##################################################
35-
# Absolute path to the local python interpreter
36-
mapping-service.pythonLocation=file:///usr/bin/python3
37-
38-
# Absolute path to the local gemma mappings folder
38+
# Absolute path to the local python interpreter.
39+
mapping-service.pythonLocation=${pythonLocation:'file:///usr/bin/python3'}
40+
# Absolute path to the folder where all plugins are located.
41+
mapping-service.pluginLocation=file:///${user.dir}/plugins
42+
# Absolute path to the local gemma mappings folder.
3943
mapping-service.mappingSchemasLocation=file:///tmp/mapping-service/mappingSchemas

echo.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo @1

output

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/java/edu/kit/datamanager/mappingservice/MappingServiceApplication.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ public ApplicationProperties applicationProperties() {
2424
return new ApplicationProperties();
2525
}
2626

27+
@Bean
28+
public PluginManager pluginManager(){
29+
return new PluginManager(applicationProperties());
30+
}
31+
2732
public static void main(String[] args) {
2833
SpringApplication.run(MappingServiceApplication.class, args);
2934

30-
PluginManager.soleInstance().getListOfAvailableValidators().forEach((value) -> LOG.info("Found validator: " + value));
31-
PythonRunnerUtil.printPythonVersion();
35+
//pluginManager().getListOfAvailableValidators().forEach((value) -> LOG.info("Found validator: " + value));
36+
//PythonRunnerUtil.printPythonVersion();
3237

3338
System.out.println("Mapping service is running! Access it at http://localhost:8095");
3439
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import edu.kit.datamanager.annotations.ExecutableFileURL;
1919
import edu.kit.datamanager.annotations.LocalFolderURL;
20-
import edu.kit.datamanager.configuration.GenericPluginProperties;
2120
import lombok.Data;
2221
import lombok.EqualsAndHashCode;
2322
import org.springframework.beans.factory.annotation.Value;
@@ -28,8 +27,8 @@
2827
import java.net.URL;
2928

3029
/**
31-
* This class is used to configure the application.
32-
* It reads the values from the application.properties file.
30+
* This class is used to configure the application. It reads the values from the
31+
* application.properties file.
3332
*
3433
* @author maximilianiKIT
3534
*/
@@ -39,12 +38,20 @@
3938
@Validated
4039
@EqualsAndHashCode
4140
public class ApplicationProperties {
41+
4242
/**
4343
* The absolute path to the python interpreter.
4444
*/
4545
@ExecutableFileURL
46-
@Value("${mapping-service.pythonLocation}")
47-
private URL pythonLocation;
46+
@Value("${mapping-service.pythonExecutable}")
47+
private URL pythonExecutable;
48+
49+
/**
50+
* The absolute path where the plugins are stored.
51+
*/
52+
@LocalFolderURL
53+
@Value("${mapping-service.pluginLocation}")
54+
private URL pluginLocation;
4855

4956
/**
5057
* The absolute path where the mappings are stored.

0 commit comments

Comments
 (0)