Skip to content

Commit 2a504c7

Browse files
committed
get rid of groovy
1 parent 5e64bcf commit 2a504c7

11 files changed

+148
-223
lines changed

pom.xml

Lines changed: 9 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
<artifactId>java-openbis20-dropboxes</artifactId>
7-
<version>1.0.0</version>
8-
<groupId>life.qbic</groupId>
6+
97
<name>OpenBIS ETL routines written in Java</name>
108
<url>https://github.com/qbicsoftware/openbis20-java-dropboxes</url>
119
<description>ETL routines written in Java for OpenBIS version 20</description>
10+
11+
<groupId>life.qbic.registration</groupId>
12+
<artifactId>java-openbis20-dropboxes</artifactId>
13+
<version>1.0.0</version>
1214
<packaging>jar</packaging>
15+
1316
<properties>
1417
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<maven.compiler.source>17</maven.compiler.source>
16-
<maven.compiler.target>17</maven.compiler.target>
18+
<maven.compiler.source>11</maven.compiler.source>
19+
<maven.compiler.target>11</maven.compiler.target>
1720
<openbis.version>20.10.7.3</openbis.version>
1821
<openbis.classifier>r1700646105</openbis.classifier>
19-
<groovy.version>3.0.10</groovy.version>
2022
</properties>
2123

2224
<repositories>
@@ -56,53 +58,7 @@
5658
<url>https://qbic-repo.qbic.uni-tuebingen.de/repository/maven-releases</url>
5759
</repository>
5860
</repositories>
59-
<dependencyManagement>
60-
<dependencies>
61-
<dependency>
62-
<groupId>org.codehaus.groovy</groupId>
63-
<artifactId>groovy-bom</artifactId>
64-
<version>${groovy.version}</version>
65-
<type>pom</type>
66-
<scope>import</scope>
67-
</dependency>
68-
<dependency>
69-
<groupId>org.spockframework</groupId>
70-
<artifactId>spock-bom</artifactId>
71-
<version>2.0-M4-groovy-3.0</version>
72-
<type>pom</type>
73-
<scope>import</scope>
74-
</dependency>
75-
</dependencies>
76-
</dependencyManagement>
7761
<dependencies>
78-
79-
<!-- Bean Validation API and RI -->
80-
<dependency>
81-
<groupId>javax.validation</groupId>
82-
<artifactId>validation-api</artifactId>
83-
<version>1.0.0.GA</version>
84-
</dependency>
85-
86-
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-log4j2 -->
87-
<dependency>
88-
<groupId>org.springframework.boot</groupId>
89-
<artifactId>spring-boot-starter-log4j2</artifactId>
90-
<version>3.2.5</version>
91-
</dependency>
92-
93-
94-
<!-- Groovy dependencies -->
95-
<dependency>
96-
<groupId>org.codehaus.groovy</groupId>
97-
<artifactId>groovy-all</artifactId>
98-
<version>${groovy.version}</version>
99-
<type>pom</type>
100-
</dependency>
101-
<dependency>
102-
<groupId>org.codehaus.groovy</groupId>
103-
<artifactId>groovy-sql</artifactId>
104-
<version>${groovy.version}</version>
105-
</dependency>
10662
<dependency>
10763
<groupId>life.qbic</groupId>
10864
<artifactId>openbis-api</artifactId>
@@ -135,24 +91,12 @@
13591
<version>18.06.2</version>
13692
<scope>provided</scope>
13793
</dependency>
138-
94+
<!-- Additional dependencies needed for openbis connection to work -->
13995
<dependency>
14096
<groupId>life.qbic</groupId>
14197
<artifactId>hotdeploy-plugins</artifactId>
14298
<version>13.01.0</version>
14399
</dependency>
144-
<dependency>
145-
<groupId>org.spockframework</groupId>
146-
<artifactId>spock-core</artifactId>
147-
<scope>test</scope>
148-
</dependency>
149-
<dependency>
150-
<groupId>org.springframework</groupId>
151-
<artifactId>spring-test</artifactId>
152-
<version>6.1.6</version>
153-
<scope>test</scope>
154-
</dependency>
155-
156100
</dependencies>
157101

158102
<!-- This configures the target artifact repositories for deployment
@@ -172,104 +116,4 @@
172116
<url>https://qbic-repo.qbic.uni-tuebingen.de/repository/maven-snapshots</url>
173117
</snapshotRepository>
174118
</distributionManagement>
175-
<build>
176-
<plugins>
177-
<plugin>
178-
<groupId>org.apache.maven.plugins</groupId>
179-
<artifactId>maven-site-plugin</artifactId>
180-
<version>3.7.1</version>
181-
</plugin>
182-
<plugin>
183-
<groupId>org.apache.maven.plugins</groupId>
184-
<artifactId>maven-project-info-reports-plugin</artifactId>
185-
<version>3.1.1</version>
186-
</plugin>
187-
<plugin>
188-
<groupId>org.codehaus.gmavenplus</groupId>
189-
<artifactId>gmavenplus-plugin</artifactId>
190-
<version>1.12.1</version>
191-
<executions>
192-
<execution>
193-
<id>default</id>
194-
<goals>
195-
<goal>addSources</goal>
196-
<goal>addTestSources</goal>
197-
<goal>generateStubs</goal>
198-
<goal>compile</goal>
199-
<goal>generateTestStubs</goal>
200-
<goal>compileTests</goal>
201-
<goal>removeStubs</goal>
202-
<goal>removeTestStubs</goal>
203-
</goals>
204-
</execution>
205-
<execution>
206-
<id>site</id>
207-
<phase>site</phase>
208-
<goals>
209-
<goal>generateStubs</goal>
210-
<goal>generateTestStubs</goal>
211-
<goal>groovydoc</goal>
212-
<goal>groovydocTests</goal>
213-
</goals>
214-
</execution>
215-
</executions>
216-
<configuration>
217-
<groovyDocOutputDirectory>${project.build.directory}/site/gapidocs</groovyDocOutputDirectory>
218-
<testGroovyDocOutputDirectory>${project.build.directory}/site/testgapidocs</testGroovyDocOutputDirectory>
219-
</configuration>
220-
</plugin>
221-
<plugin>
222-
<artifactId>maven-surefire-plugin</artifactId>
223-
<version>3.0.0-M5</version>
224-
<configuration>
225-
<includes>
226-
<include>**/*Spec</include>
227-
</includes>
228-
</configuration>
229-
</plugin>
230-
<plugin>
231-
<groupId>life.qbic</groupId>
232-
<artifactId>groovydoc-maven-plugin</artifactId>
233-
<version>1.0.2</version>
234-
</plugin>
235-
<plugin>
236-
<artifactId>maven-assembly-plugin</artifactId>
237-
<executions>
238-
<execution>
239-
<configuration>
240-
<archive>
241-
<manifest>
242-
<mainClass>life.qbic.cli.PostregistrationToolEntryPoint</mainClass>
243-
</manifest>
244-
</archive>
245-
<descriptorRefs>
246-
<descriptorRef>jar-with-dependencies</descriptorRef>
247-
</descriptorRefs>
248-
</configuration>
249-
<goals>
250-
<goal>single</goal>
251-
</goals>
252-
<phase>package</phase>
253-
</execution>
254-
</executions>
255-
<groupId>org.apache.maven.plugins</groupId>
256-
</plugin>
257-
<plugin>
258-
<groupId>org.apache.maven.plugins</groupId>
259-
<artifactId>maven-compiler-plugin</artifactId>
260-
<configuration>
261-
<source>14</source>
262-
<target>14</target>
263-
</configuration>
264-
</plugin>
265-
</plugins>
266-
</build>
267-
<reporting>
268-
<plugins>
269-
<plugin>
270-
<groupId>life.qbic</groupId>
271-
<artifactId>groovydoc-maven-plugin</artifactId>
272-
</plugin>
273-
</plugins>
274-
</reporting>
275119
</project>

src/main/java/life/qbic/registration/openbis/DataSetProvenance.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package life.qbic.registration.openbis;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4-
import java.io.Serial;
54
import java.io.Serializable;
65
import java.util.Arrays;
76
import java.util.Objects;
@@ -15,7 +14,6 @@
1514
*/
1615
public class DataSetProvenance implements Serializable {
1716

18-
@Serial
1917
private static final long serialVersionUID = -1597156104025439195L;
2018

2119
@JsonProperty("origin")

src/main/java/life/qbic/registration/openbis/DataSetRegistrationDropboxETL.java renamed to src/main/java/life/qbic/registration/openbis/OpenBisDropboxETL.java

Lines changed: 33 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package life.qbic.registration.openbis;
22

3+
import static java.util.Objects.requireNonNull;
4+
35
import ch.systemsx.cisd.common.exceptions.NotImplementedException;
46
import ch.systemsx.cisd.etlserver.registrator.DataSetRegistrationContext;
57
import ch.systemsx.cisd.etlserver.registrator.api.v2.AbstractJavaDataSetRegistrationDropboxV2;
@@ -12,25 +14,44 @@
1214
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause;
1315
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute;
1416
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria;
15-
import com.fasterxml.jackson.databind.ObjectMapper;
1617
import java.io.File;
17-
import java.io.IOException;
1818
import java.util.List;
19+
import life.qbic.registration.openbis.exceptions.fail.MeasurementHasDataException;
20+
import life.qbic.registration.openbis.exceptions.fail.ToManyMeasurementsException;
21+
import life.qbic.registration.openbis.exceptions.fail.UnknownSampleTypeException;
22+
import life.qbic.registration.openbis.exceptions.retry.NoMeasurementsFoundException;
1923
import life.qbic.registration.openbis.types.QDatasetType;
2024
import life.qbic.registration.openbis.types.QPropertyType;
2125
import life.qbic.registration.openbis.types.QSampleType;
2226

2327
/**
24-
* TODO!
25-
* <b>short description</b>
26-
*
27-
* <p>detailed description</p>
28-
*
29-
* @since <version tag>
28+
* The Dropbox ETL process.
29+
* <p>
30+
* This process is responsible for
31+
* <ol>
32+
* <li>fetching the measurement sample from openbis
33+
* <li>creating a data set linked to the sample
34+
* <li> moving files into the dataset
35+
* </ol>
36+
* Some constraints are taken care of during this process. These constraints being:
37+
* <ul>
38+
* <li>the measurement sample already exists in openbis
39+
* <li>only one measurement sample exists with the provided identifier
40+
* <li>the measurement sample has no data set linked as one measurement can only have one dataset.
41+
* </ul>
3042
*/
31-
public class DataSetRegistrationDropboxETL extends AbstractJavaDataSetRegistrationDropboxV2 {
43+
public class OpenBisDropboxETL extends AbstractJavaDataSetRegistrationDropboxV2 {
44+
45+
private static final String PROVENANCE_FILE_NAME = "provenance.json";
46+
private final ProvenanceParser provenanceParser;
47+
48+
public OpenBisDropboxETL() {
49+
provenanceParser = new ProvenanceParser();
50+
}
3251

33-
private final String provenanceFileName = "provenance.json";
52+
protected OpenBisDropboxETL(ProvenanceParser provenanceParser) {
53+
this.provenanceParser = requireNonNull(provenanceParser, "provenanceParser must not be null");
54+
}
3455

3556

3657
public interface WithRetryOption {
@@ -44,8 +65,8 @@ public boolean shouldRetryProcessing(DataSetRegistrationContext context, Excepti
4465

4566
@Override
4667
public void process(IDataSetRegistrationTransactionV2 transaction) {
47-
DataSetProvenance dataSetProvenance = parseProvenanceJson(
48-
new File(transaction.getIncoming(), provenanceFileName));
68+
DataSetProvenance dataSetProvenance = provenanceParser.parseProvenanceJson(
69+
new File(transaction.getIncoming(), PROVENANCE_FILE_NAME));
4970

5071
String measurementId = dataSetProvenance.measurementId();
5172

@@ -105,47 +126,4 @@ private boolean doesMeasurementHaveData(ISampleImmutable sample, ISearchService
105126

106127
}
107128

108-
private DataSetProvenance parseProvenanceJson(File provenanceFile) {
109-
ObjectMapper objectMapper = new ObjectMapper();
110-
try {
111-
return objectMapper.readValue(provenanceFile,
112-
DataSetProvenance.class);
113-
} catch (IOException e) {
114-
throw new ProvenanceParseException(
115-
"Could not parse '" + provenanceFile.getAbsolutePath() + "'", e);
116-
}
117-
}
118-
119-
public static class NoMeasurementsFoundException extends RuntimeException implements
120-
WithRetryOption {
121-
public NoMeasurementsFoundException(String message) {
122-
super(message);
123-
}
124-
}
125-
126-
public static class ProvenanceParseException extends RuntimeException {
127-
128-
public ProvenanceParseException(String message, Throwable cause) {
129-
super(message, cause);
130-
}
131-
}
132-
133-
public static class UnknownSampleTypeException extends RuntimeException {
134-
public UnknownSampleTypeException(String message) {
135-
super(message);
136-
}
137-
}
138-
139-
public static class ToManyMeasurementsException extends RuntimeException {
140-
public ToManyMeasurementsException(String message) {
141-
super(message);
142-
}
143-
}
144-
145-
public static class MeasurementHasDataException extends RuntimeException {
146-
public MeasurementHasDataException(String message) {
147-
super(message);
148-
}
149-
}
150-
151129
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package life.qbic.registration.openbis;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import java.io.File;
5+
import java.io.IOException;
6+
import life.qbic.registration.openbis.exceptions.fail.ProvenanceParseException;
7+
8+
/**
9+
* Parses a provenance file and produces a java object from it.
10+
*/
11+
public class ProvenanceParser {
12+
13+
14+
private final ObjectMapper objectMapper = new ObjectMapper();
15+
16+
DataSetProvenance parseProvenanceJson(File provenanceFile) {
17+
try {
18+
return objectMapper.readValue(provenanceFile,
19+
DataSetProvenance.class);
20+
} catch (IOException e) {
21+
throw new ProvenanceParseException(
22+
"Could not parse '" + provenanceFile.getAbsolutePath() + "'", e);
23+
}
24+
}
25+
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package life.qbic.registration.openbis.exceptions.fail;
2+
3+
/**
4+
* Thrown when the dataset type cannot be determined.
5+
*/
6+
public class DatasetTypeMappingException extends RuntimeException {
7+
public DatasetTypeMappingException(String message) {
8+
super(message);
9+
}
10+
}

0 commit comments

Comments
 (0)