Mercurial > dive4elements > river
changeset 2877:f0a67bc0e777 2.7
merged flys-backend/2.7
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:31 +0200 |
parents | 6310b1582f2d (current diff) d3438e271b3c (diff) |
children | 3cda41b5eb23 |
files | |
diffstat | 194 files changed, 28131 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/ChangeLog Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,3081 @@ +2012-05-27 Ingo Weinzierl <ingo@intevation.de> + + * Tagged module as '2.7'. + +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/BedHeightEpoch.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added lower + and upper km to function that returns all singles and epochs for a given + river. + +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/BedHeightSingleValue.java: Fixed + a typo. + +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/BedHeightSingleValue.java, + src/main/java/de/intevation/flys/model/BedHeightEpochValue.java: Added + functions to retrieve single and epoch values based on its owner and km + range. + +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/BedHeightEpoch.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added + functions to get singles and epochs by river and by id. + +2012-05-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/FlowVelocityModel.java, + src/main/java/de/intevation/flys/model/FlowVelocityModelValue.java, + src/main/java/de/intevation/flys/model/DischargeZone.java: Added static + functions to retrieve data from database. + +2012-05-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/DischargeZone.java: Added a + function getDischargeZones() that returns all DischargeZones for a given + river. + +2012-05-10 Ingo Weinzierl <ingo@intevation.de> + + * contrib/shpimporter/gauges.py: Search for field 'MPNAAM' and use its + value as name for the geometry. + + * src/main/java/de/intevation/flys/model/GaugeLocation.java: New model + class for storing locations of gauges. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered GaugeLocation class. + +2012-05-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/HydrBoundary.java, + src/main/java/de/intevation/flys/model/HydrBoundaryPoly.java: New. + Hydrological boundaries. + + * src/main/java/de/intevation/flys/model/Line.java: Modified signature of + Line.getLines(). It now also takes the name of a line to retrieve more + specific lines. + + * src/main/java/de/intevation/flys/model/Building.java: Modified signature + of Building.getBuildings(). It now also takes the name of a building to + retrieve more specific lines. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered HydrBoundary and HydrBoundaryPoly classes. + +2012-05-10 Ingo Weinzierl <ingo@intevation.de> + + * contrib/shpimporter/crosssectiontracks.py: Search for 'STATION' field in + shapefile to extract the current km. + +2012-05-08 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Hws.java: The getHws() function + got a further parameter 'name' to retrieve specific hws only. + + +2012-05-08 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Catchment.java: The + getCatchments() function got a further parameter 'name' to retrieve + specific catchments only. + +2012-05-08 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-spatial_idx.sql: Set the geometry type of 'catchments' + to 'multipolygon'. + + * src/main/java/de/intevation/flys/model/Catchment.java: The geometry + attribute in such instances is now from type 'Geometry'. + +2012-05-08 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/import-dems.sql: New. Insert statements to insert dems into + database. + +2012-05-04 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-drop-spatial.sql, + doc/schema/oracle-spatial.sql: New relation 'gauge_location' and some + bugfixes in the drop schema. + + * contrib/shpimporter/catchments.py, + contrib/shpimporter/hws.py, + contrib/shpimporter/gauges.py: New importers. + + * contrib/shpimporter/importer.py: Added a debug statement to improve the + visibility of the log output. + + * contrib/shpimporter/shpimporter.py: Make use of the new importers. + + +2012-05-03 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-drop-spatial.sql, + doc/schema/oracle-spatial.sql: Added new relations for hydrological + boundaries and appended a 'name' field to relations that had no such + field yet. + + * contrib/shpimporter/floodplains.py, + contrib/shpimporter/boundaries.py: New importers for floodplain and + hydrological boundaries. + + * contrib/shpimporter/lines.py, + contrib/shpimporter/buildings.py, + contrib/shpimporter/uesg.py, + contrib/shpimporter/fixpoints.py, + contrib/shpimporter/axis.py, + contrib/shpimporter/crosssectiontracks.py, + contrib/shpimporter/km.py: Set the 'name' attribute for new features. + + * contrib/shpimporter/importer.py: Some bugfixes and improvements: + geometries are transformed into a destination coordinate system now. + + * contrib/shpimporter/shpimporter.py: Use all importers and defined the + destination srs. + +2012-05-02 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/FastCrossSectionLine.java, + src/main/java/de/intevation/flys/model/CrossSectionPoint.java, + src/main/java/de/intevation/flys/model/CrossSectionLine.java, + src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Store meassure points of profiles as Doubles not as BigDecimal. + This should save a lot of memory during the import. + +2012-04-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java: + Removed superfluous imports. + +2012-04-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql-minfo.sql: Adjusted PostgreSQL port + to match the Oracle schema. + +2012-04-27 Ingo Weinzierl <ingo@intevation.de> + + * doc/annotation-types.xml: Adapted annotation typed based on BfG wishes. + +2012-04-27 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-drop.sql: New SQL file to drop WINFO specific db + schema. + +2012-04-27 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle.sql: Made SQL instructions upper case. + +2012-04-27 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-drop-spatial.sql: New statements to drop the whole + spatial schema. + +2012-04-27 Ingo Weinzierl <ingo@intevation.de> + + * contrib/shpimporter/lines.py, + contrib/shpimporter/buildings.py, + contrib/shpimporter/importer.py, + contrib/shpimporter/fixpoints.py, + contrib/shpimporter/axis.py, + contrib/shpimporter/crosssectiontracks.py, + contrib/shpimporter/km.py: New classes for importing specific + shapefiles. Each of this imports defines its target db tablename and a + directory path to the shapefiles it should import. + + * contrib/shpimporter/uesg.py: Some modifications necessary to streamline + the import process of shapefiles. + + * contrib/shpimporter/shpimporter.py: Use all available imports for the + import process. + +2012-04-26 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-spatial.sql: Repaired broken schema. + +2012-04-26 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added a config + option to skip parsing MINFO waterlevel differences: + + -Dflys.backend.importer.skip.waterlevel.differences=True + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Parse and + store MINFO specific waterlevel differences. + +2012-04-26 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/WaterlevelDifferencesParser.java: + New parser for MINFO specific waterlevel differences. + + * src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceValue.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelDifference.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelDifferenceColumn.java: + New importer classes used during the import process of MINFO specific + waterlevel differences. + +2012-04-26 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added a missing constraint to + 'waterlevel_difference' relation. Remove that constraint in + oracle-drop-minfo.sql. + +2012-04-25 Felix Wolfsteller <felix@intevation.de> + + * src/main/java/de/intevation/flys/model/WaterlevelDifferenceValue.java: + (setValue, setValues): Change setter name to allow hibernate to recognize + it. + +2012-04-24 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/WaterlevelDifferenceColumn.java, + src/main/java/de/intevation/flys/model/WaterlevelDifference.java, + src/main/java/de/intevation/flys/model/WaterlevelDifferenceValue.java: + New model classes for MINFO specific waterlevel differences. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model classes. + +2012-04-24 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Improved the schema to store MINFO + specific waterlevel differences. + +2012-04-24 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/WaterlevelValue.java: Renamed a + property ('qRange' -> 'qrange') because there have been problem during the + import. + + * src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java: + Filled the stub with code. + + * src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelQRange.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevel.java: Some + adaptions and missing methods which are required during the import. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Use the + correct directory to search for waterlevel files. + +2012-04-24 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql: Small type adaptions in the waterlevel_values + relation. + + * src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java: + First stub of a parser for MINFO specific waterlevel values. + + * src/main/java/de/intevation/flys/importer/Config.java: Added a new config + option to skip parsing MINFO specifc waterlevel_values: + + -Dflys.backend.importer.skip.waterlevels=True + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Added code + path to start parsing and storing MINFO specific waterlevel values. + +2012-04-20 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevelQRange.java, + src/main/java/de/intevation/flys/importer/ImportWaterlevel.java: New + importer classes used for MINFO specific waterlevel import. + +2012-04-20 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/WaterlevelQRange.java, + src/main/java/de/intevation/flys/model/WaterlevelValue.java, + src/main/java/de/intevation/flys/model/Waterlevel.java: New model + classes for MINFO specific waterlevel data. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model classes. + +2012-04-20 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added relations for waterlevels + specific to MINFO. Note: those waterlevel values are not stored in the + WINFO specific relations! + +2012-04-19 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + src/main/java/de/intevation/flys/importer/ImportSedimentYield.java, + src/main/java/de/intevation/flys/model/SedimentYield.java: Added a + column 'description' to the sediment_yield relation. + + * src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java: + New parser for sediment yield data. + + * src/main/java/de/intevation/flys/model/GrainFraction.java: Added constants + that represent the names of the grain fraction types. + + * src/main/java/de/intevation/flys/importer/ImportGrainFraction.java: New + constructor that takes a name only. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Improved the + process of parsing sediment yield files. + +2012-04-19 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added new config + option to skip parsing sediment yield data: + + -Dflys.backend.importer.skip.sediment.yield=true + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Prepared the + importer to parse sediment yield data. + + * src/main/java/de/intevation/flys/importer/ImportSedimentYield.java: + storeDependencies() now throws SQLExceptions and + ConstraintViolationExceptions. + +2012-04-19 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportGrainFraction.java, + src/main/java/de/intevation/flys/importer/ImportSedimentYieldValue.java, + src/main/java/de/intevation/flys/importer/ImportSedimentYield.java: New + importer classes for importing sediment yield data. + +2012-04-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/SedimentYield.java, + src/main/java/de/intevation/flys/model/SedimentYieldValue.java, + src/main/java/de/intevation/flys/model/GrainFraction.java: New model + classes for sediment yield data. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model classes. + +2012-04-18 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added missing river_id column to + sediment_yield relation. + +2012-04-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Floodmaps.java, + src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java, + src/main/java/de/intevation/flys/importer/ImportDischargeZone.java: + Removed superflous imports. + +2012-04-18 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added relations for storing sediment + yield values. + +2012-04-18 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: The discharge_zone relation has no + longer a reference to a named main value but stores a lower and upper + discharge as string. + + * src/main/java/de/intevation/flys/model/DischargeZone.java, + src/main/java/de/intevation/flys/importer/ImportDischargeZone.java: + Adapted the code to the changes in the db schema. + + * src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java: + This parser now reads the meta information properly. + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java: + Repaired broken HQL statement. + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java: + Log the number of flow velocity model values that have been written into + database. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/FlowVelocityMeasurementParser.java: + New parser for flow velocity measurements. + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurementValue.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java: + Fixed broken HQL statements. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Store flow + velocity measurements into database after parsing them. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model classes for flow velocity measurements. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurementValue.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java: + New temp classes used during the import process of flow velocity + measurements. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/FlowVelocityMeasurementValue.java, + src/main/java/de/intevation/flys/model/FlowVelocityMeasurement.java: New + model classes for storing flow velocity measurements. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added new relations for MINFO specific + flow velocity measurements. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java: + New. Parser for model files of MINFO specific flow velocity data. + + * doc/schema/oracle-minfo.sql: Added a missing q column to + flow_velocity_model_values relation. + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java, + src/main/java/de/intevation/flys/model/FlowVelocityModelValue.java: + Added missing q column. + + * src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java: + Added setter methods for meta data and an addValue() for adding new + ImportFlowVelocityModelValues. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Use + FlowVelocityModelParser for parsing model data of flow velocity files. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportDischargeZone.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java, + src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java: + Temp classes used during the import process of flow velocity data. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Implemented + the method that stores flow velocity model data. + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Prepared for + parsing flow velocity files. + + * src/main/java/de/intevation/flys/importer/Config.java: Added a config + option to skip parsing flow velocity files: + + -Dflys.backend.importer.skip.flow.velocity=true + +2012-04-17 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/FlowVelocityModel.java, + src/main/java/de/intevation/flys/model/FlowVelocityModelValue.java, + src/main/java/de/intevation/flys/model/DischargeZone.java: New model + classes for MINFO specific database relations. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the new model classes. + +2012-04-16 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added new relations for MINFO specific + flow velocity values. + +2012-02-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/oracle-minfo.sql: Fixed column unit_id in table depths + to match type of column id in table units. + + * doc/schema/postgresql-minfo.sql: oracle-minfo.sql for a better DBMS. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/MorphologicalWidth.java: Added + annotation for values. + + * src/main/java/de/intevation/flys/importer/ImportMorphWidthValue.java: + Removed debug output in getPeer() and storeDependencies(). + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java: + New parser for morphological widths files. + + * src/main/java/de/intevation/flys/importer/ImportMorphWidth.java: Throw + constraint violation exceptions. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Parse and + store morphological widths. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added a config + option to skip parsing morphological widths: + + -Dflys.backend.importer.skip.morphological.width=true + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql: Added a description field to morphological + width values. + + * src/main/java/de/intevation/flys/model/MorphologicalWidthValue.java: + Added new instance variable for descriptions. + + * src/main/java/de/intevation/flys/importer/ImportMorphWidthValue.java, + src/main/java/de/intevation/flys/importer/ImportMorphWidth.java: New + temp classes used to store morphological width values during the import. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Added new relations for MINFO specific + morphological width. + + * src/main/java/de/intevation/flys/model/MorphologicalWidth.java, + src/main/java/de/intevation/flys/model/MorphologicalWidthValue.java: New + model classes for morphological width. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model classes. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql: Added a description field to table + sediment_density. + + * src/main/java/de/intevation/flys/model/SedimentDensityValue.java, + src/main/java/de/intevation/flys/model/SedimentDensity.java: Some + modifications based on the changes of the schema adaption in last commit. + + * src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java: + Override parse() of parent class to get the filename. + + * src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java, + src/main/java/de/intevation/flys/importer/ImportDepth.java, + src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java: + Implemented the methods storeDependencies() and getPeer() to save new + instances into database. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Save all + ImportSedimentDensity objects to database. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the new model classes. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Modified the db schema specific to + MINFO; replaced some columns. + + * src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java: + Implemented the method stubs: parse meta data and data values. + + * src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java, + src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java: + Added and replaced some instance variables because the db schema has + changed. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/LineParser.java: New. + An abstract parser that might be used to read a file and handle each + line contained in the file seperatly. + + * src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java: + New. Subclasses LineParser. It is able to parse MINFO specific sediment + density files. NOTE: currently just a stub. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Prepared to + read MINFO specific sediment density files. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added a new + config option to skip parsing MINFO sediment density values: + + -Dflys.backend.importer.skip.sediment.density=true + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java, + src/main/java/de/intevation/flys/importer/ImportSedimentDensityValue.java, + src/main/java/de/intevation/flys/importer/ImportDepth.java: New importer + classes used during MINFO sediment density import. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Improved the MINFO schema to store + sediment density values specific to a river and depth. + + * src/main/java/de/intevation/flys/model/SedimentDensityValue.java, + src/main/java/de/intevation/flys/model/SedimentDensity.java, + src/main/java/de/intevation/flys/model/Depth.java: New model classes + used to store sediment density values specific to a river and depth. + +2012-04-13 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightParser.java: + New. An abstract super class for BedHeightSingleParser and + BedHeightEpochParser. It implements methods for parsing meta data. + Concrete subclasses need to implements the method for parsing data rows + only. + + * src/main/java/de/intevation/flys/importer/ImportBedHeight.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightValue.java: New. + Interfaces that define some major methods which enables the BedHeightParser + to parse both - single and epoch bed heights. + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java: + Moved the code for parsing meta data to BedHeightParser which is now the + parent class. + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightEpochParser.java: + New. A further subclass of BedHeightParser for parsing MINFO bed heights + for epochs. + + * src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightEpochValue.java: + Made them subclasses of ImportBedHeightValue. + + * src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java: Made + them subclasses of ImportBedHeight. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Some + adjustments to store ImportBedHeight and ImportBedHeightValue instances + instead of concrete subclasses. + +2012-04-12 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql: Added a link to the river to bed_height_epoch + table. + + * src/main/java/de/intevation/flys/model/BedHeightEpochValue.java, + src/main/java/de/intevation/flys/model/BedHeightEpoch.java: New model + classes for MINFO bed height epochs. + + * src/main/java/de/intevation/flys/importer/Config.java: Splitted up the + config option to skip parsing bed heights. Now, we are able to skip single + and epoch bed heights using the following options: + + -Dflys.backend.importer.skip.bed.height.single=true (skip singles) + -Dflys.backend.importer.skip.bed.height.epoch=true (skip epochs) + + * src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightEpochValue.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: Implemented + the whole stuff to parse those data. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the new model classes. + +2012-04-12 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Schema adaptions specific to MINFO bed + heights. + + * src/main/java/de/intevation/flys/model/BedHeightSingleValue.java, + src/main/java/de/intevation/flys/model/BedHeightType.java, + src/main/java/de/intevation/flys/model/ElevationModel.java, + src/main/java/de/intevation/flys/model/LocationSystem.java, + src/main/java/de/intevation/flys/model/BedHeightSingle.java: New model + classes for MINFO bed heights. + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java: + Some logging adjustments and a little bugfix: add BedHeightSingle objects + after they were parsed; otherwise they are not saved to database. + + * src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java, + src/main/java/de/intevation/flys/importer/ImportElevationModel.java, + src/main/java/de/intevation/flys/importer/ImportLocationSystem.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightType.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: Implemented + storeDependencies() and getPeer(). + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered model classes. + +2012-04-11 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java: + Finished work on parsing meta information and data specific to single bed + heights. + + * src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java, + src/main/java/de/intevation/flys/importer/ImportElevationModel.java, + src/main/java/de/intevation/flys/importer/ImportLocationSystem.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightType.java: Some + new and modified temp storages used during MINFO import. + +2012-04-11 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: Some schema adaptions specific to bed + heights in MINFO. + +2012-04-11 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added new command + line option to skip parsing bed heights (german "Sohlhoehen"). + Set "-Dflys.backend.importer.skip.bed.height=true" to skip parsing this + file type. + + * src/main/java/de/intevation/flys/importer/parsers/BedHeightEpochParser.java, + src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java: + Initial checkin of parsers for bed heights (single and epoch). + + * src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java, + src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java: Temp + storage for bed heights data used during the import. + + * src/main/java/de/intevation/flys/importer/Importer.java: Added an INFO + statement that signals the start of parsing rivers. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Collect and + trigger parsing of bed heights files (placed in 'Morphologie/Sohlhoehen'). + +2012-04-11 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-minfo.sql, + doc/schema/oracle-drop-minfo.sql: MINFO specific DB schema and sql statements + to drop MINFO specific stuff. + +2012-03-29 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: Added a config + option "flys.backend.importer.infogew.file" to set the path of an + INFO.gew file. + + * src/main/java/de/intevation/flys/importer/Importer.java: Read the path + to the INFO.gew from the new config option and try to parse it. + +2012-03-19 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-spatial.sql: Set the type of 'lower' and 'upper' column + of relation 'dem' to NUMBER(19,5). + +2012-03-19 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Floodmaps.java: Set geometry type + to 'Geometry', because Oracle can save POLYGONS and MULTIPOLYGONS in the + same relation; Hibernate seems unable to load both types. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered missing Floodmaps. + +2012-03-16 Ingo Weinzierl <ingo@intevation.de> + + * Tagged module as 'pre2.7-2012-03-16'. + +2012-03-16 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-spatial.sql: Repaired broken oracle db schema for + relation 'floodmaps'. + +2012-03-08 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Floodmaps.java: New model class for + 'floodmaps'. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the Floodmaps model class. + +2012-03-07 Ingo Weinzierl <ingo@intevation.de> + + * contrib/shpimporter/shpimporter.py, + contrib/shpimporter/utils.py, + contrib/shpimporter/uesg.py: A python based tool for importing + shapefiles into a database. This tool is based on python because it + makes use of GDAL OGR to read shapefiles and write features into + database. + +2012-03-07 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: Adapted the PostgreSQL schema for + floodmaps. + +2012-03-06 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql, + doc/schema/oracle-spatial.sql: Added new relations for existing + floodmaps (currently tested for PostgreSQL only!). + +2012-03-06 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java: Adapted method call of + Log4J logger 'warning()' -> 'warn()'. + +2012-03-02 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Fix or workaround flys/issue632 . + + * src/main/java/de/intevation/flys/model/Wst.java: Avoid NPE when + trying to get min/max q values. + +2012-02-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/DischargeTable.java: + The list of DischargeTableValue is now sorted by Q. + +2012-02-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: Added a method + getMasterDischargeTable() to retrieve the discharge table with kind 0. + +2012-02-03 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java + (getGaugeDatumsKMs,queryGaugeDatumsKMs): renamed to avoid hibernate + running into trouble finding db-mapping for type Map for + what looks like a 'getter' of GaugeDatumsKMs. + +2012-02-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java(getGaugeDatumsKMs): + New method to build a map of gauge stattion km to + the datums (PNP) of the gauge. Useful look if a km + is a gauge station. + +2012-01-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/FastAnnotations.java: + New. Fetches all informations of annotations in one go for + a river. Useful to speed up annotation handling. + +2012-01-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: Added a function that + returns a Gauge based on its official number. + +2012-01-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/FastCrossSectionLine.java: + New. Cacheable representation of the cross section line. + + * src/main/java/de/intevation/flys/model/CrossSectionLine.java: + Add a new isValid() method. + + * src/main/java/de/intevation/flys/model/CrossSection.java: + Added method getFastLines() to fetch the lines (FastCrossSectionLines) + directly with a single SQL statement and without expensive + intermediate representations. + +2012-01-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSection.java(getLines): + Added method to fetch the lines of a cross section in a given interval. + Useful to have chunked access to the lines. + +2012-01-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSectionLine.java + (fetchCrossSectionLinesPoints): Simplified and prevent reallocations. + +2012-01-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java: + Introduced boolean system property 'flys.backend.sta.parse.gauge.numbers' + default: false. If set the official number is parsed out of + the first line of the STA files. This leads to problems with the + data of the Elbe river. + + * src/main/java/de/intevation/flys/backend/SpatialInfo.java: Removed + superfluous import. + +2012-01-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql-spatial.sql: Fixed table hws. + +2012-01-05 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/RiverAxis.java: The method + getRiverAxis() now returns a list of RiverAxis objects. There is a + modeling problem (see comment in the header of the class) which should + be fixed! + + * src/main/java/de/intevation/flys/backend/SpatialInfo.java: Adapted the + code based on the modified signature in RiverAxis. + +2012-01-03 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java: Added a method + determineMinMaxQFree() that determines the min/max Qs at a given + kilometer. + +2012-01-02 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Remove 'NOT NULL' constraint from + gauges.range_id because there are gauges which don't have + a 'Gueltigkeitsbereich' + + To adjust existing PostgreSQL databases use: + + ALTER TABLE gauges ALTER COLUMN range_id DROP NOT NULL; + + * src/main/java/de/intevation/flys/model/River.java: Handle + null references to 'Gueltigkeitsbereiche'. + +2011-12-28 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java: Added a method + determineMinMaxQ(double double) to be able to determine the Q range of a + WST without having a Range object. + +2011-12-19 Sascha L. Teichmann <sascha.teichmann@intevation.de>: + + * src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java: + Parse the official 'Pegelnummer' out of the STA files, too. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Adjusted import model. + + * src/main/java/de/intevation/flys/model/Gauge.java: Make the + official gauge number accessible via Hibernate. + + * doc/schema/postgresql.sql, doc/schema/oracle.sql: Added + an official_number to the gauges table. + +2011-11-30 Bjoern Schilberg <bjoern.schilberg@intevation.de>: + + * doc/schema/oracle-spatial.sql: Adjust extent of germany to EPSG:31467 + (GK3) coordinates. + +2011-11-30 Bjoern Schilberg <bjoern.schilberg@intevation.de>: + + * doc/schema/oracle-spatial.sql: Adjust extent to the extent of germany + and srs to 31467 in USER_SDO_GEOM_METADATA. + +2011-11-29 Bjoern Schilberg <bjoern.schilberg@intevation.de>: + + * doc/schema/oracle_create_user.sql: Fixed notation of the table in the + alter statement. + +2011-11-18 Sascha L. Teichmann <sascha.teichmann@intevation.de>: + + Fixed flys/issue415 + + * doc/schema/oracle.sql: Increased precision of a and b in ranges. + +2011-11-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Building.java, + src/main/java/de/intevation/flys/model/Fixpoint.java: Added functions + that return a list of Buildings/Fixpoints for a given river. + +2011-11-10 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/oracle-spatial.sql, + doc/schema/postgresql-spatial.sql: Adapted the "kind" field of "lines" + relation (Int -> Varchar). + + * doc/schema/oracle-spatial_idx.sql: Added missing spatial index for + "lines" relation. + + * src/main/java/de/intevation/flys/model/Line.java: Added a function that + returns all lines of a given river. + +2011-11-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Catchment.java: New. A model for + the 'catchment' relation. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the Catchment model. + +2011-11-09 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: Synced "hws" relation with oracle + schema. + + * src/main/java/de/intevation/flys/model/Hws.java: New. A model for the + "hws" relation. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the Hws model. + +2011-11-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Added methods that return information about the database connection used + by a concrete SessionFactoryImpl. + +2011-11-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Floodplain.java: Changed the + geometry type from MultiPolygon to Polygon. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Added a function that returns the db driver of a given + SessionFactoryImpl instance. + +2011-11-01 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/RiverAxisKm.java: New. Model class + for 'river_axes_km' relation. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Added mapping for RiverAxisKm. + +2011-10-25 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle_create_user.sql: + Added explizit TABLESPACE definition for the user. + +2011-10-25 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle_create_user.sql: + Adjusted oracle_create_user.sql script. Added USER SQL snippet to change + tablespace to users. + +2011-10-05 Sascha L. Teichmann <sascha.teichmann@intevation.de>: + + * src/main/java/de/intevation/flys/utils/DateGuesser.java: + New. Date guesser from desktop FLYS. + + * src/main/java/de/intevation/flys/importer/parsers/WstParser.java: + Try to parse the name of a WST column as a date and store + the date into the database + + * src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Added code to store the date of the column in the database. + +2011-10-24 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/postgresql-spatial.sql: + Adjusted geometry type for floodplain and hws in AddGeometryColumn. + +2011-10-19 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle.sql: + Added missing views (wst_value_table,wst_w_values,wst_q_values). + +2011-10-18 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle.sql: + Removed all CREATE OR REPLACE TRIGGER statements. + +2011-10-17 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle.sql: + Adjusted NUMBER format for units, positions and cross_section_points tables. + +2011-10-10 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle.sql: + Fix errors. + +2011-10-10 Bjoern Schilberg <bjoern.schilberg@intevation.de> + + * doc/schema/oracle.sql: + Adjust oracle schema [I382]. + +2011-10-10 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportUnit.java: + Removed obsolete imports. + +2011-10-05 Sascha L. Teichmann <sascha.teichmann@intevation.de>: + + * ChangeLog: Added database update statements. + + To update existing databases: + + BEGIN; + CREATE SEQUENCE UNITS_ID_SEQ; + CREATE TABLE units ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(32) NOT NULL UNIQUE + ); + ALTER TABLE rivers ADD COLUMN wst_unit_id int REFERENCES units(id); + INSERT INTO units (id, name) VALUES (nextval('UNITS_ID_SEQ'), 'NN + m'); + INSERT INTO units (id, name) VALUES (nextval('UNITS_ID_SEQ'), 'NHN + m'); + UPDATE rivers SET wst_unit_id = (SELECT id FROM units WHERE name = 'NHN + m') WHERE name = 'Elbe'; + UPDATE rivers SET wst_unit_id = (SELECT id FROM units WHERE name = 'NN + m') WHERE name <> 'Elbe'; + ALTER TABLE rivers ALTER COLUMN wst_unit_id SET NOT NULL; + COMMIT; + +2011-10-05 Ingo Weinzierl <ingo@intevation.de> + + * contrib/dump-schema.sh: New. A small shell script that dumps the + database schema of a given database to SQL. + + * pom.xml: Added dependency for hibernate-spatial-oracle stuff. + +2011-10-04 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql.sql: Removed unit column from wsts; added a + wst_unit_id column to rivers. We decided to support a single elevation + model for the whole river. + + * src/main/java/de/intevation/flys/model/River.java: Added a WstUnit + column. + + * src/main/java/de/intevation/flys/model/Wst.java: Removed the Unit + column. + + * src/main/java/de/intevation/flys/importer/ImportWst.java: Provide a + getUnit() method that allows querying the elevation unit for this wst. + + * src/main/java/de/intevation/flys/importer/ImportUnit.java: Removed + storeDependencies(). + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: Save the + Unit of the wst file or a default one into database before all other + dependencies as well as the river itself is saved to database. + +2011-10-04 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql.sql: Added a "units" table. + + * src/main/java/de/intevation/flys/model/Unit.java: New. Model class that + represents a unit. + + * src/main/java/de/intevation/flys/importer/ImportUnit.java: New. Model + class that is used to import units. + + * src/main/java/de/intevation/flys/model/Wst.java: A Wst stores a Unit + which references "units" table now. + + * src/main/java/de/intevation/flys/importer/parsers/WstParser.java: Set + units which have already been parsed on Wsts. + + * src/main/java/de/intevation/flys/importer/ImportWst.java: Added setter + method for Units and call storeDependencies() for ImportUnits. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model class Unit. + +2011-10-04 Ingo Weinzierl <ingo@intevation.de> + + flys/issue333 (W-INFO / Berechnung Wasserspiegellage, Zuordnung Bezugspegel) + + * src/main/java/de/intevation/flys/model/River.java: Modified + determination of gauge based on a km range. River.determineGauge(double, + double) will now return the gauge which matches the start km. + +2011-09-28 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/utils/StringUtil.java: + (wWrap): New method (extracted from WaterlevelSelectState). + +2011-09-28 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/utils/StringUtil.java: + (unbracket): New method (extracted from WaterlevelSelectState). + +2011-09-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSectionLine.java: + Moved some logic from cross section demo app to this model. + +2011-09-26 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSectionTrack.java: + Added new function that the nearest CrossSectionTrack of a river to a + given kilometer. + +2011-09-23 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/postgresql-spatial.sql: + Added missing river_axes_km schema. + * doc/schema/oracle-spatial.sql: + Added missing dem and lines schema. + +2011-09-22 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/postgresql-spatial.sql, doc/schema/oracle-spatial.sql: + Harmonized oracle and postgresql spatial schema. + +2011-09-22 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Harmonized Extent for Saar and Mosel. Some cleanups. + +2011-09-22 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Added the possibility to enable JMX (/MBean) support for hibernate. By + default, this support is NOT enabled. To enable JMX support for + hibernate, set the system property "flys.backend.enablejmx=true". + +2011-09-20 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle_create_user.sql: Added right to create views. + +2011-09-20 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Generalized oracle spatial schema. + +2011-09-19 Ingo Weinzierl <ingo@intevation.de> + + Tagged RELEASE 2.5 + + * Changes: Prepared changes for release. + +2011-09-16 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/DGM.java: Added function to query + a DGM by Id. + +2011-09-15 Bjoern Schilberg <bjoern@intevation.de> + + * pom.xml: Removed oracle dependency. + +2011-09-15 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle.sql: Added inital oracle schema. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial_idx.sql: Added inital oracle-spatial_idx.sql + script. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Deactivated spatial indexes. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle_create_user.sql: Added inital oracle_create_user.sql + script. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema floodplain. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema hws. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema cross_section_tracks. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema river_axes. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema fixpoints. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added schema buildings. + +2011-09-14 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Fixed table river_axes_km. + +2011-09-13 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/oracle-spatial.sql: Added initial oracle schemas. + +2011-09-12 Bjoern Schilberg <bjoern@intevation.de> + + * doc/schema/postgresql-spatial.sql: Added initial schemas for + Hydrologie/Einzugsgebiete, Hydrologie/HW-Schutzanlagen, Hydrologie/Hydr. + Grenzen/Linien, BfG/hauptoeff_*.shp, BfG/MNQ-*.shp, + BfG/modellgrenze*.shp, BfG/uferlinie.shp, BfG/vorland_*.shp, + Hydrologie/Streckendaten, Hydrologie/UeSG/Berechnung, + Hydrologie/UeSG/Messung + +2011-09-02 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: Removed SERIALs from schema. + Auto-Increment is realized through SERIALs now. + + * src/main/java/de/intevation/flys/model/DGM.java: The table for dem has + been renamed to 'dem' (before 'dgm'). + +2011-09-01 Hans Plum <hans@intevation.de> + + * doc/schema/postgresql-spatial.sql: + Hint for unifying table names: dgm -> dem + +2011-09-01 Hans Plum <hans@intevation.de> + + * doc/schema/postgresql-spatial.sql: + Added mappings to existing data in file system (based on + river Saar); added TODOs for missing tables/mappings + +2011-08-31 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: New relation for floodplains (german + "Talaue"). + + * src/main/java/de/intevation/flys/model/Floodplain.java: New. Model class + that represents a floodplain. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the Floodplain mapping. + +2011-08-31 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: Added a relation for DGMs. Note, that + no data of the DGM is stored in this relation, but only the file path to + the DGM file. + + * src/main/java/de/intevation/flys/model/DGM.java: New. This class provides + information for a DGM (km range and file path). + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the DGM. + +2011-08-30 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSectionTrack.java: New + static function to retrieve all CrossSectionTracks of a specific river. + +2011-08-25 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/utils/FileTools.java: Moved to + artifacts-common module. + + * src/main/java/de/intevation/flys/importer/parsers/PegelGltParser.java, + src/main/java/de/intevation/flys/importer/parsers/PRFParser.java, + src/main/java/de/intevation/flys/importer/parsers/HYKParser.java, + src/main/java/de/intevation/flys/importer/parsers/AnnotationsParser.java, + src/main/java/de/intevation/flys/importer/parsers/InfoGewParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportGauge.java: Adjusted + imports of FileTools. + +2011-08-25 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java (getMainValues) + (setMainValues): + New method and mapping to get/set MainValues of a Gauge. Essentially + developed by Sascha L. Teichmann. + +2011-08-22 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Reverted the default db dialect to PostgreSQL - this has been changed to + PostGIS by accident. + Configure the dialect "org.hibernatespatial.postgis.PostgisDialect" to + use the PostGIS stuff. + +2011-08-22 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/RiverAxis.java: Added a function + that returns the RiverAxis for a given River. + + * src/main/java/de/intevation/flys/backend/SpatialInfo.java: Use the new + function of RiverAxis to retrieve the RiverAxis. + +2011-08-18 Ingo Weinzierl <ingo@intevation.de> + + * doc/schema/postgresql-spatial.sql: The PostGIS database schema for + FLYS spatial data. + + * src/main/java/de/intevation/flys/model/CrossSectionTrack.java, + src/main/java/de/intevation/flys/model/RiverAxis.java, + src/main/java/de/intevation/flys/model/Line.java, + src/main/java/de/intevation/flys/model/Building.java, + src/main/java/de/intevation/flys/model/Fixpoint.java: Model classes that + represent FLYS spatial data. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered model classes. + + * pom.xml: Added dependencies to HibernateSpatial and PostGIS. + + * src/main/java/de/intevation/flys/backend/SpatialInfo.java, + contrib/spatial-info.sh: A small demo application that prints out some + information about spatial data of specific rivers. Modify the system + property -Dflys.backend.spatial.river to get information of a river of + your choice. + +2011-07-31 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Re-enabled Hibernate schema dumps. + + * src/main/java/de/intevation/flys/App.java: Removed old code + and use new SessionFactoryProvider infrastructure. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Added methods to create db configurations without opening them. + Useful for introspection only purposes. + +2011-07-31 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * pom.xml: Bumped Apache DBCP up to 1.4 to use the same version + as artifact database. + +2011-07-28 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Make use of the LRU cache from artifacts common. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added missing foreign key contraint on hyks table. + To update existing databases: + + ALTER TABLE hyks ADD CONSTRAINT hyks_river_id_fkey FOREIGN KEY (river_id) REFERENCES rivers(id); + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/HYKParser.java: + Check if zone coordinates in HYKs are swapped and warn the user. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/HYK.java + src/main/java/de/intevation/flys/importer/parsers/HYKParser.java, + src/main/java/de/intevation/flys/importer/ImportHYKFormation.java, + src/main/java/de/intevation/flys/importer/ImportHYKEntry.java, + src/main/java/de/intevation/flys/importer/ImportHYK.java: + Various small fixes and some extra logging. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/Config.java: New. + Central singleton to configure the Importer. + Uses system properties by now: + + flys.backend.importer.dry.run: boolean + default false. true: don't write to database. + + flys.backend.importer.annotation.types: String + default unset. Filename of annotation type classifications. + + flys.backend.importer.skip.gauges: boolean + default: false. true: don't parse/store *.glt, *.sta files + + flys.backend.importer.skip.annotations: boolean + default: false. true: don't parse/store *.km files + + flys.backend.importer.skip.prfs: boolean + default: false. true: don't parse/store *.prf files + + flys.backend.importer.skip.hyks: boolean + default: false. true: don't parse/store *.hyk files + + flys.backend.importer.skip.wst: boolean + default: false. true: don't parse/store river wst files + + flys.backend.importer.skip.extra.wsts: boolean + default: false. true: don't parse/store extra *.zus, *.wst files + + flys.backend.importer.skip.fixations: boolean + default: false. true: don't parse/store fixation *.wst files + + flys.backend.importer.skip.official.lines: boolean + default: false. true: don't parse/store 'amtliche Linien' *.wst files + + flys.backend.importer.skip.flood.water: boolean + default: false. true: don't parse/store 'HW-Marken' *.wst files + + flys.backend.importer.skip.flood.protection: boolean + default: false. true: don't parse/store 'HW-Schutzanlagen' *.wst files + +2011-07-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/HYKEntry.java: Fixed OrderBy + clause. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportHYKFormation.java, + src/main/java/de/intevation/flys/importer/ImportHYKFlowZone.java, + src/main/java/de/intevation/flys/importer/ImportHYKEntry.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportHYK.java: + Store HYK data structures to database. Needs testing. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse the HYKs from the importer. TODO: Store them in database. + +2011-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/HYKParser.java: + Create data structures while parsing. + + * src/main/java/de/intevation/flys/importer/ImportHYKFormation.java, + src/main/java/de/intevation/flys/importer/ImportHYK.java: Added + getters/setters to ease model wiring. + +2011-07-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportHYKFormation.java, + src/main/java/de/intevation/flys/importer/ImportHYKFlowZone.java, + src/main/java/de/intevation/flys/importer/ImportHYKEntry.java, + src/main/java/de/intevation/flys/importer/ImportHYK.java: New. + Importer models for HYKs. + +2011-07-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Each entry in a HYK can have + an optional 'Peilungsjahr' (measure) not only the whole HYK. + To update existing databases: + BEGIN; + ALTER TABLE hyks DROP COLUMN measure; + ALTER TABLE hyk_entries ADD COLUMN measure TIMESTAMP; + COMMIT; + + * src/main/java/de/intevation/flys/model/HYKEntry.java, + src/main/java/de/intevation/flys/model/HYK.java: + Adjusted Hibernate models. + +2011-07-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/HYKParser.java: + Added callback mechanism and recursive file search like in the PRF parser. + All BfG-HYK files seem to parse correctly now. TODO: Build the data structures. + + * src/main/java/de/intevation/flys/importer/parsers/PRFParser.java: + Added x.canRead() before accepting files for parsing. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/HYKParser.java: + Initial version of the HYK parser. Not ready, yet. + + * src/main/java/de/intevation/flys/importer/ImportHYKFlowZoneType.java: + Importer model for HYK flow zone types. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Argh! Added distance_{vl|hf|vr} to + wrong table. + To update existing databases: + BEGIN; + ALTER TABLE hyk_entries DROP COLUMN distance_vl; + ALTER TABLE hyk_entries DROP COLUMN distance_hf; + ALTER TABLE hyk_entries DROP COLUMN distance_vr; + ALTER TABLE hyk_formations ADD COLUMN distance_vl NUMERIC NOT NULL; + ALTER TABLE hyk_formations ADD COLUMN distance_hf NUMERIC NOT NULL; + ALTER TABLE hyk_formations ADD COLUMN distance_vr NUMERIC NOT NULL; + COMMIT; + + * src/main/java/de/intevation/flys/model/HYKFormation.java, + src/main/java/de/intevation/flys/model/HYKEntry.java: + Adjusted Hibernate models. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/utils/FileTools.java: Added method + walkTree() to traverse a directory tree. To be reused in HYK parser. + + * src/main/java/de/intevation/flys/importer/parsers/PRFParser.java: + Uses the FileTools.walkTree() method now to find all PRF file. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added missing columns. + To update existing databases: + BEGIN; + ALTER TABLE hyks ADD COLUMN measure TIMESTAMP; + ALTER TABLE hyk_entries ADD COLUMN distance_vl NUMERIC NOT NULL; + ALTER TABLE hyk_entries ADD COLUMN distance_hf NUMERIC NOT NULL; + ALTER TABLE hyk_entries ADD COLUMN distance_vr NUMERIC NOT NULL; + COMMIT; + + * src/main/java/de/intevation/flys/model/HYKEntry.java, + src/main/java/de/intevation/flys/model/HYK.java: + Adjusted Hibernate models. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/parsers/*.java: + New package. Moved the file parsers (*.gew, *.sta, *.at, *.glt, *.prf, *.km, *.wst) + into this package. + + * src/main/java/de/intevation/flys/importer/*.java: Adjusted the imports. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/HYKFormation.java, + src/main/java/de/intevation/flys/model/HYKEntry.java, + src/main/java/de/intevation/flys/model/HYKFlowZone.java, + src/main/java/de/intevation/flys/model/HYKFlowZoneType.java, + src/main/java/de/intevation/flys/model/HYK.java: New. The hibernate models + for the HYK structures. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new models. + + * src/main/java/de/intevation/flys/model/CrossSection.java: Added + 'order by' annotation for fetching the cross section lines. + +2011-07-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added structures for HYKs "Hydraulische Kenngroessen" + To update existing databases: + + BEGIN; + CREATE SEQUENCE HYKS_ID_SEQ; + CREATE TABLE hyks ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL, + description VARCHAR(256) NOT NULL + ); + + CREATE SEQUENCE HYK_ENTRIES_ID_SEQ; + CREATE TABLE hyk_entries ( + id int PRIMARY KEY NOT NULL, + hyk_id int NOT NULL REFERENCES hyks(id), + km NUMERIC NOT NULL, + UNIQUE (hyk_id, km) + ); + + CREATE SEQUENCE HYK_FORMATIONS_ID_SEQ; + CREATE TABLE hyk_formations ( + id int PRIMARY KEY NOT NULL, + formation_num int NOT NULL DEFAULT 0, + hyk_entry_id int NOT NULL REFERENCES hyk_entries(id), + top NUMERIC NOT NULL, + bottom NUMERIC NOT NULL, + UNIQUE (hyk_entry_id, formation_num) + ); + + CREATE SEQUENCE HYK_FLOW_ZONE_TYPES_ID_SEQ; + CREATE TABLE hyk_flow_zone_types ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(50) NOT NULL UNIQUE, + description VARCHAR(256) + ); + + CREATE SEQUENCE HYK_FLOW_ZONES_ID_SEQ; + CREATE TABLE hyk_flow_zones ( + id int PRIMARY KEY NOT NULL, + formation_id int NOT NULL REFERENCES hyk_formations(id), + type_id int NOT NULL REFERENCES hyk_flow_zone_types(id), + a NUMERIC NOT NULL, + b NUMERIC NOT NULL, + CHECK (a <= b) + ); + COMMIT; + +2011-07-13 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * pom.xml: Bumped Hibernate up to 3.6.5. + +2011-07-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/utils/FileTools.java: Argh! + Forget to call the file hashing so only the file lengths were + compared. + +2011-07-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/utils/FileTools.java: + Added a class HashedFile to compare files by there length + and a message digest. Digest can be set with system property + "flys.backend.file.cmp.digest" and defaults to MD5. Useful to + detect file duplicates. + + * src/main/java/de/intevation/flys/importer/PRFParser.java: Added + method prfAccept(File) to callback to check if a found PRF file + should be parsed. Useful to prevent parsing file duplicates. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Use the HashedFile and the PRFParser.Callback to prevent + parsing of PRF duplicates. + +2011-07-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Misspelled sequence. + To update existing databases: + + DROP SEQUENCE CROSS_SECTION_LINES_SEQ; + CREATE SEQUENCE CROSS_SECTION_LINES_ID_SEQ; + + * src/main/java/de/intevation/flys/importer/ImportCrossSection.java: + Added some logging because importing is slow. + + * src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java: + Prevent NPE if a cross section line from db has no points. + +2011-07-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Parse all PRFs in all subfolders of a river and store them + as cross sections into the database. Needs testing! + + * src/main/java/de/intevation/flys/importer/ImportCrossSection.java, + src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java: + New. Importer models for cross sections. + + * src/main/java/de/intevation/flys/importer/XY.java: + New. Made top level class from inner PRFParser.XY. + + * src/main/java/de/intevation/flys/importer/PRFParser.java: + Moved out XY class. Renamed callback. + + * src/main/java/de/intevation/flys/model/CrossSection.java, + src/main/java/de/intevation/flys/model/CrossSectionLine.java, + src/main/java/de/intevation/flys/model/CrossSectionPoint.java, + src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: + Added convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse and store cross sections into database. + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Introduced a new table cross_section_line + holding the km of a set of points. + + * src/main/java/de/intevation/flys/model/CrossSectionLine.java: + New. Model for a single line of a "Querprofil". + + * src/main/java/de/intevation/flys/model/CrossSection.java: Removed + 'km' and 'points' they are part of the line now. + + * src/main/java/de/intevation/flys/model/CrossSectionPoint.java: + They reference to the containing line now. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered new model. + + To update existing databases: + BEGIN; + DROP SEQUENCE CROSS_SECTIONS_ID_SEQ; + DROP SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; + DROP TABLE cross_section_points; + DROP TABLE cross_sections; + CREATE SEQUENCE CROSS_SECTIONS_ID_SEQ; + CREATE TABLE cross_sections ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + time_interval_id int REFERENCES time_intervals(id), + description VARCHAR(256) + ); + CREATE SEQUENCE CROSS_SECTION_LINES_SEQ; + CREATE TABLE cross_section_lines ( + id int PRIMARY KEY NOT NULL, + km NUMERIC NOT NULL, + cross_section_id int NOT NULL REFERENCES cross_sections(id), + UNIQUE (km, cross_section_id) + ); + CREATE SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; + CREATE TABLE cross_section_points ( + id int PRIMARY KEY NOT NULL, + cross_section_line_id int NOT NULL REFERENCES cross_section_lines(id), + col_pos int NOT NULL, + x NUMERIC NOT NULL, + y NUMERIC NOT NULL, + UNIQUE (cross_section_line_id, col_pos) + ); + COMMIT; + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Dropped constraint that enforces the + uniqueness of km and river. This is violated because there are + more than one sounding in different year at the same km of a river. + Added column 'description' to the cross section table to make it + human readable. + + To update existing databases: + + ALTER TABLE cross_sections DROP CONSTRAINT cross_sections_km_key; + ALTER TABLE cross_sections ADD COLUMN description VARCHAR(256); + + * src/main/java/de/intevation/flys/model/CrossSection.java: + Added the description column to the Hibernate model. + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Dropped constraint that enforces the + uniqueness of x in a "Querprofil-Spur". There are vertical lines + in the soundings so this constraint is violated. + + To update existing databases: + + ALTER TABLE cross_section_points DROP CONSTRAINT cross_section_points_cross_section_id_key2; + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PRFParser.java: + Added a callback to be called from parsePRFs() if + a PRF was parsed successfully. Useful to scan whole + sub directories for PRF files. + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PRFParser.java: + Extract the year of sounding from file names. If not found + from the name of th containing directory. Description is made + of file name and parent directory file name. + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PRFParser.java: + Extracted the data. All BfG PRFs are parsed correctly, now. + +2011-07-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PRFParser.java: + Extract km from lines. TODO: extract data. + +2011-07-06 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PRFParser.java: New. + Parser for PRF files. TODO extra data and station from data lines. + +2011-07-06 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Point3d.java: Deleted. + Not needed (braindead). + + * src/main/java/de/intevation/flys/model/CrossSectionPoint.java: + Directly store the x/y values now. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Removed registration of Point3d. + + To update existing databases: + + BEGIN; + ALTER TABLE cross_section_points DROP COLUMN point3d_id; + DROP SEQUENCE POINTS3D_ID_SEQ; + DROP TABLE points3d; + ALTER TABLE cross_section_points ADD COLUMN x NUMERIC NOT NULL; + ALTER TABLE cross_section_points ADD COLUMN y NUMERIC NOT NULL; + ALTER TABLE cross_section_points ADD CONSTRAINT + cross_section_points_cross_section_id_key2 UNIQUE (cross_section_id, x); + COMMIT; + +2011-07-06 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/CrossSection.java, + src/main/java/de/intevation/flys/model/CrossSectionPoint.java: + New. Hibernate models for cross-sections and their forming points. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered the new models. + +2011-07-06 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Point3d.java: New. point3d model + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Registered point3d model. + +2011-07-06 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Add relations for cross sections. + To update existing databases: + BEGIN; + + CREATE SEQUENCE CROSS_SECTIONS_ID_SEQ; + CREATE TABLE cross_sections ( + id int PRIMARY KEY NOT NULL, + km NUMERIC NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + time_interval_id int REFERENCES time_intervals(id), + UNIQUE (km, river_id) + ); + + CREATE SEQUENCE POINTS3D_ID_SEQ; + CREATE TABLE points3d ( + id int PRIMARY KEY NOT NULL, + x NUMERIC NOT NULL, + y NUMERIC NOT NULL, + z NUMERIC NOT NULL + ); + + CREATE SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; + CREATE TABLE cross_section_points ( + id int PRIMARY KEY NOT NULL, + cross_section_id int NOT NULL REFERENCES cross_sections(id), + point3d_id int NOT NULL REFERENCES points3d(id), + col_pos int NOT NULL, + UNIQUE (cross_section_id, point3d_id, col_pos), + UNIQUE (cross_section_id, col_pos) + ); + + COMMIT; + +2011-06-28 Ingo Weinzierl <ingo@intevation.de> + + Tagged RELEASE 2.4 + +2011-06-27 Ingo Weinzierl <ingo@intevation.de> + + * Changes: Prepared changes for the upcoming release. + +2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java, + src/main/java/de/intevation/flys/importer/AnnotationClassifier.java, + src/main/java/de/intevation/flys/importer/AtFileParser.java, + src/main/java/de/intevation/flys/importer/ValueKey.java, + src/main/java/de/intevation/flys/importer/WstParser.java: + Removed trailing whitespace. + +2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AnnotationClassifier.java: + Removed superfluous imports. + +2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Added a method maxOverlap to determine the gauge which has + the max common length to a given interval. This is for + numerical stability in slightly overlapping gauge ranges. + +2011-06-26 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: When + looking up a gauge by km containment use precision of 1e-6. + +2011-06-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Added method to find gauge by its name. + +2011-06-19 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/annotation-types.xml: Fixed some rules. + + * src/main/java/de/intevation/flys/importer/Importer.java, + src/main/java/de/intevation/flys/importer/InfoGewParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Call the right constructors now. + + * src/main/java/de/intevation/flys/importer/ImportAnnotationType.java: + Added getter/setter for name property. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java: + Print duplicated at WARN level not as DEBUG. + + * src/main/java/de/intevation/flys/importer/AnnotationClassifier.java: + Fixed XPath expression to build the internal lookup structures + correctly. + +2011-06-19 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Added classification of annotation types. Needs testing! + + * doc/annotation-types.xml: New. Rules to classify the different + types of annotations. The classification works like this: + + There are unique types like 'Bruecke', 'Pegel' and so on. + They are defined in the /annotation/type section and + identified by their name. One of the types can be set + as the default type if no rule applies. + + In the /annotation/pattern section are two types of pattern. + + 1 - file pattern: If a KM file is opened its filename is + matched against the regular expressions of these + patterns. If a match is found the corresponding type + is used as the default type in the open file. + If no match is found the global default type is used + as the default type. + + 2 - line patterns: For each line of an open KM file these + patterns are applied to find a match. If a match is + found the corresponding type is used as the type of + the annotation. If no match is found the default + file default is assumed to be the right type. For + the file default see 1. + + * src/main/java/de/intevation/flys/importer/Importer.java: + To activate the annotation type classification set + the system property + + 'flys.backend.importer.annotation.types' + + to the path of a XML looking like the annotation-types.xml + file. If the system property is not set no classification + is done. + + * src/main/java/de/intevation/flys/importer/AnnotationClassifier.java: + New. Implements the classification. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java, + src/main/java/de/intevation/flys/importer/InfoGewParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Looped through the annotation type classification. + +2011-06-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Added method to find gauge by a position lying in its range. + +2011-06-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + First part of flys/issue18 + + * doc/schema/postgresql.sql: Add new table 'annotation_types'. + To update existing databases: + BEGIN; + CREATE SEQUENCE ANNOTATION_TYPES_ID_SEQ; + CREATE TABLE annotation_types ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL UNIQUE + ); + ALTER TABLE annotations ADD COLUMN type_id int REFERENCES annotation_types(id); + COMMIT; + + * doc/schema/postgresql-cleanup.sql: Removed. Hopeless out-dated. + + * src/main/java/de/intevation/flys/model/AnnotationType.java: + New. Hibernate model to access the type. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Register the new backend type. + + * src/main/java/de/intevation/flys/model/Annotation.java: + References the annotation type. + + * src/main/java/de/intevation/flys/importer/ImportAnnotationType.java: + New. Model to help import the annotation type. + + * src/main/java/de/intevation/flys/importer/ImportAnnotation.java: + Uses the import type. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java: + Set the annotation type to 'null'. TODO: Do the classification! + +2011-06-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Fix for flys/issue110. start index was shifted by one. + +2011-06-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportAnnotation.java: + Forgot to store reference to edge. + +2011-06-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Register backend model. + + * src/main/java/de/intevation/flys/importer/ImportEdge.java: New. Model + for importing the edges. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java: + Parses the edges of an annotation, too. + +2011-06-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added table edges to model 'Kanten' of an annotation. + To update existing databases: + BEGIN; + CREATE SEQUENCE EDGES_ID_SEQ; + CREATE TABLE edges ( + id int PRIMARY KEY NOT NULL, + top NUMERIC, + bottom NUMERIC); + ALTER TABLE annotations ADD COLUMN edge_id int REFERENCES edges(id); + COMMIT; + + * src/main/java/de/intevation/flys/model/Edge.java: New. A 'Kanten'-Model. + * src/main/java/de/intevation/flys/model/Annotation.java: References the + edges. + +2011-06-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Added method to find gauge only by station position. + +2011-05-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Make search for gauges independent of from/to order. + +2011-05-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added a new view to select qs of a WST. + To update existing databases: + + CREATE VIEW wst_q_values AS + SELECT wc.position AS column_pos, + wqr.q AS q, + r.a AS a, + r.b AS b, + wc.wst_id AS wst_id + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r ON wqr.range_id = r.id + JOIN wst_columns wc ON wcqr.wst_column_id = wc.id + ORDER BY wc.position, wcqr.wst_column_id, r.a; + +2011-05-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added a new view to select ws of a WST. + To update existing databases: + + CREATE VIEW wst_w_values AS + SELECT wcv."position" AS km, + wcv.w AS w, + wc."position" AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc ON wcv.wst_column_id = wc.id + JOIN wsts w ON wc.wst_id = w.id + ORDER BY wcv."position", wc."position"; + +2011-05-23 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + flys/issue76 + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Close gaps between q ranges. + +2011-05-20 Ingo Weinzierl <ingo@intevation.de> + + Tagged RELEASE 2.3.1 + +2011-05-13 Ingo Weinzierl <ingo@intevation.de> + + Tagged RELEASE 2.3 + +2011-05-13 Ingo Weinzierl <ingo@intevation.de> + + * Changes: Changes for release 2.3 - see Changes file to get to know about + the version numbers of this software. + +2011-05-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added a column which tells + if a river counts its km up or downwards. + To update existing databases: + + ALTER TABLE rivers ADD COLUMN km_up BOOLEAN NOT NULL DEFAULT true; + + * src/main/java/de/intevation/flys/model/River.java: + Adjust Hibernate mapping of new column. + +2011-05-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Fixed flys/issue11 and flys51. + +2011-05-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ValueKey.java: + Add some unsharp comparison (eps = 1e-6) to avoid + numerical problems. + + * src/main/java/de/intevation/flys/importer/IdValueKey.java: + Removed. Not need any longer. + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Use unsharp lookup. + + * src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Flush more often. Hopefully this reduces hibernate sync + problems?! + +2011-05-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Fixed silly bug. Set flush mode back to auto because + manual flushing causes some undetermined problems. + +2011-05-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Do not load _all_ values from discharge tables and + wst columns. This is extremly slow and will lead + to OOM if more rivers are imported. Now only the + last 20 columns und discharge tables are cached. + + * src/main/java/de/intevation/flys/importer/ValueKey.java: + New. Key for caching discharge table values and wst + column values. + + * src/main/java/de/intevation/flys/importer/IdValueKey.java: + Fixed bug in equals(). + + * src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Removed too eloquent debug output. + +2011-05-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/IdValueKey.java: + Use BigDecimals as representation for the numeric components + which prevents running into unique constraint problems + caused by imprecision. + + * src/main/java/de/intevation/flys/importer/ImportRange.java, + src/main/java/de/intevation/flys/importer/ImporterSession.java: + Ranges are now cached globally, too. + + * src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Improved logging. + + * src/main/java/de/intevation/flys/importer/ImportDischargeTableValue.java: + Removed superfluous imports. + +2011-05-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/StaFileParser.java: + Only accept main value types 'Q', 'W', 'D' and 'T' by default. + '-' is not handled any more because it causes too much constraint + problems. You can overwrite the imported type with the + system property flys.backend.main.value.types" (default "QWTD") + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Set session flush mode to manual. Hopefully this improves the + performance a bit. + + * src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportGauge.java, + src/main/java/de/intevation/flys/importer/ImportWstColumn.java, + src/main/java/de/intevation/flys/importer/ImportRange.java, + src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + Improved logging. + +2011-05-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstColumnValueKey.java: Deleted + * src/main/java/de/intevation/flys/importer/IdValueKey.java: Reinserted + here in a more generalized form. + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + Cache the discharge table value, too. + + * src/main/java/de/intevation/flys/importer/ImportDischargeTableValue.java: + Use the global cache. + +2011-05-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImporterSession.java: + New. Centralized caching in the thread local context. Importing + the Elbe leads to OOM because the column values of the + WST files where loaded separately for every file. + + * src/main/java/de/intevation/flys/importer/ImportPosition.java, + src/main/java/de/intevation/flys/importer/Importer.java, + src/main/java/de/intevation/flys/importer/ImportAnnotation.java, + src/main/java/de/intevation/flys/importer/ImportWstQRange.java, + src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportMainValue.java, + src/main/java/de/intevation/flys/importer/ImportMainValueType.java, + src/main/java/de/intevation/flys/importer/ImportNamedMainValue.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportGauge.java, + src/main/java/de/intevation/flys/importer/ImportWstColumnValue.java, + src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java, + src/main/java/de/intevation/flys/importer/ImportWstColumn.java, + src/main/java/de/intevation/flys/importer/ImportRange.java, + src/main/java/de/intevation/flys/importer/ImportDischargeTableValue.java, + src/main/java/de/intevation/flys/importer/ImportDischargeTable.java, + src/main/java/de/intevation/flys/importer/ImportAttribute.java, + src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: + Adjusted to use the new global context. + +2011-05-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Dropped constraint which + forces discharge tables to have a unique time interval + for a given gauge and kind. + + There are AT files (historical Mosel/Perl/Perl/1967-1981.at + and Mosel/Perl/1967-1981-1.at) which violate this + constraint. Its a technical question to the customer + how to handle these cases. + + To adjust existing databases: + + ALTER TABLE discharge_tables DROP CONSTRAINT discharge_tables_gauge_id_key; + +2011-05-08 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + There are wst files where column names are not unique. + Make them unique by appending (1), (2) and so on. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Import the "HW-Schutzanlagen", too. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Make import of historical discharge tables work. + + * doc/schema/postgresql.sql: Added forgotten column 'description'. + + !!! You have to drop your database !!! + + * src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + src/main/java/de/intevation/flys/model/DischargeTable.java: + Add the forgotten description property. + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Fixed problems with date recognition. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Prefix the description of the historical discharge tables + with "Histor.Abflusstafeln". + + * src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: + Fixed silly programming error. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Inject 'kind' attribute. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Traverse the "Histor.Abflusstafeln" for the historical + discharge tables. too. TODO: Store them in the database. + + * src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + Added convinience constructor to set the kind of the + discharge table. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Prefix "Zusätzliche Längsschnitte" with "Zus.Längsschnitte" + in description. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Import 'Hochwasser-Marken', too. + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Removed superfluous import. + +2011-05-05 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Ignore lines that contain km positions which were found + before in the same file. + +2011-05-05 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: Added a method that + returns all gauges of the river intersected by a given start and end + point. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: + Forgot to fetch peer from result set. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportTimeInterval.java: + New. Importer model help fetching the database peer. + + * src/main/java/de/intevation/flys/model/TimeInterval.java: + Add convinience constructor with start and stop time. + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Attach a time interval to a discharge table if we find one. + + * src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + Store the reference to the importer model of the + time interval of the discharge table. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: + Try to extract time ranges from at files. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse and store "amtliche Linien" wst files. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse and store fixation wst files as well. + +2011-05-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse the "zusaetzliche Laengsschnitte", too. + + * src/main/java/de/intevation/flys/importer/ImportWst.java: + Add getter/setter for column 'kind'. + +2011-05-02 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Fixed flys/issue19: Do not take km column in wst file as a water level. + +2011-05-02 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: Introduced a 'scale' + that is used to adjust the range of min/max W values. + +2011-05-01 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Removed superfluous import. + +2011-04-20 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstColumnValueKey.java: + New. This class is used as distinct key of a WstColumnValue - e.g. as + key in a map. + + * src/main/java/de/intevation/flys/importer/ImportWst.java: A + WstColumnValue cache is build up while initialization. This cache + contains all WstColumnValues that exist in the database. + + * src/main/java/de/intevation/flys/importer/ImportWstColumn.java: New + constructor that takes the WstColumnValues cache. It is used to + initialize new ImportWstColumnValue objects. + + * src/main/java/de/intevation/flys/importer/ImportWstColumnValue.java: + Speedup: A ImportWstColumnValue has a WstColumnValues cache that + contains all WstColumnValues existing in the database. This makes it + unnecessary to call an sql statement for each WstColumnValue to + determine its existence in the database. + +2011-04-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql, doc/schema/postgresql-cleanup.sql: + Added a view 'wst_value_table' which aggregates the data + to build w/q value tables. + + To update existing databases: + + BEGIN; + CREATE VIEW wst_value_table AS + SELECT wcv.position AS position, + w, + (SELECT q + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr + ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r + ON r.id = wqr.range_id + WHERE wcqr.wst_column_id = wc.id + AND wcv.position BETWEEN r.a AND r.b) AS q, + wc.position AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc + ON wcv.wst_column_id = wc.id + JOIN wsts w + ON wc.wst_id = w.id + ORDER BY wcv.position ASC, + wc.position DESC; + COMMIT; + +2011-04-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java: + Add forgotten one to many relation Wst -> WstColumn. + +2011-04-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/WstParser.java: + Import of q ranges of wst files was totally broken. :-/ + You have to reimport all your data. + +2011-04-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + Forgot kind parameter in peer fetching query. + +2011-04-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java:: + Added a new method to determine the gauge based on a given start and end + point of the river. + +2011-04-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added 'position' column to wst_columns + to allow order them by there column position in the original + wst file. + + Update existing database with: + + BEGIN; + ALTER TABLE wst_columns ADD COLUMN position int; + UPDATE wst_columns w SET + position = id - (SELECT min(id) FROM wst_columns WHERE wst_id = w.wst_id); + ALTER TABLE wst_columns ADD CONSTRAINT wst_columns_wst_id_position_key + UNIQUE (wst_id, position); + COMMIT; + + * src/main/java/de/intevation/flys/model/Wst.java, + src/main/java/de/intevation/flys/model/WstColumn.java: + Adjusted models. + + * src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Adjusted importer. + +2011-04-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Forget ',' in schema. + +2011-04-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java (determineMinMaxQ): + Fixed index problem when an empty list is returned. + +2011-04-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java: A Wst is now able to + return its min and max Q values. + + * src/main/java/de/intevation/flys/model/Gauge.java: A Gauge is now able + to return its min and max W values. + +2011-04-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Added new column 'kind' in + discharge tables and wst to distinguish between different + kinds like 'Haupt-WST', 'zusaetzliche Laengsschnitte', + 'amtliche Daten' and so on. + + Update existing databases with: + BEGIN; + ALTER TABLE discharge_tables ADD COLUMN kind int NOT NULL DEFAULT 0; + ALTER TABLE wsts ADD COLUMN kind int NOT NULL DEFAULT 0; + COMMIT; + + * src/main/java/de/intevation/flys/model/DischargeTable.java + src/main/java/de/intevation/flys/model/Wst.java, + src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: + Adjusted the models. + +2011-04-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionHolder.java: Moved to + this module from flys-artifacts. This is necessary to get access to the + current session in this module as well. + +2011-04-14 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: Added a method that + returns the min and max distance of a river. + +2011-04-03 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/**/*.java: Removed trailing whitespace. + +2011-03-30 Ingo Weinzierl <ingo@intevation.de> + + Tagged RELEASE 0.1 + +2011-03-28 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Range.java: + Forgot to save the last change before commit. + +2011-03-28 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Range.java: + Added methods to find out if two ranges intersects. + +2011-03-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: + Added an one to many relation to the discharge tables of a gauge. + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Finished import of WSTs. + + TODO 1: Speed it up! It takes on a high end machine over 7(!) + minutes only for the data of the Saar. + TODO 2: Double precision floating point representations produced + by the the parsers leed to unique constraint violations + in the backend on a second run. So the import is currently + only working on freshly initialized data bases. + More consequent working with BigDecimal and some + rounding may be of help here. + + * src/main/java/de/intevation/flys/model/WstColumnValue.java: + Added convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportWstColumnValue.java: + Added getPeer() method. + + * src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Add a list of the ImportWstColumnValues produced by the WST parser. + + * src/main/java/de/intevation/flys/importer/WstParser.java: Add + the (km, w) values to the ImportWstColumns. + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Build models for wsts, wst columns and q ranges and + store them in the backend. TODO: store the w values. + + * src/main/java/de/intevation/flys/model/WstQRange.java + src/main/java/de/intevation/flys/model/Wst.java, + src/main/java/de/intevation/flys/model/Range.java, + src/main/java/de/intevation/flys/model/WstColumnQRange.java, + src/main/java/de/intevation/flys/model/WstColumn.java: + Added convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportWstQRange.java, + src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java, + src/main/java/de/intevation/flys/importer/ImportWstColumn.java, + src/main/java/de/intevation/flys/importer/ImportRange.java: + Added getPeer() methods. + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + The unit extraction in the WST parser of desktop FLYS + is broken! Add a hack here to repair this for our + importer. Desktop FLYS needs a fix, too! + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java: + Ported some stuff ver from WSTSource.java of desktop flys to + parse WST files. TODO: create instances of the import models. + + * src/main/java/de/intevation/flys/utils/StringUtil.java: + Copied from desktop flys. Used for some string operations + in WST parser. + + * src/main/java/de/intevation/flys/importer/Importer.java: + Added system property 'flys.backend.importer.dry.run'. + Set to true only the parsing is done and no writing + to the backend. Default: false. + + * src/main/java/de/intevation/flys/App.java, + src/main/java/de/intevation/flys/model/MainValueType.java: + Removed needless imports. + +2011-03-22 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/model/DischargeTableValue.java, + src/main/java/de/intevation/flys/model/DischargeTable.java: Added new + constructors. + + * src/main/java/de/intevation/flys/importer/AtFileParser.java: New. This + parser is used to '*.at' files. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: Added code to + import discharge tables. + + * src/main/java/de/intevation/flys/importer/ImportDischargeTableValue.java, + src/main/java/de/intevation/flys/importer/ImportDischargeTable.java: New. + Helper models for import discharge tables. + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/WstParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Added stub for WST parser. + +2011-03-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportWstQRange.java, + src/main/java/de/intevation/flys/importer/ImportWst.java, + src/main/java/de/intevation/flys/importer/ImportWstColumnValue.java, + src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java, + src/main/java/de/intevation/flys/importer/ImportWstColumn.java: + Added importer helper model stubs for WST imports. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Second part of parsing/storing main values. Should be finished now. + + * src/main/java/de/intevation/flys/importer/ImportNamedMainValue.java, + src/main/java/de/intevation/flys/importer/ImportMainValue.java: + New. Helper models for import main values, + + * src/main/java/de/intevation/flys/model/MainValue.java, + src/main/java/de/intevation/flys/model/NamedMainValue.java: + Added convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Write main values to backend, too. + + * src/main/java/de/intevation/flys/importer/StaFileParser.java: + Build importer models for main values. + + * src/main/java/de/intevation/flys/importer/ImportMainValueType.java: + Data was called 'value'. Now it is 'name' to fit the + schema. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Fixed wrong unique constraint. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Added some logging when storing gauges. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: + Add forgotten column river_id. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Small HQL fix. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Gauge.java: + Added convinience contructor. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Fixed getPeer() method. + + * src/main/java/de/intevation/flys/importer/StaFileParser.java: + Fixed parsing of STA files. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportGauge.java: + Propagate river into storing of gauges. + +2011-03-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/Importer.java: + Added code to store rivers not only annotations. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Added stub code to write gauges. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + First part of parsing main values. + + * src/main/java/de/intevation/flys/App.java: Commented out + creation of dummy rivers. + + * src/main/java/de/intevation/flys/model/NamedMainValues.java: + Moved to NamedMainValue. + + * src/main/java/de/intevation/flys/model/NamedMainValue.java: + New. Formerly NamedMainValues. + + * src/main/java/de/intevation/flys/model/MainValue.java: + New. Forgotten part of the model. + + * src/main/java/de/intevation/flys/model/MainValueType.java: + Data is String not BigDecimal + + * src/main/java/de/intevation/flys/model/Range.java: Removed + contructor with double arguments. Using BigDecimal now. + + * src/main/java/de/intevation/flys/importer/PegelGltParser.java: + Propagate BigDecimal usage. + + * src/main/java/de/intevation/flys/importer/Importer.java: + Removed needless import. Added TODO + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Parse the dependencies of the gauges, too. + + * src/main/java/de/intevation/flys/importer/StaFileParser.java: + New. Parser for STA files. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + Call STA file parser. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java, + src/main/java/de/intevation/flys/importer/ImportRange.java: + Uses BigDecimal now. + + * src/main/java/de/intevation/flys/importer/ImportAttribute.java: + Fixed wrong type cast in equals. + + * src/main/java/de/intevation/flys/importer/ImportMainValueType.java: + New. Helper model for importing main value types. + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Register forgotten MainValue model. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + Store annotations in backend. + + * src/main/java/de/intevation/flys/model/Annotation.java: + New convinience constructor. + + * src/main/java/de/intevation/flys/model/River.java: + Added toString() method. + + * src/main/java/de/intevation/flys/model/Range.java: + Fixed nasty mistake in @OneToOne annotatation. + New convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportPosition.java + src/main/java/de/intevation/flys/importer/ImportAnnotation.java, + src/main/java/de/intevation/flys/importer/ImportRange.java + src/main/java/de/intevation/flys/importer/ImportAttribute.java: + Make storing to backend work. It's a bit too slow. :-/ + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Fetch peer from backend. Added method to store annotations. + * src/main/java/de/intevation/flys/importer/Importer.java: + Stored annotations into backend. More eloquent SQL exception + handling. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Attribute.java, + src/main/java/de/intevation/flys/model/Position.java: + Added convinience constructors. + + * src/main/java/de/intevation/flys/importer/ImportPosition.java, + src/main/java/de/intevation/flys/importer/ImportAttribute.java: + Bound them to there backend peers. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java: + New. Added parser to read *.KM files. + + * src/main/java/de/intevation/flys/importer/ImportPosition.java, + src/main/java/de/intevation/flys/importer/PegelGltParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java, + src/main/java/de/intevation/flys/importer/ImportAnnotation.java, + src/main/java/de/intevation/flys/importer/ImportRange.java, + src/main/java/de/intevation/flys/importer/InfoGewParser.java, + src/main/java/de/intevation/flys/importer/ImportAttribute.java: + Adjusted to load the annotations from *.KM files. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/ImportPosition.java, + src/main/java/de/intevation/flys/importer/ImportRange.java, + src/main/java/de/intevation/flys/importer/ImportAttribute.java, + src/main/java/de/intevation/flys/importer/ImportAnnotation.java: + New helper models for import. + + * src/main/java/de/intevation/flys/importer/PegelGltParser.java, + src/main/java/de/intevation/flys/importer/ImportGauge.java: + Use new models. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/PegelGltParser.java: + New. Parser for PEGEL.GLT files. + + * src/main/java/de/intevation/flys/importer/ImportGauge.java: + New. Import model for gauges. + + * src/main/java/de/intevation/flys/utils/DBCPConnectionProvider.java: + Removed needless imports. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Added method to parse the gauges. + + * src/main/java/de/intevation/flys/importer/InfoGewParser.java: + Trigger pegel glt file parsing. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/Importer.java: + Used thread local pattern to make sharing of session easier. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/Importer.java: + Fixed error in HQL statement. + +2011-03-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/utils/DBCPConnectionProvider.java: + Commented out a debug block because it leaks the db password. + +2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/importer/InfoGewParser.java: + Expose imported rivers. + + * src/main/java/de/intevation/flys/importer/InfoGewParser.java: + Store imported rivers into database. Needs testing! + +2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Default connection parameters are now overwritable with + system properties (defaults in brackets): + - user name: flys.backend.user (flys) + - user password: flys.backend.password (flys) + - db dialect: flys.backend.dialect (org.hibernate.dialect.PostgreSQLDialect) + - db driver: flys.backend.driver (org.postgresql.Driver) + - db url: flys.backend.url (jdbc:postgresql://localhost:5432/flys) + +2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Expose createSessionFactory() as public to be usable without + a artifact database running. + +2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/utils/FileTools.java: + Tools for handling with filenames. Currently there is + a repair(File) method with repairs letter case errors + which is useful when reading windows filenames on a + un*x platform. + + * src/main/java/de/intevation/flys/importer/Importer.java: + Standalone app to read data from the file system and + store it in a database. Currently it does not store + anything. It only loads info gew files. + + * src/main/java/de/intevation/flys/importer/InfoGewParser.java: + Info gew parser. + + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Helper model of a river used produced by parsing the + info gew files. + +2011-03-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + New. SessionFactoryProvider.getSessionFactory() provides a + SessionFactory to use the Hibernate O/R mapper for the FLYS backend. + +2011-03-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * pom.xml: Added dependency to artifacts-commons to + be able to use the global configuration of the artifact database. + +2011-03-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/App.java: Wire all POJOs + to corresponding factory. + + * src/main/java/de/intevation/flys/model/*.java: Generate + all foreign key constraints. TODO: name them correctly + because the machine generated names are ugly and do + not fit the PostgreSQL names. + + * doc/schema/postgresql.sql: Small quantifier fix in descriptions + of wst columns. + +2011-03-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql: Fixed wrong spelled + column references in foreign keys introduces with + last change. + +2011-03-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/*.java: Added + column annotations for simple fields. TODO: foreign keys. + +2011-03-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql, doc/schema/postgresql-cleanup.sql: + Fixed inconsistent table names. + + * src/main/java/de/intevation/flys/model/*.java: Added + entity and id annotations. + +2011-03-14 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql.sql, doc/schema/postgresql-cleanup.sql: + Added missing sequences. + + * doc/schema/sqlite.sql: Deleted. Not longer supported. + +2011-03-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql-cleanup.sql: Forgot to add. + + * src/main/java/de/intevation/flys/App.java: Use + Apache Commons DBCP as Hibernate connection provide. + + * src/main/java/de/intevation/flys/model/River.java: + Added a constructor with string argument. Set the + sequence increment to 1 (eat up 100 at a time before). + + * pom.xml: Added PostgreSQL 8.4 driver as runtime dependency. + +2011-03-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/postgresql-cleanup.sql: New. Tear down schema + for a postgres database. + + * doc/schema/postgresql.sql: Added squence for + auto generating ids in river table. Cleaned up schema. + + * src/main/java/de/intevation/flys/App.java: Simple + test app to interact with hibernate. Needs to be removed + because its only a toy. + + * src/main/java/de/intevation/flys/utils/DBCPConnectionProvider.java: + New. Binds Apache Commons to Hibernate. + + * pom.xml: Added dependencies to log4j, commons dbcp, + JPA of hibernate. + + * src/main/java/de/intevation/flys/model/River.java: Added + JPA annotations. + + * src/main/java/de/intevation/flys/model/*.java: Replaced + Long with Integer because column ids are only four bytes wide. + +2011-03-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/sqlite.sql, doc/schema/postgresql.sql: Fixed + smaller issues in ddl. + + * src/main/java/de/intevation/flys/model/*.java: Added POJOs + of to be mapped. TODO: Map them! + + * pom.xml: Added plugin config for hibernate. + +2011-03-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * pom.xml: Added dependency (and corresponding repository) to + Hibernate Core 3.6.1 Final + +2011-03-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * pom.xml, src/**: Created a new empty maven project: + $ mvn archetype:create \ + -DgroupId=de.intevation.flys \ + -DartifactId=flys-backend + +2011-03-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * README: New. Some setup instructions. + + * doc/schema/postgresql.sql: New. Schema converted to PostgreSQL + + * doc/schema/sqlite.sql: Fixed defect foreign key constraints. + +2011-03-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/schema/sqlite.sql: Factorized time intervals out into + a separated table. + +2011-01-22 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * contrib/import-kms.py, contrib/import-gew.py: Initial scripts + to import data into SQLite database. They still need some work. + +2011-02-10 Sascha L. Teichmann <sascha.teichmann@intevation.de>: + + * doc/schema/sqlite.sql: Added initial schema for + FLYS database.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/Changes Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,109 @@ +2011-09-19 RELEASE 2.5 + + NEW: + + * Improved the data model to support: + - cross sections + - hyks ("Hydraulische Kenngroessen") + + * Improved the importer to read: + - PRF files + - HYK files + + * Added a central Config to configure the Importer. There are several + system properties to adjust what to import (see ChangeLog for + details). + + * Added a Postgis and Oracle models for spatial flys data: + - catchments + - river axes + - buildings + - fixpoints + - cross section tracks + - hws ("HW-Schutzanlagen") + - floodplains + + * Bumped Hibernate up to 3.6.5. + + * Bumped Apache DBCP up to 1.4. + + + +2011-06-27 RELEASE 2.4 + + New: + + * Improved the data model to support: + - edges ("Oberkante", "Unterkante") + - annotations + + * Improved the importer to read: + - edges + - annotations + + * Made search for gauges in River independent of from/to + kilometer order. + + + Fixes: + + * flys/issue76 Close gaps between q ranges + + * flys/issue110 Fixed import of ATs that skipped the first value. + + + +2011-05-13 RELEASE 2.3 + + New: + + * Import of: + - "zusätzliche Längsschnitte" + - "Fixierungen" + - "amtliche Linien" + - "Hochwassermarken" + - "Historische Abflusskurven" + - "HW-Schutzanlagen" + + * Improvements in the SQL schema: + - Added a 'kind' column to WSTs + - Added a 'position' column to WST columns to enable sorting WST columns. + - Added a 'km_up' column to rivers to determine the flow direction of rivers. + + * Rivers are now able to: + - determine their min/max kilometer range + - determine the selected gauge(s) based on a kilometer range + + * WSTs are able to determine their min/max Q range. + + * Gauges are able to determine their min/max W range. + + * Added a view 'wst_value_table' that aggregates the data to build w/q + value tables. + + * Added one-to-many relation Wst -> WstColumn + + * Speedup of the importer by using an internal caching mechanism. + + * Sta-Parse just accepts the following main value types: 'Q', 'W', 'D' and 'T' + + + Fixes: + + * Fixed import of Q ranges in wst files. + + * Fixed flys/issue19: Do not take km column in wst file as a water level. + + * Fixed flys/issue11 (Diagramm: Fehlerhafte Werte in Abflusskurven) + + * Fixed flys/issue51 (WINFO: Fachdaten am Pegel Perl enthält Sprünge) + + + !!! + + The version number of this release depends on an existing desktop variant of + this software that is in version 2.1. + + !!! + +2011-03-30 RELEASE 0.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/README Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,10 @@ +For the artifact database +# su - postgres +$ createuser --no-createrole --no-superuser --pwprompt --no-createdb artifacts +$ createdb --encoding=UTF-8 --owner artifacts artifactsdb + +For the flys database + +# su - postgres +$ createuser --no-createrole --no-superuser --pwprompt --no-createdb flys +$ createdb --encoding=UTF-8 --owner flys flystest1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/dump-schema.sh Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,16 @@ +#!/bin/bash + +DB_URL=jdbc:postgresql://czech-republic.atlas.intevation.de:5432/flys3 +DB_USER=flys +DB_PASS=flys +DB_DIALECT=org.hibernatespatial.oracle.OracleSpatial10gDialect + +mvn compile package -e \ + -Dlog4j.configuration=file://`readlink -f contrib/log4j.properties` \ + -Dflys.backend.user=$DB_USER \ + -Dflys.backend.password=$DB_PASS \ + -Dflys.backend.dialect=$DB_DIALECT \ + -Dflys.backend.url=$DB_URL \ + -Dexec.mainClass=de.intevation.flys.App \ + exec:java +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/import-gew.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,223 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +import os +import codecs +import re + +HAUPTWERT = re.compile(r"\s*([^\s]+)\s+([^\s+]+)\s+([QWDT-])") +WHITESPACE = re.compile(r"\s+") + +class KM(object): + + def __init__(self, filename): + self.filename = filename + self.load_values() + + def load_values(self): + with codecs.open(self.filename, "r", "latin-1") as f: + for line in f: + line = line.strip() + if not line or line.startswith("*"): + parts = [s.strip() for s in line.split(";")] + # TODO: Use code from import-kms.py + +class AbflussTafel(object): + + def __init__(self, filename): + self.filename = filename + self.name = "" + self.values = [] + self.load_values() + + def load_values(self): + with codecs.open(self.filename, "r", "latin-1") as f: + first = True + for line in f: + line = line.strip() + if not line: continue + if line.startswith("#! name="): + self.name = line[8:] + continue + if line.startswith("#") or line.startswith("*"): + continue + line = line.replace(",", ".") + splits = WHITESPACE.split(line) + + if len(splits) < 2 or len(splits) > 11: + continue + + w = float(splits[0]) + + shift = 0 + + if len(splits) != 11 and first: + shift = 11 - len(splits) + + for idx, q in enumerate(splits[1:]): + i_w = w + shift + idx + i_q = float(q) + w_q = (i_w/100.0, i_q/100.0) + self.values.append(w_q) + + first = False + + +class Hauptwert(object): + def __init__(self, name, value, kind): + self.name = name + self.extra = value + self.kind = kind + +class Pegel(object): + def __init__(self, name, start, stop, sta, at, html): + self.name = name + self.start = start + self.stop = stop + self.sta = sta + self.at = at + self.html = html + self.aeo = 0.0 + self.nullpunkt = 0.0 + self.km = 0.0 + self.hauptwerte = [] + self.load_hauptwerte() + self.at_data = AbflussTafel(self.at) + + def load_hauptwerte(self): + with codecs.open(self.sta, "r", "latin-1") as f: + for line_no, line in enumerate(f): + line = line.rstrip() + if line_no == 0: + first = False + name = line[16:37].strip() + line = [s.replace(",", ".") for s in line[37:].split()] + self.aeo = float(line[0]) + self.nullpunkt = float(line[1]) + print >> sys.stderr, "pegel name: '%s'" % name + print >> sys.stderr, "pegel aeo: '%f'" % self.aeo + print >> sys.stderr, "pegel nullpunkt: '%f'" % self.nullpunkt + elif line_no == 1: + self.km = float(line[29:36].strip().replace(",", ".")) + print >> sys.stderr, "km: '%f'" % self.km + else: + if not line: continue + line = line.replace(",", ".") + m = HAUPTWERT.match(line) + if not m: continue + self.hauptwerte.append(Hauptwert( + m.group(1), float(m.group(2)), m.group(3))) + +class Gewaesser(object): + + def __init__(self, name=None, b_b=None, wst=None): + self.name = name + self.b_b = b_b + self.wst = wst + self.pegel = [] + + def load_pegel(self): + dir_name = os.path.dirname(self.wst) + pegel_glt = find_file(dir_name, "PEGEL.GLT") + if not pegel_glt: + print >> sys.stderr, "Missing PEGEL.GLT for %r" % self.name + return + + print >> sys.stderr, "pegel_glt: %r" % pegel_glt + + with codecs.open(pegel_glt, "r", "latin-1") as f: + for line in f: + line = line.strip() + if not line or line.startswith("#"): + continue + # using re to cope with quoted columns, + # shlex has unicode problems. + parts = [p for p in re.split("( |\\\".*?\\\"|'.*?')", line) + if p.strip()] + if len(parts) < 7: + print >> sys.stderr, "too less colums (need 7): %r" % line + continue + + print >> sys.stderr, "%r" % parts + self.pegel.append(Pegel( + parts[0], + min(float(parts[2]), float(parts[3])), + max(float(parts[2]), float(parts[3])), + norm_path(parts[4], dir_name), + norm_path(parts[5], dir_name), + parts[6])) + + + def __repr__(self): + return u"Gewaesser(name=%r, b_b=%r, wst=%r)" % ( + self.name, self.b_b, self.wst) + +def norm_path(path, ref): + if not os.path.isabs(path): + path = os.path.normpath(os.path.join(ref, path)) + return path + +def find_file(path, what): + what = what.lower() + for filename in os.listdir(path): + p = os.path.join(path, filename) + if os.path.isfile(p) and filename.lower() == what: + return p + return None + + +def read_gew(filename): + + gewaesser = [] + + current = Gewaesser() + + filename = os.path.abspath(filename) + dirname = os.path.dirname(filename) + + with codecs.open(filename, "r", "latin-1") as f: + for line in f: + line = line.strip() + if not line or line.startswith("*"): + continue + + if line.startswith(u"Gewässer:"): + if current.name: + gewaesser.append(current) + current = Gewaesser() + current.name = line[len(u"Gewässer:"):].strip() + elif line.startswith(u"B+B-Info:"): + current.b_b = norm_path(line[len(u"B+B-Info:"):].strip(), + dirname) + elif line.startswith(u"WSTDatei:"): + current.wst = norm_path(line[len(u"WSTDatei:"):].strip(), + dirname) + + if current.name: + gewaesser.append(current) + + return gewaesser + +def main(): + + if len(sys.argv) < 2: + print >> sys.stderr, "missing gew file" + sys.exit(1) + + gew_filename = sys.argv[1] + + if not os.path.isfile(gew_filename): + print >> sys.stderr, "'%s' is not a file" % gew_filename + sys.exit(1) + + gewaesser = read_gew(gew_filename) + + for gew in gewaesser: + gew.load_pegel() + + + +if __name__ == '__main__': + main() +# vim: set fileencoding=utf-8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/import-kms.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,213 @@ +#!/usr/bin/env python + +import sys +import logging +import re +import os + +import sqlite3 as db +import locale +import codecs + +from optparse import OptionParser + +log = logging.getLogger(__name__) +log.setLevel(logging.WARNING) +log.addHandler(logging.StreamHandler(sys.stderr)) + +RANGE = re.compile("([^#]*)#(.*)") +DEFAULT_DATABASE = "flys.db" + +SQL_NEXT_ID = "SELECT coalesce(max(id), -1) + 1 FROM %s" +SQL_SELECT_ID = "SELECT id FROM %s WHERE %s = ?" +SQL_INSERT_ID = "INSERT INTO %s (id, %s) VALUES (?, ?)" + +SQL_SELECT_RANGE_ID = """ +SELECT id FROM ranges WHERE river_id = ? AND a = ? AND b = ? +""" +SQL_INSERT_RANGE_ID = """ +INSERT INTO ranges (id, river_id, a, b) VALUES (?, ?, ?, ?) +""" +SQL_SELECT_ANNOTATION_ID = """ +SELECT id FROM annotations +WHERE range_id = ? AND attribute_id = ? AND position_id = ? +""" +SQL_INSERT_ANNOTATION_ID = """ +INSERT INTO annotations (id, range_id, attribute_id, position_id) +VALUES (?, ?, ?, ?) +""" + +def encode(s): + try: + return unicode(s, "latin-1") + except UnicodeDecodeError: + return unicode.encode(s, locale.getpreferredencoding()) + +class hashabledict(dict): + def __key(self): + return tuple((k, self[k]) for k in sorted(self)) + def __hash__(self): + return hash(self.__key()) + def __eq__(self, other): + return self.__key() == other.__key() + +def cache(f): + def func(*args, **kw): + key = (args, hashabledict(kw)) + try: + return f.__cache__[key] + except KeyError: + value = f(*args, **kw) + f.__cache__[key] = value + return value + f.__cache__ = {} + return func + +NEXT_IDS = {} +def next_id(cur, relation): + idx = NEXT_IDS.get(relation) + if idx is None: + cur.execute(SQL_NEXT_ID % relation) + idx = cur.fetchone()[0] + NEXT_IDS[relation] = idx + 1 + return idx + +def get_id(cur, relation, attribute, value): + select_stmt = SQL_SELECT_ID % (relation, attribute) + #log.debug(select_stmt) + cur.execute(select_stmt, (value,)) + row = cur.fetchone() + if row: return row[0] + idx = next_id(cur, relation) + insert_stmnt = SQL_INSERT_ID % (relation, attribute) + #log.debug(insert_stmnt) + cur.execute(insert_stmnt, (idx, value)) + cur.connection.commit() + log.debug("insert %s '%s' id: '%d'" % (relation, value, idx)) + return idx + +#@cache +def get_river_id(cur, name): + return get_id(cur, "rivers", "name", name) + +#@cache +def get_attribute_id(cur, value): + return get_id(cur, "attributes", "value", value) + +#@cache +def get_position_id(cur, value): + return get_id(cur, "positions", "value", value) + +#@cache +def get_range_id(cur, river_id, a, b): + cur.execute(SQL_SELECT_RANGE_ID, (river_id, a, b)) + row = cur.fetchone() + if row: return row[0] + idx = next_id(cur, "ranges") + cur.execute(SQL_INSERT_RANGE_ID, (idx, river_id, a, b)) + cur.connection.commit() + return idx + +#@cache +def get_annotation_id(cur, range_id, attribute_id, position_id): + cur.execute(SQL_SELECT_ANNOTATION_ID, ( + range_id, attribute_id, position_id)) + row = cur.fetchone() + if row: return row[0] + idx = next_id(cur, "annotations") + cur.execute(SQL_INSERT_ANNOTATION_ID, ( + idx, range_id, attribute_id, position_id)) + cur.connection.commit() + return idx + +def files(root, accept=lambda x: True): + if os.path.isfile(root): + if accept(root): yield root + elif os.path.isdir(root): + stack = [ root ] + while stack: + cur = stack.pop() + for f in os.listdir(cur): + p = os.path.join(cur, f) + if os.path.isdir(p): + stack.append(p) + elif os.path.isfile(p) and accept(p): + yield p + +def feed_km(cur, river_id, km_file): + + log.info("processing: %s" % km_file) + + for line in codecs.open(km_file, "r", "latin-1"): + line = line.strip() + if not line or line.startswith('*'): + continue + parts = [x.strip() for x in line.split(';')] + if len(parts) < 3: + log.error("cannot process: '%s'" % line) + continue + m = RANGE.match(parts[2]) + try: + if m: + x = [float(x.replace(",", ".")) for x in m.groups()] + a, b = min(x), max(x) + if a == b: b = None + else: + a, b = float(parts[2].replace(",", ".")), None + except ValueError: + log.error("cannot process: '%s'" % line) + continue + + attribute = parts[0] + position = parts[1] + attribute_id = get_attribute_id(cur, attribute) if attribute else None + position_id = get_position_id(cur, position) if position else None + + range_id = get_range_id(cur, river_id, a, b) + + get_annotation_id(cur, range_id, attribute_id, position_id) + +def main(): + + usage = "usage: %prog [options] river km-file ..." + parser = OptionParser(usage=usage) + parser.add_option( + "-v", "--verbose", action="store_true", + dest="verbose", + help="verbose output") + parser.add_option( + "-r", "--recursive", action="store_true", + dest="recursive", default=False, + help="recursive") + parser.add_option( + "-d", "--database", action="store", + dest="database", + help="database to connect with", + default=DEFAULT_DATABASE) + + options, args = parser.parse_args() + + if options.verbose: + log.setLevel(logging.INFO) + + if len(args) < 1: + log.error("missing river argument") + sys.exit(1) + + river = unicode(args[0], locale.getpreferredencoding()) + + with db.connect(options.database) as con: + cur = con.cursor() + river_id = get_river_id(cur, river) + + for arg in args[1:]: + if options.recursive: + for km_file in files( + arg, lambda x: x.lower().endswith(".km")): + feed_km(cur, river_id, km_file) + else: + feed_km(cur, river_id, arg) + + +if __name__ == '__main__': + main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/axis.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,46 @@ +import ogr + +from importer import Importer + +TABLE_NAME="river_axes" +PATH="Geodaesie/Flussachse+km" + + +class Axis(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 + + + def isShapeRelevant(self, name, path): + return name == "achse" + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + newFeat.SetGeometry(feat.GetGeometryRef()) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + riverId = feat.GetField("river_id") + else: + riverId = self.river_id + + if self.IsFieldSet(feat, "kind"): + kind = feat.GetField("kind") + else: + kind = 0 + + newFeat.SetField("river_id", riverId) + newFeat.SetField("kind", kind) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/boundaries.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,82 @@ +import ogr + +from importer import Importer + +TABLE_NAME="hydr_boundaries" +TABLE_NAME_POLY="hydr_boundaries_poly" +PATH="Hydrologie/Hydr.Grenzen/Linien" + + +class HydrBoundary(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 + + + def isShapeRelevant(self, name, path): + return True + + + def getKind(self, path): + if path.find("BfG") > 0: + return 1 + else: + return 2 + + + def createNewFeature(self, featureDef, feat, **args): + kind = self.getKind(args['path']) + + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + newFeat.SetField("name", args['name']) + newFeat.SetField("kind", kind) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + return newFeat + + + +class HydrBoundaryPoly(HydrBoundary): + + def getTablename(self): + return TABLE_NAME_POLY + + + def isGeometryValid(self, geomType): + return geomType == 3 or geomType == 6 + + + def createNewFeature(self, featureDef, feat, **args): + kind = self.getKind(args['path']) + + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + newFeat.SetField("name", args['name']) + newFeat.SetField("kind", kind) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/buildings.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,42 @@ +import ogr + +from importer import Importer + +TABLE_NAME="buildings" +PATH="Geodaesie/Bauwerke" + + +class Building(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + newFeat.SetGeometry(feat.GetGeometryRef()) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "Name"): + newFeat.SetField("name", feat.GetField("Name")) + elif self.IsFieldSet(feat, "KWNAAM"): + newFeat.SetField("name", feat.GetField("KWNAAM")) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/catchments.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,48 @@ +import ogr + +from importer import Importer + +TABLE_NAME="catchment" +PATH="Hydrologie/Einzugsgebiet" + + +class Catchment(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 3 or geomType == 6 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "Name"): + newFeat.SetField("name", feat.GetField("name")) + else: + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "AREA"): + newFeat.SetField("area", feat.GetField("area")) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/crosssectiontracks.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,52 @@ +import ogr + +from importer import Importer + +TABLE_NAME="cross_section_tracks" +PATH="Geodaesie/Querprofile" + + +class CrosssectionTrack(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + newFeat.SetGeometry(feat.GetGeometryRef()) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "KILOMETER"): + newFeat.SetField("km", feat.GetFieldAsDouble("KILOMETER")) + elif self.IsFieldSet(feat, "KM"): + newFeat.SetField("km", feat.GetFieldAsDouble("KM")) + elif self.IsFieldSet(feat, "STATION"): + newFeat.SetField("km", feat.GetFieldAsDouble("STATION")) + else: + return None + + if self.IsFieldSet(feat, "ELEVATION"): + newFeat.SetField("z", feat.GetFieldAsDouble("ELEVATION")) + else: + newFeat.SetField("z", 0) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/fixpoints.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,56 @@ +import ogr, osr + +from importer import Importer + +TABLE_NAME="fixpoints" +PATH="Geodaesie/Festpunkte" + + +class Fixpoint(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 1 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + + newFeat.SetGeometry(geometry) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "KM"): + newFeat.SetField("km", feat.GetFieldAsDouble("KM")) + elif self.IsFieldSet(feat, "ELBE_KM"): + newFeat.SetField("km", feat.GetFieldAsDouble("ELBE_KM")) + else: + return None + + if self.IsFieldSet(feat, "X"): + newFeat.SetField("x", feat.GetFieldAsDouble("X")) + + if self.IsFieldSet(feat, "Y"): + newFeat.SetField("y", feat.GetFieldAsDouble("Y")) + + if self.IsFieldSet(feat, "HPGP"): + newFeat.SetField("HPGP", feat.GetField("HPGP")) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/floodplains.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,40 @@ +import ogr + +from importer import Importer + +TABLE_NAME="floodplain" +PATH="Hydrologie/Hydr.Grenzen" + + +class Floodplain(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 3 or geomType == 6 + + + def isShapeRelevant(self, name, path): + return name.find("talaue") >= 0 + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + + newFeat.SetGeometry(geometry) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/gauges.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,47 @@ +import ogr + +from importer import Importer + +TABLE_NAME="gauge_location" +PATH="Hydrologie/Streckendaten" + + +class GaugeLocation(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 1 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "Name"): + newFeat.SetField("name", feat.GetField("name")) + elif self.IsFieldSet(feat, "MPNAAM"): + newFeat.SetField("name", feat.GetField("MPNAAM")) + else: + newFeat.SetField("name", args['name']) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/hws.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,51 @@ +import ogr + +from importer import Importer + +TABLE_NAME="hws" +PATH="Hydrologie/HW-Schutzanlagen" + + +class HWS(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "TYP"): + newFeat.SetField("type", feat.GetField("TYP")) + + if self.IsFieldSet(feat, "Bauart"): + newFeat.SetField("hws_facility", feat.GetField("Bauart")) + + if self.IsFieldSet(feat, "Name"): + newFeat.SetField("name", feat.GetField("name")) + else: + newFeat.SetField("name", args['name']) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/importer.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,139 @@ +import ogr, osr + +class Importer: + + def __init__(self, dbconn, river_id, dest_srs): + self.dbconn = dbconn + self.river_id = river_id + self.dest_srs = osr.SpatialReference() + self.dest_srs.ImportFromEPSG(dest_srs) + + + def getKind(self, path): + raise NotImplementedError("Importer.getKind is abstract!") + + + def getPath(self, base): + raise NotImplementedError("Importer.getPath is abstract!") + + + def getTablename(self): + raise NotImplementedError("Importer.getTablename is abstract!") + + + def IsFieldSet(self, feat, name): + try: + isset = feat.GetField(name) + return isset is not None + except: + return False + + + def IsDoubleFieldSet(self, feat, name): + try: + isset = feat.GetFieldAsDouble(name) + return isset is not None + except: + return False + + + def isShapeRelevant(self, name, path): + return True + + + def walkOverShapes(self, shape): + print "---" + (name, path) = shape + if not self.isShapeRelevant(name, path): + print "Skip shapefile '%s'" % name + return + + shp = ogr.Open(shape[1]) + if shp is None: + print "Shapefile '%s' could not be opened!" % path + return + + print "Opened shapefile '%s'" % path + srcLayer = shp.GetLayerByName(name) + + if srcLayer is None: + print "Layer '%s' was not found!" % name + return + + return self.shape2Database(srcLayer, name, path) + + + def transform(self, feat): + geometry = feat.GetGeometryRef() + src_srs = geometry.GetSpatialReference() + + if src_srs is None: + print "Error: No source SRS given! No transformation possible!" + return feat + + transformer = osr.CoordinateTransformation(src_srs, self.dest_srs) + geometry.Transform(transformer) + + return feat + + + def shape2Database(self, srcLayer, name, path): + table = ogr.Open(self.dbconn) + destLayer = table.GetLayerByName(self.getTablename()) + + if srcLayer is None: + print "Shapefile is None!" + return -1 + + if destLayer is None: + print "No destination layer given!" + return -1 + + count = srcLayer.GetFeatureCount() + print "Try to add %i features to database." % count + + srcLayer.ResetReading() + + geomType = -1 + success = 0 + unsupported = 0 + creationFailed = 0 + featureDef = destLayer.GetLayerDefn() + + for feat in srcLayer: + geom = feat.GetGeometryRef() + + if geom is None: + continue + + geomType = geom.GetGeometryType() + + if self.isGeometryValid(geomType): + newFeat = self.createNewFeature(featureDef, + feat, + name=name, + path=path) + + if newFeat is not None: + newFeat = self.transform(newFeat) + res = destLayer.CreateFeature(newFeat) + if res is None or res > 0: + print "Error while inserting feature: %r" % res + else: + success = success + 1 + else: + creationFailed = creationFailed + 1 + else: + unsupported = unsupported + 1 + + print "Inserted %i features" % success + print "Failed to create %i features" % creationFailed + print "Found %i unsupported features" % unsupported + + try: + destLayer.CommitTransaction() + except e: + print "Exception while committing transaction." + + return geomType +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/km.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,45 @@ +import ogr + +from importer import Importer + +TABLE_NAME="river_axes_km" +PATH="Geodaesie/Flussachse+km" + + +class KM(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 1 + + + def isShapeRelevant(self, name, path): + return name == "km" + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + newFeat.SetGeometry(feat.GetGeometryRef()) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsDoubleFieldSet(feat, "km"): + newFeat.SetField("km", feat.GetFieldAsDouble("km")) + elif self.IsDoubleFieldSet(feat, "KM"): + newFeat.SetField("km", feat.GetFieldAsDouble("KM")) + else: + return None + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/lines.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,51 @@ +import ogr + +from importer import Importer + +TABLE_NAME="lines" +PATH="Geodaesie/Linien" + + +class Line(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + return geomType == 2 or geomType == -2147483646 + + + def isShapeRelevant(self, name, path): + return True + + + def createNewFeature(self, featureDef, feat, **args): + newFeat = ogr.Feature(featureDef) + geometry = feat.GetGeometryRef() + geometry.SetCoordinateDimension(2) + + newFeat.SetGeometry(geometry) + newFeat.SetField("name", args['name']) + + if self.IsFieldSet(feat, "river_id"): + newFeat.SetField("river_id", feat.GetField("river_id")) + else: + newFeat.SetField("river_id", self.river_id) + + if self.IsFieldSet(feat, "TYP"): + newFeat.SetField("kind", feat.GetFieldAsDouble("TYP")) + else: + newFeat.SetField("kind", "DAMM") + + if self.IsFieldSet(feat, "Z"): + newFeat.SetField("z", feat.GetFieldAsDouble("Z")) + else: + newFeat.SetField("z", 9999) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/shpimporter.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,60 @@ +import ogr + +import utils +from uesg import UESG +from axis import Axis +from km import KM +from lines import Line +from fixpoints import Fixpoint +from buildings import Building +from crosssectiontracks import CrosssectionTrack +from floodplains import Floodplain +from boundaries import HydrBoundary, HydrBoundaryPoly +from hws import HWS +from gauges import GaugeLocation +from catchments import Catchment + +DBCONN='OCI:user/pass@host' +PATH='/path/to/Gewaesser/Elbe' +RIVER_ID=the_river_id +DEST_SRS=31467 + + +def getImporters(): + return [ + Axis(DBCONN, RIVER_ID, DEST_SRS), + KM(DBCONN, RIVER_ID, DEST_SRS), + CrosssectionTrack(DBCONN, RIVER_ID, DEST_SRS), + Line(DBCONN, RIVER_ID, DEST_SRS), + Fixpoint(DBCONN, RIVER_ID, DEST_SRS), + Building(DBCONN, RIVER_ID, DEST_SRS), + Floodplain(DBCONN, RIVER_ID, DEST_SRS), + HydrBoundary(DBCONN, RIVER_ID, DEST_SRS), + HydrBoundaryPoly(DBCONN, RIVER_ID, DEST_SRS), + HWS(DBCONN, RIVER_ID, DEST_SRS), + GaugeLocation(DBCONN, RIVER_ID, DEST_SRS), + Catchment(DBCONN, RIVER_ID, DEST_SRS), + UESG(DBCONN, RIVER_ID, DEST_SRS) + ] + + +if __name__ == '__main__': + importers = getImporters() + + types = {} + + for importer in importers: + shapes = utils.findShapefiles(importer.getPath(PATH)) + print "Found %i Shapefiles" % len(shapes) + + for shpTuple in shapes: + geomType = importer.walkOverShapes(shpTuple) + try: + num = types[geomType] + types[geomType] = num+1 + except: + types[geomType] = 1 + + for key in types: + print "%i x geometry type %s" % (types[key], key) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/uesg.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,89 @@ +import ogr + +from importer import Importer + + +TABLE_NAME="floodmaps" +PATH="Hydrologie/UeSG/Berechnung" + + +class UESG(Importer): + + def getPath(self, base): + return "%s/%s" % (base, PATH) + + + def getTablename(self): + return TABLE_NAME + + + def isGeometryValid(self, geomType): + if geomType == 3 or geomType == 6: + return True + else: + return False + + + def getKind(self, path): + kind = 0 + if path.find("Berechnung") > 0: + kind = kind + 100 + + if path.find("Aktuell") > 0: + kind = kind + 10 + else: + kind = kind + 20 + + if path.find("Land") > 0: + kind = kind + 2 + else: + kind = kind + 1 + else: + kind = kind + 200 + + return kind + + + def createNewFeature(self, featureDef, feat, **args): + kind = self.getKind(args['path']) + + newFeat = ogr.Feature(featureDef) + newFeat.SetGeometry(feat.GetGeometryRef()) + + if self.IsFieldSet(feat, "river_id"): + riverId = feat.GetField(feat) + else: + riverId = self.river_id + + if self.IsFieldSet(feat, "diff"): + diff = feat.GetFieldAsDouble("diff") + else: + diff = 0 + + if self.IsFieldSet(feat, "count"): + count = feat.GetFieldAsInteger("count") + else: + count = 0 + + if self.IsFieldSet(feat, "area"): + area = feat.GetFieldAsDouble("area") + else: + area = 0 + + if self.IsFieldSet(feat, "perimeter"): + perimeter = feat.GetFieldAsDouble("perimeter") + else: + perimeter = 0 + + groupId = 2 + + newFeat.SetField("river_id", riverId) + newFeat.SetField("diff", diff) + newFeat.SetField("count", count) + newFeat.SetField("area", area) + newFeat.SetField("perimeter", perimeter) + newFeat.SetField("kind", kind) + newFeat.SetField("name", args['name']) + + return newFeat +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/shpimporter/utils.py Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,20 @@ +import os + +SHP='.shp' + +def findShapefiles(path): + shapes = [] + + for root, dirs, files in os.walk(path): + if len(files) == 0: + continue + + print "Processing directory '%s' with %i files " % (root, len(files)) + + for f in files: + idx = f.find(SHP) + if (idx+len(SHP)) == len(f): + shapes.append((f.replace(SHP, ''), root + "/" + f)) + + return shapes +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/contrib/spatial-info.sh Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,10 @@ +#!/bin/bash + +mvn -e \ + -Dlog4j.configuration=file://`readlink -f contrib/log4j.properties` \ + -Dflys.backend.user=USER \ + -Dflys.backend.password=PASSWORD \ + -Dflys.backend.url=jdbc:postgresql://THE.DATABASE.HOST:PORT/DBNAME \ + -Dflys.backend.spatial.river=Saar \ + -Dexec.mainClass=de.intevation.flys.backend.SpatialInfo \ + exec:java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/annotation-types.xml Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<annotation> + <types> + <type name="Abzweigung"/> + <type name="Berechnungsstrecke"/> + <type name="Brücke"/> + <type name="Bundesland"/> + <type name="Deich-Kilometrierung"/> + <type name="Einmündung"/> + <type name="Fähre"/> + <type name="Grenze"/> + <type name="Hafen"/> + <type name="Hauptpegel"/> + <type name="Hauptzufluss"/> + <type name="HW-Marken"/> + <type name="HW-Schutz"/> + <type name="Insel"/> + <type name="Kraftwerk"/> + <type name="Landkreis"/> + <type name="Landesgewässerkilometrierung"/> + <type name="Meldestelle"/> + <type name="Nebenarm / Altarm"/> + <type name="sonstige Messstelle"/> + <type name="Morphologische Messstelle"/> + <type name="Pegel (inkl. Nebenpegel)"/> + <type name="Ort"/> + <type name="Schleuse"/> + <type name="Stauwehr"/> + <type name="Staatsgrenze"/> + <type name="Staat"/> + <type name="WSA"/> + <type name="WSD"/> + <type name="Zufluss (inkl. kleinerer Gewässer)"/> + <type name="Sonstige" default="true"/> + </types> + + <patterns> + <file pattern="^Verzweigung$" type="Abzweigung"/> + <file pattern="^Brücken$" type="Brücke"/> + <file pattern="^Deich.*$" type="Deich"/> + <file pattern="^Hafen$" type="Hafen"/> + <file pattern="^Hauptpegel$" type="Hauptpegel"/> + <file pattern="^Zufluss$" type="Hauptzufluss"/> + <file pattern="^Zufluß$" type="Hauptzufluss"/> + <file pattern="^HW-Marken$" type="HW-Marken"/> + <file pattern="^HW-Schutzanlagen$" type="HW-Schutz"/> + <file pattern="^Morphologische_Messstelle$" type="Morphologische Messstelle"/> + <file pattern="^Pegel$" type="Pegel (inkl. Nebenpegel)"/> + <file pattern="^Pegel-alle$" type="Pegel (inkl. Nebenpegel)"/> + <file pattern="^Stauwehr$" type="Stauwehr"/> + <file pattern="^Wehr$" type="Stauwehr"/> + <file pattern="^Zufluss-alle$" type="Zufluss (inkl. kleinerer Gewässer)"/> + <file pattern="^Zufluß-alle$" type="Zufluss (inkl. kleinerer Gewässer)"/> + + <line pattern="^Abz\.?[:\s].*$" type="Abzweigung"/> + <line pattern="^Berechnungsstrecke.*$" type="Berechnungsstrecke"/> + <line pattern="^Brücke[:\s].*$" type="Brücke"/> + <line pattern="^Bundesland[:\s].*$" type="Bundesland"/> + <line pattern="^Einmündung[:\s].*$" type="Einmündung"/> + <line pattern="^Fähre[:\s].*$" type="Fähre"/> + <line pattern="^Grenze[:\s].*$" type="Grenze"/> + <line pattern="^Hafen[:\s].*$" type="Hafen"/> + <line pattern="^Pegel[:\s].*$" type="Hauptpegel"/> + <line pattern="^Zufluss[:\s].*$" type="Hauptzufluss"/> + <line pattern="^Zufluß[:\s].*$" type="Hauptzufluss"/> + <line pattern="^HW-Marken[:\s].*$" type="HW-Marken"/> + <line pattern="^Deich[:\s].*$" type="HW-Schutz"/> + <line pattern="^HW-Schutz[:\s].*$" type="HW-Schutz"/> + <line pattern="^HW-Schutzanlage[:\s].*$" type="HW-Schutz"/> + <line pattern="^Sommerdeich[:\s].*$" type="HW-Schutz"/> + <line pattern="^Hauptdeich[:\s].*$" type="HW-Schutz"/> + <line pattern="^Insel[:\s].*$" type="Insel"/> + <line pattern="^Kraftwerk[:\s].*$" type="Kraftwerk"/> + <line pattern="^Landkreis[:\s].*$" type="Landkreis"/> + <line pattern="^Meldestelle[:\s].*$" type="Meldestelle"/> + <line pattern="^Nebenarm[:\s].*$" type="Nebenarm / Altarm"/> + <line pattern="^Altarm[:\s].*$" type="Nebenarm / Altarm"/> + <line pattern="^Messstelle[:\s].*$" type="sonstige Messstelle"/> + <line pattern="^Messtelle[:\s].*$" type="sonstige Messstelle"/> + <line pattern="^Gemeinde[:\s].*$" type="Ort"/> + <line pattern="^Ort[:\s].*$" type="Ort"/> + <line pattern="^Orte[:\s].*$" type="Ort"/> + <line pattern="^Stadt[:\s].*$" type="Ort"/> + <line pattern="^Schleuse[:\s].*$" type="Schleuse"/> + <line pattern="^Stauwehr[:\s].*$" type="Stauwehr"/> + <line pattern="^Wehr[:\s].*$" type="Stauwehr"/> + <line pattern="^Nadelwehr[:\s].*$" type="Stauwehr"/> + <line pattern="^Hauptwehr[:\s].*$" type="Stauwehr"/> + <line pattern="^Staatsgrenze[:\s].*$" type="Staatsgrenze"/> + <line pattern="^Staat[:\s].*$" type="Staat"/> + <line pattern="^WSA[:\s].*$" type="WSA"/> + <line pattern="^WSD[:\s].*$" type="WSD"/> + </patterns> +</annotation>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/import-dems.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,165 @@ +-- SAAR +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 0, + 7.9, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0000-0079_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 8.0, + 20.4, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0080-0204_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 20.5, + 31.4, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0205-0314_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 31.5, + 54.1, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0315-0541_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 54.2, + 65.5, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0542-0655_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 65.6, + 82.8, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0656-0828_long.txt' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Saar'), + 82.9, + 93.1, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Saar/Geodaesie/Hoehenmodelle/km0829-0931_erweitert.txt' +); + + +-- ELBE +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 0.0, + 101.1, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_00000_10110.grd' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 99.2, + 203.0, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_09920_20300.grd' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 202.0, + 299.8, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_20200_29980.grd' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 298.1, + 401.0, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_29810_40100.grd' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 400.0, + 500.9, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_40000_50090.grd' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Elbe'), + 500.1, + 583.3, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Elbe/Geodaesie/Hoehenmodelle/m_50010_58330.grd' +); + + +-- MOSEL +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 0.0, + 5.8, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/0000-0580.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 5.8, + 15.3, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/0058-0153.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 15.3, + 41.6, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/0153-0416.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 41.4, + 101.2, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/0414-1012O.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 41.4, + 101.21, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/0414-1012W.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 101.2, + 148.8, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/1012-1488.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 148.8, + 166.6, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/1488-1666.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 166.6, + 196.0, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/1666-1960.xyz' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 196.0, + 204.4, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/1960-2044.XYZ' +); + +INSERT INTO dem (river_id, lower, upper, path) VALUES ( + (SELECT id FROM rivers WHERE name = 'Mosel'), + 204.4, + 218.4, + '/vol1/projects/Geospatial/flys-3.0/testdaten/Gewaesser/Mosel/Geodaesie/Hoehenmodelle/DGMW-ASCII/2044-2184.XYZ' +);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-drop-minfo.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,96 @@ +SET AUTOCOMMIT ON; + +ALTER TABLE elevation_model DROP CONSTRAINT fk_unit; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_bed_single_river_id; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_type; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_location_system; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_cur_elevation_model; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_old_elevation_model; +ALTER TABLE bed_height_single DROP CONSTRAINT fk_range; +ALTER TABLE bed_height_single_values DROP CONSTRAINT fk_bed_single_values_parent; +ALTER TABLE bed_height_epoch_values DROP CONSTRAINT fk_bed_epoch_values_parent; +ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_cur_elevation_model; +ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_old_elevation_model; +ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_range; +ALTER TABLE depths DROP CONSTRAINT fk_depths_unit_id; +ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_depth_id; +ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_unit_id; +ALTER TABLE sediment_density_values DROP CONSTRAINT fk_sdv_sediment_density_id; +ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_river_id; +ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_unit_id; +ALTER TABLE morphologic_width_values DROP CONSTRAINT fk_mwv_morphologic_width_id; +ALTER TABLE flow_velocity_model_values DROP CONSTRAINT fk_fvv_flow_velocity_model_id; +ALTER TABLE flow_velocity_model DROP CONSTRAINT fk_fvm_river_id; +ALTER TABLE flow_velocity_model DROP CONSTRAINT fk_fvm_discharge_zone_id; +ALTER TABLE discharge_zone DROP CONSTRAINT fk_dz_river_id; +ALTER TABLE flow_velocity_measurements DROP CONSTRAINT fk_fvm_rivers_id; +ALTER TABLE flow_velocity_measure_values DROP CONSTRAINT fk_fvmv_measurements_id; +ALTER TABLE grain_fraction DROP CONSTRAINT fk_gf_unit_id; +ALTER TABLE sediment_yield DROP CONSTRAINT fk_sy_grain_fraction_id; +ALTER TABLE sediment_yield DROP CONSTRAINT fk_sy_unit_id; +ALTER TABLE sediment_yield DROP CONSTRAINT fk_sy_time_interval_id; +ALTER TABLE sediment_yield DROP CONSTRAINT fk_sy_river_id; +ALTER TABLE sediment_yield_values DROP CONSTRAINT fk_syv_sediment_yield_id; +ALTER TABLE waterlevel DROP CONSTRAINT fk_w_river_id; +ALTER TABLE waterlevel DROP CONSTRAINT fk_w_unit_id; +ALTER TABLE waterlevel_q_range DROP CONSTRAINT fk_wqr_waterlevel_id; +ALTER TABLE waterlevel_values DROP CONSTRAINT fk_wv_waterlevel_q_range_id; +ALTER TABLE waterlevel_difference DROP CONSTRAINT fk_wd_river_id; +ALTER TABLE waterlevel_difference DROP CONSTRAINT fk_wd_unit_id; +ALTER TABLE waterlevel_difference_column DROP CONSTRAINT fk_wdc_difference_id; +ALTER TABLE waterlevel_difference_values DROP CONSTRAINT fk_wdv_column_id; + +DROP TABLE bed_height_type; +DROP TABLE location_system; +DROP TABLE elevation_model; +DROP TABLE bed_height_single; +DROP TABLE bed_height_single_values; +DROP TABLE bed_height_epoch_values; +DROP TABLE bed_height_epoch; +DROP TABLE depths; +DROP TABLE sediment_density; +DROP TABLE sediment_density_values; +DROP TABLE morphologic_width; +DROP TABLE morphologic_width_values; +DROP TABLE discharge_zone; +DROP TABLE flow_velocity_model; +DROP TABLE flow_velocity_model_values; +DROP TABLE flow_velocity_measurements; +DROP TABLE flow_velocity_measure_values; +DROP TABLE grain_fraction; +DROP TABLE sediment_yield; +DROP TABLE sediment_yield_values; +DROP TABLE waterlevel; +DROP TABLE waterlevel_q_range; +DROP TABLE waterlevel_values; +DROP TABLE waterlevel_difference; +DROP TABLE waterlevel_difference_column; +DROP TABLE waterlevel_difference_values; + +DROP SEQUENCE BED_HEIGHT_TYPE_SEQ; +DROP SEQUENCE LOCATION_SYSTEM_SEQ; +DROP SEQUENCE ELEVATION_MODEL_SEQ; +DROP SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; +DROP SEQUENCE BED_SINGLE_VALUES_ID_SEQ; +DROP SEQUENCE BED_EPOCH_VALUES_ID_SEQ; +DROP SEQUENCE BED_HEIGHT_EPOCH_ID_SEQ; +DROP SEQUENCE DEPTHS_ID_SEQ; +DROP SEQUENCE SEDIMENT_DENSITY_ID_SEQ; +DROP SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ; +DROP SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ; +DROP SEQUENCE MORPH_WIDTH_VALUES_ID_SEQ; +DROP SEQUENCE DISCHARGE_ZONE_ID_SEQ; +DROP SEQUENCE FLOW_VELOCITY_MODEL_ID_SEQ; +DROP SEQUENCE FLOW_VELOCITY_M_VALUES_ID_SEQ; +DROP SEQUENCE FV_MEASURE_ID_SEQ; +DROP SEQUENCE FV_MEASURE_VALUES_ID_SEQ; +DROP SEQUENCE GRAIN_FRACTION_ID_SEQ; +DROP SEQUENCE SEDIMENT_YIELD_ID_SEQ; +DROP SEQUENCE SEDIMENT_YIELD_VALUES_ID_SEQ; +DROP SEQUENCE WATERLEVEL_ID_SEQ; +DROP SEQUENCE WATERLEVEL_Q_RANGES_ID_SEQ; +DROP SEQUENCE WATERLEVEL_VALUES_ID_SEQ; +DROP SEQUENCE WATERLEVEL_DIFFERENCE_ID_SEQ; +DROP SEQUENCE WATERLEVEL_DIFF_COLUMN_ID_SEQ; +DROP SEQUENCE WATERLEVEL_DIFF_VALUES_ID_SEQ; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-drop-spatial.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,68 @@ +DROP TRIGGER river_axes_trigger; +DROP TABLE river_axes; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'RIVER_AXES'; +DROP SEQUENCE RIVER_AXES_ID_SEQ; + +DROP TRIGGER river_axes_km_trigger; +DROP TABLE river_axes_km; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'RIVER_AXES_KM'; +DROP SEQUENCE RIVER_AXES_KM_ID_SEQ; + +DROP TRIGGER cross_section_tracks_trigger; +DROP TABLE cross_section_tracks; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'CROSS_SECTION_TRACKS'; +DROP SEQUENCE CROSS_SECTION_TRACKS_ID_SEQ; + +DROP TRIGGER lines_trigger; +DROP TABLE lines; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'LINES'; +DROP SEQUENCE LINES_ID_SEQ; + +DROP TRIGGER buildings_trigger; +DROP TABLE buildings; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'BUILDINGS'; +DROP SEQUENCE BUILDINGS_ID_SEQ; + +DROP TRIGGER fixpoints_trigger; +DROP TABLE fixpoints; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'FIXPOINTS'; +DROP SEQUENCE FIXPOINTS_ID_SEQ; + +DROP TRIGGER floodplain_trigger; +DROP TABLE floodplain; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'FLOODPLAIN'; +DROP SEQUENCE FLOODPLAIN_ID_SEQ; + +DROP TRIGGER dem_trigger; +DROP TABLE dem; +DROP SEQUENCE DEM_ID_SEQ; + +DROP TRIGGER catchment_trigger; +DROP TABLE catchment; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'CATCHMENT'; +DROP SEQUENCE CATCHMENT_ID_SEQ; + +DROP TRIGGER hws_trigger; +DROP TABLE hws; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'HWS'; +DROP SEQUENCE HWS_ID_SEQ; + +DROP TRIGGER floodmaps_trigger; +DROP TABLE floodmaps; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'FLOODMAPS'; +DROP SEQUENCE FLOODMAPS_ID_SEQ; + +DROP TRIGGER hydr_boundaries_trigger; +DROP TABLE hydr_boundaries; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'HYDR_BOUNDARIES'; +DROP SEQUENCE HYDR_BOUNDARIES_ID_SEQ; + +DROP TRIGGER hydr_boundaries_poly_trigger; +DROP TABLE hydr_boundaries_poly; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'HYDR_BOUNDARIES_POLY'; +DROP SEQUENCE HYDR_BOUNDARIES_POLY_ID_SEQ; + +DROP TRIGGER gauge_location_trigger; +DROP TABLE gauge_location; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'GAUGE_LOCATION'; +DROP SEQUENCE GAUGE_LOCATION_ID_SEQ;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-drop.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,90 @@ +ALTER TABLE annotations DROP CONSTRAINT cAnnotationsRanges; +ALTER TABLE annotations DROP CONSTRAINT cAnnotationsEdges; +ALTER TABLE annotations DROP CONSTRAINT cAnnotationsPositions; +ALTER TABLE annotations DROP CONSTRAINT cAnnotationsAttributes; +ALTER TABLE annotations DROP CONSTRAINT cAnnotationsTypes; +ALTER TABLE cross_section_lines DROP CONSTRAINT cQPSLinesCrossSections; +ALTER TABLE cross_section_points DROP CONSTRAINT cQPSPointsCrossSectionLines; +ALTER TABLE cross_sections DROP CONSTRAINT cCrossSectionsRivers; +ALTER TABLE cross_sections DROP CONSTRAINT cCrossSectionsTimeIntervals; +ALTER TABLE discharge_tables DROP CONSTRAINT cDischargeTablesTime_intervals; +ALTER TABLE discharge_tables DROP CONSTRAINT cDischargeTablesGauges; +ALTER TABLE gauges DROP CONSTRAINT cGaugesRivers; +ALTER TABLE gauges DROP CONSTRAINT cGaugesRanges; +ALTER TABLE hyk_entries DROP CONSTRAINT cHykEntriesHyks; +ALTER TABLE hyk_flow_zones DROP CONSTRAINT cHykFlowZonesHykFormations; +ALTER TABLE hyk_flow_zones DROP CONSTRAINT cHykFlowZonesHykFlowZoneTypes; +ALTER TABLE hyks DROP CONSTRAINT cHyksRivers; +ALTER TABLE hyk_formations DROP CONSTRAINT cHykFormationsHykEntries; +ALTER TABLE main_values DROP CONSTRAINT cMainValuesTimeIntervals; +ALTER TABLE main_values DROP CONSTRAINT cMainValuesGauges; +ALTER TABLE main_values DROP CONSTRAINT cMainValuesNamedMainValues; +ALTER TABLE named_main_values DROP CONSTRAINT cNamedMainValuesMainValueTypes; +ALTER TABLE ranges DROP CONSTRAINT cRangesRivers; +ALTER TABLE rivers DROP CONSTRAINT cRiversUnits; +ALTER TABLE wst_column_q_ranges DROP CONSTRAINT cWstColumnQRangesWstColums; +ALTER TABLE wst_column_q_ranges DROP CONSTRAINT cWstColumnQRangesWstQRanges; +ALTER TABLE wst_column_values DROP CONSTRAINT cWstColumnValuesWstColumns; +ALTER TABLE wst_columns DROP CONSTRAINT cWstColumnsTime_intervals; +ALTER TABLE wst_columns DROP CONSTRAINT cWstColumnsWsts; +ALTER TABLE wst_q_ranges DROP CONSTRAINT cWstQRangesRanges; +ALTER TABLE wsts DROP CONSTRAINT cWstsRivers; +DROP TABLE annotation_types; +DROP TABLE annotations; +DROP TABLE attributes; +DROP TABLE cross_section_lines; +DROP TABLE cross_section_points; +DROP TABLE cross_sections; +DROP TABLE discharge_table_values; +DROP TABLE discharge_tables; +DROP TABLE edges; +DROP TABLE gauges; +DROP TABLE hyk_entries; +DROP TABLE hyk_flow_zone_types; +DROP TABLE hyk_flow_zones; +DROP TABLE hyk_formations; +DROP TABLE hyks; +DROP TABLE main_value_types; +DROP TABLE main_values; +DROP TABLE named_main_values; +DROP TABLE positions; +DROP TABLE ranges; +DROP TABLE rivers; +DROP TABLE time_intervals; +DROP TABLE units; +DROP TABLE wst_column_q_ranges; +DROP TABLE wst_column_values; +DROP TABLE wst_columns; +DROP TABLE wst_q_ranges; +DROP TABLE wsts; +DROP SEQUENCE ANNOTATION_TYPES_ID_SEQ; +DROP SEQUENCE ANNOTATIONS_ID_SEQ; +DROP SEQUENCE ATTRIBUTES_ID_SEQ; +DROP SEQUENCE CROSS_SECTION_LINES_ID_SEQ; +DROP SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; +DROP SEQUENCE CROSS_SECTIONS_ID_SEQ; +DROP SEQUENCE DISCHARGE_TABLE_VALUES_ID_SEQ; +DROP SEQUENCE DISCHARGE_TABLES_ID_SEQ; +DROP SEQUENCE EDGES_ID_SEQ; +DROP SEQUENCE GAUGES_ID_SEQ; +DROP SEQUENCE HYK_ENTRIES_ID_SEQ; +DROP SEQUENCE HYK_FLOW_ZONE_TYPES_ID_SEQ; +DROP SEQUENCE HYK_FLOW_ZONES_ID_SEQ; +DROP SEQUENCE HYK_FORMATIONS_ID_SEQ; +DROP SEQUENCE HYKS_ID_SEQ; +DROP SEQUENCE MAIN_VALUE_TYPES_ID_SEQ; +DROP SEQUENCE MAIN_VALUES_ID_SEQ; +DROP SEQUENCE NAMED_MAIN_VALUES_ID_SEQ; +DROP SEQUENCE POSITIONS_ID_SEQ; +DROP SEQUENCE RANGES_ID_SEQ; +DROP SEQUENCE RIVERS_ID_SEQ; +DROP SEQUENCE TIME_INTERVALS_ID_SEQ; +DROP SEQUENCE UNITS_ID_SEQ; +DROP SEQUENCE WST_COLUMN_Q_RANGES_ID_SEQ; +DROP SEQUENCE WST_COLUMN_VALUES_ID_SEQ; +DROP SEQUENCE WST_COLUMNS_ID_SEQ; +DROP SEQUENCE WST_Q_RANGES_ID_SEQ; +DROP SEQUENCE WSTS_ID_SEQ; +DROP VIEW wst_value_table; +DROP VIEW wst_w_values ; +DROP VIEW wst_q_values;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-minfo.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,353 @@ +SET AUTOCOMMIT ON; + +CREATE SEQUENCE LOCATION_SYSTEM_SEQ; + +CREATE TABLE location_system ( + id NUMBER(38,0) NOT NULL, + name VARCHAR(32) NOT NULL, + description VARCHAR(255), + PRIMARY KEY(id) +); + + +CREATE SEQUENCE ELEVATION_MODEL_SEQ; + +CREATE TABLE elevation_model ( + id NUMBER(38,0) NOT NULL, + name VARCHAR(32) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_unit FOREIGN KEY (unit_id) REFERENCES units(id) +); + +CREATE SEQUENCE BED_HEIGHT_TYPE_SEQ; + +CREATE TABLE bed_height_type ( + id NUMBER(38,0) NOT NULL, + name VARCHAR(16) NOT NULL, + description VARCHAR(255), + PRIMARY KEY(id) +); + + + +CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; + +CREATE TABLE bed_height_single ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + year NUMBER(38,0) NOT NULL, + sounding_width NUMBER(38,0) NOT NULL, + type_id NUMBER(38,0) NOT NULL, + location_system_id NUMBER(38,0) NOT NULL, + cur_elevation_model_id NUMBER(38,0) NOT NULL, + old_elevation_model_id NUMBER(38,0), + range_id NUMBER(38,0) NOT NULL, + evaluation_by VARCHAR(255), + description VARCHAR(255), + PRIMARY KEY(id), + CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), + CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), + CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) +); + + +CREATE SEQUENCE BED_HEIGHT_EPOCH_ID_SEQ; + +CREATE TABLE bed_height_epoch ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + time_interval_id NUMBER(38,0) NOT NULL, + -- sounding_with NUMBER(38,0) NOT NULL, + -- type_id NUMBER(38,0) NOT NULL, + cur_elevation_model_id NUMBER(38,0) NOT NULL, + old_elevation_model_id NUMBER(38,0), + range_id NUMBER(38,0) NOT NULL, + evaluation_by VARCHAR(255), + description VARCHAR(255), + PRIMARY KEY(id), + CONSTRAINT fk_time_interval FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id), + CONSTRAINT fk_epoch_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_epoch_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_epoch_range FOREIGN KEY (range_id) REFERENCES ranges(id) +); + + +CREATE SEQUENCE BED_SINGLE_VALUES_ID_SEQ; + +CREATE TABLE bed_height_single_values ( + id NUMBER(38,0) NOT NULL, + bed_height_single_id NUMBER(38,0) NOT NULL, + station NUMBER(38,2) NOT NULL, + height NUMBER(38,2), + uncertainty NUMBER(38,2), + data_gap NUMBER(38,2) NOT NULL, + sounding_width NUMBER(38,2) NOT NULL, + width NUMBER(38,2) NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) +); + + +CREATE SEQUENCE BED_EPOCH_VALUES_ID_SEQ; + +CREATE TABLE bed_height_epoch_values ( + id NUMBER(38,0) NOT NULL, + bed_height_epoch_id NUMBER(38,0) NOT NULL, + station NUMBER(38,2) NOT NULL, + height NUMBER(38,2), + PRIMARY KEY(id), + CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id) +); + + +CREATE SEQUENCE DEPTHS_ID_SEQ; + +CREATE TABLE depths ( + id NUMBER(38,0) NOT NULL, + lower NUMBER(38,2) NOT NULL, + upper NUMBER(38,2) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_DENSITY_ID_SEQ; + +CREATE TABLE sediment_density ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + depth_id NUMBER(38,0) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id), + CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ; + +CREATE TABLE sediment_density_values ( + id NUMBER(38,0) NOT NULL, + sediment_density_id NUMBER(38,0) NOT NULL, + station NUMBER(38,2) NOT NULL, + density NUMBER(38,2) NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) +); + + +CREATE SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ; + +CREATE TABLE morphologic_width ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id), + CONSTRAINT fk_mw_unit_id FOREIGN KEY(unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE MORPH_WIDTH_VALUES_ID_SEQ; + +CREATE TABLE morphologic_width_values ( + id NUMBER(38,0) NOT NULL, + morphologic_width_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + width NUMBER(38,3) NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) +); + + +CREATE SEQUENCE DISCHARGE_ZONE_ID_SEQ; + +CREATE TABLE discharge_zone ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + gauge_name VARCHAR(64) NOT NULL, -- this is not very proper, but there are gauges with no db instance + value NUMBER(38,3) NOT NULL, + lower_discharge VARCHAR(16) NOT NULL, + upper_discharge VARCHAR(16), + PRIMARY KEY(id), + CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) +); + + +CREATE SEQUENCE FLOW_VELOCITY_MODEL_ID_SEQ; + +CREATE TABLE flow_velocity_model ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + discharge_zone_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvm_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) +); + + +CREATE SEQUENCE FLOW_VELOCITY_M_VALUES_ID_SEQ; + +CREATE TABLE flow_velocity_model_values ( + id NUMBER(38,0) NOT NULL, + flow_velocity_model_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + q NUMBER(38,3) NOT NULL, + total_channel NUMBER(38,3) NOT NULL, + main_channel NUMBER(38,3) NOT NULL, + shear_stress NUMBER(38,3) NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) +); + + + +CREATE SEQUENCE FV_MEASURE_ID_SEQ; + +CREATE TABLE flow_velocity_measurements ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) +); + +CREATE SEQUENCE FV_MEASURE_VALUES_ID_SEQ; + +CREATE TABLE flow_velocity_measure_values ( + id NUMBER(38,0) NOT NULL, + measurements_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + datetime TIMESTAMP, + w NUMBER(38,3) NOT NULL, + q NUMBER(38,3) NOT NULL, + v NUMBER(38,3) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) +); + + +CREATE SEQUENCE GRAIN_FRACTION_ID_SEQ; + +CREATE TABLE grain_fraction ( + id NUMBER(38,0) NOT NULL, + name VARCHAR(64) NOT NULL, + lower NUMBER(38,3), + upper NUMBER(38,3), + unit_id NUMBER (38,0), + PRIMARY KEY (id), + CONSTRAINT fk_gf_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_YIELD_ID_SEQ; + +CREATE TABLE sediment_yield ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + grain_fraction_id NUMBER(38,0), + unit_id NUMBER(38,0) NOT NULL, + time_interval_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_sy_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sy_grain_fraction_id FOREIGN KEY (grain_fraction_id) REFERENCES grain_fraction(id), + CONSTRAINT fk_sy_unit_id FOREIGN KEY (unit_id) REFERENCES units(id), + CONSTRAINT fk_sy_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) +); + + +CREATE SEQUENCE SEDIMENT_YIELD_VALUES_ID_SEQ; + +CREATE TABLE sediment_yield_values ( + id NUMBER(38,0) NOT NULL, + sediment_yield_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + value NUMBER(38,3) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_syv_sediment_yield_id FOREIGN KEY (sediment_yield_id) REFERENCES sediment_yield(id) +); + + +CREATE SEQUENCE WATERLEVEL_ID_SEQ; + +CREATE TABLE waterlevel ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_w_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_w_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE WATERLEVEL_Q_RANGES_ID_SEQ; + +CREATE TABLE waterlevel_q_range ( + id NUMBER(38,0) NOT NULL, + waterlevel_id NUMBER(38,0) NOT NULL, + q NUMBER(38,2) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wqr_waterlevel_id FOREIGN KEY (waterlevel_id) REFERENCES waterlevel(id) +); + + +CREATE SEQUENCE WATERLEVEL_VALUES_ID_SEQ; + +CREATE TABLE waterlevel_values( + id NUMBER(38,0) NOT NULL, + waterlevel_q_range_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + w NUMBER(38,2) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFFERENCE_ID_SEQ; + +CREATE TABLE waterlevel_difference ( + id NUMBER(38,0) NOT NULL, + river_id NUMBER(38,0) NOT NULL, + unit_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_wd_river_id FOREIGN KEY (river_id) REFERENCES rivers (id), + CONSTRAINT fk_wd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFF_COLUMN_ID_SEQ; + +CREATE TABLE waterlevel_difference_column ( + id NUMBER(38,0) NOT NULL, + difference_id NUMBER(38,0) NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_wdc_difference_id FOREIGN KEY (difference_id) REFERENCES waterlevel_difference (id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFF_VALUES_ID_SEQ; + +CREATE TABLE waterlevel_difference_values ( + id NUMBER(38,0) NOT NULL, + column_id NUMBER(38,0) NOT NULL, + station NUMBER(38,3) NOT NULL, + value NUMBER(38,2) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wdv_column_id FOREIGN KEY (column_id) REFERENCES waterlevel_difference_column (id) +); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-spatial.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,276 @@ +-- Geodaesie/Flussachse+km/achse +CREATE SEQUENCE RIVER_AXES_ID_SEQ; +CREATE TABLE river_axes( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + kind NUMBER(38) DEFAULT 0 NOT NULL, + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('river_axes', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER river_axes_trigger BEFORE INSERT ON river_axes FOR each ROW + BEGIN + SELECT RIVER_AXES_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX river_axes_spatial_idx ON river_axes(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); + + +-- Geodaesie/Flussachse+km/km.shp +CREATE SEQUENCE RIVER_AXES_KM_ID_SEQ; +CREATE TABLE river_axes_km( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + km NUMBER(6,3), + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('river_axes_km', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER river_axes_km_trigger BEFORE INSERT ON river_axes_km FOR each ROW + BEGIN + SELECT river_axes_km_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX river_axes_km_spatial_idx ON river_axes_km(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=point'); + + +--Geodaesie/Querprofile/QP-Spuren/qps.shp +CREATE SEQUENCE CROSS_SECTION_TRACKS_ID_SEQ; +CREATE TABLE cross_section_tracks ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + km NUMBER(38,12) NOT NULL, + z NUMBER(38,12) DEFAULT 0 NOT NULL, + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('cross_section_tracks', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER cross_section_tracks_trigger BEFORE INSERT ON cross_section_tracks FOR each ROW + BEGIN + SELECT CROSS_SECTION_TRACKS_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX CrossSectionTracks_spatial_idx ON cross_section_tracks(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); + + +-- TODO: TestMe. Fix Importer-Script. Fix oracle_spatial_idx.sql script. +-- Geodaesie/Linien/rohre-und-speeren +CREATE SEQUENCE LINES_ID_SEQ; +CREATE TABLE lines ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + kind VARCHAR2(16) NOT NULL, + z NUMBER(38,12) DEFAULT 0, + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('lines', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER lines_trigger BEFORE INSERT ON lines FOR each ROW + BEGIN + SELECT LINES_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +-- NOTE: Should lines should be 3D. +-- TODO: Test index. +--CREATE INDEX lines_idx ON lines(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); +-- 'kind': +-- 0: ROHR1 +-- 1: DAMM + + +-- Geodaesie/Bauwerke/Wehre.shp +CREATE SEQUENCE BUILDINGS_ID_SEQ; +CREATE TABLE buildings( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR2(255), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('buildings', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER buildings_trigger BEFORE INSERT ON buildings FOR each ROW + BEGIN + SELECT BUILDINGS_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX buildings_spatial_idx ON buildings(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); + + +-- Geodaesie/Festpunkte/Festpunkte.shp +CREATE SEQUENCE FIXPOINTS_ID_SEQ; +CREATE TABLE fixpoints ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + x NUMBER(38,11), + y NUMBER(38,11), + km NUMBER(38,11) NOT NULL, + HPGP VARCHAR2(255), + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('fixpoints', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER fixpoints_trigger BEFORE INSERT ON fixpoints FOR each ROW + BEGIN + SELECT FIXPOINTS_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX fixpoints_spatial_idx ON fixpoints(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT'); + + +-- Hydrologie/Hydr. Grenzen/talaue.shp +CREATE SEQUENCE FLOODPLAIN_ID_SEQ; +CREATE TABLE floodplain( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('floodplain', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER floodplain_trigger BEFORE INSERT ON floodplain FOR each ROW + BEGIN + SELECT FLOODPLAIN_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX floodplain_spatial_idx ON floodplain(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POLYGON'); + + +-- TODO: Test-Me. Fix Importer-Skript. +-- NOTE: It's not a spatial schema! +-- Geodaesie/Hoehenmodelle/* +CREATE SEQUENCE DEM_ID_SEQ; +CREATE TABLE dem ( + ID NUMBER PRIMARY KEY NOT NULL, + river_id NUMBER(38), + -- XXX Should we use the ranges table instead? + lower NUMBER(19,5), + upper NUMBER(19,5), + path VARCHAR(256), + UNIQUE (river_id, lower, upper) +); +CREATE OR REPLACE TRIGGER dem_trigger BEFORE INSERT ON dem FOR each ROW + BEGIN + SELECT DEM_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ + + +-- Hydrologie/Einzugsgebiete/EZG.shp +CREATE SEQUENCE CATCHMENT_ID_SEQ; +CREATE TABLE catchment( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + area NUMBER(19,5), + name VARCHAR2(255), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('CATCHMENT', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); + +CREATE TRIGGER catchment_trigger BEFORE INSERT ON catchment FOR each ROW + BEGIN + SELECT CATCHMENT_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX catchment_spatial_idx ON catchment(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=polygon'); + +--Hydrologie/HW-Schutzanlagen/hws.shp +CREATE SEQUENCE HWS_ID_SEQ; +CREATE TABLE hws( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + hws_facility VARCHAR2(255), + type VARCHAR2(255), + name VARCHAR(64), + ID NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('hws', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER hws_trigger BEFORE INSERT ON hws FOR each ROW + BEGIN + SELECT HWS_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +--CREATE INDEX hws_spatial_idx ON hws(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); + + +--Hydrologie/UeSG +CREATE SEQUENCE FLOODMAPS_ID_SEQ; +CREATE TABLE floodmaps ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR(255), + kind NUMBER(38), + diff NUMBER(19,5), + count NUMBER(38), + area NUMBER(19,5), + perimeter NUMBER(19,5), + id NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('floodmaps', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER floodmaps_trigger BEFORE INSERT ON floodmaps FOR each ROW + BEGIN + SELECT FLOODMAPS_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +CREATE INDEX floodmaps_spatial_idx ON floodmaps(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTIPOLYGON'); + + +--Hydrologie/Hydr.Grenzen/Linien +CREATE SEQUENCE HYDR_BOUNDARIES_ID_SEQ; +CREATE TABLE hydr_boundaries ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR(255), + kind NUMBER(38), + id NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('hydr_boundaries', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER hydr_boundaries_trigger BEFORE INSERT ON hydr_boundaries FOR each ROW + BEGIN + SELECT HYDR_BOUNDARIES_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +CREATE INDEX hydr_boundaries_idx ON hydr_boundaries(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); + +CREATE SEQUENCE HYDR_BOUNDARIES_POLY_ID_SEQ; +CREATE TABLE hydr_boundaries_poly ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR(255), + kind NUMBER(38), + id NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('hydr_boundaries_poly', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER hydr_boundaries_poly_trigger BEFORE INSERT ON hydr_boundaries_poly FOR each ROW + BEGIN + SELECT HYDR_BOUNDARIES_POLY_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +CREATE INDEX hydr_boundaries_poly_idx ON hydr_boundaries_poly(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=MULTIPOLYGON'); + + +-- Hydrologie/Streckendaten/ +CREATE SEQUENCE GAUGE_LOCATION_ID_SEQ; +CREATE TABLE gauge_location ( + OGR_FID NUMBER(38), + GEOM MDSYS.SDO_GEOMETRY, + river_id NUMBER(38), + name VARCHAR(64), + id NUMBER PRIMARY KEY NOT NULL +); +INSERT INTO USER_SDO_GEOM_METADATA VALUES ('gauge_location', 'GEOM', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',3282450,3912240,0.001),MDSYS.SDO_DIM_ELEMENT('Y',5248260,6100130,0.001),MDSYS.SDO_DIM_ELEMENT('Z',-100000,100000,0.002)), 31467); +CREATE OR REPLACE TRIGGER gauge_location_trigger BEFORE INSERT ON gauge_location FOR EACH ROW + BEGIN + SELECT GAUGE_LOCATION_ID_SEQ.nextval INTO :new.id FROM dual; + END; +/ +CREATE INDEX gauge_location_idx ON gauge_location(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle-spatial_idx.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,9 @@ +CREATE INDEX catchment_spatial_idx ON catchment(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=multipolygon'); +CREATE INDEX river_axes_km_spatial_idx ON river_axes_km(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=point'); +CREATE INDEX buildings_spatial_idx ON buildings(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); +CREATE INDEX fixpoints_spatial_idx ON fixpoints(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POINT'); +CREATE INDEX river_axes_spatial_idx ON river_axes(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); +CREATE INDEX CrossSectionTracks_spatial_idx ON cross_section_tracks(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); +CREATE INDEX hws_spatial_idx ON hws(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE'); +CREATE INDEX floodplain_spatial_idx ON floodplain(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=POLYGON'); +CREATE INDEX lines_idx ON lines(GEOM) indextype IS MDSYS.SPATIAL_INDEX parameters ('LAYER_GTYPE=LINE');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,414 @@ +-- ANNOTATION_TYPES +CREATE SEQUENCE ANNOTATION_TYPES_ID_SEQ; + +CREATE TABLE annotation_types ( + id NUMBER(38,0) NOT NULL, + name VARCHAR2(255), + PRIMARY KEY (id) +); + + +-- ANNOTATIONS +CREATE SEQUENCE ANNOTATIONS_ID_SEQ; + +CREATE TABLE annotations ( + id NUMBER(38,0) NOT NULL, + attribute_id NUMBER(38,0), + edge_id NUMBER(38,0), + position_id NUMBER(38,0), + range_id NUMBER(38,0), + type_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- ATTRIBUTES +CREATE SEQUENCE ATTRIBUTES_ID_SEQ; + +CREATE TABLE attributes ( + id NUMBER(38,0) NOT NULL, + value VARCHAR2(255), + primary key (id) +); + + +-- CROSS_SECTION_LINES +CREATE SEQUENCE CROSS_SECTION_LINES_ID_SEQ; + +CREATE TABLE cross_section_lines ( + id NUMBER(38,0) NOT NULL, + km NUMBER(38,2), + cross_section_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- CROSS_SECTION_POINTS +CREATE SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; + +CREATE TABLE cross_section_points ( + id NUMBER(38,0) NOT NULL, + col_pos NUMBER(38,0), + x NUMBER(38,2), + y NUMBER(38,2), + cross_section_line_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- CROSS_SECTIONS +CREATE SEQUENCE CROSS_SECTIONS_ID_SEQ; + +CREATE TABLE cross_sections ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + river_id NUMBER(38,0), + time_interval_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- DISCHARGE_TABLE_VALUES +CREATE SEQUENCE DISCHARGE_TABLE_VALUES_ID_SEQ; + +CREATE TABLE discharge_table_values ( + id NUMBER(38,0) NOT NULL, + q NUMBER(38,2), + w NUMBER(38,2), + table_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- DISCHARGE_TABLES +CREATE SEQUENCE DISCHARGE_TABLES_ID_SEQ; + +CREATE TABLE discharge_tables ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + kind NUMBER(38,0), + gauge_id NUMBER(38,0), + time_interval_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- EDGES +CREATE SEQUENCE EDGES_ID_SEQ; + +CREATE TABLE edges ( + id NUMBER(38,0) NOT NULL, + bottom NUMBER(38,2), + top NUMBER(38,2), + PRIMARY KEY (id) +); + + +-- GAUGES +CREATE SEQUENCE GAUGES_ID_SEQ; + +CREATE TABLE gauges ( + id NUMBER(38,0) NOT NULL, + aeo NUMBER(38,2), + datum NUMBER(38,2), + name VARCHAR2(255), + station NUMBER(38,2), + official_number NUMBER(38,0), + range_id NUMBER(38,0), + river_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- HYK_ENTRIES +CREATE SEQUENCE HYK_ENTRIES_ID_SEQ; + +CREATE TABLE hyk_entries ( + id NUMBER(38,0) NOT NULL, + km NUMBER(38,2), + measure TIMESTAMP, + hyk_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- HYK_FLOW_ZONE_TYPES +CREATE SEQUENCE HYK_FLOW_ZONE_TYPES_ID_SEQ; + +CREATE TABLE hyk_flow_zone_types ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + name VARCHAR2(255), + PRIMARY KEY (id) +); + + +-- HYK_FLOW_ZONES +CREATE SEQUENCE HYK_FLOW_ZONES_ID_SEQ; + +CREATE TABLE hyk_flow_zones ( + id NUMBER(38,0) NOT NULL, + a NUMBER(38,2), + b NUMBER(38,2), + formation_id NUMBER(38,0), + type_id NUMBER(38,0), + primary key (id) +); + + +-- HYK_FORMATIONS +CREATE SEQUENCE HYK_FORMATIONS_ID_SEQ; + +CREATE TABLE hyk_formations ( + id NUMBER(38,0) NOT NULL, + bottom NUMBER(38,2), + distance_hf NUMBER(38,2), + distance_vl NUMBER(38,2), + distance_vr NUMBER(38,2), + formation_num NUMBER(38,0), + top NUMBER(38,2), + hyk_entry_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- HYKS +CREATE SEQUENCE HYKS_ID_SEQ; + +CREATE TABLE hyks ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + river_id NUMBER(38,0), + primary key (id) +); + + +-- MAIN_VALUE_TYPES +CREATE SEQUENCE MAIN_VALUE_TYPES_ID_SEQ; + +CREATE TABLE main_value_types ( + id NUMBER(38,0) NOT NULL, + name VARCHAR2(255), + PRIMARY KEY (id) +); + + +-- MAIN_VALUES +CREATE SEQUENCE MAIN_VALUES_ID_SEQ; + +CREATE TABLE main_values ( + id NUMBER(38,0) NOT NULL, + value NUMBER(38,2), + gauge_id NUMBER(38,0), + named_value_id NUMBER(38,0), + time_interval_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- NAMED_MAIN_VALUES +CREATE SEQUENCE NAMED_MAIN_VALUES_ID_SEQ; + +CREATE TABLE named_main_values ( + id NUMBER(38,0) NOT NULL, + name VARCHAR2(255), + type_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- POSITIONS +CREATE SEQUENCE POSITIONS_ID_SEQ; + +CREATE TABLE positions ( + id NUMBER(38,0) NOT NULL, + value VARCHAR2(255 char), + PRIMARY KEY (id) +); + + +--- RANGES +CREATE SEQUENCE RANGES_ID_SEQ; + +CREATE TABLE ranges ( + id NUMBER(38,0) NOT NULL, + a NUMBER(38,10), + b NUMBER(38,10), + river_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- RIVERS +CREATE SEQUENCE RIVERS_ID_SEQ; + +CREATE TABLE rivers ( + id NUMBER(38,0) NOT NULL, + km_up NUMBER(38,0), + name VARCHAR2(255), + wst_unit_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- TIME_INTERVALS +CREATE SEQUENCE TIME_INTERVALS_ID_SEQ; + +CREATE TABLE time_intervals ( + id NUMBER(38,0) NOT NULL, + start_time TIMESTAMP, + stop_time TIMESTAMP, + PRIMARY KEY (id) +); + + +--- UNITS +CREATE SEQUENCE UNITS_ID_SEQ; + +CREATE TABLE units ( + id NUMBER(38,0) NOT NULL, + name VARCHAR2(255), + PRIMARY KEY (id) +); + + +-- WST_COLUMN_Q_RANGES +CREATE SEQUENCE WST_COLUMN_Q_RANGES_ID_SEQ; + +CREATE TABLE wst_column_q_ranges ( + id NUMBER(38,0) NOT NULL, + wst_column_id NUMBER(38,0), + wst_q_range_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- WST_COLUMN_VALUES +CREATE SEQUENCE WST_COLUMN_VALUES_ID_SEQ; + +CREATE TABLE wst_column_values ( + id NUMBER(38,0) NOT NULL, + position NUMBER(38,2), + w NUMBER(38,2), + wst_column_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- WST_COLUMNS +CREATE SEQUENCE WST_COLUMNS_ID_SEQ; + +CREATE TABLE wst_columns ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + name VARCHAR2(255), + position NUMBER(38,0), + time_interval_id NUMBER(38,0), + wst_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- WST_Q_RANGES +CREATE SEQUENCE WST_Q_RANGES_ID_SEQ; + +CREATE TABLE wst_q_ranges ( + id NUMBER(38,0) NOT NULL, + q NUMBER(38,2), + range_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- WSTS +CREATE SEQUENCE WSTS_ID_SEQ; + +CREATE TABLE wsts ( + id NUMBER(38,0) NOT NULL, + description VARCHAR2(255), + kind NUMBER(38,0), + river_id NUMBER(38,0), + PRIMARY KEY (id) +); + + +-- ADD CONSTRAINTs +ALTER TABLE annotations ADD CONSTRAINT cAnnotationsRanges FOREIGN KEY (range_id) REFERENCES ranges; +ALTER TABLE annotations ADD CONSTRAINT cAnnotationsEdges FOREIGN KEY (edge_id) REFERENCES edges; +ALTER TABLE annotations ADD CONSTRAINT cAnnotationsPositions FOREIGN KEY (position_id) REFERENCES positions; +ALTER TABLE annotations ADD CONSTRAINT cAnnotationsAttributes FOREIGN KEY (attribute_id) REFERENCES attributes; +ALTER TABLE annotations ADD CONSTRAINT cAnnotationsTypes FOREIGN KEY (type_id) REFERENCES annotation_types; +ALTER TABLE cross_section_lines ADD CONSTRAINT cQPSLinesCrossSections FOREIGN KEY (cross_section_id) REFERENCES cross_sections; +ALTER TABLE cross_section_points ADD CONSTRAINT cQPSPointsCrossSectionLines FOREIGN KEY (cross_section_line_id) REFERENCES cross_section_lines; +ALTER TABLE cross_sections ADD CONSTRAINT cCrossSectionsRivers FOREIGN KEY (river_id) REFERENCES rivers; +ALTER TABLE cross_sections ADD CONSTRAINT cCrossSectionsTimeIntervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; +ALTER TABLE discharge_table_values ADD CONSTRAINT cTableValuesDischargeTables foreign key (table_id) REFERENCES discharge_tables; +ALTER TABLE discharge_tables ADD CONSTRAINT cDischargeTablesTime_intervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; +ALTER TABLE discharge_tables ADD CONSTRAINT cDischargeTablesGauges FOREIGN KEY (gauge_id) REFERENCES gauges; +ALTER TABLE gauges ADD CONSTRAINT cGaugesRivers FOREIGN KEY (river_id) REFERENCES rivers; +ALTER TABLE gauges ADD CONSTRAINT cGaugesRanges FOREIGN KEY (range_id) REFERENCES ranges; +ALTER TABLE hyk_entries ADD CONSTRAINT cHykEntriesHyks FOREIGN KEY (hyk_id) REFERENCES hyks; +ALTER TABLE hyk_flow_zones ADD CONSTRAINT cHykFlowZonesHykFormations FOREIGN KEY (formation_id) REFERENCES hyk_formations; +ALTER TABLE hyk_flow_zones ADD CONSTRAINT cHykFlowZonesHykFlowZoneTypes FOREIGN KEY (type_id) REFERENCES hyk_flow_zone_types; +ALTER TABLE hyks ADD CONSTRAINT cHyksRivers FOREIGN KEY (river_id) REFERENCES rivers; +ALTER TABLE hyk_formations ADD CONSTRAINT cHykFormationsHykEntries FOREIGN KEY (hyk_entry_id) REFERENCES hyk_entries; +ALTER TABLE main_values ADD CONSTRAINT cMainValuesTimeIntervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; +ALTER TABLE main_values ADD CONSTRAINT cMainValuesGauges FOREIGN KEY (gauge_id) REFERENCES gauges; +ALTER TABLE main_values ADD CONSTRAINT cMainValuesNamedMainValues FOREIGN KEY (named_value_id) REFERENCES named_main_values; +ALTER TABLE named_main_values ADD CONSTRAINT cNamedMainValuesMainValueTypes FOREIGN KEY (type_id) REFERENCES main_value_types; +ALTER TABLE ranges ADD CONSTRAINT cRangesRivers FOREIGN KEY (river_id) REFERENCES rivers; +ALTER TABLE rivers ADD CONSTRAINT cRiversUnits FOREIGN KEY (wst_unit_id) REFERENCES units; +ALTER TABLE wst_column_q_ranges ADD CONSTRAINT cWstColumnQRangesWstColums FOREIGN KEY (wst_column_id) REFERENCES wst_columns; +ALTER TABLE wst_column_q_ranges ADD CONSTRAINT cWstColumnQRangesWstQRanges FOREIGN KEY (wst_q_range_id) REFERENCES wst_q_ranges; +ALTER TABLE wst_column_values ADD CONSTRAINT cWstColumnValuesWstColumns FOREIGN KEY (wst_column_id) REFERENCES wst_columns; +ALTER TABLE wst_columns ADD CONSTRAINT cWstColumnsTime_intervals FOREIGN KEY (time_interval_id) REFERENCES time_intervals; +ALTER TABLE wst_columns ADD CONSTRAINT cWstColumnsWsts FOREIGN KEY (wst_id) REFERENCES wsts; +ALTER TABLE wst_q_ranges ADD CONSTRAINT cWstQRangesRanges FOREIGN KEY (range_id) REFERENCES RANGES; +ALTER TABLE wsts ADD CONSTRAINT cWstsRivers FOREIGN KEY (river_id) REFERENCES rivers; + +-- VIEWS + +CREATE VIEW wst_value_table AS + SELECT wcv.position AS position, + w, + (SELECT q + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr + ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r + ON r.id = wqr.range_id + WHERE wcqr.wst_column_id = wc.id + AND wcv.position BETWEEN r.a AND r.b) AS q, + wc.position AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc + ON wcv.wst_column_id = wc.id + JOIN wsts w + ON wc.wst_id = w.id + ORDER BY wcv.position ASC, + wc.position DESC; + +-- view to select the w values of a WST +CREATE VIEW wst_w_values AS + SELECT wcv.position AS km, + wcv.w AS w, + wc.position AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc ON wcv.wst_column_id = wc.id + JOIN wsts w ON wc.wst_id = w.id + ORDER BY wcv.position, wc.position; + +-- view to select the q values of a WST +CREATE VIEW wst_q_values AS + SELECT wc.position AS column_pos, + wqr.q AS q, + r.a AS a, + r.b AS b, + wc.wst_id AS wst_id + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r ON wqr.range_id = r.id + JOIN wst_columns wc ON wcqr.wst_column_id = wc.id + ORDER BY wc.position, wcqr.wst_column_id, r.a;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/oracle_create_user.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,12 @@ +--CREATE TABLESPACE for user +CREATE TABLESPACE "test" DATAFILE '/u01/app/oracle/oradata/XE/test.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE 1G LOGGING ONLINE PERMANENT BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO; +--CREATE USER +CREATE USER test IDENTIFIED BY test; +-- USER SQL +ALTER USER test DEFAULT TABLESPACE "test" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK ; +-- QUOTA for user on TABLESPACE +ALTER USER test QUOTA UNLIMITED ON "test"; +GRANT ALL on "MDSYS"."ALL_SDO_GEOM_METADATA" to test ; +GRANT CREATE SESSION TO test ; +GRANT CREATE VIEW TO test; +GRANT CONNECT, RESOURCE TO test;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/postgresql-minfo.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,354 @@ +BEGIN; + +CREATE SEQUENCE LOCATION_SYSTEM_SEQ; + +CREATE TABLE location_system ( + id int NOT NULL, + name VARCHAR(32) NOT NULL, + description VARCHAR(255), + PRIMARY KEY(id) +); + + +CREATE SEQUENCE ELEVATION_MODEL_SEQ; + +CREATE TABLE elevation_model ( + id int NOT NULL, + name VARCHAR(32) NOT NULL, + unit_id int NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_unit FOREIGN KEY (unit_id) REFERENCES units(id) +); + +CREATE SEQUENCE BED_HEIGHT_TYPE_SEQ; + +CREATE TABLE bed_height_type ( + id int NOT NULL, + name VARCHAR(16) NOT NULL, + description VARCHAR(255), + PRIMARY KEY(id) +); + + + +CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; + +CREATE TABLE bed_height_single ( + id int NOT NULL, + river_id int NOT NULL, + year int NOT NULL, + sounding_width int NOT NULL, + type_id int NOT NULL, + location_system_id int NOT NULL, + cur_elevation_model_id int NOT NULL, + old_elevation_model_id int, + range_id int NOT NULL, + evaluation_by VARCHAR(255), + description VARCHAR(255), + PRIMARY KEY(id), + CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), + CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), + CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) +); + + +CREATE SEQUENCE BED_HEIGHT_EPOCH_ID_SEQ; + +CREATE TABLE bed_height_epoch ( + id int NOT NULL, + river_id int NOT NULL, + time_interval_id int NOT NULL, + -- sounding_with int NOT NULL, + -- type_id int NOT NULL, + cur_elevation_model_id int NOT NULL, + old_elevation_model_id int, + range_id int NOT NULL, + evaluation_by VARCHAR(255), + description VARCHAR(255), + PRIMARY KEY(id), + CONSTRAINT fk_time_interval FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id), + CONSTRAINT fk_epoch_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_epoch_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), + CONSTRAINT fk_epoch_range FOREIGN KEY (range_id) REFERENCES ranges(id) +); + + +CREATE SEQUENCE BED_SINGLE_VALUES_ID_SEQ; + +CREATE TABLE bed_height_single_values ( + id int NOT NULL, + bed_height_single_id int NOT NULL, + station NUMERIC NOT NULL, + height NUMERIC, + uncertainty NUMERIC, + data_gap NUMERIC NOT NULL, + sounding_width NUMERIC NOT NULL, + width NUMERIC NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) +); + + +CREATE SEQUENCE BED_EPOCH_VALUES_ID_SEQ; + +CREATE TABLE bed_height_epoch_values ( + id int NOT NULL, + bed_height_epoch_id int NOT NULL, + station NUMERIC NOT NULL, + height NUMERIC, + PRIMARY KEY(id), + CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id) +); + + +CREATE SEQUENCE DEPTHS_ID_SEQ; + +CREATE TABLE depths ( + id int NOT NULL, + lower NUMERIC NOT NULL, + upper NUMERIC NOT NULL, + unit_id int NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_DENSITY_ID_SEQ; + +CREATE TABLE sediment_density ( + id int NOT NULL, + river_id int NOT NULL, + depth_id int NOT NULL, + unit_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id), + CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ; + +CREATE TABLE sediment_density_values ( + id int NOT NULL, + sediment_density_id int NOT NULL, + station NUMERIC NOT NULL, + density NUMERIC NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) +); + + +CREATE SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ; + +CREATE TABLE morphologic_width ( + id int NOT NULL, + river_id int NOT NULL, + unit_id int NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id), + CONSTRAINT fk_mw_unit_id FOREIGN KEY(unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE MORPH_WIDTH_VALUES_ID_SEQ; + +CREATE TABLE morphologic_width_values ( + id int NOT NULL, + morphologic_width_id int NOT NULL, + station NUMERIC NOT NULL, + width NUMERIC NOT NULL, + description VARCHAR(256), + PRIMARY KEY(id), + CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) +); + + +CREATE SEQUENCE DISCHARGE_ZONE_ID_SEQ; + +CREATE TABLE discharge_zone ( + id int NOT NULL, + river_id int NOT NULL, + gauge_name VARCHAR(64) NOT NULL, -- this is not very proper, but there are gauges with no db instance + value NUMERIC NOT NULL, + lower_discharge VARCHAR(16) NOT NULL, + upper_discharge VARCHAR(16), + PRIMARY KEY(id), + CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) +); + + +CREATE SEQUENCE FLOW_VELOCITY_MODEL_ID_SEQ; + +CREATE TABLE flow_velocity_model ( + id int NOT NULL, + river_id int NOT NULL, + discharge_zone_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvm_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) +); + + +CREATE SEQUENCE FLOW_VELOCITY_M_VALUES_ID_SEQ; + +CREATE TABLE flow_velocity_model_values ( + id int NOT NULL, + flow_velocity_model_id int NOT NULL, + station NUMERIC NOT NULL, + q NUMERIC NOT NULL, + total_channel NUMERIC NOT NULL, + main_channel NUMERIC NOT NULL, + shear_stress NUMERIC NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) +); + + + +CREATE SEQUENCE FV_MEASURE_ID_SEQ; + +CREATE TABLE flow_velocity_measurements ( + id int NOT NULL, + river_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) +); + +CREATE SEQUENCE FV_MEASURE_VALUES_ID_SEQ; + +CREATE TABLE flow_velocity_measure_values ( + id int NOT NULL, + measurements_id int NOT NULL, + station NUMERIC NOT NULL, + datetime TIMESTAMP, + w NUMERIC NOT NULL, + q NUMERIC NOT NULL, + v NUMERIC NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) +); + + +CREATE SEQUENCE GRAIN_FRACTION_ID_SEQ; + +CREATE TABLE grain_fraction ( + id int NOT NULL, + name VARCHAR(64) NOT NULL, + lower NUMERIC, + upper NUMERIC, + unit_id int, + PRIMARY KEY (id), + CONSTRAINT fk_gf_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE SEDIMENT_YIELD_ID_SEQ; + +CREATE TABLE sediment_yield ( + id int NOT NULL, + river_id int NOT NULL, + grain_fraction_id int, + unit_id int NOT NULL, + time_interval_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_sy_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sy_grain_fraction_id FOREIGN KEY (grain_fraction_id) REFERENCES grain_fraction(id), + CONSTRAINT fk_sy_unit_id FOREIGN KEY (unit_id) REFERENCES units(id), + CONSTRAINT fk_sy_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) +); + + +CREATE SEQUENCE SEDIMENT_YIELD_VALUES_ID_SEQ; + +CREATE TABLE sediment_yield_values ( + id int NOT NULL, + sediment_yield_id int NOT NULL, + station NUMERIC NOT NULL, + value NUMERIC NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_syv_sediment_yield_id FOREIGN KEY (sediment_yield_id) REFERENCES sediment_yield(id) +); + + +CREATE SEQUENCE WATERLEVEL_ID_SEQ; + +CREATE TABLE waterlevel ( + id int NOT NULL, + river_id int NOT NULL, + unit_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_w_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_w_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE WATERLEVEL_Q_RANGES_ID_SEQ; + +CREATE TABLE waterlevel_q_range ( + id int NOT NULL, + waterlevel_id int NOT NULL, + q NUMERIC NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wqr_waterlevel_id FOREIGN KEY (waterlevel_id) REFERENCES waterlevel(id) +); + + +CREATE SEQUENCE WATERLEVEL_VALUES_ID_SEQ; + +CREATE TABLE waterlevel_values( + id int NOT NULL, + waterlevel_q_range_id int NOT NULL, + station NUMERIC NOT NULL, + w NUMERIC NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFFERENCE_ID_SEQ; + +CREATE TABLE waterlevel_difference ( + id int NOT NULL, + river_id int NOT NULL, + unit_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_wd_river_id FOREIGN KEY (river_id) REFERENCES rivers (id), + CONSTRAINT fk_wd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFF_COLUMN_ID_SEQ; + +CREATE TABLE waterlevel_difference_column ( + id int NOT NULL, + difference_id int NOT NULL, + description VARCHAR(256), + PRIMARY KEY (id), + CONSTRAINT fk_wdc_difference_id FOREIGN KEY (difference_id) REFERENCES waterlevel_difference (id) +); + + +CREATE SEQUENCE WATERLEVEL_DIFF_VALUES_ID_SEQ; + +CREATE TABLE waterlevel_difference_values ( + id int NOT NULL, + column_id int NOT NULL, + station NUMERIC NOT NULL, + value NUMERIC NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_wdv_column_id FOREIGN KEY (column_id) REFERENCES waterlevel_difference_column (id) +); + +COMMIT;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/postgresql-spatial.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,161 @@ +BEGIN; + +-- Geodaesie/Flussachse+km/achse +CREATE SEQUENCE RIVER_AXES_ID_SEQ; +CREATE TABLE river_axes ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + kind int NOT NULL DEFAULT 0 +); +SELECT AddGeometryColumn('river_axes', 'geom', 31466, 'LINESTRING', 2); +ALTER TABLE river_axes ALTER COLUMN id SET DEFAULT NEXTVAL('RIVER_AXES_ID_SEQ'); + + +-- TODO: TestMe. +-- Geodaesie/Flussachse+km/km.shp +CREATE SEQUENCE RIVER_AXES_KM_ID_SEQ; +CREATE TABLE river_axes_km ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + km NUMERIC NOT NULL +); +SELECT AddGeometryColumn('river_axes_km', 'geom', 31466, 'POINT', 2); +ALTER TABLE river_axes_km ALTER COLUMN id SET DEFAULT NEXTVAL('RIVER_AXES_KM_ID_SEQ'); + + +--Geodaesie/Querprofile/QP-Spuren/qps.shp +CREATE SEQUENCE CROSS_SECTION_TRACKS_ID_SEQ; +CREATE TABLE cross_section_tracks ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + km NUMERIC NOT NULL, + z NUMERIC NOT NULL DEFAULT 0 +); +SELECT AddGeometryColumn('cross_section_tracks', 'geom', 31466, 'LINESTRING', 2); +ALTER TABLE cross_section_tracks ALTER COLUMN id SET DEFAULT NEXTVAL('CROSS_SECTION_TRACKS_ID_SEQ'); + + +-- Geodaesie/Linien/rohre-und-spreen +CREATE SEQUENCE LINES_ID_SEQ; +CREATE TABLE lines ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + kind VARCHAR(16) NOT NULL, + z NUMERIC DEFAULT 0 +); +SELECT AddGeometryColumn('lines', 'geom', 31466, 'LINESTRING', 4); +ALTER TABLE lines ALTER COLUMN id SET DEFAULT NEXTVAL('LINES_ID_SEQ'); +-- 'kind': +-- 0: ROHR1 +-- 1: DAMM + + +-- Geodaesie/Bauwerke/Wehre.shp +CREATE SEQUENCE BUILDINGS_ID_SEQ; +CREATE TABLE buildings ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + name VARCHAR(256) +); +SELECT AddGeometryColumn('buildings', 'geom', 31466, 'LINESTRING', 2); +ALTER TABLE buildings ALTER COLUMN id SET DEFAULT NEXTVAL('BUILDINGS_ID_SEQ'); + + +-- Geodaesie/Festpunkte/Festpunkte.shp +CREATE SEQUENCE FIXPOINTS_ID_SEQ; +CREATE TABLE fixpoints ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + x int, + y int, + km NUMERIC NOT NULL, + HPGP VARCHAR(2) +); +SELECT AddGeometryColumn('fixpoints', 'geom', 31466, 'POINT', 2); +ALTER TABLE fixpoints ALTER COLUMN id SET DEFAULT NEXTVAL('FIXPOINTS_ID_SEQ'); + + +-- Hydrologie/Hydr. Grenzen/talaue.shp +CREATE SEQUENCE FLOODPLAIN_ID_SEQ; +CREATE TABLE floodplain ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id) +); +SELECT AddGeometryColumn('floodplain', 'geom', 31466, 'POLYGON', 2); +ALTER TABLE floodplain ALTER COLUMN id SET DEFAULT NEXTVAL('FLOODPLAIN_ID_SEQ'); + + +-- Geodaesie/Hoehenmodelle/* +CREATE SEQUENCE DEM_ID_SEQ; +CREATE TABLE dem ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + -- XXX Should we use the ranges table instead? + lower NUMERIC, + upper NUMERIC, + path VARCHAR(256), + UNIQUE (river_id, lower, upper) +); +ALTER TABLE dem ALTER COLUMN id SET DEFAULT NEXTVAL('DEM_ID_SEQ'); + + +-- Hydrologie/Einzugsgebiete/EZG.shp +CREATE SEQUENCE CATCHMENT_ID_SEQ; +CREATE TABLE catchment ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + area NUMERIC, + name VARCHAR(256) +); +SELECT AddGeometryColumn('catchment','geom',31466,'POLYGON',2); +ALTER TABLE catchment ALTER COLUMN id SET DEFAULT NEXTVAL('CATCHMENT_ID_SEQ'); + + +--Hydrologie/HW-Schutzanlagen/hws.shp +CREATE SEQUENCE HWS_ID_SEQ; +CREATE TABLE hws ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + hws_facility VARCHAR(256), + type VARCHAR(256) +); +SELECT AddGeometryColumn('hws','geom',31466,'LINESTRING',2); +ALTER TABLE hws ALTER COLUMN id SET DEFAULT NEXTVAL('HWS_ID_SEQ'); + + +-- +--Hydrologie/UeSG +-- +-- 'kind' can be one of: +-- 200 = Messung +-- 111 = Berechnung->Aktuell->BfG +-- 112 = Berechnung->Aktuell->Land +-- 121 = Berechnung->Potenziell->BfG +-- 122 = Berechnung->Potenziell->Land +-- +CREATE SEQUENCE FLOODMAPS_SEQ; +CREATE FUNCTION floodmaps_id_func() RETURNS trigger AS $floodmaps_id_func$ + BEGIN + NEW.id := nextval('floodmaps_seq'); + RETURN NEW; + END; +$floodmaps_id_func$ LANGUAGE plpgsql; + +CREATE TABLE floodmaps ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + name varchar(64) NOT NULL, + kind int NOT NULL, + diff real, + count int, + area real, + perimeter real +); +SELECT AddGeometryColumn('floodmaps', 'geom', 31466, 'MULTIPOLYGON', 2); +ALTER TABLE floodmaps DROP CONSTRAINT enforce_geotype_geom; +ALTER TABLE floodmaps ADD CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POLYGON'::text OR geometrytype(geom) = 'MULTIPOLYGON'::text); +ALTER TABLE floodmaps ALTER COLUMN id SET DEFAULT NEXTVAL('FLOODMAPS_SEQ'); + +CREATE TRIGGER floodmaps_id_trigger BEFORE INSERT OR UPDATE ON floodmaps + FOR EACH ROW EXECUTE PROCEDURE floodmaps_id_func(); +END;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/doc/schema/postgresql.sql Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,356 @@ +BEGIN; + +CREATE SEQUENCE UNITS_ID_SEQ; + +CREATE TABLE units ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(32) NOT NULL UNIQUE +); + +-- Gewaesser +CREATE SEQUENCE RIVERS_ID_SEQ; + +CREATE TABLE rivers ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL UNIQUE, + km_up BOOLEAN NOT NULL DEFAULT true, + wst_unit_id int NOT NULL REFERENCES units(id) +); + +-- Bruecke, Haefen, etc. +CREATE SEQUENCE ATTRIBUTES_ID_SEQ; + +CREATE TABLE attributes ( + id int PRIMARY KEY NOT NULL, + value VARCHAR(256) NOT NULL UNIQUE +); + +-- segments from/to at a river +CREATE SEQUENCE RANGES_ID_SEQ; + +CREATE TABLE ranges ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + a NUMERIC NOT NULL, + b NUMERIC, + UNIQUE (river_id, a, b) +); + +-- Lage 'links', 'rechts', etc. +CREATE SEQUENCE POSITIONS_ID_SEQ; + +CREATE TABLE positions ( + id int PRIMARY KEY NOT NULL, + value VARCHAR(256) NOT NULL UNIQUE +); + +-- Kante 'oben', 'unten' +CREATE SEQUENCE EDGES_ID_SEQ; + +CREATE TABLE edges ( + id int PRIMARY KEY NOT NULL, + top NUMERIC, + bottom NUMERIC +); + +-- Types of annotatations (Hafen, Bruecke, Zufluss, ...) +CREATE SEQUENCE ANNOTATION_TYPES_ID_SEQ; + +CREATE TABLE annotation_types ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL UNIQUE +); + +-- Some object (eg. Hafen) at a segment of river +-- plus its position. +CREATE SEQUENCE ANNOTATIONS_ID_SEQ; + +CREATE TABLE annotations ( + id int PRIMARY KEY NOT NULL, + range_id int NOT NULL REFERENCES ranges(id), + attribute_id int NOT NULL REFERENCES attributes(id), + position_id int REFERENCES positions(id), + edge_id int REFERENCES edges(id), + type_id int REFERENCES annotation_types(id) +); + +-- Pegel +CREATE SEQUENCE GAUGES_ID_SEQ; + +CREATE TABLE gauges ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + station NUMERIC NOT NULL UNIQUE, + aeo NUMERIC NOT NULL, + official_number int8 UNIQUE, + + -- Pegelnullpunkt + datum NUMERIC NOT NULL, + -- Streckengueltigkeit + range_id int REFERENCES ranges (id), + + UNIQUE (name, river_id), + UNIQUE (river_id, station) +); + +-- Type of a Hauptwert 'W', 'Q', 'D', etc. +CREATE SEQUENCE MAIN_VALUE_TYPES_ID_SEQ; + +CREATE TABLE main_value_types ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL UNIQUE +); + +-- Named type of a Hauptwert (eg. HQ100) +CREATE SEQUENCE NAMED_MAIN_VALUES_ID_SEQ; + +CREATE TABLE named_main_values ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(256) NOT NULL UNIQUE, + type_id int NOT NULL REFERENCES main_value_types(id), + UNIQUE (name, type_id) +); + +-- Table for time intervals +CREATE SEQUENCE TIME_INTERVALS_ID_SEQ; + +CREATE TABLE time_intervals ( + id int PRIMARY KEY NOT NULL, + start_time TIMESTAMP NOT NULL, + stop_time TIMESTAMP, + CHECK (start_time <= stop_time) +); + +-- Stammdaten +CREATE SEQUENCE MAIN_VALUES_ID_SEQ; + +CREATE TABLE main_values ( + id int PRIMARY KEY NOT NULL, + gauge_id int NOT NULL REFERENCES gauges(id), + named_value_id int NOT NULL REFERENCES named_main_values(id), + value NUMERIC NOT NULL, + + time_interval_id int REFERENCES time_intervals(id), + + -- TODO: better checks + UNIQUE (gauge_id, named_value_id, time_interval_id) +); + +-- Abflusstafeln +CREATE SEQUENCE DISCHARGE_TABLES_ID_SEQ; + +CREATE TABLE discharge_tables ( + id int PRIMARY KEY NOT NULL, + gauge_id int NOT NULL REFERENCES gauges(id), + description VARCHAR(256) NOT NULL, + kind int NOT NULL DEFAULT 0, + time_interval_id int REFERENCES time_intervals(id) + + -- TODO: better checks + -- UNIQUE (gauge_id, kind, time_interval_id) +); + +-- Values of the Abflusstafeln +CREATE SEQUENCE DISCHARGE_TABLE_VALUES_ID_SEQ; + +CREATE TABLE discharge_table_values ( + id int PRIMARY KEY NOT NULL, + table_id int NOT NULL REFERENCES discharge_tables(id), + q NUMERIC NOT NULL, + w NUMERIC NOT NULL, + + UNIQUE (table_id, q, w) +); + +-- WST files +CREATE SEQUENCE WSTS_ID_SEQ; + +CREATE TABLE wsts ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + description VARCHAR(256) NOT NULL, + kind int NOT NULL DEFAULT 0, + -- TODO: more meta infos + UNIQUE (river_id, description) +); + +-- columns of WST files +CREATE SEQUENCE WST_COLUMNS_ID_SEQ; + +CREATE TABLE wst_columns ( + id int PRIMARY KEY NOT NULL, + wst_id int NOT NULL REFERENCES wsts(id), + name VARCHAR(256) NOT NULL, + description VARCHAR(256), + position int NOT NULL DEFAULT 0, + + time_interval_id int REFERENCES time_intervals(id), + + UNIQUE (wst_id, name), + UNIQUE (wst_id, position) +); + +-- w values in WST file column +CREATE SEQUENCE WST_COLUMN_VALUES_ID_SEQ; + +CREATE TABLE wst_column_values ( + id int PRIMARY KEY NOT NULL, + wst_column_id int NOT NULL REFERENCES wst_columns(id), + position NUMERIC NOT NULL, + w NUMERIC NOT NULL, + + UNIQUE (position, wst_column_id), + UNIQUE (position, wst_column_id, w) +); + +-- bind q values to range +CREATE SEQUENCE WST_Q_RANGES_ID_SEQ; + +CREATE TABLE wst_q_ranges ( + id int PRIMARY KEY NOT NULL, + range_id int NOT NULL REFERENCES ranges(id), + q NUMERIC NOT NULL +); + +-- bind q ranges to wst columns +CREATE SEQUENCE WST_COLUMN_Q_RANGES_ID_SEQ; + +CREATE TABLE wst_column_q_ranges ( + id int PRIMARY KEY NOT NULL, + wst_column_id int NOT NULL REFERENCES wst_columns(id), + wst_q_range_id int NOT NULL REFERENCES wst_q_ranges(id), + + UNIQUE (wst_column_id, wst_q_range_id) +); + +CREATE VIEW wst_value_table AS + SELECT wcv.position AS position, + w, + (SELECT q + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr + ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r + ON r.id = wqr.range_id + WHERE wcqr.wst_column_id = wc.id + AND wcv.position BETWEEN r.a AND r.b) AS q, + wc.position AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc + ON wcv.wst_column_id = wc.id + JOIN wsts w + ON wc.wst_id = w.id + ORDER BY wcv.position ASC, + wc.position DESC; + +-- view to select the w values of a WST +CREATE VIEW wst_w_values AS + SELECT wcv."position" AS km, + wcv.w AS w, + wc."position" AS column_pos, + w.id AS wst_id + FROM wst_column_values wcv + JOIN wst_columns wc ON wcv.wst_column_id = wc.id + JOIN wsts w ON wc.wst_id = w.id + ORDER BY wcv."position", wc."position"; + +-- view to select the q values of a WST +CREATE VIEW wst_q_values AS + SELECT wc.position AS column_pos, + wqr.q AS q, + r.a AS a, + r.b AS b, + wc.wst_id AS wst_id + FROM wst_column_q_ranges wcqr + JOIN wst_q_ranges wqr ON wcqr.wst_q_range_id = wqr.id + JOIN ranges r ON wqr.range_id = r.id + JOIN wst_columns wc ON wcqr.wst_column_id = wc.id + ORDER BY wc.position, wcqr.wst_column_id, r.a; + +-- data for the cross-sections + +CREATE SEQUENCE CROSS_SECTIONS_ID_SEQ; + +CREATE TABLE cross_sections ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + time_interval_id int REFERENCES time_intervals(id), + description VARCHAR(256) +); + +CREATE SEQUENCE CROSS_SECTION_LINES_ID_SEQ; + +CREATE TABLE cross_section_lines ( + id int PRIMARY KEY NOT NULL, + km NUMERIC NOT NULL, + cross_section_id int NOT NULL REFERENCES cross_sections(id), + UNIQUE (km, cross_section_id) +); + +CREATE SEQUENCE CROSS_SECTION_POINTS_ID_SEQ; + +CREATE TABLE cross_section_points ( + id int PRIMARY KEY NOT NULL, + cross_section_line_id int NOT NULL REFERENCES cross_section_lines(id), + col_pos int NOT NULL, + x NUMERIC NOT NULL, + y NUMERIC NOT NULL, + UNIQUE (cross_section_line_id, col_pos) +); + +-- Hydraulische Kenngroessen + +CREATE SEQUENCE HYKS_ID_SEQ; + +CREATE TABLE hyks ( + id int PRIMARY KEY NOT NULL, + river_id int NOT NULL REFERENCES rivers(id), + description VARCHAR(256) NOT NULL +); + +CREATE SEQUENCE HYK_ENTRIES_ID_SEQ; + +CREATE TABLE hyk_entries ( + id int PRIMARY KEY NOT NULL, + hyk_id int NOT NULL REFERENCES hyks(id), + km NUMERIC NOT NULL, + measure TIMESTAMP, + UNIQUE (hyk_id, km) +); + +CREATE SEQUENCE HYK_FORMATIONS_ID_SEQ; + +CREATE TABLE hyk_formations ( + id int PRIMARY KEY NOT NULL, + formation_num int NOT NULL DEFAULT 0, + hyk_entry_id int NOT NULL REFERENCES hyk_entries(id), + top NUMERIC NOT NULL, + bottom NUMERIC NOT NULL, + distance_vl NUMERIC NOT NULL, + distance_hf NUMERIC NOT NULL, + distance_vr NUMERIC NOT NULL, + UNIQUE (hyk_entry_id, formation_num) +); + +CREATE SEQUENCE HYK_FLOW_ZONE_TYPES_ID_SEQ; + +CREATE TABLE hyk_flow_zone_types ( + id int PRIMARY KEY NOT NULL, + name VARCHAR(50) NOT NULL UNIQUE, + description VARCHAR(256) +); + +CREATE SEQUENCE HYK_FLOW_ZONES_ID_SEQ; + +CREATE TABLE hyk_flow_zones ( + id int PRIMARY KEY NOT NULL, + formation_id int NOT NULL REFERENCES hyk_formations(id), + type_id int NOT NULL REFERENCES hyk_flow_zone_types(id), + a NUMERIC NOT NULL, + b NUMERIC NOT NULL, + CHECK (a <= b) +); + +COMMIT;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/pom.xml Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,113 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.intevation.flys</groupId> + <artifactId>flys-backend</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>flys-backend</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>hibernate3-maven-plugin</artifactId> + <version>2.2</version> + <!-- + <configuration> + <componentProperties> + <propertyfile>src/main/config/hbm.properties</propertyfile> + </componentProperties> + </configuration> + --> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>de.intevation.artifacts.common</groupId> + <artifactId>artifacts-common</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>3.6.5.Final</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>3.6.5.Final</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.14</version> + </dependency> + <dependency> + <groupId>commons-dbcp</groupId> + <artifactId>commons-dbcp</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>8.4-702.jdbc4</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.hibernatespatial</groupId> + <artifactId>hibernate-spatial-postgis</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.hibernatespatial</groupId> + <artifactId>hibernate-spatial-oracle</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.postgis</groupId> + <artifactId>postgis-jdbc</artifactId> + <version>1.3.3</version> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>repository.jboss.org/nexus</id> + <name>JBoss Repository - Nexus</name> + <url>http://repository.jboss.org/nexus/content/groups/public/</url> + </repository> + <repository> + <id>OSGEO GeoTools repo</id> + <url>http://download.osgeo.org/webdav/geotools</url> + </repository> + <repository> + <id>Hibernate Spatial repo</id> + <url>http://www.hibernatespatial.org/repository</url> + </repository> + </repositories> +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/App.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,29 @@ +package de.intevation.flys; + +import de.intevation.flys.backend.SessionFactoryProvider; + +import org.hibernate.cfg.Configuration; + +import org.hibernate.dialect.resolver.DialectFactory; + +public class App +{ + public static void dumpSchema(Configuration cfg) { + System.out.println("BEGIN;"); + + String [] setupScript = cfg.generateSchemaCreationScript( + DialectFactory.constructDialect( + SessionFactoryProvider.DEFAULT_DIALECT)); + + for (String line: setupScript) { + System.out.println(line + ";"); + } + + System.out.println("COMMIT;"); + } + + public static void main(String [] args) { + dumpSchema(SessionFactoryProvider.createConfiguration()); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,361 @@ +package de.intevation.flys.backend; + +import de.intevation.artifacts.common.utils.Config; + +import java.lang.management.ManagementFactory; +import java.util.Properties; + +import javax.management.InstanceAlreadyExistsException; +import javax.management.MalformedObjectNameException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectName; + +import org.hibernate.SessionFactory; + +import org.hibernate.impl.SessionFactoryImpl; + +import org.hibernate.jmx.StatisticsService; + +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; + +import de.intevation.flys.model.Annotation; +import de.intevation.flys.model.AnnotationType; +import de.intevation.flys.model.Attribute; +import de.intevation.flys.model.BedHeightEpoch; +import de.intevation.flys.model.BedHeightEpochValue; +import de.intevation.flys.model.BedHeightSingle; +import de.intevation.flys.model.BedHeightSingleValue; +import de.intevation.flys.model.BedHeightType; +import de.intevation.flys.model.Building; +import de.intevation.flys.model.Catchment; +import de.intevation.flys.model.CrossSection; +import de.intevation.flys.model.CrossSectionLine; +import de.intevation.flys.model.CrossSectionPoint; +import de.intevation.flys.model.CrossSectionTrack; +import de.intevation.flys.model.Depth; +import de.intevation.flys.model.DGM; +import de.intevation.flys.model.DischargeTable; +import de.intevation.flys.model.DischargeTableValue; +import de.intevation.flys.model.DischargeZone; +import de.intevation.flys.model.Edge; +import de.intevation.flys.model.ElevationModel; +import de.intevation.flys.model.Fixpoint; +import de.intevation.flys.model.Floodmaps; +import de.intevation.flys.model.Floodplain; +import de.intevation.flys.model.FlowVelocityMeasurement; +import de.intevation.flys.model.FlowVelocityMeasurementValue; +import de.intevation.flys.model.FlowVelocityModel; +import de.intevation.flys.model.FlowVelocityModelValue; +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.GaugeLocation; +import de.intevation.flys.model.GrainFraction; +import de.intevation.flys.model.Hws; +import de.intevation.flys.model.HydrBoundary; +import de.intevation.flys.model.HydrBoundaryPoly; +import de.intevation.flys.model.HYK; +import de.intevation.flys.model.HYKEntry; +import de.intevation.flys.model.HYKFormation; +import de.intevation.flys.model.HYKFlowZoneType; +import de.intevation.flys.model.HYKFlowZone; +import de.intevation.flys.model.Line; +import de.intevation.flys.model.LocationSystem; +import de.intevation.flys.model.MainValueType; +import de.intevation.flys.model.MorphologicalWidth; +import de.intevation.flys.model.MorphologicalWidthValue; +import de.intevation.flys.model.NamedMainValue; +import de.intevation.flys.model.MainValue; +import de.intevation.flys.model.Position; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.River; +import de.intevation.flys.model.RiverAxis; +import de.intevation.flys.model.RiverAxisKm; +import de.intevation.flys.model.SedimentDensity; +import de.intevation.flys.model.SedimentDensityValue; +import de.intevation.flys.model.SedimentYield; +import de.intevation.flys.model.SedimentYieldValue; +import de.intevation.flys.model.TimeInterval; +import de.intevation.flys.model.Unit; +import de.intevation.flys.model.Waterlevel; +import de.intevation.flys.model.WaterlevelDifference; +import de.intevation.flys.model.WaterlevelDifferenceColumn; +import de.intevation.flys.model.WaterlevelDifferenceValue; +import de.intevation.flys.model.WaterlevelQRange; +import de.intevation.flys.model.WaterlevelValue; +import de.intevation.flys.model.WstColumn; +import de.intevation.flys.model.WstColumnQRange; +import de.intevation.flys.model.WstColumnValue; +import de.intevation.flys.model.Wst; +import de.intevation.flys.model.WstQRange; + +import org.apache.log4j.Logger; + +public final class SessionFactoryProvider +{ + private static Logger log = Logger.getLogger(SessionFactoryProvider.class); + + public static final String XPATH_USER = + "/artifact-database/backend-database/user/text()"; + + public static final String XPATH_PASSWORD = + "/artifact-database/backend-database/password/text()"; + + public static final String XPATH_DIALECT = + "/artifact-database/backend-database/dialect/text()"; + + public static final String XPATH_DRIVER = + "/artifact-database/backend-database/driver/text()"; + + public static final String XPATH_URL = + "/artifact-database/backend-database/url/text()"; + + public static final String DEFAULT_USER = + System.getProperty("flys.backend.user", "flys"); + + public static final String DEFAULT_PASSWORD = + System.getProperty("flys.backend.password", "flys"); + + public static final String DEFAULT_DIALECT = + System.getProperty( + "flys.backend.dialect", + "org.hibernate.dialect.PostgreSQLDialect"); + + public static final String DEFAULT_DRIVER = + System.getProperty( + "flys.backend.driver", + "org.postgresql.Driver"); + + public static final String DEFAULT_URL = + System.getProperty( + "flys.backend.url", + "jdbc:postgresql://localhost:5432/flys"); + + public static final boolean ENABLE_JMX = + Boolean.getBoolean("flys.backend.enablejmx"); + + private static SessionFactory sessionFactory; + + private SessionFactoryProvider() { + } + + public static synchronized SessionFactory getSessionFactory() { + if (sessionFactory == null) { + String user = + Config.getStringXPath(XPATH_USER, DEFAULT_USER); + String password = + Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD); + String dialect = + Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT); + String driver = + Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER); + String url = + Config.getStringXPath(XPATH_URL, DEFAULT_URL); + + sessionFactory = createSessionFactory( + user, password, dialect, driver, url); + } + return sessionFactory; + } + + public static SessionFactory createSessionFactory() { + return createSessionFactory( + DEFAULT_USER, + DEFAULT_PASSWORD, + DEFAULT_DIALECT, + DEFAULT_DRIVER, + DEFAULT_URL); + } + + public static SessionFactory createSessionFactory( + String user, + String password, + String dialect, + String driver, + String url + ) { + Configuration cfg = createConfiguration( + user, password, dialect, driver, url); + + SessionFactory factory = cfg.buildSessionFactory(); + + if (ENABLE_JMX) { + registerAsMBean(factory); + } + else { + log.info("No JMX support for hibernate."); + } + + return factory; + } + + + public static void registerAsMBean(SessionFactory factory) { + + StatisticsService statsMBean = new StatisticsService(); + statsMBean.setSessionFactory(factory); + statsMBean.setStatisticsEnabled(true); + + try { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + mbs.registerMBean( + statsMBean, + new ObjectName("Hibernate:application=Statistics")); + + log.info("Enabled JMX support for hibernate."); + } + catch (MalformedObjectNameException mone) { + log.warn(mone, mone); + } + catch (InstanceAlreadyExistsException iaee) { + log.warn(iaee, iaee); + } + catch (MBeanRegistrationException mbre) { + log.warn(mbre, mbre); + } + catch (NotCompliantMBeanException ncmbe) { + log.warn(ncmbe, ncmbe); + } + } + + + public static Configuration createConfiguration() { + return createConfiguration( + DEFAULT_USER, + DEFAULT_PASSWORD, + DEFAULT_DIALECT, + DEFAULT_DRIVER, + DEFAULT_URL); + } + + public static Configuration createConfiguration( + String user, + String password, + String dialect, + String driver, + String url + ) { + Configuration cfg = new Configuration(); + + // TODO: Use package reflection here. + cfg.addAnnotatedClass(Annotation.class); + cfg.addAnnotatedClass(AnnotationType.class); + cfg.addAnnotatedClass(Attribute.class); + cfg.addAnnotatedClass(BedHeightEpoch.class); + cfg.addAnnotatedClass(BedHeightEpochValue.class); + cfg.addAnnotatedClass(BedHeightSingle.class); + cfg.addAnnotatedClass(BedHeightSingleValue.class); + cfg.addAnnotatedClass(BedHeightType.class); + cfg.addAnnotatedClass(Building.class); + cfg.addAnnotatedClass(Catchment.class); + cfg.addAnnotatedClass(CrossSection.class); + cfg.addAnnotatedClass(CrossSectionLine.class); + cfg.addAnnotatedClass(CrossSectionPoint.class); + cfg.addAnnotatedClass(CrossSectionTrack.class); + cfg.addAnnotatedClass(Depth.class); + cfg.addAnnotatedClass(DGM.class); + cfg.addAnnotatedClass(DischargeTable.class); + cfg.addAnnotatedClass(DischargeTableValue.class); + cfg.addAnnotatedClass(DischargeZone.class); + cfg.addAnnotatedClass(Edge.class); + cfg.addAnnotatedClass(ElevationModel.class); + cfg.addAnnotatedClass(Fixpoint.class); + cfg.addAnnotatedClass(Floodplain.class); + cfg.addAnnotatedClass(Floodmaps.class); + cfg.addAnnotatedClass(FlowVelocityMeasurement.class); + cfg.addAnnotatedClass(FlowVelocityMeasurementValue.class); + cfg.addAnnotatedClass(FlowVelocityModel.class); + cfg.addAnnotatedClass(FlowVelocityModelValue.class); + cfg.addAnnotatedClass(Gauge.class); + cfg.addAnnotatedClass(GaugeLocation.class); + cfg.addAnnotatedClass(GrainFraction.class); + cfg.addAnnotatedClass(Hws.class); + cfg.addAnnotatedClass(HydrBoundary.class); + cfg.addAnnotatedClass(HydrBoundaryPoly.class); + cfg.addAnnotatedClass(HYK.class); + cfg.addAnnotatedClass(HYKEntry.class); + cfg.addAnnotatedClass(HYKFormation.class); + cfg.addAnnotatedClass(HYKFlowZoneType.class); + cfg.addAnnotatedClass(HYKFlowZone.class); + cfg.addAnnotatedClass(Line.class); + cfg.addAnnotatedClass(LocationSystem.class); + cfg.addAnnotatedClass(MainValueType.class); + cfg.addAnnotatedClass(MorphologicalWidth.class); + cfg.addAnnotatedClass(MorphologicalWidthValue.class); + cfg.addAnnotatedClass(NamedMainValue.class); + cfg.addAnnotatedClass(MainValue.class); + cfg.addAnnotatedClass(Position.class); + cfg.addAnnotatedClass(Range.class); + cfg.addAnnotatedClass(River.class); + cfg.addAnnotatedClass(RiverAxis.class); + cfg.addAnnotatedClass(RiverAxisKm.class); + cfg.addAnnotatedClass(SedimentDensity.class); + cfg.addAnnotatedClass(SedimentDensityValue.class); + cfg.addAnnotatedClass(SedimentYield.class); + cfg.addAnnotatedClass(SedimentYieldValue.class); + cfg.addAnnotatedClass(TimeInterval.class); + cfg.addAnnotatedClass(Unit.class); + cfg.addAnnotatedClass(Waterlevel.class); + cfg.addAnnotatedClass(WaterlevelDifference.class); + cfg.addAnnotatedClass(WaterlevelDifferenceColumn.class); + cfg.addAnnotatedClass(WaterlevelDifferenceValue.class); + cfg.addAnnotatedClass(WaterlevelQRange.class); + cfg.addAnnotatedClass(WaterlevelValue.class); + cfg.addAnnotatedClass(WstColumn.class); + cfg.addAnnotatedClass(WstColumnQRange.class); + cfg.addAnnotatedClass(WstColumnValue.class); + cfg.addAnnotatedClass(Wst.class); + cfg.addAnnotatedClass(WstQRange.class); + + if (log.isDebugEnabled()) { + log.debug("user: " + user); + log.debug("dialect: " + dialect); + log.debug("driver: " + driver); + log.debug("url: " + url); + } + + Properties props = new Properties(); + + // We rely on our own connection pool + props.setProperty( + "hibernate.connection.provider_class", + "org.hibernate.connection.DBCPConnectionProvider"); + + props.setProperty(Environment.DIALECT, dialect); + props.setProperty(Environment.USER, user); + props.setProperty(Environment.PASS, password); + props.setProperty(Environment.DRIVER, driver); + props.setProperty(Environment.URL, url); + + cfg.mergeProperties(props); + + return cfg; + } + + + public static String getProperty(SessionFactoryImpl factory, String key) { + Properties props = factory.getProperties(); + return props.getProperty(key); + } + + public static String getUser(SessionFactoryImpl factory) { + return getProperty(factory, Environment.USER); + } + + + public static String getPass(SessionFactoryImpl factory) { + return getProperty(factory, Environment.PASS); + } + + + public static String getURL(SessionFactoryImpl factory) { + return getProperty(factory, Environment.URL); + } + + + public static String getDriver(SessionFactoryImpl factory) { + return getProperty(factory, Environment.DRIVER); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionHolder.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,43 @@ +package de.intevation.flys.backend; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; + + +public class SessionHolder +{ + private static Logger logger = + Logger.getLogger(SessionHolder.class); + + public static final ThreadLocal<Session> HOLDER = + new ThreadLocal<Session>() { + protected Session initialValue() { + return create(); + } + }; + + private SessionHolder() { + } + + public synchronized static Session create() { + logger.debug("create"); + SessionFactory sessionFactory = + SessionFactoryProvider.getSessionFactory(); + return sessionFactory.openSession(); + } + + public static Session acquire() { + logger.debug("acquire"); + Session session = create(); + HOLDER.set(session); + return session; + } + + public static void release() { + logger.debug("release"); + HOLDER.remove(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,166 @@ +package de.intevation.flys.backend; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Query; +import org.hibernate.Session; + +import de.intevation.flys.backend.SessionFactoryProvider; +import de.intevation.flys.model.Building; +import de.intevation.flys.model.CrossSectionTrack; +import de.intevation.flys.model.Fixpoint; +import de.intevation.flys.model.Line; +import de.intevation.flys.model.River; +import de.intevation.flys.model.RiverAxis; + + +public class SpatialInfo { + + private static Logger logger = Logger.getLogger(SpatialInfo.class); + + protected static String RIVERNAME = System.getProperty( + "flys.backend.spatial.river", "Saar"); + + protected Session session; + + + public static void main(String[] args) { + logger.info("Start SpatialInfo application."); + + SpatialInfo spatial = null; + + try { + spatial = new SpatialInfo(); + + River river = spatial.getRiver(RIVERNAME); + if (river == null) { + logger.warn("Could not find river '" + RIVERNAME + "'!"); + return; + } + + logger.info("Spatial information of River '" + RIVERNAME + "'"); + spatial.doRiverAxisInfo(river); + spatial.doCrossSectionTracksInfo(river); + spatial.doLinesInfo(river); + spatial.doBuildingsInfo(river); + spatial.doFixpointsInfo(river); + } + finally { + if (spatial != null) { + spatial.close(); + } + } + + logger.info("Finish SpatialInfo application."); + } + + + public SpatialInfo() { + session = SessionFactoryProvider + .createSessionFactory() + .openSession(); + } + + + public void close() { + session.close(); + } + + + protected River getRiver(String rivername) { + Query query = session.createQuery( + "from River where name =:name"); + query.setParameter("name", rivername); + + List<River> list = query.list(); + + if (list == null || list.size() == 0) { + logger.warn("No river '" + rivername + "' found!"); + return null; + } + + return list.get(0); + } + + + protected void doRiverAxisInfo(River river) { + List<RiverAxis> axis = RiverAxis.getRiverAxis(river.getName()); + if (axis != null && axis.size() > 0) { + logger.debug("TODO: Compute length and boundary."); + } + else { + logger.warn("River has no RiverAxis."); + } + } + + + protected void doCrossSectionTracksInfo(River river) { + Query query = session.createQuery( + "from CrossSectionTrack where river =:river"); + query.setParameter("river", river); + + List<CrossSectionTrack> list = query.list(); + + if (list == null || list.size() == 0) { + logger.warn("No CrossSectionTracks for '" + river.getName() + "' found!"); + return; + } + else { + logger.info("River contains " + list.size() + " CrossSectionTracks."); + } + } + + + protected void doLinesInfo(River river) { + Query query = session.createQuery( + "from Line where river =:river"); + query.setParameter("river", river); + + List<Line> list = query.list(); + + if (list == null || list.size() == 0) { + logger.warn("No Lines for '" + river.getName() + "' found!"); + return; + } + else { + logger.info("River contains " + list.size() + " Lines."); + } + } + + + protected void doBuildingsInfo(River river) { + Query query = session.createQuery( + "from Building where river =:river"); + query.setParameter("river", river); + + List<Building> list = query.list(); + + if (list == null || list.size() == 0) { + logger.warn("No Buildings for '" + river.getName() + "' found!"); + return; + } + else { + logger.info("River contains " + list.size() + " Buildings."); + } + } + + + protected void doFixpointsInfo(River river) { + Query query = session.createQuery( + "from Fixpoint where river =:river"); + query.setParameter("river", river); + + List<Fixpoint> list = query.list(); + + if (list == null || list.size() == 0) { + logger.warn("No Fixpoints for '" + river.getName() + "' found!"); + return; + } + else { + logger.info("River contains " + list.size() + " Fixpoints."); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,158 @@ +package de.intevation.flys.importer; + +public class Config +{ + public static final String DRY_RUN = + "flys.backend.importer.dry.run"; + + public static final String INFO_GEW_FILE = + "flys.backend.importer.infogew.file"; + + public static final String ANNOTATION_TYPES = + "flys.backend.importer.annotation.types"; + + public static final String SKIP_GAUGES = + "flys.backend.importer.skip.gauges"; + + public static final String SKIP_ANNOTATIONS = + "flys.backend.importer.skip.annotations"; + + public static final String SKIP_PRFS = + "flys.backend.importer.skip.prfs"; + + public static final String SKIP_HYKS = + "flys.backend.importer.skip.hyks"; + + public static final String SKIP_WST = + "flys.backend.importer.skip.wst"; + + public static final String SKIP_EXTRA_WSTS = + "flys.backend.importer.skip.extra.wsts"; + + public static final String SKIP_FIXATIONS = + "flys.backend.importer.skip.fixations"; + + public static final String SKIP_OFFICIAL_LINES = + "flys.backend.importer.skip.official.lines"; + + public static final String SKIP_FLOOD_WATER = + "flys.backend.importer.skip.flood.water"; + + public static final String SKIP_FLOOD_PROTECTION = + "flys.backend.importer.skip.flood.protection"; + + public static final String SKIP_BED_HEIGHT_SINGLE = + "flys.backend.importer.skip.bed.height.single"; + + public static final String SKIP_BED_HEIGHT_EPOCH = + "flys.backend.importer.skip.bed.height.epoch"; + + public static final String SKIP_SEDIMENT_DENSITY = + "flys.backend.importer.skip.sediment.density"; + + public static final String SKIP_MORPHOLOGICAL_WIDTH = + "flys.backend.importer.skip.morphological.width"; + + public static final String SKIP_FLOW_VELOCITY = + "flys.backend.importer.skip.flow.velocity"; + + public static final String SKIP_SEDIMENT_YIELD = + "flys.backend.importer.skip.sediment.yield"; + + public static final String SKIP_WATERLEVELS = + "flys.backend.importer.skip.waterlevels"; + + public static final String SKIP_WATERLEVEL_DIFFERENCES = + "flys.backend.importer.skip.waterlevel.differences"; + + + public static final Config INSTANCE = new Config(); + + private Config () { + } + + public boolean dryRun() { + return Boolean.getBoolean(DRY_RUN); + } + + public String getInfoGewFile() { + return System.getProperty(INFO_GEW_FILE); + } + + public String getAnnotationTypes() { + return System.getProperty(ANNOTATION_TYPES); + } + + public boolean skipGauges() { + return Boolean.getBoolean(SKIP_GAUGES); + } + + public boolean skipAnnotations() { + return Boolean.getBoolean(SKIP_ANNOTATIONS); + } + + public boolean skipPRFs() { + return Boolean.getBoolean(SKIP_PRFS); + } + + public boolean skipHYKs() { + return Boolean.getBoolean(SKIP_HYKS); + } + + public boolean skipWst() { + return Boolean.getBoolean(SKIP_WST); + } + + public boolean skipExtraWsts() { + return Boolean.getBoolean(SKIP_EXTRA_WSTS); + } + + public boolean skipFixations() { + return Boolean.getBoolean(SKIP_FIXATIONS); + } + + public boolean skipOfficialLines() { + return Boolean.getBoolean(SKIP_OFFICIAL_LINES); + } + + public boolean skipFloodWater() { + return Boolean.getBoolean(SKIP_FLOOD_WATER); + } + + public boolean skipFloodProtection() { + return Boolean.getBoolean(SKIP_FLOOD_PROTECTION); + } + + public boolean skipBedHeightSingle() { + return Boolean.getBoolean(SKIP_BED_HEIGHT_SINGLE); + } + + public boolean skipBedHeightEpoch() { + return Boolean.getBoolean(SKIP_BED_HEIGHT_EPOCH); + } + + public boolean skipSedimentDensity() { + return Boolean.getBoolean(SKIP_SEDIMENT_DENSITY); + } + + public boolean skipMorphologicalWidth() { + return Boolean.getBoolean(SKIP_MORPHOLOGICAL_WIDTH); + } + + public boolean skipFlowVelocity() { + return Boolean.getBoolean(SKIP_FLOW_VELOCITY); + } + + public boolean skipSedimentYield() { + return Boolean.getBoolean(SKIP_SEDIMENT_YIELD); + } + + public boolean skipWaterlevels() { + return Boolean.getBoolean(SKIP_WATERLEVELS); + } + + public boolean skipWaterlevelDifferences() { + return Boolean.getBoolean(SKIP_WATERLEVEL_DIFFERENCES); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotation.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,146 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.Annotation; +import de.intevation.flys.model.AnnotationType; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.Position; +import de.intevation.flys.model.Attribute; +import de.intevation.flys.model.River; +import de.intevation.flys.model.Edge; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; + +public class ImportAnnotation +implements Comparable<ImportAnnotation> +{ + protected ImportAttribute attribute; + protected ImportPosition position; + protected ImportRange range; + protected ImportEdge edge; + protected ImportAnnotationType type; + + protected Annotation peer; + + public ImportAnnotation() { + } + + public ImportAnnotation( + ImportAttribute attribute, + ImportPosition position, + ImportRange range, + ImportEdge edge, + ImportAnnotationType type + ) { + this.attribute = attribute; + this.position = position; + this.range = range; + this.edge = edge; + this.type = type; + } + + public int compareTo(ImportAnnotation other) { + int d = attribute.compareTo(other.attribute); + if (d != 0) { + return d; + } + + if ((d = position.compareTo(other.position)) != 0) { + return d; + } + + if ((d = range.compareTo(other.range)) != 0) { + return d; + } + + if (edge == null && other.edge != null) return -1; + if (edge != null && other.edge == null) return +1; + if (edge == null && other.edge == null) return 0; + + if ((d = edge.compareTo(other.edge)) != 0) { + return d; + } + + if (type == null && other.type != null) return -1; + if (type != null && other.type == null) return +1; + if (type == null && other.type == null) return 0; + + return type.compareTo(other.type); + } + + public ImportAttribute getAttribute() { + return attribute; + } + + public void setAttribute(ImportAttribute attribute) { + this.attribute = attribute; + } + + public ImportPosition getPosition() { + return position; + } + + public void setPosition(ImportPosition position) { + this.position = position; + } + + public ImportRange getRange() { + return range; + } + + public void setRange(ImportRange range) { + this.range = range; + } + + public ImportEdge getEdge() { + return edge; + } + + public void setEdge(ImportEdge edge) { + this.edge = edge; + } + + public ImportAnnotationType getType() { + return type; + } + + public void setType(ImportAnnotationType type) { + this.type = type; + } + + public Annotation getPeer(River river) { + if (peer == null) { + Range r = range.getPeer(river); + Attribute a = attribute.getPeer(); + Position p = position.getPeer(); + Edge e = edge != null ? edge.getPeer() : null; + AnnotationType t = type != null ? type.getPeer() : null; + + Session session = ImporterSession.getInstance().getDatabaseSession(); + Query query = session.createQuery( + "from Annotation where " + + "range=:range and " + + "attribute=:attribute and " + + "position=:position and " + + "edge=:edge and " + + "type=:type"); + query.setParameter("range", r); + query.setParameter("attribute", a); + query.setParameter("position", p); + query.setParameter("edge", e); + query.setParameter("type", t); + List<Annotation> annotations = query.list(); + if (annotations.isEmpty()) { + peer = new Annotation(r, a, p, e, t); + session.save(peer); + } + else { + peer = annotations.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotationType.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,54 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.AnnotationType; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; + +public class ImportAnnotationType +implements Comparable<ImportAnnotationType> +{ + protected String name; + protected AnnotationType peer; + + public ImportAnnotationType() { + } + + public ImportAnnotationType(String name) { + this.name = name; + } + + public int compareTo(ImportAnnotationType other) { + return name.compareTo(other.name); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public AnnotationType getPeer() { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + Query query = session.createQuery( + "from AnnotationType where name=:name"); + query.setParameter("name", name); + List<AnnotationType> types = query.list(); + if (types.isEmpty()) { + peer = new AnnotationType(name); + session.save(peer); + } + else { + peer = types.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportAttribute.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,65 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.Attribute; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; + +public class ImportAttribute +implements Comparable<ImportAttribute> +{ + protected String value; + + protected Attribute peer; + + public ImportAttribute() { + } + + public ImportAttribute(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int compareTo(ImportAttribute other) { + return value.compareTo(other.value); + } + + @Override + public boolean equals(Object other) { + if (other == this) return true; + if (!(other instanceof ImportAttribute)) return false; + return value.equals(((ImportAttribute)other).value); + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + public Attribute getPeer() { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + Query query = session.createQuery("from Attribute where value=:value"); + query.setString("value", value); + List<Attribute> attributes = query.list(); + if (attributes.isEmpty()) { + peer = new Attribute(value); + session.save(peer); + } + else { + peer = attributes.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeight.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,44 @@ +package de.intevation.flys.importer; + + +import java.sql.SQLException; + +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.River; + + +public interface ImportBedHeight { + + String getDescription(); + + void addValue(ImportBedHeightValue value); + + void storeDependencies(River river) + throws SQLException, ConstraintViolationException; + + Object getPeer(River river); + + int getValueCount(); + + void setYear(int year); + + void setTimeInterval(ImportTimeInterval timeInterval); + + void setSoundingWidth(int soundingWidth); + + void setDescription(String description); + + void setEvaluationBy(String evaluationBy); + + void setRange(ImportRange range); + + void setType(ImportBedHeightType type); + + void setLocationSystem(ImportLocationSystem locationSystem); + + void setCurElevationModel(ImportElevationModel model); + + void setOldElevationModel(ImportElevationModel model); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,198 @@ +package de.intevation.flys.importer; + +import java.util.ArrayList; +import java.util.List; + +import java.sql.SQLException; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.BedHeightEpoch; +import de.intevation.flys.model.ElevationModel; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.River; +import de.intevation.flys.model.TimeInterval; + + +public class ImportBedHeightEpoch implements ImportBedHeight +{ + private static Logger log = Logger.getLogger(ImportBedHeightEpoch.class); + + protected String evaluationBy; + protected String description; + + protected ImportTimeInterval timeInterval; + protected ImportRange range; + protected ImportElevationModel curElevationModel; + protected ImportElevationModel oldElevationModel; + + protected List<ImportBedHeightEpochValue> values; + + protected BedHeightEpoch peer; + + + public ImportBedHeightEpoch(String description) { + this.description = description; + this.values = new ArrayList<ImportBedHeightEpochValue>(); + } + + + public String getDescription() { + return description; + } + + + public int getValueCount() { + return values.size(); + } + + public void setTimeInterval(ImportTimeInterval timeInterval) { + this.timeInterval = timeInterval; + } + + + public void setEvaluationBy(String evaluationBy) { + this.evaluationBy = evaluationBy; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setRange(ImportRange range) { + this.range = range; + } + + public void setCurElevationModel(ImportElevationModel curElevationModel) { + this.curElevationModel = curElevationModel; + } + + public void setOldElevationModel(ImportElevationModel oldElevationModel) { + this.oldElevationModel = oldElevationModel; + } + + public void setYear(int year) { + // do nothing + } + + public void setSoundingWidth(int soundingWidth) { + // do nothing + } + + public void setLocationSystem(ImportLocationSystem locationSystem) { + // do nothing + } + + public void setType(ImportBedHeightType type) { + // do nothing + } + + @Override + public void addValue(ImportBedHeightValue value) { + values.add((ImportBedHeightEpochValue) value); + } + + + @Override + public void storeDependencies(River river) + throws SQLException, ConstraintViolationException + { + log.info("Store dependencies for epoch: '" + getDescription() + "'"); + + if (curElevationModel != null) { + curElevationModel.storeDependencies(); + } + + if (oldElevationModel != null) { + oldElevationModel.storeDependencies(); + } + + BedHeightEpoch peer = getPeer(river); + + log.debug("store values now..."); + + for (ImportBedHeightEpochValue value: values) { + value.storeDependencies(peer); + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + session.flush(); + } + + + @Override + public BedHeightEpoch getPeer(River river) { + if (peer == null) { + ElevationModel theCurModel = curElevationModel != null + ? curElevationModel.getPeer() + : null; + + if (theCurModel == null) { + log.warn("Skip file - invalid current elevation model."); + return null; + } + + TimeInterval theTime = timeInterval != null + ? timeInterval.getPeer() + : null; + + if (theTime == null) { + log.warn("Skip file - invalid time range."); + return null; + } + + Range theRange = range != null ? range.getPeer(river) : null; + + if (theRange == null) { + log.warn("Skip file - invalid km range."); + return null; + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightEpoch where " + + " river=:river and " + + " timeInterval=:timeInterval and " + + " curElevationModel=:curElevationModel and " + + " range=:range and " + + " evaluationBy=:evaluationBy and " + + " description=:description"); + + query.setParameter("river", river); + query.setParameter("timeInterval", theTime); + query.setParameter("curElevationModel", theCurModel); + query.setParameter("range", theRange); + query.setParameter("evaluationBy", evaluationBy); + query.setParameter("description", description); + + List<BedHeightEpoch> bedHeights = query.list(); + + if (bedHeights.isEmpty()) { + log.info("Create new BedHeightEpoch DB instance."); + + peer = new BedHeightEpoch( + river, + theTime, + theRange, + theCurModel, + oldElevationModel != null ? oldElevationModel.getPeer() : null, + evaluationBy, + description + ); + + session.save(peer); + } + else { + peer = bedHeights.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpochValue.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,75 @@ +package de.intevation.flys.importer; + +import java.util.List; + +import java.math.BigDecimal; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.BedHeightEpoch; +import de.intevation.flys.model.BedHeightEpochValue; + + +public class ImportBedHeightEpochValue implements ImportBedHeightValue { + + private static final Logger log = + Logger.getLogger(ImportBedHeightEpochValue.class); + + + private BigDecimal station; + private BigDecimal height; + + private BedHeightEpochValue peer; + + + public ImportBedHeightEpochValue() { + } + + + public ImportBedHeightEpochValue(BigDecimal station, BigDecimal height) { + this.station = station; + this.height = height; + } + + + public void storeDependencies(BedHeightEpoch bedHeight) { + getPeer(bedHeight); + } + + + public BedHeightEpochValue getPeer(BedHeightEpoch bedHeight) { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightEpochValue where " + + " bedHeight=:bedHeight and " + + " station=:station and " + + " height=:height"); + + query.setParameter("bedHeight", bedHeight); + query.setParameter("station", station); + query.setParameter("height", height); + + List<BedHeightEpochValue> values = query.list(); + + if (values.isEmpty()) { + peer = new BedHeightEpochValue( + bedHeight, + station, + height + ); + session.save(peer); + } + else { + peer = values.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,189 @@ +package de.intevation.flys.importer; + +import java.util.ArrayList; +import java.util.List; + +import java.sql.SQLException; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.BedHeightSingle; +import de.intevation.flys.model.BedHeightType; +import de.intevation.flys.model.ElevationModel; +import de.intevation.flys.model.Range; +import de.intevation.flys.model.River; + + +public class ImportBedHeightSingle implements ImportBedHeight +{ + private static Logger log = Logger.getLogger(ImportBedHeightSingle.class); + + protected int year; + protected int soundingWidth; + + protected String evaluationBy; + protected String description; + + protected ImportRange range; + protected ImportBedHeightType type; + protected ImportLocationSystem locationSystem; + protected ImportElevationModel curElevationModel; + protected ImportElevationModel oldElevationModel; + + protected List<ImportBedHeightSingleValue> values; + + protected BedHeightSingle peer; + + + public ImportBedHeightSingle(String description) { + this.description = description; + this.values = new ArrayList<ImportBedHeightSingleValue>(); + } + + + public String getDescription() { + return description; + } + + public int getValueCount() { + return values.size(); + } + + + public void setYear(int year) { + this.year = year; + } + + public void setTimeInterval(ImportTimeInterval timeInterval) { + // do nothing + } + + public void setSoundingWidth(int soundingWidth) { + this.soundingWidth = soundingWidth; + } + + public void setEvaluationBy(String evaluationBy) { + this.evaluationBy = evaluationBy; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setRange(ImportRange range) { + this.range = range; + } + + public void setType(ImportBedHeightType type) { + this.type = type; + } + + public void setLocationSystem(ImportLocationSystem locationSystem) { + this.locationSystem = locationSystem; + } + + public void setCurElevationModel(ImportElevationModel curElevationModel) { + this.curElevationModel = curElevationModel; + } + + public void setOldElevationModel(ImportElevationModel oldElevationModel) { + this.oldElevationModel = oldElevationModel; + } + + @Override + public void addValue(ImportBedHeightValue value) { + values.add((ImportBedHeightSingleValue) value); + } + + @Override + public void storeDependencies(River river) + throws SQLException, ConstraintViolationException + { + log.info("Store dependencies for single: '" + getDescription() + "'"); + + if (type != null) { + type.storeDependencies(); + } + + if (locationSystem != null) { + locationSystem.storeDependencies(); + } + + if (curElevationModel != null) { + curElevationModel.storeDependencies(); + } + + if (oldElevationModel != null) { + oldElevationModel.storeDependencies(); + } + + BedHeightSingle peer = getPeer(river); + + for (ImportBedHeightSingleValue value: values) { + value.storeDependencies(peer); + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + session.flush(); + } + + @Override + public BedHeightSingle getPeer(River river) { + if (peer == null) { + BedHeightType theType = type != null ? type.getPeer() : null; + ElevationModel theCurModel = curElevationModel.getPeer(); + Range theRange = range != null ? range.getPeer(river) : null; + + if (theType == null || theCurModel == null || theRange == null) { + log.warn("Skip invalid file '" + description + "'"); + return null; + } + + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightSingle where " + + "river=:river and year=:year and soundingWidth=:soundingWidth " + + "and type=:type and locationSystem=:locationSystem and " + + "curElevationModel=:curElevationModel and range=:range"); + + query.setParameter("river", river); + query.setParameter("year", year); + query.setParameter("soundingWidth", soundingWidth); + query.setParameter("type", theType); + query.setParameter("locationSystem", locationSystem.getPeer()); + query.setParameter("curElevationModel", theCurModel); + query.setParameter("range", range.getPeer(river)); + + List<BedHeightSingle> bedHeights = query.list(); + if (bedHeights.isEmpty()) { + log.info("Create new BedHeightSingle DB instance."); + + peer = new BedHeightSingle( + river, + year, + soundingWidth, + theType, + locationSystem.getPeer(), + theCurModel, + oldElevationModel != null ? oldElevationModel.getPeer() : null, + range.getPeer(river), + evaluationBy, + description + ); + + session.save(peer); + } + else { + peer = bedHeights.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,101 @@ +package de.intevation.flys.importer; + +import java.util.List; + +import java.math.BigDecimal; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.BedHeightSingle; +import de.intevation.flys.model.BedHeightSingleValue; + + +public class ImportBedHeightSingleValue implements ImportBedHeightValue { + + private static final Logger log = + Logger.getLogger(ImportBedHeightSingleValue.class); + + + protected ImportBedHeightSingle bedHeight; + + protected BigDecimal station; + protected BigDecimal height; + protected BigDecimal uncertainty; + protected BigDecimal dataGap; + protected BigDecimal soundingWidth; + protected BigDecimal width; + + protected BedHeightSingleValue peer; + + + public ImportBedHeightSingleValue( + ImportBedHeightSingle bedHeight, + BigDecimal station, + BigDecimal height, + BigDecimal uncertainty, + BigDecimal dataGap, + BigDecimal soundingWidth, + BigDecimal width + ) { + this.bedHeight = bedHeight; + this.station = station; + this.height = height; + this.uncertainty = uncertainty; + this.dataGap = dataGap; + this.soundingWidth = soundingWidth; + this.width = width; + } + + + public void storeDependencies(BedHeightSingle bedHeight) { + getPeer(bedHeight); + } + + + public BedHeightSingleValue getPeer(BedHeightSingle bedHeight) { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightSingleValue where " + + " bedHeight=:bedHeight and " + + " station=:station and " + + " height=:height and " + + " uncertainty=:uncertainty and " + + " dataGap=:dataGap and " + + " soundingWidth=:soundingWidth and " + + " width=:width"); + + query.setParameter("bedHeight", bedHeight); + query.setParameter("station", station); + query.setParameter("height", height); + query.setParameter("uncertainty", uncertainty); + query.setParameter("dataGap", dataGap); + query.setParameter("soundingWidth", soundingWidth); + query.setParameter("width", width); + + List<BedHeightSingleValue> values = query.list(); + if (values.isEmpty()) { + peer = new BedHeightSingleValue( + bedHeight, + station, + height, + uncertainty, + dataGap, + soundingWidth, + width + ); + session.save(peer); + } + else { + peer = values.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightType.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,60 @@ +package de.intevation.flys.importer; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.BedHeightType; + + +public class ImportBedHeightType { + + private static final Logger log = + Logger.getLogger(ImportBedHeightType.class); + + protected String name; + protected String description; + + protected BedHeightType peer; + + + public ImportBedHeightType(String name, String description) { + this.name = name; + this.description = description; + } + + + public void storeDependencies() { + BedHeightType type = getPeer(); + } + + + public BedHeightType getPeer() { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from BedHeightType where " + + "name=:name and description=:description"); + + query.setParameter("name", name); + query.setParameter("description", description); + + List<BedHeightType> types = query.list(); + + if (types.isEmpty()) { + peer = new BedHeightType(name, description); + session.save(peer); + } + else { + peer = types.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightValue.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,7 @@ +package de.intevation.flys.importer; + + +public interface ImportBedHeightValue { + +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportCrossSection.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,119 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.River; +import de.intevation.flys.model.CrossSection; +import de.intevation.flys.model.TimeInterval; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; + +import org.apache.log4j.Logger; + +public class ImportCrossSection +{ + private static Logger log = Logger.getLogger(ImportRiver.class); + + protected ImportRiver river; + protected String description; + protected ImportTimeInterval timeInterval; + protected List<ImportCrossSectionLine> lines; + + protected CrossSection peer; + + public ImportCrossSection() { + } + + public ImportCrossSection( + ImportRiver river, + String description, + ImportTimeInterval timeInterval, + List<ImportCrossSectionLine> lines + ) { + this.river = river; + this.description = description; + this.timeInterval = timeInterval; + this.lines = lines; + wireWithLines(); + } + + public void wireWithLines() { + for (ImportCrossSectionLine line: lines) { + line.setCrossSection(this); + } + } + + public ImportRiver getRiver() { + return river; + } + + public void setRiver(ImportRiver river) { + this.river = river; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ImportTimeInterval getTimeInterval() { + return timeInterval; + } + + public void setTimeInterval(ImportTimeInterval timeInterval) { + this.timeInterval = timeInterval; + } + + public void storeDependencies() { + + log.info("store cross section '" + description + "'"); + + getPeer(); + + int i = 1, N = lines.size(); + + for (ImportCrossSectionLine line: lines) { + line.storeDependencies(); + log.info(" stored " + i + " lines. remaining: " + (N-i)); + ++i; + } + } + + public CrossSection getPeer() { + + if (peer == null) { + River r = river.getPeer(); + TimeInterval t = timeInterval != null + ? timeInterval.getPeer() + : null; + + Session session = + ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from CrossSection where " + + "river=:r and " + + "timeInterval=:t and " + + "description=:d"); + + query.setParameter("r", r); + query.setParameter("t", t); + query.setParameter("d", description); + + List<CrossSection> crossSections = query.list(); + if (crossSections.isEmpty()) { + peer = new CrossSection(r, t, description); + session.save(peer); + } + else { + peer = crossSections.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,118 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.CrossSection; +import de.intevation.flys.model.CrossSectionPoint; +import de.intevation.flys.model.CrossSectionLine; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; +import java.util.Comparator; +import java.util.Map; +import java.util.TreeMap; + +public class ImportCrossSectionLine +{ + public static final Comparator<CrossSectionPoint> INDEX_CMP = + new Comparator<CrossSectionPoint>() { + public int compare(CrossSectionPoint a, CrossSectionPoint b) { + return a.getColPos().compareTo(b.getColPos()); + } + }; + + protected Double km; + protected ImportCrossSection crossSection; + protected List<XY> points; + + protected CrossSectionLine peer; + + public ImportCrossSectionLine() { + } + + public ImportCrossSectionLine(Double km, List<XY> points) { + this.km = km; + this.points = points; + } + + public ImportCrossSection getCrossSection() { + return crossSection; + } + + public void setCrossSection(ImportCrossSection crossSection) { + this.crossSection = crossSection; + } + + public Double getKm() { + return km; + } + + public void setKm(Double km) { + this.km = km; + } + + public void storeDependencies() { + storePoints(); + } + + protected void storePoints() { + CrossSectionLine csl = getPeer(); + + Map<CrossSectionPoint, CrossSectionPoint> map = + new TreeMap<CrossSectionPoint, CrossSectionPoint>(INDEX_CMP); + + // build index for faster collision lookup + List<CrossSectionPoint> ps = csl.getPoints(); + if (ps != null) { + for (CrossSectionPoint point: ps) { + map.put(point, point); + } + } + + Session session = + ImporterSession.getInstance().getDatabaseSession(); + + CrossSectionPoint key = new CrossSectionPoint(); + + for (XY xy: points) { + key.setColPos(xy.getIndex()); + CrossSectionPoint csp = map.get(key); + if (csp == null) { // create new + csp = new CrossSectionPoint( + csl, key.getColPos(), + Double.valueOf(xy.getX()), + Double.valueOf(xy.getY())); + } + else { // update old + csp.setX(Double.valueOf(xy.getX())); + csp.setY(Double.valueOf(xy.getY())); + } + session.save(csp); + } + } + + public CrossSectionLine getPeer() { + if (peer == null) { + CrossSection cs = crossSection.getPeer(); + + Session session = + ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from CrossSectionLine where crossSection=:cs and km=:km"); + query.setParameter("cs", cs); + query.setParameter("km", km); + + List<CrossSectionLine> lines = query.list(); + if (lines.isEmpty()) { + peer = new CrossSectionLine(cs, km); + session.save(peer); + } + else { + peer = lines.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,75 @@ +package de.intevation.flys.importer; + +import java.math.BigDecimal; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.Depth; + + +public class ImportDepth { + + private static Logger log = Logger.getLogger(ImportDepth.class); + + + protected Depth peer; + + protected BigDecimal lower; + protected BigDecimal upper; + + protected ImportUnit unit; + + + public ImportDepth(BigDecimal lower, BigDecimal upper, ImportUnit unit) { + this.lower = lower; + this.upper = upper; + this.unit = unit; + } + + + public void storeDependencies() { + log.info("store dependencies"); + + getPeer(); + } + + + public Depth getPeer() { + log.info("get peer"); + + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from Depth where " + + " lower=:lower and " + + " upper=:upper and " + + " unit=:unit"); + + query.setParameter("lower", lower); + query.setParameter("upper", upper); + query.setParameter("unit", unit.getPeer()); + + List<Depth> depths = query.list(); + + if (depths.isEmpty()) { + log.debug("Create new Depth DB instance."); + + peer = new Depth(lower, upper, unit.getPeer()); + + session.save(peer); + } + else { + peer = depths.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTable.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,116 @@ +package de.intevation.flys.importer; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.DischargeTable; +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.TimeInterval; + +import org.apache.log4j.Logger; + +public class ImportDischargeTable +{ + private static Logger log = Logger.getLogger(ImportDischargeTable.class); + + protected DischargeTable peer; + + protected String description; + + protected Integer kind; + + protected List<ImportDischargeTableValue> dischargeTableValues; + + protected ImportTimeInterval timeInterval; + + public ImportDischargeTable() { + this(0, null); + } + + public ImportDischargeTable(int kind, String description) { + this.kind = kind; + this.description = description; + dischargeTableValues = new ArrayList<ImportDischargeTableValue>(); + } + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public void addDischargeTableValue(ImportDischargeTableValue value) { + dischargeTableValues.add(value); + } + + + public void setDischargeTableValues(List<ImportDischargeTableValue> values){ + this.dischargeTableValues = values; + } + + + public List<ImportDischargeTableValue> getDischargeTableValues() { + return dischargeTableValues; + } + + public ImportTimeInterval getTimeInterval() { + return timeInterval; + } + + public void setTimeInterval(ImportTimeInterval timeInterval) { + this.timeInterval = timeInterval; + } + + + public DischargeTable getPeer(Gauge gauge) { + if (peer == null) { + TimeInterval ti = timeInterval != null + ? timeInterval.getPeer() + : null; + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from DischargeTable where " + + "gauge.id=:gauge and kind=:kind and " + + "description=:description and timeInterval=:interval"); + query.setParameter("gauge", gauge.getId()); + query.setParameter("description", description); + query.setParameter("kind", kind); + query.setParameter("interval", ti); + + List<DischargeTable> dischargeTables = query.list(); + if (dischargeTables.isEmpty()) { + peer = new DischargeTable(gauge, description, kind, ti); + session.save(peer); + } + else { + peer = dischargeTables.get(0); + } + } + + return peer; + } + + + public void storeDependencies(Gauge gauge) { + log.info("store discharge table '" + description + "'"); + storeDischargeTableValues(gauge); + } + + + public void storeDischargeTableValues(Gauge gauge) { + DischargeTable dischargeTable = getPeer(gauge); + + for (ImportDischargeTableValue value: dischargeTableValues) { + value.getPeer(dischargeTable); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeTableValue.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,34 @@ +package de.intevation.flys.importer; + +import java.math.BigDecimal; + +import de.intevation.flys.model.DischargeTable; +import de.intevation.flys.model.DischargeTableValue; + + +public class ImportDischargeTableValue +{ + private BigDecimal q; + private BigDecimal w; + + private DischargeTableValue peer; + + public ImportDischargeTableValue() { + } + + + public ImportDischargeTableValue(BigDecimal q, BigDecimal w) { + this.q = q; + this.w = w; + } + + + public DischargeTableValue getPeer(DischargeTable dischargeTable) { + if (peer == null) { + peer = ImporterSession.getInstance() + .getDischargeTableValue(dischargeTable, q, w); + } + + return peer; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeZone.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,90 @@ +package de.intevation.flys.importer; + +import java.math.BigDecimal; +import java.sql.SQLException; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; +import org.hibernate.exception.ConstraintViolationException; + +import de.intevation.flys.model.DischargeZone; +import de.intevation.flys.model.River; + + +public class ImportDischargeZone { + + private static final Logger log = + Logger.getLogger(ImportDischargeZone.class); + + + private String gaugeName; + + private BigDecimal value; + + private String lowerDischarge; + private String upperDischarge; + + private DischargeZone peer; + + + public ImportDischargeZone( + String gaugeName, + BigDecimal value, + String lowerDischarge, + String upperDischarge + ) { + this.gaugeName = gaugeName; + this.value = value; + this.lowerDischarge = lowerDischarge; + this.upperDischarge = upperDischarge; + } + + + public void storeDependencies(River river) + throws SQLException, ConstraintViolationException + { + log.debug("store dependencies"); + + getPeer(river); + } + + + public DischargeZone getPeer(River river) { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + + Query query = session.createQuery( + "from DischargeZone where " + + " river=:river and " + + " gaugeName=:gaugeName and " + + " value=:value" + ); + + query.setParameter("river", river); + query.setParameter("gaugeName", gaugeName); + query.setParameter("value", value); + + List<DischargeZone> zone = query.list(); + + if (zone.isEmpty()) { + peer = new DischargeZone( + river, + gaugeName, + value, + lowerDischarge, + upperDischarge); + + session.save(peer); + } + else { + peer = zone.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportEdge.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,75 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.Edge; + +import org.hibernate.Session; +import org.hibernate.Query; + +import java.util.List; + +import java.math.BigDecimal; + +public class ImportEdge +implements Comparable<ImportEdge> +{ + protected BigDecimal top; + protected BigDecimal bottom; + + protected Edge peer; + + public ImportEdge() { + } + + public ImportEdge(BigDecimal top, BigDecimal bottom) { + this.top = top; + this.bottom = bottom; + } + + public BigDecimal getTop() { + return top; + } + + public void setTop(BigDecimal top) { + this.top = top; + } + + public BigDecimal getBottom() { + return bottom; + } + + public void setBottom(BigDecimal bottom) { + this.bottom = bottom; + } + + private static final int compare(BigDecimal a, BigDecimal b) { + if (a == null && b != null) return -1; + if (a != null && b == null) return +1; + if (a == null && b == null) return 0; + return a.compareTo(b); + } + + public int compareTo(ImportEdge other) { + int cmp = compare(top, other.top); + return cmp != 0 ? cmp : compare(bottom, other.bottom); + } + + public Edge getPeer() { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + Query query = session.createQuery( + "from Edge where top=:top and bottom=:bottom"); + query.setParameter("top", top); + query.setParameter("bottom", bottom); + List<Edge> edges = query.list(); + if (edges.isEmpty()) { + peer = new Edge(top, bottom); + session.save(peer); + } + else { + peer = edges.get(0); + } + } + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,59 @@ +package de.intevation.flys.importer; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.hibernate.Session; +import org.hibernate.Query; + +import de.intevation.flys.model.ElevationModel; + + +public class ImportElevationModel { + + private static final Logger log = + Logger.getLogger(ImportElevationModel.class); + + protected String name; + + protected ImportUnit unit; + + protected ElevationModel peer; + + + public ImportElevationModel(String name, ImportUnit unit) { + this.name = name; + this.unit = unit; + } + + + public void storeDependencies() { + ElevationModel model = getPeer(); + } + + public ElevationModel getPeer() { + if (peer == null) { + Session session = ImporterSession.getInstance().getDatabaseSession(); + Query query = session.createQuery( + "from ElevationModel where " + + "name=:name and unit=:unit"); + query.setParameter("name", name); + query.setParameter("unit", unit.getPeer()); + List<ElevationModel> models = query.list(); + + if (models.isEmpty()) { + log.info("Create new ElevationModel DB instance."); + + peer = new ElevationModel(name, unit.getPeer()); + session.save(peer); + } + else { + peer = models.get(0); + } + } + + return peer; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java Fri Sep 28 12:14:31 2012 +0200 @@ -0,0 +1,92 @@ +package de.intevation.flys.importer; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List;