Skip to content

Commit

Permalink
get rid of groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
KochTobi committed May 23, 2024
1 parent 5e64bcf commit 2a504c7
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 223 deletions.
174 changes: 9 additions & 165 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
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>
<artifactId>java-openbis20-dropboxes</artifactId>
<version>1.0.0</version>
<groupId>life.qbic</groupId>

<name>OpenBIS ETL routines written in Java</name>
<url>https://github.com/qbicsoftware/openbis20-java-dropboxes</url>
<description>ETL routines written in Java for OpenBIS version 20</description>

<groupId>life.qbic.registration</groupId>
<artifactId>java-openbis20-dropboxes</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<openbis.version>20.10.7.3</openbis.version>
<openbis.classifier>r1700646105</openbis.classifier>
<groovy.version>3.0.10</groovy.version>
</properties>

<repositories>
Expand Down Expand Up @@ -56,53 +58,7 @@
<url>https://qbic-repo.qbic.uni-tuebingen.de/repository/maven-releases</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-bom</artifactId>
<version>${groovy.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-bom</artifactId>
<version>2.0-M4-groovy-3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>

<!-- Bean Validation API and RI -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-log4j2 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>3.2.5</version>
</dependency>


<!-- Groovy dependencies -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-sql</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>life.qbic</groupId>
<artifactId>openbis-api</artifactId>
Expand Down Expand Up @@ -135,24 +91,12 @@
<version>18.06.2</version>
<scope>provided</scope>
</dependency>

<!-- Additional dependencies needed for openbis connection to work -->
<dependency>
<groupId>life.qbic</groupId>
<artifactId>hotdeploy-plugins</artifactId>
<version>13.01.0</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>6.1.6</version>
<scope>test</scope>
</dependency>

</dependencies>

<!-- This configures the target artifact repositories for deployment
Expand All @@ -172,104 +116,4 @@
<url>https://qbic-repo.qbic.uni-tuebingen.de/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.12.1</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>compileTests</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
<execution>
<id>site</id>
<phase>site</phase>
<goals>
<goal>generateStubs</goal>
<goal>generateTestStubs</goal>
<goal>groovydoc</goal>
<goal>groovydocTests</goal>
</goals>
</execution>
</executions>
<configuration>
<groovyDocOutputDirectory>${project.build.directory}/site/gapidocs</groovyDocOutputDirectory>
<testGroovyDocOutputDirectory>${project.build.directory}/site/testgapidocs</testGroovyDocOutputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*Spec</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>life.qbic</groupId>
<artifactId>groovydoc-maven-plugin</artifactId>
<version>1.0.2</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>life.qbic.cli.PostregistrationToolEntryPoint</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>life.qbic</groupId>
<artifactId>groovydoc-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package life.qbic.registration.openbis;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
Expand All @@ -15,7 +14,6 @@
*/
public class DataSetProvenance implements Serializable {

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

@JsonProperty("origin")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package life.qbic.registration.openbis;

import static java.util.Objects.requireNonNull;

import ch.systemsx.cisd.common.exceptions.NotImplementedException;
import ch.systemsx.cisd.etlserver.registrator.DataSetRegistrationContext;
import ch.systemsx.cisd.etlserver.registrator.api.v2.AbstractJavaDataSetRegistrationDropboxV2;
Expand All @@ -12,25 +14,44 @@
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.List;
import life.qbic.registration.openbis.exceptions.fail.MeasurementHasDataException;
import life.qbic.registration.openbis.exceptions.fail.ToManyMeasurementsException;
import life.qbic.registration.openbis.exceptions.fail.UnknownSampleTypeException;
import life.qbic.registration.openbis.exceptions.retry.NoMeasurementsFoundException;
import life.qbic.registration.openbis.types.QDatasetType;
import life.qbic.registration.openbis.types.QPropertyType;
import life.qbic.registration.openbis.types.QSampleType;

/**
* TODO!
* <b>short description</b>
*
* <p>detailed description</p>
*
* @since <version tag>
* The Dropbox ETL process.
* <p>
* This process is responsible for
* <ol>
* <li>fetching the measurement sample from openbis
* <li>creating a data set linked to the sample
* <li> moving files into the dataset
* </ol>
* Some constraints are taken care of during this process. These constraints being:
* <ul>
* <li>the measurement sample already exists in openbis
* <li>only one measurement sample exists with the provided identifier
* <li>the measurement sample has no data set linked as one measurement can only have one dataset.
* </ul>
*/
public class DataSetRegistrationDropboxETL extends AbstractJavaDataSetRegistrationDropboxV2 {
public class OpenBisDropboxETL extends AbstractJavaDataSetRegistrationDropboxV2 {

private static final String PROVENANCE_FILE_NAME = "provenance.json";
private final ProvenanceParser provenanceParser;

public OpenBisDropboxETL() {
provenanceParser = new ProvenanceParser();
}

private final String provenanceFileName = "provenance.json";
protected OpenBisDropboxETL(ProvenanceParser provenanceParser) {
this.provenanceParser = requireNonNull(provenanceParser, "provenanceParser must not be null");
}


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

@Override
public void process(IDataSetRegistrationTransactionV2 transaction) {
DataSetProvenance dataSetProvenance = parseProvenanceJson(
new File(transaction.getIncoming(), provenanceFileName));
DataSetProvenance dataSetProvenance = provenanceParser.parseProvenanceJson(
new File(transaction.getIncoming(), PROVENANCE_FILE_NAME));

String measurementId = dataSetProvenance.measurementId();

Expand Down Expand Up @@ -105,47 +126,4 @@ private boolean doesMeasurementHaveData(ISampleImmutable sample, ISearchService

}

private DataSetProvenance parseProvenanceJson(File provenanceFile) {
ObjectMapper objectMapper = new ObjectMapper();
try {
return objectMapper.readValue(provenanceFile,
DataSetProvenance.class);
} catch (IOException e) {
throw new ProvenanceParseException(
"Could not parse '" + provenanceFile.getAbsolutePath() + "'", e);
}
}

public static class NoMeasurementsFoundException extends RuntimeException implements
WithRetryOption {
public NoMeasurementsFoundException(String message) {
super(message);
}
}

public static class ProvenanceParseException extends RuntimeException {

public ProvenanceParseException(String message, Throwable cause) {
super(message, cause);
}
}

public static class UnknownSampleTypeException extends RuntimeException {
public UnknownSampleTypeException(String message) {
super(message);
}
}

public static class ToManyMeasurementsException extends RuntimeException {
public ToManyMeasurementsException(String message) {
super(message);
}
}

public static class MeasurementHasDataException extends RuntimeException {
public MeasurementHasDataException(String message) {
super(message);
}
}

}
26 changes: 26 additions & 0 deletions src/main/java/life/qbic/registration/openbis/ProvenanceParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package life.qbic.registration.openbis;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import life.qbic.registration.openbis.exceptions.fail.ProvenanceParseException;

/**
* Parses a provenance file and produces a java object from it.
*/
public class ProvenanceParser {


private final ObjectMapper objectMapper = new ObjectMapper();

DataSetProvenance parseProvenanceJson(File provenanceFile) {
try {
return objectMapper.readValue(provenanceFile,
DataSetProvenance.class);
} catch (IOException e) {
throw new ProvenanceParseException(
"Could not parse '" + provenanceFile.getAbsolutePath() + "'", e);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package life.qbic.registration.openbis.exceptions.fail;

/**
* Thrown when the dataset type cannot be determined.
*/
public class DatasetTypeMappingException extends RuntimeException {
public DatasetTypeMappingException(String message) {
super(message);
}
}
Loading

0 comments on commit 2a504c7

Please sign in to comment.