You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/11/17 13:06:39 UTC
(incubator-baremaps) 03/07: Add javadoc
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch workflow
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit 30b7eed72674750f5fd21fa7b8583f70ebe546eb
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Mon Nov 13 16:33:29 2023 +0100
Add javadoc
---
.../baremaps/workflow/tasks/DecompressBZip2.java | 78 --------------
.../baremaps/workflow/tasks/DecompressFile.java | 117 ++++++++++++++++++---
.../baremaps/workflow/tasks/DownloadUrl.java | 17 ++-
.../baremaps/workflow/tasks/ExecuteCommand.java | 25 +++++
.../apache/baremaps/workflow/tasks/ExecuteSql.java | 50 ++++++++-
.../baremaps/workflow/tasks/ExecuteSqlScript.java | 35 ++++++
.../baremaps/workflow/tasks/ExportVectorTiles.java | 1 +
.../workflow/tasks/ImportDaylightFeatures.java | 44 ++++++--
.../workflow/tasks/ImportDaylightTranslations.java | 35 ++++++
.../baremaps/workflow/tasks/ImportGeoPackage.java | 57 ++++++++++
.../baremaps/workflow/tasks/ImportOsmOsc.java | 68 ++++++++++++
.../baremaps/workflow/tasks/ImportOsmPbf.java | 92 ++++++++++++++++
.../baremaps/workflow/tasks/ImportShapefile.java | 57 ++++++++++
.../apache/baremaps/workflow/tasks/LogMessage.java | 24 +++++
.../apache/baremaps/workflow/tasks/UngzipFile.java | 35 ++++++
.../apache/baremaps/workflow/tasks/UnzipFile.java | 35 ++++++
.../baremaps/workflow/tasks/UpdateOsmDatabase.java | 66 ++++++++++++
.../apache/baremaps/workflow/ObjectMapperTest.java | 2 +-
.../org/apache/baremaps/workflow/WorkflowTest.java | 15 +--
.../baremaps/workflow/tasks/DownloadUrlTest.java | 6 +-
20 files changed, 738 insertions(+), 121 deletions(-)
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressBZip2.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressBZip2.java
deleted file mode 100644
index ef17fe00..00000000
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressBZip2.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.baremaps.workflow.tasks;
-
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import java.io.BufferedInputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import org.apache.baremaps.workflow.Task;
-import org.apache.baremaps.workflow.WorkflowContext;
-import org.apache.baremaps.workflow.WorkflowException;
-import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@JsonTypeName("DecompressBZip2")
-public class DecompressBZip2 implements Task {
-
- private static final Logger logger = LoggerFactory.getLogger(DecompressBZip2.class);
-
- private Path source;
- private Path target;
-
- public DecompressBZip2() {}
-
- public DecompressBZip2(Path source, Path target) {
- this.source = source;
- this.target = target;
- }
-
- public Path getSource() {
- return source;
- }
-
- public void setSource(Path source) {
- this.source = source;
- }
-
- public Path getTarget() {
- return target;
- }
-
- public void setTarget(Path target) {
- this.target = target;
- }
-
- @Override
- public void execute(WorkflowContext context) throws Exception {
- var sourcePath = source.toAbsolutePath();
- try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(sourcePath));
- var compressedInputStream = new BZip2CompressorInputStream(bufferedInputStream)) {
- var targetPath = target.toAbsolutePath();
- if (!Files.exists(targetPath)) {
- Files.createDirectories(targetPath.getParent());
- Files.createFile(targetPath);
- }
- Files.copy(compressedInputStream, targetPath, StandardCopyOption.REPLACE_EXISTING);
- } catch (Exception e) {
- throw new WorkflowException(e);
- }
- }
-}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
index 4d991077..37b0ac0e 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
@@ -33,11 +33,18 @@ import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Decompresses a file based on a given compression format. The supported formats are zip, targz,
+ * tarbz2, gzip and bzip2.
+ */
@JsonTypeName("DecompressFile")
public class DecompressFile implements Task {
private static final Logger logger = LoggerFactory.getLogger(DecompressFile.class);
+ /**
+ * The compression format.
+ */
public enum Compression {
zip,
targz,
@@ -47,43 +54,84 @@ public class DecompressFile implements Task {
}
private Path source;
-
private Path target;
-
private Compression compression;
+ /**
+ * Constructs a {@code DecompressFile}.
+ */
public DecompressFile() {}
+ /**
+ * Constructs a {@code DecompressFile}.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @param compression the compression format (zip, targz, tarbz2, gzip or bzip2)
+ */
public DecompressFile(Path source, Path target, Compression compression) {
this.source = source;
this.target = target;
this.compression = compression;
}
+ /**
+ * Returns the source file.
+ *
+ * @return the source file
+ */
public Path getSource() {
return source;
}
+ /**
+ * Sets the source file.
+ *
+ * @param source the source file
+ */
public void setSource(Path source) {
this.source = source;
}
+ /**
+ * Returns the target file.
+ *
+ * @return the target file
+ */
public Path getTarget() {
return target;
}
+ /**
+ * Sets the target file.
+ *
+ * @param target the target file
+ */
public void setTarget(Path target) {
this.target = target;
}
+ /**
+ * Returns the compression format.
+ *
+ * @return the compression format
+ */
public Compression getCompression() {
return compression;
}
+ /**
+ * Sets the compression format.
+ *
+ * @param compression the compression format
+ */
public void setCompression(Compression compression) {
this.compression = compression;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var sourcePath = source.toAbsolutePath();
@@ -97,26 +145,47 @@ public class DecompressFile implements Task {
}
}
- public static void decompressBzip2(Path sourcePath, Path targetPath) throws IOException {
- try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(sourcePath));
+ /**
+ * Decompresses a bzip2 file.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @throws IOException if an I/O error occurs
+ */
+ protected static void decompressBzip2(Path source, Path target) throws IOException {
+ try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(source));
var bzip2InputStream = new BZip2CompressorInputStream(bufferedInputStream)) {
- Files.copy(bzip2InputStream, targetPath, StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(bzip2InputStream, target, StandardCopyOption.REPLACE_EXISTING);
}
}
- public static void decompressGzip(Path sourcePath, Path targetPath) throws IOException {
- try (var zis = new GZIPInputStream(new BufferedInputStream(Files.newInputStream(sourcePath)))) {
- Files.copy(zis, targetPath, StandardCopyOption.REPLACE_EXISTING);
+ /**
+ * Decompresses a gzip file.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @throws IOException if an I/O error occurs
+ */
+ protected static void decompressGzip(Path source, Path target) throws IOException {
+ try (var zis = new GZIPInputStream(new BufferedInputStream(Files.newInputStream(source)))) {
+ Files.copy(zis, target, StandardCopyOption.REPLACE_EXISTING);
}
}
- public static void decompressTarGz(Path sourcePath, Path targetPath) throws IOException {
- try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(sourcePath));
+ /**
+ * Decompresses a tar.gz file.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @throws IOException if an I/O error occurs
+ */
+ protected static void decompressTarGz(Path source, Path target) throws IOException {
+ try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(source));
var gzipInputStream = new GZIPInputStream(bufferedInputStream);
var tarInputStream = new TarArchiveInputStream(gzipInputStream)) {
TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
- var path = targetPath.resolve(entry.getName());
+ var path = target.resolve(entry.getName());
if (entry.isDirectory()) {
Files.createDirectories(path);
} else {
@@ -134,13 +203,20 @@ public class DecompressFile implements Task {
}
}
- public static void decompressTarBz2(Path sourcePath, Path targetPath) throws IOException {
- try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(sourcePath));
+ /**
+ * Decompresses a tar.bz2 file.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @throws IOException if an I/O error occurs
+ */
+ protected static void decompressTarBz2(Path source, Path target) throws IOException {
+ try (var bufferedInputStream = new BufferedInputStream(Files.newInputStream(source));
var bzip2InputStream = new BZip2CompressorInputStream(bufferedInputStream);
var tarInputStream = new TarArchiveInputStream(bzip2InputStream)) {
TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
- var path = targetPath.resolve(entry.getName());
+ var path = target.resolve(entry.getName());
if (entry.isDirectory()) {
Files.createDirectories(path);
} else {
@@ -158,12 +234,19 @@ public class DecompressFile implements Task {
}
}
- public static void decompressZip(Path sourcePath, Path targetPath) throws IOException {
- try (var zipFile = new ZipFile(sourcePath.toFile())) {
+ /**
+ * Decompresses a zip file.
+ *
+ * @param source the source file
+ * @param target the target file
+ * @throws IOException if an I/O error occurs
+ */
+ protected static void decompressZip(Path source, Path target) throws IOException {
+ try (var zipFile = new ZipFile(source.toFile())) {
var entries = zipFile.entries();
while (entries.hasMoreElements()) {
var entry = entries.nextElement();
- var path = targetPath.resolve(entry.getName());
+ var path = target.resolve(entry.getName());
Files.createDirectories(path.getParent());
Files.write(path, new byte[] {}, StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DownloadUrl.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DownloadUrl.java
index 3b7bd5b6..767de347 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DownloadUrl.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DownloadUrl.java
@@ -30,6 +30,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Downloads a file from a URL.
+ */
@JsonTypeName("DownloadUrl")
public class DownloadUrl implements Task {
@@ -47,12 +50,18 @@ public class DownloadUrl implements Task {
private Boolean replaceExisting;
+ /**
+ * Constructs an {@code DownloadUrl}.
+ */
public DownloadUrl() {}
- public DownloadUrl(String url, Path path) {
- this(url, path, false);
- }
-
+ /**
+ * Constructs an {@code DownloadUrl}.
+ *
+ * @param url the url
+ * @param path the path
+ * @param replaceExisting whether to replace existing files
+ */
public DownloadUrl(String url, Path path, boolean replaceExisting) {
this.url = url;
this.path = path;
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteCommand.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteCommand.java
index 6ccd6ddb..6d273a09 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteCommand.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteCommand.java
@@ -23,6 +23,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Execute a bash command.
+ */
@JsonTypeName("ExecuteCommand")
public class ExecuteCommand implements Task {
@@ -30,22 +33,44 @@ public class ExecuteCommand implements Task {
private String command;
+ /**
+ * Constructs an {@code ExecuteCommand}.
+ */
public ExecuteCommand() {}
+ /**
+ * Constructs an {@code ExecuteCommand}.
+ *
+ * @param command the bash command
+ */
public ExecuteCommand(String command) {
this.command = command;
}
+ /**
+ * Returns the bash command.
+ *
+ * @return the bash command
+ */
public String getCommand() {
return command;
}
+ /**
+ * Sets the bash command.
+ *
+ * @param command the bash command
+ */
public void setCommand(String command) {
this.command = command;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
new ProcessBuilder().command("/bin/sh", "-c", command).start().waitFor();
}
+
}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSql.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSql.java
index f405250c..96bb151e 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSql.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSql.java
@@ -30,6 +30,9 @@ import org.apache.baremaps.workflow.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Execute a SQL query (single statement).
+ */
@JsonTypeName("ExecuteSql")
public class ExecuteSql implements Task {
@@ -39,42 +42,85 @@ public class ExecuteSql implements Task {
private Path file;
- private boolean parallel;
+ private Boolean parallel;
+ /**
+ * Constructs an {@code ExecuteSql}.
+ */
public ExecuteSql() {
}
- public ExecuteSql(Object database, Path file, boolean parallel) {
+ /**
+ * Constructs an {@code ExecuteSql}.
+ *
+ * @param database the database
+ * @param file the SQL file
+ * @param parallel whether to execute the queries in parallel
+ */
+ public ExecuteSql(Object database, Path file, Boolean parallel) {
this.database = database;
this.file = file;
this.parallel = parallel;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the SQL file.
+ *
+ * @return the SQL file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the SQL file.
+ *
+ * @param file the SQL file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns whether to execute the queries in parallel.
+ *
+ * @return whether to execute the queries in parallel
+ */
public boolean isParallel() {
return parallel;
}
+ /**
+ * Sets whether to execute the queries in parallel.
+ *
+ * @param parallel whether to execute the queries in parallel
+ */
public void setParallel(boolean parallel) {
this.parallel = parallel;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var script = clean(Files.readString(file));
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSqlScript.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSqlScript.java
index e8b95e82..af8dff0d 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSqlScript.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExecuteSqlScript.java
@@ -27,6 +27,9 @@ import org.apache.baremaps.workflow.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Execute a SQL script (multiple statements).
+ */
@JsonTypeName("ExecuteSqlScript")
public class ExecuteSqlScript implements Task {
@@ -36,31 +39,63 @@ public class ExecuteSqlScript implements Task {
private Path file;
+ /**
+ * Constructs an {@code ExecuteSqlScript}.
+ */
public ExecuteSqlScript() {
}
+ /**
+ * Constructs an {@code ExecuteSqlScript}.
+ *
+ * @param database the database
+ * @param file the SQL file
+ */
public ExecuteSqlScript(Object database, Path file) {
this.database = database;
this.file = file;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the SQL file.
+ *
+ * @return the SQL file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the SQL file.
+ *
+ * @param file the SQL file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var script = Files.readString(file);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
index cf6c7202..7e54476a 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
@@ -44,6 +44,7 @@ import org.locationtech.jts.geom.Envelope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
@JsonTypeName("ExportVectorTiles")
public class ExportVectorTiles implements Task {
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightFeatures.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightFeatures.java
index ba00a255..d116e339 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightFeatures.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightFeatures.java
@@ -32,6 +32,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import daylight features.
+ */
@JsonTypeName("ImportDaylightFeatures")
public class ImportDaylightFeatures implements Task {
@@ -49,31 +52,63 @@ public class ImportDaylightFeatures implements Task {
private Object database;
+ /**
+ * Constructs an {@code ImportDaylightFeatures}.
+ */
public ImportDaylightFeatures() {
}
+ /**
+ * Constructs an {@code ImportDaylightFeatures}.
+ *
+ * @param file the daylight file
+ * @param database the database
+ */
public ImportDaylightFeatures(Path file, Object database) {
this.file = file;
this.database = database;
}
+ /**
+ * Returns the daylight file.
+ *
+ * @return the daylight file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the daylight file.
+ *
+ * @param file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the database.
+ *
+ * @return
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var datasource = context.getDataSource(database);
@@ -95,42 +130,33 @@ public class ImportDaylightFeatures implements Task {
case "node" -> {
var node = nodeRepository.get(feature.id());
if (node != null) {
- // Merge the tags
var tags = new HashMap<>(feature.tags());
if (node.getTags() != null) {
tags.putAll(node.getTags());
}
node.setTags(tags);
-
- // Update the node
nodeRepository.put(node);
}
}
case "way" -> {
var way = wayRepository.get(feature.id());
if (way != null) {
- // Merge the tags
var tags = new HashMap<>(feature.tags());
if (way.getTags() != null) {
tags.putAll(way.getTags());
}
way.setTags(tags);
-
- // Update the way
wayRepository.put(way);
}
}
case "relation" -> {
var relation = relationRepository.get(feature.id());
if (relation != null) {
- // Merge the tags
var tags = new HashMap<>(feature.tags());
if (relation.getTags() != null) {
tags.putAll(relation.getTags());
}
relation.setTags(tags);
-
- // Update the relation
relationRepository.put(relation);
}
}
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightTranslations.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightTranslations.java
index dc6dc619..93ef1b09 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightTranslations.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportDaylightTranslations.java
@@ -30,6 +30,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import daylight translations.
+ */
@JsonTypeName("ImportDaylightTranslations")
public class ImportDaylightTranslations implements Task {
@@ -61,31 +64,63 @@ public class ImportDaylightTranslations implements Task {
private Object database;
+ /**
+ * Constructs an {@code ImportDaylightTranslations}.
+ */
public ImportDaylightTranslations() {
}
+ /**
+ * Constructs an {@code ImportDaylightTranslations}.
+ *
+ * @param file the daylight file
+ * @param database the database
+ */
public ImportDaylightTranslations(Path file, Object database) {
this.file = file;
this.database = database;
}
+ /**
+ * Returns the daylight file.
+ *
+ * @return the daylight file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the daylight file.
+ *
+ * @param file the daylight file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var datasource = context.getDataSource(database);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
index 882f8548..c2e73f5a 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
@@ -30,6 +30,9 @@ import org.apache.baremaps.workflow.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import a GeoPackage into a database.
+ */
@JsonTypeName("ImportGeoPackage")
public class ImportGeoPackage implements Task {
@@ -40,10 +43,21 @@ public class ImportGeoPackage implements Task {
private Integer sourceSRID;
private Integer targetSRID;
+ /**
+ * Constructs an {@code ImportGeoPackage}.
+ */
public ImportGeoPackage() {
}
+ /**
+ * Constructs an {@code ImportGeoPackage}.
+ *
+ * @param file the GeoPackage file
+ * @param database the database
+ * @param sourceSRID the source SRID
+ * @param targetSRID the target SRID
+ */
public ImportGeoPackage(Path file, Object database, Integer sourceSRID, Integer targetSRID) {
this.file = file;
this.database = database;
@@ -51,38 +65,81 @@ public class ImportGeoPackage implements Task {
this.targetSRID = targetSRID;
}
+ /**
+ * Returns the GeoPackage file.
+ *
+ * @return the GeoPackage file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the GeoPackage file.
+ *
+ * @param file the GeoPackage file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the source SRID.
+ *
+ * @return the source SRID
+ */
public Integer getSourceSRID() {
return sourceSRID;
}
+ /**
+ * Sets the source SRID.
+ *
+ * @param sourceSRID the source SRID
+ */
public void setSourceSRID(Integer sourceSRID) {
this.sourceSRID = sourceSRID;
}
+ /**
+ * Returns the target SRID.
+ *
+ * @return the target SRID
+ */
public Integer getTargetSRID() {
return targetSRID;
}
+ /**
+ * Sets the target SRID.
+ *
+ * @param targetSRID the target SRID
+ */
public void setTargetSRID(Integer targetSRID) {
this.targetSRID = targetSRID;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var path = file.toAbsolutePath();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmOsc.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmOsc.java
index da65e523..045ce4c2 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmOsc.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmOsc.java
@@ -42,6 +42,9 @@ import org.locationtech.jts.geom.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import an OSM OSC file into a database.
+ */
@JsonTypeName("ImportOsmOsc")
public class ImportOsmOsc implements Task {
@@ -53,10 +56,22 @@ public class ImportOsmOsc implements Task {
private Integer srid;
private Compression compression;
+ /**
+ * Constructs an {@code ImportOsmOsc}.
+ */
public ImportOsmOsc() {
}
+ /**
+ * Constructs an {@code ImportOsmOsc}.
+ *
+ * @param file the OSM OSC file
+ * @param cache the cache directory
+ * @param database the database
+ * @param srid the database SRID
+ * @param compression the compression
+ */
public ImportOsmOsc(Path file, Path cache, Object database, Integer srid,
Compression compression) {
this.file = file;
@@ -66,46 +81,99 @@ public class ImportOsmOsc implements Task {
this.compression = compression;
}
+ /**
+ * Returns the OSM OSC file.
+ *
+ * @return the OSM OSC file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the OSM OSC file.
+ *
+ * @param file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the cache directory.
+ *
+ * @return the cache directory
+ */
public Path getCache() {
return cache;
}
+ /**
+ * Sets the cache directory.
+ *
+ * @param cache the cache directory
+ */
public void setCache(Path cache) {
this.cache = cache;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the database SRID.
+ *
+ * @return the database SRID
+ */
public Integer getSrid() {
return srid;
}
+ /**
+ * Sets the database SRID.
+ *
+ * @param srid the database SRID
+ */
public void setSrid(Integer srid) {
this.srid = srid;
}
+ /**
+ * Returns the compression.
+ *
+ * @return the compression
+ */
public Compression getCompression() {
return compression;
}
+ /**
+ * Sets the compression.
+ *
+ * @param compression the compression
+ */
public void setCompression(Compression compression) {
this.compression = compression;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var datasource = context.getDataSource(database);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java
index 8a14d78c..d996037c 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java
@@ -47,6 +47,9 @@ import org.locationtech.jts.geom.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import an OSM PBF file into a database.
+ */
@JsonTypeName("ImportOsmPbf")
public class ImportOsmPbf implements Task {
@@ -59,10 +62,23 @@ public class ImportOsmPbf implements Task {
private Integer databaseSrid;
private Boolean replaceExisting;
+ /**
+ * Constructs an {@code ImportOsmPbf}.
+ */
public ImportOsmPbf() {
}
+ /**
+ * Constructs an {@code ImportOsmPbf}.
+ *
+ * @param file the OSM PBF file
+ * @param cache the cache directory
+ * @param cleanCache whether to clean the cache directory
+ * @param database the database
+ * @param databaseSrid the database SRID
+ * @param replaceExisting whether to replace the existing tables
+ */
public ImportOsmPbf(Path file, Path cache, Boolean cleanCache, Object database,
Integer databaseSrid, Boolean replaceExisting) {
this.file = file;
@@ -73,54 +89,117 @@ public class ImportOsmPbf implements Task {
this.replaceExisting = replaceExisting;
}
+ /**
+ * Returns the OSM PBF file.
+ *
+ * @return the OSM PBF file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the OSM PBF file.
+ *
+ * @param file the OSM PBF file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the cache directory.
+ *
+ * @return the cache directory
+ */
public Path getCache() {
return cache;
}
+ /**
+ * Sets the cache directory.
+ *
+ * @param cache the cache directory
+ */
public void setCache(Path cache) {
this.cache = cache;
}
+ /**
+ * Returns whether to clean the cache directory.
+ *
+ * @return whether to clean the cache directory
+ */
public Boolean getCleanCache() {
return cleanCache;
}
+ /**
+ * Sets whether to clean the cache directory.
+ *
+ * @param cleanCache whether to clean the cache directory
+ */
public void setCleanCache(Boolean cleanCache) {
this.cleanCache = cleanCache;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the database SRID.
+ *
+ * @return the database SRID
+ */
public Integer getDatabaseSrid() {
return databaseSrid;
}
+ /**
+ * Sets the database SRID.
+ *
+ * @param databaseSrid the database SRID
+ */
public void setDatabaseSrid(Integer databaseSrid) {
this.databaseSrid = databaseSrid;
}
+ /**
+ * Returns whether to replace the existing tables.
+ *
+ * @return whether to replace the existing tables
+ */
public Boolean getReplaceExisting() {
return replaceExisting;
}
+ /**
+ * Sets whether to replace the existing tables.
+ *
+ * @param replaceExisting whether to replace the existing tables
+ */
public void setReplaceExisting(Boolean replaceExisting) {
this.replaceExisting = replaceExisting;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var dataSource = context.getDataSource(database);
@@ -189,6 +268,19 @@ public class ImportOsmPbf implements Task {
}
}
+ /**
+ * Imports an OSM PBF file into a database.
+ *
+ * @param path the OSM PBF file
+ * @param coordinateMap the coordinate map
+ * @param referenceMap the reference map
+ * @param headerRepository the header repository
+ * @param nodeRepository the node repository
+ * @param wayRepository the way repository
+ * @param relationRepository the relation repository
+ * @param databaseSrid the database SRID
+ * @throws IOException
+ */
public static void execute(
Path path,
DataMap<Long, Coordinate> coordinateMap,
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
index 5a68ce03..d67cad51 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
@@ -30,6 +30,9 @@ import org.apache.baremaps.workflow.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Import a shapefile into a database.
+ */
@JsonTypeName("ImportShapefile")
public class ImportShapefile implements Task {
@@ -40,10 +43,21 @@ public class ImportShapefile implements Task {
private Integer sourceSRID;
private Integer targetSRID;
+ /**
+ * Constructs an {@code ImportShapefile}.
+ */
public ImportShapefile() {
}
+ /**
+ * Constructs an {@code ImportShapefile}.
+ *
+ * @param file the shapefile file
+ * @param database the database
+ * @param sourceSRID the source SRID
+ * @param targetSRID the target SRID
+ */
public ImportShapefile(Path file, Object database, Integer sourceSRID, Integer targetSRID) {
this.file = file;
this.database = database;
@@ -51,38 +65,81 @@ public class ImportShapefile implements Task {
this.targetSRID = targetSRID;
}
+ /**
+ * Returns the shapefile file.
+ *
+ * @return the shapefile file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the shapefile file.
+ *
+ * @param file the shapefile file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the source SRID.
+ *
+ * @return the source SRID
+ */
public Integer getSourceSRID() {
return sourceSRID;
}
+ /**
+ * Sets the source SRID.
+ *
+ * @param sourceSRID the source SRID
+ */
public void setSourceSRID(Integer sourceSRID) {
this.sourceSRID = sourceSRID;
}
+ /**
+ * Returns the target SRID.
+ *
+ * @return the target SRID
+ */
public Integer getTargetSRID() {
return targetSRID;
}
+ /**
+ * Sets the target SRID.
+ *
+ * @param targetSRID the target SRID
+ */
public void setTargetSRID(Integer targetSRID) {
this.targetSRID = targetSRID;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var path = file.toAbsolutePath();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/LogMessage.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/LogMessage.java
index f57387bd..2261d3f6 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/LogMessage.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/LogMessage.java
@@ -23,6 +23,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Log a message.
+ */
@JsonTypeName("LogMessage")
public class LogMessage implements Task {
@@ -30,22 +33,43 @@ public class LogMessage implements Task {
private String message;
+ /**
+ * Constructs an {@code LogMessage}.
+ */
public LogMessage() {
}
+ /**
+ * Constructs an {@code LogMessage}.
+ *
+ * @param message the message
+ */
public LogMessage(String message) {
this.message = message;
}
+ /**
+ * Returns the message.
+ *
+ * @return the message
+ */
public String getMessage() {
return message;
}
+ /**
+ * Sets the message.
+ *
+ * @param message the message
+ */
public void setMessage(String message) {
this.message = message;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
logger.info(message);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UngzipFile.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UngzipFile.java
index cd9d3f8c..c34bcb1d 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UngzipFile.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UngzipFile.java
@@ -29,6 +29,9 @@ import org.apache.baremaps.workflow.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Ungzip a file.
+ */
@JsonTypeName("UngzipFile")
public class UngzipFile implements Task {
@@ -37,31 +40,63 @@ public class UngzipFile implements Task {
private Path file;
private Path directory;
+ /**
+ * Constructs an {@code UngzipFile}.
+ */
public UngzipFile() {
}
+ /**
+ * Constructs an {@code UngzipFile}.
+ *
+ * @param file the file
+ * @param directory the directory
+ */
public UngzipFile(Path file, Path directory) {
this.file = file;
this.directory = directory;
}
+ /**
+ * Returns the file.
+ *
+ * @return the file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the file.
+ *
+ * @param file the file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the directory.
+ *
+ * @return the directory
+ */
public Path getDirectory() {
return directory;
}
+ /**
+ * Sets the directory.
+ *
+ * @param directory the directory
+ */
public void setDirectory(Path directory) {
this.directory = directory;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var filePath = file.toAbsolutePath();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UnzipFile.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UnzipFile.java
index 4c95f599..02185a90 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UnzipFile.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UnzipFile.java
@@ -26,6 +26,9 @@ import org.apache.baremaps.workflow.WorkflowContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Unzip a file.
+ */
@JsonTypeName("UnzipFile")
public class UnzipFile implements Task {
@@ -34,31 +37,63 @@ public class UnzipFile implements Task {
private Path file;
private Path directory;
+ /**
+ * Constructs an {@code UnzipFile}.
+ */
public UnzipFile() {
}
+ /**
+ * Constructs an {@code UnzipFile}.
+ *
+ * @param file the file
+ * @param directory the directory
+ */
public UnzipFile(Path file, Path directory) {
this.file = file;
this.directory = directory;
}
+ /**
+ * Returns the file.
+ *
+ * @return the file
+ */
public Path getFile() {
return file;
}
+ /**
+ * Sets the file.
+ *
+ * @param file the file
+ */
public void setFile(Path file) {
this.file = file;
}
+ /**
+ * Returns the directory.
+ *
+ * @return the directory
+ */
public Path getDirectory() {
return directory;
}
+ /**
+ * Sets the directory.
+ *
+ * @param directory the directory
+ */
public void setDirectory(Path directory) {
this.directory = directory;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var filePath = file.toAbsolutePath();
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java
index b11e8449..9dce1563 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java
@@ -21,6 +21,9 @@ import static org.apache.baremaps.stream.ConsumerUtils.consumeThenReturn;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.io.BufferedInputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
import java.util.List;
import java.util.zip.GZIPInputStream;
import org.apache.baremaps.database.collection.DataMap;
@@ -47,6 +50,9 @@ import org.locationtech.jts.geom.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Update an OSM database based on the header data stored in the database.
+ */
@JsonTypeName("UpdateOsmDatabase")
public class UpdateOsmDatabase implements Task {
@@ -58,27 +64,56 @@ public class UpdateOsmDatabase implements Task {
private String replicationUrl;
+ /**
+ * Constructs an {@code UpdateOsmDatabase}.
+ */
public UpdateOsmDatabase() {
}
+ /**
+ * Constructs an {@code UpdateOsmDatabase}.
+ *
+ * @param database the database
+ * @param databaseSrid the database SRID
+ */
public UpdateOsmDatabase(Object database, Integer databaseSrid) {
this.database = database;
this.databaseSrid = databaseSrid;
}
+ /**
+ * Returns the database.
+ *
+ * @return the database
+ */
public Object getDatabase() {
return database;
}
+ /**
+ * Sets the database.
+ *
+ * @param database the database
+ */
public void setDatabase(Object database) {
this.database = database;
}
+ /**
+ * Returns the database SRID.
+ *
+ * @return the database SRID
+ */
public Integer getDatabaseSrid() {
return databaseSrid;
}
+ /**
+ * Sets the database SRID.
+ *
+ * @param databaseSrid the database SRID
+ */
public void setDatabaseSrid(Integer databaseSrid) {
this.databaseSrid = databaseSrid;
}
@@ -91,6 +126,9 @@ public class UpdateOsmDatabase implements Task {
this.replicationUrl = replicationUrl;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void execute(WorkflowContext context) throws Exception {
var datasource = context.getDataSource(database);
@@ -111,6 +149,18 @@ public class UpdateOsmDatabase implements Task {
replicationUrl);
}
+ /**
+ * Executes the task.
+ *
+ * @param coordinateMap the coordinate map
+ * @param referenceMap the reference map
+ * @param headerRepository the header repository
+ * @param nodeRepository the node repository
+ * @param wayRepository the way repository
+ * @param relationRepository the relation repository
+ * @param databaseSrid the SRID
+ * @throws Exception if something went wrong
+ */
public static void execute(DataMap<Long, Coordinate> coordinateMap,
DataMap<Long, List<Long>> referenceMap,
HeaderRepository headerRepository, Repository<Long, Node> nodeRepository,
@@ -160,4 +210,20 @@ public class UpdateOsmDatabase implements Task {
}
}
+ /**
+ * Returns the URL of the file with the given sequence number.
+ *
+ * @param replicationUrl the replication URL
+ * @param sequenceNumber the sequence number
+ * @param extension the file extension
+ * @return the URL of the file
+ * @throws MalformedURLException if the URL is malformed
+ */
+ public static URL resolve(String replicationUrl, Long sequenceNumber, String extension)
+ throws MalformedURLException {
+ var s = String.format("%09d", sequenceNumber);
+ var uri = String.format("%s/%s/%s/%s.%s", replicationUrl, s.substring(0, 3), s.substring(3, 6),
+ s.substring(6, 9), extension);
+ return URI.create(uri).toURL();
+ }
}
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/workflow/ObjectMapperTest.java b/baremaps-core/src/test/java/org/apache/baremaps/workflow/ObjectMapperTest.java
index 0bfd1dab..a754c92d 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/workflow/ObjectMapperTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/workflow/ObjectMapperTest.java
@@ -39,7 +39,7 @@ public class ObjectMapperTest {
new Step("download", List.of(),
List.of(new DownloadUrl(
"https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf",
- Paths.get("liechtenstein-latest.osm.pbf")))),
+ Paths.get("liechtenstein-latest.osm.pbf"), false))),
new Step("import", List.of("download"),
List.of(new ImportOsmPbf(Paths.get("liechtenstein-latest.osm.pbf"),
null,
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/workflow/WorkflowTest.java b/baremaps-core/src/test/java/org/apache/baremaps/workflow/WorkflowTest.java
index d52a27b6..c8ba01d8 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/workflow/WorkflowTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/workflow/WorkflowTest.java
@@ -37,7 +37,7 @@ class WorkflowTest extends PostgresContainerTest {
void naturalearthGeoPackage() {
var workflow = new Workflow(List.of(new Step("fetch-geopackage", List.of(), List.of(
new DownloadUrl("https://naciscdn.org/naturalearth/packages/natural_earth_vector.gpkg.zip",
- Paths.get("natural_earth_vector.gpkg.zip")),
+ Paths.get("natural_earth_vector.gpkg.zip"), false),
new UnzipFile(Paths.get("natural_earth_vector.gpkg.zip"),
Paths.get("natural_earth_vector")),
new ImportGeoPackage(Paths.get("natural_earth_vector/packages/natural_earth_vector.gpkg"),
@@ -52,7 +52,7 @@ class WorkflowTest extends PostgresContainerTest {
var workflow = new Workflow(List.of(new Step("fetch-geopackage", List.of(),
List.of(
new DownloadUrl("https://osmdata.openstreetmap.de/download/coastlines-split-4326.zip",
- Paths.get("coastlines-split-4326.zip")),
+ Paths.get("coastlines-split-4326.zip"), false),
new UnzipFile(Paths.get("coastlines-split-4326.zip"),
Paths.get("coastlines-split-4326")),
new ImportShapefile(Paths.get("coastlines-split-4326/coastlines-split-4326/lines.shp"),
@@ -84,7 +84,7 @@ class WorkflowTest extends PostgresContainerTest {
void workflow() {
var workflow = new Workflow(List.of(new Step("fetch-geopackage", List.of(), List.of(
new DownloadUrl("https://naciscdn.org/naturalearth/packages/natural_earth_vector.gpkg.zip",
- Paths.get("downloads/import_db.gpkg")),
+ Paths.get("downloads/import_db.gpkg"), false),
new ImportShapefile(Paths.get("downloads/import_db.gpkg"), jdbcUrl(), 4326, 3857)))));
new WorkflowExecutor(workflow).execute();
}
@@ -95,20 +95,20 @@ class WorkflowTest extends PostgresContainerTest {
var workflow = new Workflow(List.of(
new Step("fetch-geopackage", List.of(),
List.of(new DownloadUrl("https://tiles.baremaps.com/samples/import_db.gpkg",
- Paths.get("downloads/import_db.gpkg")))),
+ Paths.get("downloads/import_db.gpkg"), false))),
new Step("import-geopackage", List.of("fetch-geopackage"),
List.of(new ImportGeoPackage(Paths.get("downloads/import_db.gpkg"), jdbcUrl(), 4326,
3857))),
new Step("fetch-osmpbf", List.of(),
List.of(new DownloadUrl("https://tiles.baremaps.com/samples/liechtenstein.osm.pbf",
- Paths.get("downloads/liechtenstein.osm.pbf")))),
+ Paths.get("downloads/liechtenstein.osm.pbf"), false))),
new Step("import-osmpbf", List.of("fetch-osmpbf"),
List.of(new ImportOsmPbf(Paths.get("downloads/liechtenstein.osm.pbf"), null, true,
jdbcUrl(),
3857, true))),
new Step("fetch-shapefile", List.of(), List.of(new DownloadUrl(
"https://osmdata.openstreetmap.de/download/simplified-water-polygons-split-3857.zip",
- Paths.get("downloads/simplified-water-polygons-split-3857.zip")))),
+ Paths.get("downloads/simplified-water-polygons-split-3857.zip"), false))),
new Step("unzip-shapefile", List.of("fetch-shapefile"),
List.of(
new UnzipFile(Paths.get("downloads/simplified-water-polygons-split-3857.zip"),
@@ -116,7 +116,8 @@ class WorkflowTest extends PostgresContainerTest {
new Step("fetch-projection", List.of("unzip-shapefile"),
List.of(new DownloadUrl("https://spatialreference.org/ref/sr-org/epsg3857/prj/",
Paths.get(
- "archives/simplified-water-polygons-split-3857/simplified_water_polygons.prj")))),
+ "archives/simplified-water-polygons-split-3857/simplified_water_polygons.prj"),
+ false))),
new Step("import-shapefile", List.of("fetch-projection"),
List.of(new ImportShapefile(
Paths.get(
diff --git a/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/DownloadUrlTest.java b/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/DownloadUrlTest.java
index ac8c68b7..1c2526f1 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/DownloadUrlTest.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/DownloadUrlTest.java
@@ -49,7 +49,7 @@ class DownloadUrlTest {
var file = directory.resolve("file");
// TODO: do not use a 3rd party server, replaces test URL to a baremaps owned test resource.
var task = new DownloadUrl("ftp://whois.in.bell.ca/bell.db.gz",
- file);
+ file, false);
task.execute(new WorkflowContext());
assertTrue(file.toFile().length() > 50, "file is less than 50 bytes");
FileUtils.deleteRecursively(directory);
@@ -62,7 +62,7 @@ class DownloadUrlTest {
var file = directory.resolve("file");
assertThrows(IllegalArgumentException.class, () -> {
var task = new DownloadUrl("file://not-existing-file-243jhks",
- file);
+ file, false);
task.execute(new WorkflowContext());
}, "Unsupported protocol throws IOException");
FileUtils.deleteRecursively(directory);
@@ -74,7 +74,7 @@ class DownloadUrlTest {
var directory = Files.createTempDirectory("tmp_");
var file = directory.resolve("README.md");
var task = new DownloadUrl("https://raw.githubusercontent.com/baremaps/baremaps/main/README.md",
- file.toAbsolutePath());
+ file.toAbsolutePath(), false);
task.execute(new WorkflowContext());
assertTrue(Files.readString(file).contains("Baremaps"));
FileUtils.deleteRecursively(directory);