diff backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 0c4bdf00f94f
children 50416a0df385 0a5239a1e46e
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Thu Jan 18 20:10:59 2018 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Thu Jan 18 20:12:01 2018 +0100
@@ -98,9 +98,11 @@
 
     public static final String POROSITY_DIR = "Porositaet";
 
-    public static final String MORPHOLOGICAL_WIDTH_DIR = "morphologische_Breite";
+    public static final String MORPHOLOGICAL_WIDTH_DIR =
+        "morphologische_Breite";
 
-    public static final String FLOW_VELOCITY_DIR = "Geschwindigkeit_Schubspannung";
+    public static final String FLOW_VELOCITY_DIR =
+        "Geschwindigkeit_Schubspannung";
 
     public static final String FLOW_VELOCITY_MODEL = "Modellrechnungen";
 
@@ -116,19 +118,23 @@
 
     public static final String SEDIMENT_LOAD_EPOCH_DIR = "Epochen";
 
-    public static final String SEDIMENT_LOAD_OFF_EPOCH_DIR = "amtliche Epochen";
+    public static final String SEDIMENT_LOAD_OFF_EPOCH_DIR =
+        "amtliche Epochen";
 
     public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse";
 
     public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen";
 
-    public static final String MINFO_WATERLEVEL_DIFF_DIR = "Wasserspiegeldifferenzen";
+    public static final String MINFO_WATERLEVEL_DIFF_DIR =
+        "Wasserspiegeldifferenzen";
 
     public static final String MINFO_BASE_DIR = "Basisdaten";
 
-    public static final String MINFO_CORE_DATA_FILE = "Stammdaten_Messstellen.csv";
+    public static final String MINFO_CORE_DATA_FILE =
+        "Stammdaten_Messstellen.csv";
 
-    public static final String MINFO_SQ_DIR = "Feststofftransport-Abfluss-Beziehung";
+    public static final String MINFO_SQ_DIR =
+        "Feststofftransport-Abfluss-Beziehung";
 
     protected String name;
 
@@ -216,7 +222,8 @@
             HashedFile hf = new HashedFile(file);
             boolean success = files.add(hf);
             if (!success) {
-                log.warn(type + " file '" + file + "' seems to be a duplicate.");
+                log.warn(type + " file '" + file
+                    + "' seems to be a duplicate.");
             }
             return success;
         }
@@ -249,7 +256,8 @@
                 List<XY> points = entry.getValue();
                 numReadPoints += points.size();
                 if (simplificationEpsilon != null) {
-                    points = DouglasPeuker.simplify(points, simplificationEpsilon);
+                    points = DouglasPeuker.simplify(
+                        points, simplificationEpsilon);
                 }
                 numRemainingPoints += points.size();
                 lines.add(new ImportCrossSectionLine(km, points));
@@ -275,29 +283,31 @@
         ImportTimeInterval           ti,
         List<ImportCrossSectionLine> lines
     ) {
-        crossSections.add(new ImportCrossSection(this, description, ti, lines));
+        crossSections.add(
+            new ImportCrossSection(this, description, ti, lines));
     }
 
 
     public ImportRiver() {
-        hyks                      = new ArrayList<ImportHYK>();
-        crossSections             = new ArrayList<ImportCrossSection>();
-        extraWsts                 = new ArrayList<ImportWst>();
-        fixations                 = new ArrayList<ImportWst>();
-        officialLines             = new ArrayList<ImportWst>();
-        floodWater                = new ArrayList<ImportWst>();
-        waterlevels               = new ArrayList<ImportWst>();
-        waterlevelDifferences     = new ArrayList<ImportWst>();
-        floodProtection           = new ArrayList<ImportWst>();
-        sedimentDensities         = new ArrayList<ImportSedimentDensity>();
-        porosities                = new ArrayList<ImportPorosity>();
-        morphologicalWidths       = new ArrayList<ImportMorphWidth>();
-        flowVelocityModels        = new ArrayList<ImportFlowVelocityModel>();
-        flowVelocityMeasurements  = new ArrayList<ImportFlowVelocityMeasurement>();
-        sedimentLoadLSs           = new ArrayList<ImportSedimentLoadLS>();
-        sedimentLoads             = new ArrayList<ImportSedimentLoad>();
-        measurementStations       = new ArrayList<ImportMeasurementStation>();
-        sqRelations               = new ArrayList<ImportSQRelation>();
+        hyks                     = new ArrayList<ImportHYK>();
+        crossSections            = new ArrayList<ImportCrossSection>();
+        extraWsts                = new ArrayList<ImportWst>();
+        fixations                = new ArrayList<ImportWst>();
+        officialLines            = new ArrayList<ImportWst>();
+        floodWater               = new ArrayList<ImportWst>();
+        waterlevels              = new ArrayList<ImportWst>();
+        waterlevelDifferences    = new ArrayList<ImportWst>();
+        floodProtection          = new ArrayList<ImportWst>();
+        sedimentDensities        = new ArrayList<ImportSedimentDensity>();
+        porosities               = new ArrayList<ImportPorosity>();
+        morphologicalWidths      = new ArrayList<ImportMorphWidth>();
+        flowVelocityModels       = new ArrayList<ImportFlowVelocityModel>();
+        flowVelocityMeasurements =
+            new ArrayList<ImportFlowVelocityMeasurement>();
+        sedimentLoadLSs          = new ArrayList<ImportSedimentLoadLS>();
+        sedimentLoads            = new ArrayList<ImportSedimentLoad>();
+        measurementStations      = new ArrayList<ImportMeasurementStation>();
+        sqRelations              = new ArrayList<ImportSQRelation>();
     }
 
     public ImportRiver(
@@ -364,7 +374,8 @@
     }
 
     public File getMinfoDir() {
-        File riverDir  = wstFile.getParentFile().getParentFile().getParentFile();
+        File riverDir  = wstFile
+            .getParentFile().getParentFile().getParentFile();
         return new File(riverDir, MINFO_DIR);
     }
 
