Skip to content

Commit b86d2de

Browse files
committed
Fixed autowire of applicationProperties in AbstractPythongMappingPlugin, fixed dependency duplication issue, tests may still fail
1 parent 63351d8 commit b86d2de

File tree

6 files changed

+23
-26
lines changed

6 files changed

+23
-26
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ dependencies {
8282
implementation 'com.google.guava:guava:33.4.8-jre'
8383
implementation 'commons-io:commons-io:2.19.0'
8484
implementation 'javax.validation:validation-api:2.0.1.Final'
85-
implementation 'edu.kit.datamanager:service-base:1.3.3'
85+
implementation ('edu.kit.datamanager:service-base:1.3.3'){
86+
//exclude dependency as spring boot includes
87+
//org.glassfish.jaxb:jaxb-core:4.0.5 which leads to a duplication conflict
88+
exclude group: "com.sun.xml.bind"
89+
}
8690
// apache
8791
implementation "org.apache.tika:tika-core:2.9.3"
8892

src/main/java/edu/kit/datamanager/mappingservice/plugins/AbstractPythonMappingPlugin.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@
4040
*
4141
* @author jejkal
4242
*/
43-
@Component
4443
public abstract class AbstractPythonMappingPlugin implements IMappingPlugin {
4544

4645
private final Logger LOGGER = LoggerFactory.getLogger(AbstractPythonMappingPlugin.class);
4746

4847
/**
49-
* Application properties autowired at instantiation time.
48+
* Application properties autowired at instantiation time via
49+
* setApplicationProperties.
5050
*/
51-
@Autowired
52-
private final ApplicationProperties applicationProperties;
51+
private ApplicationProperties applicationProperties;
5352
/**
5453
* The plugin name.
5554
*/
@@ -130,6 +129,17 @@ public AbstractPythonMappingPlugin(String pluginName, String repositoryUrl) {
130129
}
131130
}
132131

132+
/**
133+
* Setter to autowire ApplicationProperties into all implementations of this
134+
* abstract class.
135+
*
136+
* @param applicationProperties The applicationProperties bean.
137+
*/
138+
@Autowired
139+
public final void setApplicationProperties(ApplicationProperties applicationProperties) {
140+
this.applicationProperties = applicationProperties;
141+
}
142+
133143
/**
134144
* Abstract method that is supposed to be implemented by each Python mapping
135145
* plugin to gather all information required for starting a Python process

src/main/java/edu/kit/datamanager/mappingservice/plugins/impl/GemmaPlugin.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@
1616
package edu.kit.datamanager.mappingservice.plugins.impl;
1717

1818
import edu.kit.datamanager.mappingservice.plugins.*;
19-
import org.slf4j.Logger;
20-
import org.slf4j.LoggerFactory;
2119
import org.springframework.util.MimeType;
2220
import org.springframework.util.MimeTypeUtils;
2321
import java.nio.file.Path;
2422

2523
public class GemmaPlugin extends AbstractPythonMappingPlugin {
2624

27-
private final Logger LOGGER = LoggerFactory.getLogger(GemmaPlugin.class);
2825
private static final String GEMMA_REPOSITORY = "https://github.com/kit-data-manager/gemma.git";
29-
private static final String GEMMA_BRANCH = "master";
30-
private static Path gemmaDir;
31-
private boolean initialized = false;
3226

3327
public GemmaPlugin() {
3428
super("GEMMA", GEMMA_REPOSITORY);
@@ -58,17 +52,4 @@ public String[] getCommandArray(Path workingDir, Path mappingFile, Path inputFil
5852
outputFile.toString()
5953
};
6054
}
61-
62-
/* @Override
63-
public MappingPluginState mapFile(Path mappingFile, Path inputFile, Path outputFile) throws MappingPluginException {
64-
if (initialized) {
65-
LOGGER.trace("Running plugin '{}' v{} on '{}' with mapping '{}' -> '{}'", name(), version(), inputFile, mappingFile, outputFile);
66-
return PythonRunnerUtil.runPythonScript(gemmaDir + "/mapping_single.py", mappingFile.toString(), inputFile.toString(), outputFile.toString());
67-
} else {
68-
LOGGER.error("Plugin '" + name() + "' " + version() + " not initialized. Returning EXECUTION_ERROR.");
69-
MappingPluginState result = MappingPluginState.EXECUTION_ERROR();
70-
result.setDetails("Plugin not initialized, probably due to missing dependencies or external plugin repository.");
71-
return result;
72-
}
73-
}*/
7455
}

src/main/resources/gemma.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version=master
2+
min.python=3.0.0

src/test/java/edu/kit/datamanager/mappingservice/util/FileUtilTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public void testFixFileExtensionWrongFile() {
322322
@Test
323323
void cloneValidGitRepository() {
324324
Path util = null;
325-
325+
326326
try {
327327
util = FileUtil.cloneGitRepository("https://github.com/kit-data-manager/mapping-service.git", "main", "/tmp/test");
328328
} catch (Exception e) {
@@ -340,7 +340,6 @@ void cloneValidGitRepository() {
340340
@Test
341341
void cloneInvalidGitRepository() {
342342
assertThrows(MappingServiceException.class, () -> FileUtil.cloneGitRepository("test", "test", "test"));
343-
assertThrows(MappingServiceException.class, () -> FileUtil.cloneGitRepository("test", "test"));
344343
}
345344

346345
@AfterEach

src/test/resources/test-config/application-test.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ eureka.client.enabled: false
6767
mapping-service.pythonExecutable=${pythonExecutable:file:///usr/bin/python}
6868
# Absolute path to the folder where all plugins are located
6969
mapping-service.pluginLocation=file:///tmp/mapping-service/plugins
70+
mapping-service.codeLocation=file:///tmp/mapping-service/code
7071
# Absolute path to the local gemma mappings folder
7172
mapping-service.mappingSchemasLocation=file:///tmp/mapping-service/schemas
7273
# Folder where job output files for async mapping executions are stored

0 commit comments

Comments
 (0)