Mercurial > lada > lada-server
changeset 1117:a3d47e0e30a2
merged.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 28 Oct 2016 10:54:24 +0200 |
parents | 430bbc8166d6 (current diff) 2f42a7607bbd (diff) |
children | 5a7488468cb2 |
files | |
diffstat | 3 files changed, 31 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/db_schema/stammdaten_schema.sql Fri Oct 28 10:53:40 2016 +0200 +++ b/db_schema/stammdaten_schema.sql Fri Oct 28 10:54:24 2016 +0200 @@ -556,7 +556,6 @@ wert_id integer REFERENCES status_wert NOT NULL, UNIQUE(stufe_id, wert_id) ); --- 'zurückgesetzt' is left out here deliberately! INSERT INTO status_kombi VALUES (1, 1, 0); INSERT INTO status_kombi VALUES (2, 1, 1); INSERT INTO status_kombi VALUES (3, 1, 2); @@ -570,6 +569,9 @@ INSERT INTO status_kombi VALUES (11, 3, 2); INSERT INTO status_kombi VALUES (12, 3, 3); INSERT INTO status_kombi VALUES (13, 3, 4); +INSERT INTO status_kombi VALUES (14, 1, 8); +INSERT INTO status_kombi VALUES (15, 2, 8); +INSERT INTO status_kombi VALUES (16, 3, 8); CREATE TABLE status_reihenfolge ( @@ -602,9 +604,12 @@ INSERT INTO status_reihenfolge (von_id, zu_id) VALUES (kombi_from.id, kombi_to.id); - ELSEIF s_to = s_from + 1 AND w_from <> 0 AND w_from <> 4 THEN + ELSEIF s_to = s_from + 1 + AND w_from <> 0 AND w_from <> 4 + AND w_from <> 8 AND w_to <> 8 THEN -- Going to the next 'stufe' all available status_kombi are allowed - -- in case current wert is not 'nicht vergeben' or 'Rückfrage' + -- in case current wert is not 'nicht vergeben', 'Rückfrage' or + -- 'zurückgesetzt' and we are not trying to set 'zurückgesetzt' INSERT INTO status_reihenfolge (von_id, zu_id) VALUES (kombi_from.id, kombi_to.id); @@ -614,6 +619,16 @@ INSERT INTO status_reihenfolge (von_id, zu_id) VALUES (kombi_from.id, kombi_to.id); + ELSEIF w_to = 8 AND s_from = s_to THEN + -- 'zurückgesetzt' can only be set on the same 'stufe' + INSERT INTO status_reihenfolge (von_id, zu_id) + VALUES (kombi_from.id, kombi_to.id); + + ELSEIF w_from = 8 AND s_to = s_from - 1 THEN + -- after 'zurückgesetzt' always follows the next lower 'stufe' + INSERT INTO status_reihenfolge (von_id, zu_id) + VALUES (kombi_from.id, kombi_to.id); + END IF; END LOOP; END LOOP;
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java Fri Oct 28 10:53:40 2016 +0200 +++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java Fri Oct 28 10:54:24 2016 +0200 @@ -17,7 +17,7 @@ LafRawData.Probe currentProbe; LafRawData.Messung currentMessung; Map<String, List<ReportItem>> errors; - List<ReportItem> currentErrors; + ArrayList<ReportItem> currentErrors; private boolean hasDatenbasis = false; private boolean hasMessprogramm = false; @@ -94,8 +94,9 @@ identifier = identifier == null ? "not identified" : identifier; - errors.put(identifier, currentErrors); + errors.put(identifier, (ArrayList)currentErrors.clone()); } + currentErrors.clear(); currentProbe = null; hasDatenbasis = false; @@ -134,7 +135,7 @@ ? currentProbe.getAttributes().get("HAUPTPROBENNUMMER") : identifier; identifier = identifier == null ? "not identified" : identifier; - errors.put(identifier, currentErrors); + errors.put(identifier, (ArrayList)currentErrors.clone()); } currentErrors.clear(); currentProbe = null; @@ -1475,7 +1476,7 @@ err.setKey(ctx.getChild(0).toString()); err.setValue(value); err.setCode(670); - currentErrors.add(err);; + currentErrors.add(err); return; } // TODO: Add to "ursprungsort"
--- a/src/main/java/de/intevation/lada/rest/StatusService.java Fri Oct 28 10:53:40 2016 +0200 +++ b/src/main/java/de/intevation/lada/rest/StatusService.java Fri Oct 28 10:54:24 2016 +0200 @@ -247,26 +247,20 @@ status.setStatusKombi(1); } else { + Violation violation = validator.validate(status); + if (violation.hasErrors()) { + Response response = new Response(false, 604, status); + response.setErrors(violation.getErrors()); + response.setWarnings(violation.getWarnings()); + return response; + } + StatusProtokoll oldStatus = defaultRepo.getByIdPlain( StatusProtokoll.class, messung.getStatus(), "land"); StatusKombi oldKombi = defaultRepo.getByIdPlain(StatusKombi.class, oldStatus.getStatusKombi(), "stamm"); StatusKombi newKombi = defaultRepo.getByIdPlain(StatusKombi.class, status.getStatusKombi(), "stamm"); - // Check if changing to the requested status_kombi is allowed. - QueryBuilder<StatusReihenfolge> builder = new QueryBuilder<StatusReihenfolge>(defaultRepo.entityManager("stamm"), StatusReihenfolge.class); - builder.and("vonId", oldStatus.getStatusKombi()); - List<StatusReihenfolge> reachable = defaultRepo.filterPlain(builder.getQuery(), "stamm"); - boolean allowed = false; - for (int i = 0; i < reachable.size(); i++) { - if (reachable.get(i).getZuId() == status.getStatusKombi()) { - allowed = true; - } - } - if (!allowed) { - return new Response(false, 604, null); - } - // Check if the user is allowed to change to the requested // status_kombi // 1. The old 'status_wert' is 'rückfrage'