@@ -434,7 +445,8 @@
                 wstParser.parse(file);
                 ImportWst iw = wstParser.getWst();
                 iw.setKind(5);
-                iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
+                iw.setDescription(
+                    FLOOD_PROTECTION + "/" + iw.getDescription());
                 floodProtection.add(iw);
             }
             catch (WstParser.ParseException e) {
@@ -492,7 +504,8 @@
 
         sedimentDensities = parser.getSedimentDensities();
 
-        log.info("Parsed " + sedimentDensities.size() + " sediment densities.");
+        log.info("Parsed " + sedimentDensities.size()
+            + " sediment densities.");
     }
 
     protected void parsePorosity() throws IOException {
@@ -550,7 +563,8 @@
 
         morphologicalWidths = parser.getMorphologicalWidths();
 
-        log.info("Parsed " + morphologicalWidths.size() + " morph. widths files.");
+        log.info("Parsed " + morphologicalWidths.size()
+            + " morph. widths files.");
     }
 
 
@@ -668,7 +682,8 @@
 
     protected void parseSedimentLoad() throws IOException {
         if (Config.INSTANCE.skipSedimentLoad()) {
-            log.info("skip parsing sediment load data at measurement stations");
+            log.info(
+                "skip parsing sediment load data at measurement stations");
             return;
         }
 
@@ -734,7 +749,8 @@
         File coredataFile = new File(minfoBaseDir, MINFO_CORE_DATA_FILE);
 
         if (coredataFile == null || !coredataFile.exists()) {
-            log.warn("No core data file '" + coredataFile.getAbsolutePath() + "' found");
+            log.warn("No core data file '"
+                + coredataFile.getAbsolutePath() + "' found");
             return;
         }
 
@@ -743,7 +759,8 @@
             parser.parse(coredataFile);
             measurementStations = parser.getMeasurementStations();
 
-            log.info("Successfully parsed " + measurementStations.size() + " measurement stations.");
+            log.info("Successfully parsed " + measurementStations.size()
+                + " measurement stations.");
         }
         catch (IOException ioe) {
             log.error("unable to parse file '" + coredataFile.getName() +
@@ -907,7 +924,8 @@
             }
             log.debug("Found WST file: " + file);
 
-            ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY);
+            ImportWst iw = new ImportWst(
+                ImportOfficialWstColumn.COLUMN_FACTORY);
 
             WstParser wstParser = new WstParser(iw);
             try {
@@ -921,12 +939,14 @@
             iw.setKind(3);
             iw.setDescription(folder + "/" + iw.getDescription());
 
-            File configFile = FileTools.repair(new File(dir, OFFICIAL_LINES_CONFIG));
+            File configFile = FileTools.repair(
+                new File(dir, OFFICIAL_LINES_CONFIG));
             if (!configFile.isFile() || !configFile.canRead()) {
                 log.warn("no config file for official lines found");
             }
             else {
-                OfficialLinesConfigParser olcp = new OfficialLinesConfigParser();
+                OfficialLinesConfigParser olcp =
+                    new OfficialLinesConfigParser();
                 try {
                     olcp.parse(configFile);
                 }
@@ -935,16 +955,19 @@
                 }
                 List<String> mainValueNames = olcp.getMainValueNames();
                 if (mainValueNames.isEmpty()) {
-                    log.warn("config file for offical lines contains no entries");
+                    log.warn(
+                        "config file for offical lines contains no entries");
                 }
                 else {
                     // Join as much as possible.
                     Iterator<ImportWstColumn> wi = iw.getColumns().iterator();
                     Iterator<String> si = olcp.getMainValueNames().iterator();
                     while (wi.hasNext() && si.hasNext()) {
-                        ImportOfficialWstColumn wc = (ImportOfficialWstColumn)wi.next();
+                        ImportOfficialWstColumn wc =
+                            (ImportOfficialWstColumn)wi.next();
                         String name = si.next();
-                        ImportOfficialLine iol = new ImportOfficialLine(name, wc);
+                        ImportOfficialLine iol =
+                            new ImportOfficialLine(name, wc);
                         wc.setOfficialLine(iol);
                     }
                 }
@@ -1044,7 +1067,8 @@
                 wstParser.parse(file);
                 ImportWst iw = wstParser.getWst();
                 iw.setKind(1);
-                iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription());
+                iw.setDescription(
+                    EXTRA_LONGITUDINALS + "/" + iw.getDescription());
                 extraWsts.add(iw);
             }
             catch (WstParser.ParseException e) {
@@ -1131,7 +1155,8 @@
                 HashedFile hf = new HashedFile(file);
                 boolean success = hfs.add(hf);
                 if (!success) {
-                    log.warn("HYK file '" + file + "' seems to be a duplicate.");
+                    log.warn("HYK file '" + file
+                        + "' seems to be a duplicate.");
                 }
                 return success;
             }
