[Lada-commits] [PATCH 2 of 2] merged
Wald Commits
scm-commit at wald.intevation.org
Fri Feb 12 12:10:01 CET 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1455275409 -3600
# Node ID 2e9007297e78ce52c524227c9d9023aa9918a794
# Parent 501ccddaeacae993db2a1a1ad7a9aea82a82a02e
# Parent 2311374cc3e858bac309ab050622a3b18752576a
merged
diff -r 501ccddaeaca -r 2e9007297e78 db_schema/stammdaten_schema.sql
--- a/db_schema/stammdaten_schema.sql Thu Feb 11 17:07:14 2016 +0100
+++ b/db_schema/stammdaten_schema.sql Fri Feb 12 12:10:09 2016 +0100
@@ -725,17 +725,16 @@
CREATE VIEW status_erreichbar AS (
- SELECT DISTINCT k.wert_id,
- j.wert_id AS cur_wert,
- j.stufe_id AS cur_stufe
- FROM stammdaten.status_kombi k
- JOIN (SELECT r.zu_id,
- kom.wert_id,
- kom.stufe_id
- FROM stammdaten.status_reihenfolge r
- JOIN stammdaten.status_kombi kom
- ON kom.id = r.von_id) j
- ON j.zu_id = k.id
+ SELECT r.id,
+ zu.wert_id,
+ zu.stufe_id,
+ von.wert_id AS cur_wert,
+ von.stufe_id AS cur_stufe
+ FROM stammdaten.status_reihenfolge r
+ JOIN stammdaten.status_kombi von
+ ON von.id = r.von_id
+ JOIN stammdaten.status_kombi zu
+ ON zu.id = r.zu_id
);
-- Status workflow
diff -r 501ccddaeaca -r 2e9007297e78 src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java
--- a/src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java Thu Feb 11 17:07:14 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java Fri Feb 12 12:10:09 2016 +0100
@@ -24,41 +24,38 @@
public class StatusErreichbar implements Serializable {
private static final long serialVersionUID = 1L;
+ @Id
+ private Integer id;
+
+ @Column(name="wert_id")
+ private Integer wertId;
+
+ @Column(name="stufe_id")
+ private Integer stufeId;
+
@Column(name="cur_stufe")
private Integer curStufe;
@Column(name="cur_wert")
private Integer curWert;
- @Id
- @Column(name="wert_id")
- private Integer wertId;
+ public StatusErreichbar() {
+ }
- public StatusErreichbar() {
+ public Integer getWertId() {
+ return this.wertId;
+ }
+
+ public Integer getStufeId() {
+ return this.stufeId;
}
public Integer getCurStufe() {
return this.curStufe;
}
- public void setCurStufe(Integer curStufe) {
- this.curStufe = curStufe;
- }
-
public Integer getCurWert() {
return this.curWert;
}
- public void setCurWert(Integer curWert) {
- this.curWert = curWert;
- }
-
- public Integer getWertId() {
- return this.wertId;
- }
-
- public void setWertId(Integer wertId) {
- this.wertId = wertId;
- }
-
}
diff -r 501ccddaeaca -r 2e9007297e78 src/main/java/de/intevation/lada/rest/StatusService.java
--- a/src/main/java/de/intevation/lada/rest/StatusService.java Thu Feb 11 17:07:14 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java Fri Feb 12 12:10:09 2016 +0100
@@ -257,10 +257,9 @@
i < userInfo.getFunktionenForMst(status.getErzeuger()).size();
i++
) {
- if (userInfo.getFunktionenForMst(
- status.getErzeuger()).get(i) ==
- currentStatus.getStatusStufe() + 1 &&
- currentStatus.getStatusWert() != 0
+ if (userInfo.getFunktionenForMst(status.getErzeuger())
+ .get(i).equals(currentStatus.getStatusStufe() + 1)
+ && currentStatus.getStatusWert() != 0
) {
next = true;
}
diff -r 501ccddaeaca -r 2e9007297e78 src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Thu Feb 11 17:07:14 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Fri Feb 12 12:10:09 2016 +0100
@@ -35,6 +35,7 @@
import de.intevation.lada.util.annotation.RepositoryConfig;
import de.intevation.lada.util.auth.Authorization;
import de.intevation.lada.util.auth.AuthorizationType;
+import de.intevation.lada.util.auth.UserInfo;
import de.intevation.lada.util.data.QueryBuilder;
import de.intevation.lada.util.data.Repository;
import de.intevation.lada.util.data.RepositoryType;
@@ -101,7 +102,8 @@
return defaultRepo.getAll(StatusWert.class, "stamm");
}
int messungsId = Integer.valueOf(params.getFirst("messungsId"));
- List<StatusWert> werte = getReachable(messungsId);
+ UserInfo user = authorization.getInfo(request);
+ List<StatusWert> werte = getReachable(messungsId, user);
Response response = new Response(true, 200, werte);
return response;
}
@@ -128,7 +130,7 @@
"stamm");
}
- private List<StatusWert> getReachable(int messungsId) {
+ private List<StatusWert> getReachable(int messungsId, UserInfo user) {
List<StatusWert> list = new ArrayList<StatusWert>();
LMessung messung =
defaultRepo.getByIdPlain(LMessung.class, messungsId, "land");
@@ -144,6 +146,7 @@
new QueryBuilder<StatusErreichbar>(
defaultRepo.entityManager("stamm"),
StatusErreichbar.class);
+ errFilter.andIn("stufeId", user.getFunktionen());
errFilter.and("curStufe", status.getStatusStufe());
errFilter.and("curWert", status.getStatusWert());
List<StatusErreichbar> erreichbare = defaultRepo.filterPlain(
diff -r 501ccddaeaca -r 2e9007297e78 src/main/java/de/intevation/lada/util/data/QueryBuilder.java
--- a/src/main/java/de/intevation/lada/util/data/QueryBuilder.java Thu Feb 11 17:07:14 2016 +0100
+++ b/src/main/java/de/intevation/lada/util/data/QueryBuilder.java Fri Feb 12 12:10:09 2016 +0100
@@ -248,8 +248,8 @@
*
* @return The current Querybuilder.
*/
- public QueryBuilder<T> orIn(String key, List<String> values) {
- Expression<String> exp = this.root.get(key);
+ public <M> QueryBuilder<T> orIn(String key, List<M> values) {
+ Expression<M> exp = this.root.get(key);
Predicate p = exp.in(values);
if (this.filter == null) {
this.filter = this.builder.or(p);
@@ -269,8 +269,8 @@
*
* @return The current Querybuilder.
*/
- public QueryBuilder<T> andIn(String key, List<String> values) {
- Expression<String> exp = this.root.get(key);
+ public <M> QueryBuilder<T> andIn(String key, List<M> values) {
+ Expression<M> exp = this.root.get(key);
Predicate p = exp.in(values);
if (this.filter == null) {
this.filter = this.builder.and(p);
diff -r 501ccddaeaca -r 2e9007297e78 src/main/java/de/intevation/lada/validation/rules/status/StatusFolge.java
--- a/src/main/java/de/intevation/lada/validation/rules/status/StatusFolge.java Thu Feb 11 17:07:14 2016 +0100
+++ b/src/main/java/de/intevation/lada/validation/rules/status/StatusFolge.java Fri Feb 12 12:10:09 2016 +0100
@@ -68,7 +68,7 @@
kombi2.and("stufeId", last.getStatusStufe());
kombi2.and("wertId", last.getStatusWert());
List<StatusKombi> result2 =
- repository.filterPlain(kombi.getQuery(), "stamm");
+ repository.filterPlain(kombi2.getQuery(), "stamm");
if (result2.isEmpty()) {
Violation violation = new Violation();
violation.addError("status", 632);
More information about the Lada-commits
mailing list