Class ImportTools


  • public class ImportTools
    extends Object
    • Constructor Detail

      • ImportTools

        public ImportTools()
    • 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 Exception
        Import 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,
                                      org.glassfish.jersey.media.multipart.FormDataContentDisposition fileMetaData)
                               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