@@ -1211,7 +1236,8 @@
 
 
     /** Create a DA66 Parser and parse the da66 files found. */
-    // TODO this is a copy of parsePRFs, extract interfaces (e.g. CrossSectionParser).
+    // TODO this is a copy of parsePRFs, extract interfaces
+    //(e.g. CrossSectionParser).
     public void parseDA66s() {
         if (Config.INSTANCE.skipDA66s()) {
             log.info("skip parsing DA66s");
@@ -1267,7 +1293,8 @@
         query.setString("name", name);
         List<River> rivers = query.list();
         if (rivers.isEmpty() && Config.INSTANCE.skipWst()){
-            log.error("River not yet in database. You cannot skip importing waterlevel model.");
+            log.error("River not yet in database. "
+                + "You cannot skip importing waterlevel model.");
             return;
         }
 
@@ -1298,7 +1325,8 @@
 
     public void storeWstUnit() {
         if (wst == null) {
-            log.warn("No unit given. Waterlevel-model WST-file has to be imported already.");
+            log.warn("No unit given. "
+                + "Waterlevel-model WST-file has to be imported already.");
         }
         else {
             wstUnit = wst.getUnit();
@@ -1336,7 +1364,8 @@
 
             // The flow direction of the main wst and the corresponding
             // waterlevels determine if the river is 'km_up'.
-            Session session = ImporterSession.getInstance().getDatabaseSession();
+            Session session = ImporterSession.getInstance()
+                .getDatabaseSession();
             river.setKmUp(wst.getKmUp());
             session.save(river);
         }
@@ -1408,7 +1437,8 @@
                 ImportOfficialLine ioc = owc.getOfficialLine();
                 if (ioc != null) {
                     if (ioc.getPeer(river) == null) {
-                        log.warn("Cannot store official line: " + ioc.getName());
+                        log.warn("Cannot store official line: "
+                            + ioc.getName());
                     }
                 }
             }
@@ -1512,7 +1542,8 @@
 
             River river = getPeer();
 
-            for (ImportFlowVelocityModel flowVelocityModel: flowVelocityModels){
+            for (ImportFlowVelocityModel flowVelocityModel: flowVelocityModels
+            ) {
                 flowVelocityModel.storeDependencies(river);
             }
 
@@ -1609,7 +1640,8 @@
 
     public River getPeer() {
         if (peer == null) {
-            Session session = ImporterSession.getInstance().getDatabaseSession();
+            Session session = ImporterSession.getInstance()
+                .getDatabaseSession();
             Query query = session.createQuery("from River where name=:name");
 
             Unit u = null;

http://dive4elements.wald.intevation.org