Skip to content
Peat edited this page Jun 23, 2019 · 2 revisions

Welcome to the OHDMImportTool wiki!

This tool allows you to import Shapefiles into a cache database. The user can access the cached data to update the meta data of shapes like valid dates, the name or the classification of the shape.

Currently it is in a alpha stage, tested with shapefiles from OHM.

Requirements

To let it run on your system you need following things configured/installed:

  1. TomCat 9.X
  2. PGPASSWORD environment variable for the corresponding database
  3. MAVEN
  4. PostGIS

Shapefiles which are desired to be imported need the following files:

  1. Shapefile (.shp)
  2. (.shx)
  3. (.dbf)

HowTo Import

  1. Start the application (you can set it up manually or using your IDE by creating a configuration and letting it run)
  2. Call "localhost:8080" in your preferred browser.
  3. Zip the Shapefiles and its data, upload it using the UI.
  4. After a successful import the page will display a JSON containing a key (copy this!)
  5. Now go to localhost:8080/ShapeUpdate.html and insert the key into the textfield titled "key"
  6. Press "Get Shapes"

Now all shapes belonging to the key are displayed with their corresponding data, which can be updated using the "update" button beneath the map.

The internal process

Data model

To store the imported data two databases are used.

Temp

This database contains all the information of a uploaded ZIP-file containing the shapefile and its meta information. Each imported shapefile will have its own table. The key is

ImportedCache

This database contains the necessary data from the uploaded ZIP-file. It is transferred from the Temp-database.

Classes

Utility (de.htwb.model.utils)

  • Logger: designed to log (WIP)
  • Config: desired to load config files (WIP)
  • ImportResult: Is serialized and sent back to the client with the imported shapes from the cache

Model (de.htwb.model)

Database Repository (de.htwb.model.imported)

Resembles the connection and queries to the database.

Imported Shape (de.htwb.model.imported)

Describes an imported shape with data related to the whole project.

OHDM Model (de.htwb.model.ohdm)

These classes describe entities from the OHDM-Database. They are named like the entity they reflect.

Servlets (de.htwb.model.servlets)

These servlets are used to respond to client requests. These servlets are rather primitive, since no framework like Spring is being used. Mostly they respond with a JSON.

OHDMInformationServlet

Currently delivers just the existing OHDM-Classifications.

ShapeImportServlet

Servlet accepting requests to import ZIP-Files containing the shape.

ShapeUpdateServlet

Servlet accepting requests to update existing shapes in the imported cache database.

Shape Import (de.htwb.shpImport)

Shape Importer

Used to process the ZIP-File for importing shapes. It generates a temporary SQL-File using shp2psql from PostGIS which then is be used by psql to execute the generated SQL-File importing the shapes into the Temp-Database. Afterwards it transfers the necessary data to the ImportedCache-Database.

The Import process

Used endpoint: /ShapeImport

Accepts POST-Requests containing a ZIP-File (shapefile) and a username (username).

Servlet: ShapeImportServlet

Related classes:

  • ShapeImporter
  • DatabaseRepository
  • OHDM-Entity-Classes
  • ImportedShape
  1. User uploads a ZIP-file (containing shapefiles and its meta information)
  2. Crude validation
  3. Unzipping the file
  4. Creating a SQL file using shp2psql-Tool from PostGIS and generating a random target tablename
  5. Executing the SQL file using psql-Tool from PostGIS (this is what PGPASSWORD environment variable is needed for) 5.1 The imported shapes are then located in their own table in the Temp database
  6. Transferring the imported shapes from the Temp database into a table with the same table name in the ImportedCache database
  7. Responding the client with the generated random target table name

The Update process

Used Endpoint: /ShapeUpdate

Accepts POST-Requests containing following parameters:

  • JSON describing a ImportedShape
  • TableName (the table containing the shape)

Accepts GET-Requests with a tableKey-Parameter being the table name in the ImportedCache database, responding with all containing shapes.

Servlet: ShapeUpdateServlet

Related Servlet: OHDMInformationServlet

Related classes:

  • ImportedShape
  • DatabaseRepository
  • ImportResult

This servlet is used to update existing Shapes in the ImportedCache-Database.

  1. Calling the ShapeUpdate.html page will make a GET-Request to /OHDMInformation, receiving all existing classifications
  2. The User enters the key being the tablename in the ImportedCache, sends a GET-Request to /ShapeUpdate
  3. The servlet retrieves all data from the given tablename, responds it to the client
  4. All Shapes are being listed with a visualization of it on a OpenLayers Map
  5. Changing and POSTing data to the /ShapeUpdate endpoint will update the ImportedShape