From c14e80c7ef546f545af0ec5f3dc4fba3bff28efb Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Thu, 16 Nov 2017 11:07:43 +0100 Subject: [PATCH] Add GeoServerRESTImporter --- .../importer/GeoServerRESTImporter.java | 554 ++++++++++++++++++ .../GeoServerRESTImporterException.java | 43 ++ .../communication/AbstractRESTEntity.java | 21 + .../importer/communication/RESTAttribute.java | 68 +++ .../communication/RESTBoundingBox.java | 131 +++++ .../communication/RESTCoverageStore.java | 18 + .../importer/communication/RESTData.java | 109 ++++ .../communication/RESTDataDirectory.java | 19 + .../importer/communication/RESTDataFile.java | 51 ++ .../communication/RESTDataRemote.java | 37 ++ .../importer/communication/RESTDataStore.java | 67 +++ .../importer/communication/RESTImport.java | 140 +++++ .../communication/RESTImportTask.java | 175 ++++++ .../communication/RESTImportTaskList.java | 28 + .../importer/communication/RESTLayer.java | 226 +++++++ .../importer/communication/RESTStore.java | 70 +++ .../importer/communication/RESTStyle.java | 68 +++ .../importer/communication/RESTTarget.java | 26 + .../communication/RESTTargetDataStore.java | 49 ++ .../communication/RESTTargetWorkspace.java | 48 ++ .../importer/communication/RESTWorkspace.java | 50 ++ .../transform/RESTDateFormatTransform.java | 31 + .../transform/RESTGdalAddoTransform.java | 60 ++ .../transform/RESTGdalTranslateTransform.java | 51 ++ .../transform/RESTGdalWarpTransform.java | 48 ++ .../transform/RESTReprojectTransform.java | 84 +++ .../importer/transform/RESTTransform.java | 47 ++ .../transform/RESTTransformChain.java | 61 ++ 28 files changed, 2380 insertions(+) create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporter.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporterException.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/AbstractRESTEntity.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTAttribute.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTBoundingBox.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTCoverageStore.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTData.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataDirectory.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataFile.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataRemote.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataStore.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImport.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTask.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTaskList.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTLayer.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStore.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStyle.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTarget.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetDataStore.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetWorkspace.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTWorkspace.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTDateFormatTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalAddoTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalTranslateTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalWarpTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTReprojectTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransform.java create mode 100644 src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransformChain.java diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporter.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporter.java new file mode 100644 index 000000000..535efc605 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporter.java @@ -0,0 +1,554 @@ +package de.terrestris.shogun2.importer; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpException; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.log4j.Logger; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTData; +import de.terrestris.shogun2.importer.communication.RESTImport; +import de.terrestris.shogun2.importer.communication.RESTImportTask; +import de.terrestris.shogun2.importer.communication.RESTImportTaskList; +import de.terrestris.shogun2.importer.communication.RESTLayer; +import de.terrestris.shogun2.importer.communication.RESTTargetDataStore; +import de.terrestris.shogun2.importer.communication.RESTTargetWorkspace; +import de.terrestris.shogun2.importer.transform.RESTGdalAddoTransform; +import de.terrestris.shogun2.importer.transform.RESTGdalTranslateTransform; +import de.terrestris.shogun2.importer.transform.RESTGdalWarpTransform; +import de.terrestris.shogun2.importer.transform.RESTReprojectTransform; +import de.terrestris.shogun2.importer.transform.RESTTransform; +import de.terrestris.shogun2.util.http.HttpUtil; +import de.terrestris.shogun2.util.model.Response; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@Component +public class GeoServerRESTImporter { + + /** + * The Logger. + */ + private final static Logger LOG = Logger.getLogger(GeoServerRESTImporter.class); + + /** + * + */ + private String username; + + /** + * + */ + private String password; + + /** + * + */ + private ObjectMapper mapper = new ObjectMapper(); + + /** + * + */ + private URI baseUri; + + /** + * + */ + public GeoServerRESTImporter() { + + } + + /*** + * + * @param importerBaseURL + * @param defaultSRS + * @param username + * @param password + * @throws URISyntaxException + */ + public GeoServerRESTImporter(String importerBaseURL, String username, + String password) throws URISyntaxException { + if (StringUtils.isEmpty(importerBaseURL) || StringUtils.isEmpty(username) || + StringUtils.isEmpty(password)) { + LOG.error("Missing Constructor arguments. Could not create " + + "the GeoServerRESTImporter."); + } + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapper.setSerializationInclusion(Include.NON_NULL); + + this.username = username; + this.password = password; + + this.mapper = mapper; + this.baseUri = new URI(importerBaseURL); + } + + /** + * + * @param importJob + * @return + * @throws Exception + */ + public RESTImport createImportJob(String workSpaceName, String dataStoreName) + throws Exception { + RESTImport importJob = new RESTImport(); + + RESTTargetWorkspace targetWorkspace = new RESTTargetWorkspace(workSpaceName); + RESTTargetDataStore targetDataStore = new RESTTargetDataStore(dataStoreName, null); + + importJob.setTargetWorkspace(targetWorkspace); + importJob.setTargetStore(targetDataStore); + + Response httpResponse = HttpUtil.post( + this.addEndPoint(""), + this.asJSON(importJob), + ContentType.APPLICATION_JSON, + this.username, + this.password + ); + + if (httpResponse == null) { + throw new GeoServerRESTImporterException("Could not create import job in GeoServer."); + } + + RESTImport importResult = null; + try { + importResult = (RESTImport) this.asEntity(httpResponse.getBody(), RESTImport.class); + } catch (Exception e) { + if (httpResponse.getStatusCode() == HttpStatus.METHOD_NOT_ALLOWED) { + String msg = "Import job cannot be created, maybe the importer extension " + + "of GeoServer is not installed."; + LOG.debug(msg, e); + throw new GeoServerRESTImporterException(msg, e); + } + } + + return importResult; + } + + /** + * Creates an import job without target datastore (e.g. used for raster layers) + * + * @param workSpaceName + * @return + * @throws Exception + */ + public RESTImport createImportJob(String workSpaceName) throws Exception { + return createImportJob(workSpaceName, null); + } + + /** + * + * @param importJobId + * @param taskId + * @param transformTask + * @throws HttpException + * @throws URISyntaxException + */ + public boolean createReprojectTransformTask(Integer importJobId, Integer taskId, + String sourceSrs, String targetSrs) throws URISyntaxException, HttpException { + RESTReprojectTransform transformTask = new RESTReprojectTransform(); + if (StringUtils.isNotEmpty(sourceSrs)) { + transformTask.setSource(sourceSrs); + } + transformTask.setTarget(targetSrs); + + return createTransformTask(importJobId, taskId, transformTask); + } + + /** + * Create and append importer task for gdaladdo + * + * @param importJobId + * @param importTaskId + * @param opts + * @param levels + * @return + * @throws HttpException + * @throws URISyntaxException + */ + public boolean createGdalAddOverviewTask(Integer importJobId, Integer importTaskId, + List opts, List levels) throws URISyntaxException, HttpException { + RESTGdalAddoTransform transformTask = new RESTGdalAddoTransform(); + if (! opts.isEmpty()) { + transformTask.setOptions(opts); + } + if (! levels.isEmpty()) { + transformTask.setLevels(levels);; + } + return this.createTransformTask(importJobId, importTaskId, transformTask); + } + + /** + * Create and append importer task for gdalwarp + * + * @param importJobId + * @param importTaskId + * @param optsGdalWarp + * @return + * @throws HttpException + * @throws URISyntaxException + */ + public boolean createGdalWarpTask(Integer importJobId, Integer importTaskId, + List optsGdalWarp) throws URISyntaxException, HttpException { + RESTGdalWarpTransform transformTask = new RESTGdalWarpTransform(); + if (! optsGdalWarp.isEmpty()){ + transformTask.setOptions(optsGdalWarp); + } + return this.createTransformTask(importJobId, importTaskId, transformTask); + } + + /** + * Create and append importer task for gdal_translate + * + * @param importJobId + * @param importTaskId + * @param opts + * @return + * @throws HttpException + * @throws URISyntaxException + */ + public boolean createGdalTranslateTask(Integer importJobId, Integer importTaskId, + List optsGdalTranslate) throws URISyntaxException, HttpException { + RESTGdalTranslateTransform transformTask = new RESTGdalTranslateTransform(); + if (! optsGdalTranslate.isEmpty()){ + transformTask.setOptions(optsGdalTranslate); + } + return this.createTransformTask(importJobId, importTaskId, transformTask); + } + + /** + * + * @param importJobId + * @param file + * @return + * @throws Exception + */ + public RESTImportTaskList uploadFile(Integer importJobId, File file) throws Exception { + + // multipart POST + Response httpResponse = HttpUtil.post( + this.addEndPoint(importJobId + "/tasks"), + file, + this.username, + this.password + ); + + RESTImportTaskList importTaskLists = null; + // check, if it is a list of import tasks (for multiple layers) + try { + importTaskLists = mapper.readValue(httpResponse.getBody(), RESTImportTaskList.class); + LOG.info("Imported file "+ file.getName() + " contains data for multiple layers."); + } catch (Exception e) { + LOG.info("Imported file "+ file.getName() + " likely contains data for single " + + "layer. Will check this now."); + RESTImportTask helperTask = mapper.readValue(httpResponse.getBody(), RESTImportTask.class); + if (helperTask != null) { + importTaskLists = new RESTImportTaskList(); + importTaskLists.add(helperTask); + LOG.info("Imported file "+ file.getName() + " contains data for a single layers."); + } + } + return importTaskLists; + } + + /** + * Modify the "srs" definition of the target layer + * + * @param importJobId + * @param importTask + * @param sourceSrs + * + * @return + * @throws Exception + */ + public RESTLayer updateSrsForRESTImportTask(Integer importJobId, RESTImportTask importTask, + String sourceSrs) throws Exception { + Integer taskId = importTask.getId(); + + RESTLayer updatableLayer = new RESTLayer(); + updatableLayer.setSrs(sourceSrs); + + Response httpResponse = HttpUtil.put( + this.addEndPoint(importJobId + "/tasks/" + taskId + "/layer"), + this.asJSON(updatableLayer), + ContentType.APPLICATION_JSON, + this.username, + this.password + ); + + return (RESTLayer) this.asEntity(httpResponse.getBody(), RESTLayer.class); + } + + /** + * delete an importJob + * + * @param importJobId + * @return + * @throws HttpException + * @throws URISyntaxException + */ + public boolean deleteImportJob(Integer importJobId) throws URISyntaxException, HttpException{ + Response httpResponse = HttpUtil.delete( + this.addEndPoint(importJobId.toString()), + this.username, + this.password); + + return httpResponse.getStatusCode().equals(HttpStatus.NO_CONTENT); + } + + /** + * + * @param importJobId + * @return + * @throws UnsupportedEncodingException + * @throws URISyntaxException + * @throws HttpException + */ + public boolean runImportJob(Integer importJobId) throws + UnsupportedEncodingException, URISyntaxException, HttpException { + + LOG.debug("Run import for job " + importJobId); + + Response httpResponse = HttpUtil.post( + this.addEndPoint(Integer.toString(importJobId)), + this.username, + this.password + ); + + LOG.debug(""); + + if (httpResponse.getStatusCode().equals(HttpStatus.NO_CONTENT)) { + return true; + } else { + return false; + } + } + + /** + * + * @param importJobId + * @param taskId + * @return + * @throws Exception + */ + public RESTLayer getLayer(Integer importJobId, Integer taskId) throws Exception { + Response httpResponse = HttpUtil.get( + this.addEndPoint(importJobId + "/tasks/" + taskId + "/layer"), + this.username, + this.password + ); + + return (RESTLayer) this.asEntity(httpResponse.getBody(), RESTLayer.class); + } + + /** + * fetch all created Layers of import job + * + * @param importJobId + * @return + * @throws Exception + */ + public List getAllImportedLayers(Integer importJobId, List tasks) throws Exception { + ArrayList layers = new ArrayList(); + for (RESTImportTask task : tasks) { + + RESTImportTask refreshedTask = this.getRESTImportTask(importJobId, task.getId()); + if (refreshedTask.getState().equalsIgnoreCase("COMPLETE")){ + Response httpResponse = HttpUtil.get( + this.addEndPoint(importJobId + "/tasks/" + task.getId() + "/layer"), + this.username, + this.password + ); + RESTLayer layer = (RESTLayer) this.asEntity(httpResponse.getBody(), RESTLayer.class); + + if (layer != null) { + layers.add(layer); + } + } else if ((tasks.size() == 1) && refreshedTask.getState().equalsIgnoreCase("ERROR")) { + throw new GeoServerRESTImporterException(refreshedTask.getErrorMessage()); + } + } + return layers; + } + + /** + * + * @param importJobId + * @param taskId + * @return + * @throws Exception + */ + public RESTData getDataOfImportTask(Integer importJobId, Integer taskId) + throws Exception { + final DeserializationFeature unwrapRootValueFeature = DeserializationFeature.UNWRAP_ROOT_VALUE; + boolean unwrapRootValueFeatureIsEnabled = mapper.isEnabled(unwrapRootValueFeature); + + Response httpResponse = HttpUtil.get( + this.addEndPoint(importJobId + "/tasks/" + taskId + "/data"), + this.username, + this.password + ); + + // we have to disable the feature. otherwise deserialize would not work here + mapper.disable(unwrapRootValueFeature); + + final RESTData resultEntity = (RESTData) this.asEntity(httpResponse.getBody(), RESTData.class); + + if(unwrapRootValueFeatureIsEnabled) { + mapper.enable(unwrapRootValueFeature); + } + + return resultEntity; + } + + /** + * + * @param importJobId + * @param taskId + * @return + * @throws Exception + */ + public RESTImportTask getRESTImportTask(Integer importJobId, Integer taskId) throws + Exception { + Response httpResponse = HttpUtil.get( + this.addEndPoint(importJobId + "/tasks/" + taskId), + this.username, + this.password + ); + + return (RESTImportTask) this.asEntity(httpResponse.getBody(), RESTImportTask.class); + } + + /** + * + * @param importJobId + * @return + * @throws Exception + */ + public RESTImportTaskList getRESTImportTasks(Integer importJobId) throws Exception { + Response httpResponse = HttpUtil.get( + this.addEndPoint(importJobId + "/tasks/"), + this.username, + this.password + ); + return mapper.readValue(httpResponse.getBody(), RESTImportTaskList.class); + } + + /** + * Helper method to create an importer transformTask + * + * @param importJobId + * @param taskId + * @param transformTask + * @return + * @throws URISyntaxException + * @throws HttpException + */ + private boolean createTransformTask(Integer importJobId, Integer taskId, RESTTransform transformTask) + throws URISyntaxException, HttpException { + mapper.disable(SerializationFeature.WRAP_ROOT_VALUE); + Response httpResponse = HttpUtil.post( + this.addEndPoint(importJobId + "/tasks/" + taskId + "/transforms"), + this.asJSON(transformTask), + ContentType.APPLICATION_JSON, + this.username, + this.password + ); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + if (httpResponse.getStatusCode().equals(HttpStatus.CREATED)) { + return true; + } else { + return false; + } + } + + /** + * + * @param responseBody + * @param clazz + * @return + * @throws Exception + */ + private AbstractRESTEntity asEntity(byte[] responseBody, Class clazz) + throws Exception { + + AbstractRESTEntity entity = null; + + entity = (AbstractRESTEntity) mapper.readValue(responseBody, clazz); + + return entity; + } + + /** + * + * @param entity + * @return + */ + private String asJSON(Object entity) { + + String entityJson = null; + + try { + entityJson = this.mapper.writeValueAsString(entity); + } catch (Exception e) { + LOG.error("Could not parse as JSON: " + e.getMessage()); + } + + return entityJson; + } + + /** + * + * @param endPoint + * @return + * @throws URISyntaxException + */ + private URI addEndPoint(String endPoint) throws URISyntaxException { + + if (StringUtils.isEmpty(endPoint) || endPoint.equals("/")) { + return this.baseUri; + } + + if (this.baseUri.getPath().endsWith("/") || endPoint.startsWith("/")) { + endPoint = this.baseUri.getPath() + endPoint; + } else { + endPoint = this.baseUri.getPath() + "/" + endPoint; + } + + URI uri = null; + + URIBuilder builder = new URIBuilder(); + + builder.setScheme(this.baseUri.getScheme()); + builder.setHost(this.baseUri.getHost()); + builder.setPort(this.baseUri.getPort()); + builder.setPath(endPoint); + + uri = builder.build(); + return uri; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporterException.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporterException.java new file mode 100644 index 000000000..73e7292e7 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/GeoServerRESTImporterException.java @@ -0,0 +1,43 @@ +package de.terrestris.shogun2.importer; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class GeoServerRESTImporterException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * + */ + public GeoServerRESTImporterException() {} + + /** + * @param message + */ + public GeoServerRESTImporterException(String message) { + super(message); + } + + /** + * @param cause + */ + public GeoServerRESTImporterException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public GeoServerRESTImporterException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/AbstractRESTEntity.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/AbstractRESTEntity.java new file mode 100644 index 000000000..de57fe004 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/AbstractRESTEntity.java @@ -0,0 +1,21 @@ +package de.terrestris.shogun2.importer.communication; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public abstract class AbstractRESTEntity { + + /** + * Default constructor. + */ + public AbstractRESTEntity() { + + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTAttribute.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTAttribute.java new file mode 100644 index 000000000..48f2fb25c --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTAttribute.java @@ -0,0 +1,68 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTAttribute extends AbstractRESTEntity { + + /** + * + */ + private String name; + + /** + * + */ + private String binding; + + /** + * Default constructor. + */ + public RESTAttribute() { + + } + + /** + * + * @param name + * @param binding + */ + public RESTAttribute(String name, String binding) { + this.name = name; + this.binding = binding; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the binding + */ + public String getBinding() { + return binding; + } + + /** + * @param binding the binding to set + */ + public void setBinding(String binding) { + this.binding = binding; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTBoundingBox.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTBoundingBox.java new file mode 100644 index 000000000..4a596cc46 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTBoundingBox.java @@ -0,0 +1,131 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTBoundingBox extends AbstractRESTEntity { + + /** + * + */ + private String minx; + + /** + * + */ + private String miny; + + /** + * + */ + private String maxx; + + /** + * + */ + private String maxy; + + /** + * + */ + private String crs; + + /** + * Default constructor. + */ + public RESTBoundingBox() { + + } + + /** + * + * @param minx + * @param miny + * @param maxx + * @param maxy + * @param crs + */ + public RESTBoundingBox(String minx, String miny, String maxx, String maxy, + String crs) { + this.minx = minx; + this.miny = miny; + this.maxx = maxx; + this.maxy = maxy; + this.crs = crs; + } + + /** + * @return the minx + */ + public String getMinx() { + return minx; + } + + /** + * @param minx the minx to set + */ + public void setMinx(String minx) { + this.minx = minx; + } + + /** + * @return the miny + */ + public String getMiny() { + return miny; + } + + /** + * @param miny the miny to set + */ + public void setMiny(String miny) { + this.miny = miny; + } + + /** + * @return the maxx + */ + public String getMaxx() { + return maxx; + } + + /** + * @param maxx the maxx to set + */ + public void setMaxx(String maxx) { + this.maxx = maxx; + } + + /** + * @return the maxy + */ + public String getMaxy() { + return maxy; + } + + /** + * @param maxy the maxy to set + */ + public void setMaxy(String maxy) { + this.maxy = maxy; + } + + /** + * @return the crs + */ + public String getCrs() { + return crs; + } + + /** + * @param crs the crs to set + */ + public void setCrs(String crs) { + this.crs = crs; + } +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTCoverageStore.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTCoverageStore.java new file mode 100644 index 000000000..bc42bf514 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTCoverageStore.java @@ -0,0 +1,18 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.RESTDataStore; + +/** + * + * terrestris GmbH & Co. KG + * @author ahenn + * @date 01.04.2016 + * + */ +public class RESTCoverageStore extends RESTDataStore { + + public RESTCoverageStore() { + super(); + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTData.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTData.java new file mode 100644 index 000000000..ec6d7920c --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTData.java @@ -0,0 +1,109 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * A data is the description of the source data of a import (overall) or a + * task. In case the import has a global data definition, this normally refers + * to an aggregate store such as a directory or a database, and the data + * associated to the tasks refers to a single element inside such aggregation, + * such as a single file or table. + * + * A import can have a "data" representing the source of the data to be + * imported. The data can be of different types, in particular: "file", + * "directory", "mosaic", "database" and "remote". During the import + * initialization the importer will scan the contents of said resource, and + * generate import tasks for each data found in it. + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTData extends AbstractRESTEntity { + + /** + * + */ + private String type; + + /** + * + */ + private String format; + + /** + * + */ + private String file; + + /** + * + */ + private String location; + + /** + * Default constructor. + */ + public RESTData() { + + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the format + */ + public String getFormat() { + return format; + } + + /** + * @param format the format to set + */ + public void setFormat(String format) { + this.format = format; + } + + /** + * @return the file + */ + public String getFile() { + return file; + } + + /** + * @param file the file to set + */ + public void setFile(String file) { + this.file = file; + } + + /** + * + * @return + */ + public String getLocation() { + return location; + } + + /** + * + * @param location + */ + public void setLocation(String location) { + this.location = location; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataDirectory.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataDirectory.java new file mode 100644 index 000000000..105c7e1be --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataDirectory.java @@ -0,0 +1,19 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.RESTData; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTDataDirectory extends RESTData { + + /** + * + */ + @SuppressWarnings("unused") + private String location; + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataFile.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataFile.java new file mode 100644 index 000000000..f55c842be --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataFile.java @@ -0,0 +1,51 @@ +package de.terrestris.shogun2.importer.communication; + +import java.util.List; + +import de.terrestris.shogun2.importer.communication.RESTData; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTDataFile extends RESTData { + + /** + * + */ + @SuppressWarnings("unused") + private String format; + + /** + * + */ + @SuppressWarnings("unused") + private String location; + + /** + * + */ + @SuppressWarnings("unused") + private String file; + + /** + * + */ + @SuppressWarnings("unused") + private String href; + + /** + * + */ + @SuppressWarnings("unused") + private String prj; + + /** + * + */ + @SuppressWarnings("unused") + private List other; + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataRemote.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataRemote.java new file mode 100644 index 000000000..a42d5e863 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataRemote.java @@ -0,0 +1,37 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.RESTData; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTDataRemote extends RESTData { + + /** + * + */ + @SuppressWarnings("unused") + private String location; + + /** + * + */ + @SuppressWarnings("unused") + private String username; + + /** + * + */ + @SuppressWarnings("unused") + private String password; + + /** + * + */ + @SuppressWarnings("unused") + private String domain; + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataStore.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataStore.java new file mode 100644 index 000000000..83af3e7ff --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTDataStore.java @@ -0,0 +1,67 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTDataStore extends AbstractRESTEntity { + + /** + * + */ + private String name; + + /** + * + */ + private String type; + + /** + * Default constructor. + */ + public RESTDataStore() { + + } + + /** + * + * @param name + * @param type + */ + public RESTDataStore(String name, String type) { + this.name = name; + this.type = type; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImport.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImport.java new file mode 100644 index 000000000..e42750809 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImport.java @@ -0,0 +1,140 @@ +package de.terrestris.shogun2.importer.communication; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTData; +import de.terrestris.shogun2.importer.communication.RESTImportTask; +import de.terrestris.shogun2.importer.communication.RESTTargetDataStore; +import de.terrestris.shogun2.importer.communication.RESTTargetWorkspace; + +/** + * An import refers to the top level object and is a "session" like entity the + * state of the entire import. It maintains information relevant to the import + * as a whole such as user information, timestamps along with optional + * information that is uniform along all tasks, such as a target workspace, the + * shared input data (e.g. a directory, a database). An import is made of any + * number of task objects. + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonRootName(value = "import") +public class RESTImport extends AbstractRESTEntity { + + /** + * + */ + private Integer id; + + /** + * + */ + private String href; + + /** + * + */ + private String state; + + /** + * + */ + private RESTTargetWorkspace targetWorkspace; + + /** + * + */ + private RESTTargetDataStore targetStore; + + /** + * + */ + private RESTData data; + + /** + * + */ + private List importTasks; + + /** + * Default constructor. + */ + public RESTImport() { + + } + + /** + * @return the targetWorkspace + */ + public RESTTargetWorkspace getTargetWorkspace() { + return targetWorkspace; + } + + /** + * @param targetWorkspace the targetWorkspace to set + */ + public void setTargetWorkspace(RESTTargetWorkspace targetWorkspace) { + this.targetWorkspace = targetWorkspace; + } + + /** + * @return the targetStore + */ + public RESTTargetDataStore getTargetStore() { + return targetStore; + } + + /** + * @param targetStore the targetStore to set + */ + public void setTargetStore(RESTTargetDataStore targetStore) { + this.targetStore = targetStore; + } + + /** + * @return the data + */ + public RESTData getData() { + return data; + } + + /** + * @param data the data to set + */ + public void setData(RESTData data) { + this.data = data; + } + + /** + * @return the id + */ + public Integer getId() { + return id; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @return the state + */ + public String getState() { + return state; + } + + /** + * @return the importTasks + */ + public List getImportTasks() { + return importTasks; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTask.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTask.java new file mode 100644 index 000000000..b46951bf2 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTask.java @@ -0,0 +1,175 @@ +package de.terrestris.shogun2.importer.communication; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTData; +import de.terrestris.shogun2.importer.communication.RESTLayer; +import de.terrestris.shogun2.importer.communication.RESTTarget; +import de.terrestris.shogun2.importer.transform.RESTTransformChain; + + +/** + * A task represents a unit of work to the importer needed to register one + * new layer, or alter an existing one, and contains the following information: + * + * * The data being imported + * * The target store that is the destination of the import + * * The target layer + * * The data of a task, referred to as its source, is the data to be + * processed as part of the task. + * * The transformations that we need to apply to the data before it gets + * imported + * + * This data comes in a variety of forms including: + * + * * A spatial file (Shapefile, GeoTiff, KML, etc...) + * * A directory of spatial files + * * A table in a spatial database + * * A remote location that the server will download data from + * + * A task is classified as either “direct” or “indirect”. A direct task is one + * in which the data being imported requires no transformation to be imported. + * It is imported directly. An example of such a task is one that involves + * simply importing an existing Shapefile as is. An indirect task is one that + * does require a transformation to the original import data. An example of an + * indirect task is one that involves importing a Shapefile into an existing + * PostGIS database. Another example of indirect task might involve taking a + * CSV file as an input, turning a x and y column into a Point, remapping a + * string column into a timestamp, and finally import the result into a PostGIS. + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonRootName(value = "task") +public class RESTImportTask extends AbstractRESTEntity { + + /** + * + */ + private Integer id; + + /** + * + */ + private String href; + + /** + * + */ + private String state; + + /** + * + */ + private String updateMode; + + /** + * + */ + private RESTData data; + + /** + * + */ + private RESTTarget target; + + /** + * + */ + private String progress; + + /** + * + */ + private RESTLayer layer; + + /** + * + */ + private String errorMessage; + + /** + * + */ + private RESTTransformChain transformChain; + + /** + * Default constructor. + */ + public RESTImportTask() { + + } + + /** + * @return the id + */ + public Integer getId() { + return id; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @return the state + */ + public String getState() { + return state; + } + + /** + * @return the updateMode + */ + public String getUpdateMode() { + return updateMode; + } + + /** + * @return the data + */ + public RESTData getData() { + return data; + } + + /** + * @return the target + */ + public RESTTarget getTarget() { + return target; + } + + /** + * @return the progress + */ + public String getProgress() { + return progress; + } + + /** + * @return the layer + */ + public RESTLayer getLayer() { + return layer; + } + + /** + * @return the errorMessage + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * @return the transformChain + */ + public RESTTransformChain getTransformChain() { + return transformChain; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTaskList.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTaskList.java new file mode 100644 index 000000000..d5f428035 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTImportTaskList.java @@ -0,0 +1,28 @@ +package de.terrestris.shogun2.importer.communication; + +import java.util.ArrayList; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.RESTImportTask; + +/** + * + * terrestris GmbH & Co. KG + * @author ahenn + * @date 15.04.2016 + * + */ +@JsonRootName("tasks") +public class RESTImportTaskList extends ArrayList { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public RESTImportTaskList(){ + + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTLayer.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTLayer.java new file mode 100644 index 000000000..f50d3a562 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTLayer.java @@ -0,0 +1,226 @@ +package de.terrestris.shogun2.importer.communication; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTAttribute; +import de.terrestris.shogun2.importer.communication.RESTBoundingBox; +import de.terrestris.shogun2.importer.communication.RESTStyle; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonRootName(value = "layer") +public class RESTLayer extends AbstractRESTEntity { + + /** + * + */ + private String name; + + /** + * + */ + private String href; + + /** + * + */ + private String title; + + /** + * + */ + private String originalName; + + /** + * + */ + private String nativeName; + + /** + * + */ + private String srs; + + /** + * + */ + private RESTBoundingBox bbox; + + /** + * + */ + private List attributes; + + /** + * + */ + private RESTStyle style; + + /** + * Default constructor. + */ + public RESTLayer() { + + } + + /** + * + * @param name + * @param href + * @param title + * @param originalName + * @param nativeName + * @param srs + * @param bbox + * @param attributes + * @param style + */ + public RESTLayer(String name, String href, String title, + String originalName, String nativeName, String srs, + RESTBoundingBox bbox, List attributes, + RESTStyle style) { + this.name = name; + this.href = href; + this.title = title; + this.originalName = originalName; + this.nativeName = nativeName; + this.srs = srs; + this.bbox = bbox; + this.attributes = attributes; + this.style = style; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @param href the href to set + */ + public void setHref(String href) { + this.href = href; + } + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * @param title the title to set + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return the originalName + */ + public String getOriginalName() { + return originalName; + } + + /** + * @param originalName the originalName to set + */ + public void setOriginalName(String originalName) { + this.originalName = originalName; + } + + /** + * @return the nativeName + */ + public String getNativeName() { + return nativeName; + } + + /** + * @param nativeName the nativeName to set + */ + public void setNativeName(String nativeName) { + this.nativeName = nativeName; + } + + /** + * @return the srs + */ + public String getSrs() { + return srs; + } + + /** + * @param srs the srs to set + */ + public void setSrs(String srs) { + this.srs = srs; + } + + /** + * @return the bbox + */ + public RESTBoundingBox getBbox() { + return bbox; + } + + /** + * @param bbox the bbox to set + */ + public void setBbox(RESTBoundingBox bbox) { + this.bbox = bbox; + } + + /** + * @return the attributes + */ + public List getAttributes() { + return attributes; + } + + /** + * @param attributes the attributes to set + */ + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + /** + * @return the style + */ + public RESTStyle getStyle() { + return style; + } + + /** + * @param style the style to set + */ + public void setStyle(RESTStyle style) { + this.style = style; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStore.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStore.java new file mode 100644 index 000000000..4783a2b0e --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStore.java @@ -0,0 +1,70 @@ +package de.terrestris.shogun2.importer.communication; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/*** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonRootName(value = "dataStore") +public class RESTStore extends AbstractRESTEntity{ + + /** + * + */ + private String name; + + /** + * + */ + private String type; + + /** + * Default constructor. + */ + public RESTStore() { + + } + + /** + * + * @param name + */ + public RESTStore(String name) { + super(); + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStyle.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStyle.java new file mode 100644 index 000000000..4218ab5a6 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTStyle.java @@ -0,0 +1,68 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTStyle extends AbstractRESTEntity { + + /** + * + */ + private String name; + + /** + * + */ + private String href; + + /** + * Default constructor. + */ + public RESTStyle() { + + } + + /** + * + * @param name + * @param href + */ + public RESTStyle(String name, String href) { + this.name = name; + this.href = href; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @param href the href to set + */ + public void setHref(String href) { + this.href = href; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTarget.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTarget.java new file mode 100644 index 000000000..a5143c2cf --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTarget.java @@ -0,0 +1,26 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTDataStore; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTTarget extends AbstractRESTEntity { + + /** + * + */ + @SuppressWarnings("unused") + private String href; + + /** + * + */ + @SuppressWarnings("unused") + private RESTDataStore dataStore; + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetDataStore.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetDataStore.java new file mode 100644 index 000000000..b549a75f1 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetDataStore.java @@ -0,0 +1,49 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTDataStore; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTTargetDataStore extends AbstractRESTEntity { + + /** + * + */ + private RESTDataStore dataStore; + + /** + * Default constructor. + */ + public RESTTargetDataStore() { + + } + + /** + * + * @param name + * @param type + */ + public RESTTargetDataStore(String name, String type) { + this.dataStore = new RESTDataStore(name, type); + } + + /** + * @return the dataStore + */ + public RESTDataStore getDataStore() { + return dataStore; + } + + /** + * @param dataStore the dataStore to set + */ + public void setDataStore(RESTDataStore dataStore) { + this.dataStore = dataStore; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetWorkspace.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetWorkspace.java new file mode 100644 index 000000000..2fe1dd855 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTTargetWorkspace.java @@ -0,0 +1,48 @@ +package de.terrestris.shogun2.importer.communication; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; +import de.terrestris.shogun2.importer.communication.RESTWorkspace; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTTargetWorkspace extends AbstractRESTEntity { + + /** + * + */ + private RESTWorkspace workspace; + + /** + * Default constructor. + */ + public RESTTargetWorkspace() { + + } + + /** + * + * @param name + */ + public RESTTargetWorkspace(String name) { + this.workspace = new RESTWorkspace(name); + } + + /** + * @return the workspace + */ + public RESTWorkspace getWorkspace() { + return workspace; + } + + /** + * @param workspace the workspace to set + */ + public void setWorkspace(RESTWorkspace workspace) { + this.workspace = workspace; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTWorkspace.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTWorkspace.java new file mode 100644 index 000000000..bc6a1ded4 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/communication/RESTWorkspace.java @@ -0,0 +1,50 @@ +package de.terrestris.shogun2.importer.communication; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +@JsonRootName(value = "workspace") +public class RESTWorkspace extends AbstractRESTEntity { + + /** + * + */ + private String name; + + /** + * Default constructor. + */ + public RESTWorkspace() { + + } + + /** + * + * @param name + */ + public RESTWorkspace(String name) { + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTDateFormatTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTDateFormatTransform.java new file mode 100644 index 000000000..a46bab258 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTDateFormatTransform.java @@ -0,0 +1,31 @@ +package de.terrestris.shogun2.importer.transform; + +import de.terrestris.shogun2.importer.transform.RESTTransform; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTDateFormatTransform extends RESTTransform { + + /** + * + */ + @SuppressWarnings("unused") + private String href; + + /** + * + */ + @SuppressWarnings("unused") + private String field; + + /** + * + */ + @SuppressWarnings("unused") + private String format; + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalAddoTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalAddoTransform.java new file mode 100644 index 000000000..d6ddb96b9 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalAddoTransform.java @@ -0,0 +1,60 @@ +package de.terrestris.shogun2.importer.transform; + +import java.util.List; + +import de.terrestris.shogun2.importer.transform.RESTTransform; + +/** + * + * terrestris GmbH & Co. KG + * @author ahenn + * @date 01.04.2016 + * + * Task performing gdaladdo which builds or rebuilds overview images. + * @see GDAL (gdaladdo) documentation + * Requires gdaladdo to be inside the PATH used by the web container running GeoServer. + */ +public class RESTGdalAddoTransform extends RESTTransform { + + public static final String TYPE_NAME = "GdalAddoTransform"; + + private List options; + private List levels; + + /** + * Default constructor; sets type of + * {@link RESTTransform} to "GdalAddoTransform" + */ + public RESTGdalAddoTransform() { + super(TYPE_NAME); + } + + /** + * @return the options + */ + public List getOptions() { + return options; + } + + /** + * @param options the options to set + */ + public void setOptions(List options) { + this.options = options; + } + + /** + * @return the levels + */ + public List getLevels() { + return levels; + } + + /** + * @param levels the levels to set + */ + public void setLevels(List levels) { + this.levels = levels; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalTranslateTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalTranslateTransform.java new file mode 100644 index 000000000..f34f6db89 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalTranslateTransform.java @@ -0,0 +1,51 @@ +/** + * + */ +package de.terrestris.shogun2.importer.transform; + +import java.util.List; + +import de.terrestris.shogun2.importer.transform.RESTTransform; + +/** + * terrestris GmbH & Co. KG + * @author ahenn + * @date 01.04.2016 + * + * Importer transform task representing gdal_translate, a tool which converts + * raster data between different formats + * @see GDAL (gdal_translate) documentation + * Requires gdal_translate to be inside the PATH used by the web container running GeoServer. + */ +public class RESTGdalTranslateTransform extends RESTTransform { + + /** + * + */ + public static final String TYPE_NAME = "GdalTranslateTransform"; + + private List options; + + /** + * Default constructor; sets type of + * {@link RESTTransform} to "GdalTranslateTransform" + */ + public RESTGdalTranslateTransform() { + super(TYPE_NAME); + } + + /** + * @return the options + */ + public List getOptions() { + return options; + } + + /** + * @param options the options to set + */ + public void setOptions(List options) { + this.options = options; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalWarpTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalWarpTransform.java new file mode 100644 index 000000000..a16bf78ab --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTGdalWarpTransform.java @@ -0,0 +1,48 @@ +package de.terrestris.shogun2.importer.transform; + +import java.util.List; + +import de.terrestris.shogun2.importer.transform.RESTTransform; + +/** + * + * terrestris GmbH & Co. KG + * @author ahenn + * @date 01.04.2016 + * + * Importer transform task representing gdalwarp, an image reprojection and warping utility, + * @see GDAL (gdalwarp) documentation + * Requires gdalwarp to be inside the PATH used by the web container running GeoServer. + */ +public class RESTGdalWarpTransform extends RESTTransform { + + /** + * + */ + public static final String TYPE_NAME = "GdalWarpTransform"; + + private List options; + + /** + * Default constructor; sets type of + * {@link RESTTransform} to "GdalWarpTransform" + */ + public RESTGdalWarpTransform() { + super(TYPE_NAME); + } + + /** + * @return the options + */ + public List getOptions() { + return options; + } + + /** + * @param options the options to set + */ + public void setOptions(List options) { + this.options = options; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTReprojectTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTReprojectTransform.java new file mode 100644 index 000000000..604d6c375 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTReprojectTransform.java @@ -0,0 +1,84 @@ +package de.terrestris.shogun2.importer.transform; + +import de.terrestris.shogun2.importer.transform.RESTTransform; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +//@JsonRootName +public class RESTReprojectTransform extends RESTTransform { + + /** + * constant field for transform type name + */ + public static final String TYPE_NAME = "ReprojectTransform"; + + /** + * + */ + private String href; + + /** + * + */ + private String source; + + /** + * + */ + private String target; + + /** + * Default constructor; sets type of + * {@link RESTTransform} to "ReprojectTransform" + */ + public RESTReprojectTransform() { + super(TYPE_NAME); + } + + /** + * @return the source + */ + public String getSource() { + return source; + } + + /** + * @param source the source to set + */ + public void setSource(String source) { + this.source = source; + } + + /** + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * @param target the target to set + */ + public void setTarget(String target) { + this.target = target; + } + + /** + * @return the href + */ + public String getHref() { + return href; + } + + /** + * @param href the href to set + */ + public void setHref(String href) { + this.href = href; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransform.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransform.java new file mode 100644 index 000000000..3fe6ab7e1 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransform.java @@ -0,0 +1,47 @@ +package de.terrestris.shogun2.importer.transform; + +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTTransform extends AbstractRESTEntity { + + /** + * + */ + private String type; + + /** + * Default constructor + */ + public RESTTransform() { + + } + + /** + * + * @param type + */ + public RESTTransform(String type) { + this.type = type; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransformChain.java b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransformChain.java new file mode 100644 index 000000000..c3ff76521 --- /dev/null +++ b/src/shogun2-core/src/main/java/de/terrestris/shogun2/importer/transform/RESTTransformChain.java @@ -0,0 +1,61 @@ +package de.terrestris.shogun2.importer.transform; + +import java.util.List; + +import de.terrestris.shogun2.importer.transform.RESTTransform; +import de.terrestris.shogun2.importer.communication.AbstractRESTEntity; + +/** + * + * @author Daniel Koch + * @author terrestris GmbH & Co. KG + * + */ +public class RESTTransformChain extends AbstractRESTEntity { + + /** + * + */ + private String type; + + /** + * + */ + private List transforms; + + /** + * Default constructor. + */ + public RESTTransformChain() { + + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @return the transforms + */ + public List getTransforms() { + return transforms; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @param transforms the transforms to set + */ + public void setTransforms(List transforms) { + this.transforms = transforms; + } + +}