Skip to content

Commit

Permalink
Added: Export to Opal only after all files are sent
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 20, 2023
1 parent 53c517e commit 6f9f881
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.0 - 2023-12-03]
## [1.1.0 - 2023-12-20]
### Added
- Java Opts
- Divide Excel file in several files if number of rows is too large
Expand Down Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Request Template
- Query in body for CREATE_QUERY
- ConverterGraph
- Export to Opal only after all files are sent

### Changed
- Move FHIR Packages to dktk-exporter
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM eclipse-temurin:21-jre

COPY target/exporter.jar /app/

WORKDIR /app

RUN apt-get update && apt-get upgrade -y && apt-get install python3-pip -y && \
apt-get install libcurl4-openssl-dev libssl-dev -y && \
python3 -m pip install obiba-opal && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY target/exporter.jar /app/

WORKDIR /app

CMD ["sh", "-c", "java $JAVA_OPTS -jar exporter.jar"]
11 changes: 10 additions & 1 deletion src/main/java/de/samply/opal/CsvToOpalConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ public Format getOutputFormat() {

@Override
protected Flux<Path> convert(Path input, ConverterTemplate template, Session session) {
session.addPath(input);
return Flux.just(input);
}

@Override
protected Runnable getSessionCompleter(ConverterTemplate template, Session session) {
return () -> session.getOpalPaths().forEach(path -> sendPathToOpal(path, session));
}

private void sendPathToOpal(Path input, Session session){
try {
opalEngine.sendPathToOpal(input, session);
} catch (OpalEngineException e) {
logger.error(ExceptionUtils.getStackTrace(e));
}
return Flux.just(input);
}

@Override
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/de/samply/opal/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import de.samply.template.token.TokenContext;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;

public class Session {

Expand All @@ -16,6 +18,7 @@ public class Session {
private int maxNumberOfRetries;
private String project;
private final TokenContext tokenContext;
private final Set<Path> opalPaths = new HashSet<>();

public Session(ConverterTemplate template, ConverterTemplateUtils converterTemplateUtils,
int timeoutInSeconds, int maxNumberOfRetries, TokenContext tokenContext) {
Expand Down Expand Up @@ -69,4 +72,12 @@ public void setMaxNumberOfRetries(int maxNumberOfRetries) {
this.maxNumberOfRetries = maxNumberOfRetries;
}

public void addPath (Path path){
this.opalPaths.add(path);
}

public Set<Path> getOpalPaths() {
return opalPaths;
}

}

0 comments on commit 6f9f881

Please sign in to comment.