-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement dummy transformation
SVC-1398
- Loading branch information
1 parent
0340145
commit 9f7e88d
Showing
6 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/to/wetransform/hale/transformer/CustomTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package to.wetransform.hale.transformer; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import eu.esdihumboldt.hale.common.core.io.Value; | ||
|
||
public record CustomTarget(String providerId, Map<String, Value> settings) { | ||
|
||
public CustomTarget(String providerId) { | ||
this(providerId, new HashMap<>()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/to/wetransform/hale/transformer/SourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package to.wetransform.hale.transformer; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import eu.esdihumboldt.hale.common.core.io.Value; | ||
|
||
public record SourceConfig( | ||
URI location, String providerId, Map<String, Value> settings, boolean transform, List<String> attachments) { | ||
|
||
public SourceConfig(URI location, String providerId) { | ||
this(location, providerId, new HashMap<>(), true, new ArrayList<>()); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/to/wetransform/hale/transformer/TargetConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package to.wetransform.hale.transformer; | ||
|
||
public record TargetConfig(String filename, String preset, CustomTarget customTarget) {} |
71 changes: 69 additions & 2 deletions
71
src/main/java/to/wetransform/hale/transformer/Transformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,80 @@ | ||
package to.wetransform.hale.transformer; | ||
|
||
import java.io.InputStream; | ||
import java.net.URI; | ||
import java.text.MessageFormat; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import eu.esdihumboldt.hale.app.transform.ExecContext; | ||
import eu.esdihumboldt.hale.common.core.HalePlatform; | ||
import eu.esdihumboldt.hale.common.core.io.project.model.Project; | ||
import eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier; | ||
import eu.esdihumboldt.util.io.IOUtils; | ||
import org.osgi.framework.Version; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import to.wetransform.halecli.internal.Init; | ||
|
||
public class Transformer { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Transformer.class); | ||
|
||
void transform() { | ||
LOG.info("Transforming..."); | ||
private CountDownLatch latch = new CountDownLatch(1); | ||
|
||
public void transform(/* TODO add parameters for data and project sources */ ) { | ||
// TODO setup log files for reports and transformation log | ||
|
||
long heapMaxSize = Runtime.getRuntime().maxMemory(); | ||
LOG.info("Maximum heap size configured as " + IOUtils.humanReadableByteCount(heapMaxSize, false)); | ||
|
||
Init.init(); | ||
|
||
Version version = HalePlatform.getCoreVersion(); | ||
LOG.info(MessageFormat.format("Launching hale-transformer {0}...", version.toString())); | ||
|
||
ExecContext context = new ExecContext(); | ||
|
||
// URI projectUri = .... | ||
// context.setProject(projectUri); | ||
// Project project = loadProject(projectUri); | ||
|
||
// context.setSources(...) | ||
// context.setSourceProviderIds(...) | ||
// context.setSourcesSettings(...) | ||
|
||
// Value sourceCrs = null; | ||
// TODO determine source CRS | ||
|
||
// TargetConfig targetConfig = configureTarget(project, sourceCrs); | ||
|
||
try { | ||
// run the transformation | ||
|
||
LOG.info("Transforming..."); | ||
TimeUnit.SECONDS.sleep(30); | ||
// new ExecTransformation().run(context); | ||
|
||
LOG.info("Transformation complete."); | ||
} catch (Throwable t) { | ||
LOG.error("Failed to execute transformation: " + t.getMessage(), t); | ||
} finally { | ||
latch.countDown(); | ||
} | ||
} | ||
|
||
private Project loadProject(URI projectUri) { | ||
DefaultInputSupplier supplier = new DefaultInputSupplier(projectUri); | ||
Project result = null; | ||
try (InputStream in = supplier.getInput()) { | ||
result = Project.load(in); | ||
} catch (Exception e) { | ||
LOG.warn("Could not load project file to determine presets: " + e.getStackTrace()); | ||
} | ||
return result; | ||
} | ||
|
||
public CountDownLatch getLatch() { | ||
return latch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters