Package de.narimo.georepo.server.tools
Class ImportTools
- java.lang.Object
-
- de.narimo.georepo.server.tools.ImportTools
-
public class ImportTools extends Object
-
-
Constructor Summary
Constructors Constructor Description ImportTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanCSVFile(File csvFile, String fromDelimiter, String toDelimiter, List<String> columnTypes, String decimalSep, String thousandsSep, String optLongitudeName, String optLatitudeName, String keepRowColumnName, String keepRowColumnValue)Do some cleaning operations on a csv file, using CSVReader.static FilegetRemoteCSVFile(javax.servlet.ServletContext ctx, String workspace, String remoteCSVUrl, boolean approved)Retrieve a file from a remote serverstatic voidimportFile(javax.servlet.ServletContext ctx, String layerTitle, String optColumnTypes, String workspace, File csvFile, String usedCSVDelimiter, String decimalSep, String thousandsSep, String optLongitudeName, String optLatitudeName, boolean approved, String keepRowColumnName, String keepRowColumnValue)Import file from a remote http(s) resource.static FilestoreInputFile(javax.servlet.ServletContext ctx, String workspace, InputStream fileInputStream, String storeFilename)Stores the received CSV file to the upload directory.static FileuploadFile(javax.servlet.ServletContext ctx, String workspace, InputStream fileInputStream, String filename)Upload a data file into geoserver upload dir.
-
-
-
Method Detail
-
importFile
public static void importFile(javax.servlet.ServletContext ctx, String layerTitle, String optColumnTypes, String workspace, File csvFile, String usedCSVDelimiter, String decimalSep, String thousandsSep, String optLongitudeName, String optLatitudeName, boolean approved, String keepRowColumnName, String keepRowColumnValue) throws ExceptionImport file from a remote http(s) resource.- Parameters:
ctx-layerTitle-optColumnTypes-workspace-remoteCSVUrl-usedCSVDelimiter-decimalSep-thousandsSep-optLongitudeName-optLatitudeName-approved-keepRowColumnName-keepRowColumnValue-- Throws:
Exception
-
getRemoteCSVFile
public static File getRemoteCSVFile(javax.servlet.ServletContext ctx, String workspace, String remoteCSVUrl, boolean approved) throws Exception
Retrieve a file from a remote server- Parameters:
ctx-workspace-remoteCSVUrl-fromDelimiter-toDelimiter-columnTypes-decimalSep-thousandsSep-optLongitudeName-optLatitudeName-approved-keepRowColumnName-keepRowColumnValue-- Returns:
- Throws:
Exception
-
uploadFile
public static File uploadFile(javax.servlet.ServletContext ctx, String workspace, InputStream fileInputStream, String filename) throws IOException
Upload a data file into geoserver upload dir. Be sure to only insert allowed file types, which are (geo)csv and shp currently.- Throws:
IOException
-
storeInputFile
public static File storeInputFile(javax.servlet.ServletContext ctx, String workspace, InputStream fileInputStream, String storeFilename) throws IOException
Stores the received CSV file to the upload directory.- Parameters:
ctx-workspace-fileInputStream-storeFilename-- Throws:
IOException
-
cleanCSVFile
public static void cleanCSVFile(File csvFile, String fromDelimiter, String toDelimiter, List<String> columnTypes, String decimalSep, String thousandsSep, String optLongitudeName, String optLatitudeName, String keepRowColumnName, String keepRowColumnValue) throws IOException
Do some cleaning operations on a csv file, using CSVReader. 1) remove @ in column names 2) change artificial delimiter -;;- to ; and escape correctly NOTE: Be aware on changes, this must fit to all CSV file, especially OSM Overpass files. Header names must be unique!- Parameters:
csvFile-fromDelimiter-toDelimiter-columnTypes-decimalSep-thousandsSep-optLongitudeName-optLatitudeName-- Throws:
IOException
-
-