# HG changeset patch # User Raimund Renkert # Date 1389190109 -3600 # Node ID 0bc65c128530cf25f0a751ee416f1b8ff6ab6d8f # Parent b9d8bcb49e4e5228f1c929bb594878e85cb90e42# Parent 2cec94fcab0551b1e244444983aa198c37a64db0 merged. diff -r 2cec94fcab05 -r 0bc65c128530 config/import.json --- a/config/import.json Tue Jan 07 16:46:41 2014 +0100 +++ b/config/import.json Wed Jan 08 15:08:29 2014 +0100 @@ -13,7 +13,7 @@ "default": "" }, { "key": "datenbasis_s", - "regex": "[0-9]{2}", + "regex": "[0-9]{1,2}", "default": "00" }, { "key": "netzkennung", @@ -108,6 +108,10 @@ "regex": ".{1,100}", "default": "" }, { + "key": "medium", + "regex": ".{1,100}", + "default": "" + }, { "key": "rei_programmpunkt", "regex": ".{1,10}", "default": "" @@ -142,7 +146,7 @@ "default": "" }, { "key": "messzeit_sekunden", - "regex": "[0-9]{8}", + "regex": "[0-9]{1,8}", "default": "" }, { "key": "messmethode_c", @@ -171,7 +175,11 @@ }], "ort": [{ "key": "ort_id", - "regex": "[0-9]{10}", + "regex": "[0-9]{1,10}", + "default": "" + }, { + "key": "ort_code", + "regex": ".{3,12}", "default": "" }, { "key": "ort_typ", @@ -191,14 +199,14 @@ "default": "" }, { "key": "ort_land_s", - "regex": "[0-9]{8}", + "regex": "[0-9]{1,8}", "default": "" }, { "key": "ort_netzbetreiber", "regex": ".{2}", "default": "" }, { - "key": "ort_gemeindeschlüssel", + "key": "ort_gemeindeschluessel", "regex": "[0-9]{8}", "default": "" }, { @@ -227,7 +235,7 @@ "default": "" }, { "key": "ort_nuts_code", - "regex": "[0-9]{10}", + "regex": ".{1,10}", "default": "" }, { "key": "ort_hoehe_land", diff -r 2cec94fcab05 -r 0bc65c128530 src/main/java/de/intevation/lada/data/exporter/LAFCreator.java --- a/src/main/java/de/intevation/lada/data/exporter/LAFCreator.java Tue Jan 07 16:46:41 2014 +0100 +++ b/src/main/java/de/intevation/lada/data/exporter/LAFCreator.java Wed Jan 08 15:08:29 2014 +0100 @@ -227,9 +227,9 @@ new QueryBuilder( readonlyRepo.getEntityManager(), SKoordinatenArt.class); String koord = ""; + koord += "05 "; koord += ort.get(0).getLatitude() + " "; - koord += ort.get(0).getLongitude() + " "; - koord += "UTM (WGS84)"; + koord += ort.get(0).getLongitude(); //TODO: use table koordinatenart and koord*extern! laf += lafLine("ORT_KOORDINATEN_S", koord); laf += lafLine("ORT_GEMEINDESCHLUESSEL", ort.get(0).getGemId()); diff -r 2cec94fcab05 -r 0bc65c128530 src/main/java/de/intevation/lada/data/importer/OrtCreator.java --- a/src/main/java/de/intevation/lada/data/importer/OrtCreator.java Tue Jan 07 16:46:41 2014 +0100 +++ b/src/main/java/de/intevation/lada/data/importer/OrtCreator.java Wed Jan 08 15:08:29 2014 +0100 @@ -337,7 +337,7 @@ if ("ort_land_s".equals(key)) { this.setLandS(value.toString()); } - if ("ort_gemeindeschlüssel".equals(key)) { + if ("ort_gemeindeschluessel".equals(key)) { this.setGemSchluessel(value.toString()); } if ("ort_bezeichnung".equals(key)) { @@ -371,8 +371,8 @@ return null; } Ort ort = new Ort(); + ortRepo.create(ort); this.ortId = ort.getOrtId(); - ort.setBezeichnung("D_" + ort.getOrtId()); boolean koord = true; if (this.koordinatenS != null && this.koordinatenS.length() > 0) { ort = setKoordinatenS(ort); @@ -435,7 +435,10 @@ ort.setNutsCode(list.get(0).getNuts()); } ort.setBeschreibung(beschreibung); - ort.setHoeheLand(Float.valueOf(hoehe)); + if (this.hoehe != null) { + ort.setHoeheLand(Float.valueOf(hoehe)); + } + ortRepo.update(ort); return ort; } @@ -507,7 +510,7 @@ QueryBuilder builder = new QueryBuilder( readonlyRepo.getEntityManager(), SStaat.class); - builder.and("staat_id", this.landS); + builder.and("staatId", this.landS); Response response = readonlyRepo.filter(builder.getQuery()); List list = (List)response.getData(); if (list.isEmpty()) { @@ -515,7 +518,9 @@ return ort; } ort.setKoordXExtern(list.get(0).getKoordXExtern()); + ort.setLongitude(Double.valueOf(list.get(0).getKoordXExtern())); ort.setKoordYExtern(list.get(0).getKoordYExtern()); + ort.setLatitude(Double.valueOf(list.get(0).getKoordYExtern())); } return ort; } @@ -629,24 +634,24 @@ String x = ""; String y = ""; String tmp = ""; - if (this.koordinaten.startsWith("\"")) { - tmp = this.koordinaten.substring(1); + if (this.koordinatenS.startsWith("\"")) { + tmp = this.koordinatenS.substring(1); art = tmp.substring(0, tmp.indexOf("\"")); tmp = tmp.substring(tmp.indexOf("\"") + 2); } else { - art = this.koordinaten.substring(0, this.koordinaten.indexOf(" ")); - tmp = this.koordinaten.substring( - 0, this.koordinaten.indexOf(" ") + 1); + art = this.koordinatenS.substring(0, this.koordinatenS.indexOf(" ")); + tmp = this.koordinatenS.substring( + this.koordinatenS.indexOf(" ") + 1); } if (tmp.startsWith("\"")) { tmp = tmp.substring(1); x = tmp.substring(0, tmp.indexOf("\"")); - tmp = tmp.substring(0, tmp.indexOf("\"") + 2); + tmp = tmp.substring(tmp.indexOf("\"") + 2); } else { x = tmp.substring(0, tmp.indexOf(" ")); - tmp = tmp.substring(0, tmp.indexOf(" ") + 1); + tmp = tmp.substring(tmp.indexOf(" ") + 1); } if (tmp.startsWith("\"")) { tmp = tmp.substring(1); @@ -656,7 +661,9 @@ y = tmp; } ort.setKoordXExtern(x); + ort.setLongitude(Double.valueOf(x)); ort.setKoordYExtern(y); + ort.setLatitude(Double.valueOf(y)); return ort; } diff -r 2cec94fcab05 -r 0bc65c128530 src/main/java/de/intevation/lada/validation/LOrtValidator.java --- a/src/main/java/de/intevation/lada/validation/LOrtValidator.java Tue Jan 07 16:46:41 2014 +0100 +++ b/src/main/java/de/intevation/lada/validation/LOrtValidator.java Wed Jan 08 15:08:29 2014 +0100 @@ -71,7 +71,7 @@ * @param warnings */ private void validateVerwaltungseinheit(LOrt ort, Map warnings) { - if (!ort.getOrtsTyp().equals("E")) { + if (!"E".equals(ort.getOrtsTyp())) { return; } QueryBuilder ortBuilder = @@ -84,6 +84,10 @@ readonlyRepo.getEntityManager(), SVerwaltungseinheit.class); veBuilder.and("gemId", orte.get(0).getGemId()); Response ver = readonlyRepo.filter(veBuilder.getQuery()); + if (((List)ver.getData()).isEmpty()) { + warnings.put("verwaltungseinheit", 653); + return; + } SVerwaltungseinheit ve = ((List)ver.getData()).get(0); QueryBuilder vg = new QueryBuilder(readonlyRepo.getEntityManager(), DeVg.class);