[Lada-commits] [PATCH 4 of 5] Available status values need to be filtered by the users functions
Wald Commits
scm-commit at wald.intevation.org
Thu Feb 11 16:28:11 CET 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1455204218 -3600
# Node ID 6bd149c352a9b0dea985aed8a31aac4da3d1551a
# Parent 9cf4b2ac3e2a7aeff3ba75049485cef0965a3261
Available status values need to be filtered by the users functions.
diff -r 9cf4b2ac3e2a -r 6bd149c352a9 db_schema/stammdaten_schema.sql
--- a/db_schema/stammdaten_schema.sql Thu Feb 11 16:21:57 2016 +0100
+++ b/db_schema/stammdaten_schema.sql Thu Feb 11 16:23:38 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 9cf4b2ac3e2a -r 6bd149c352a9 src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java
--- a/src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java Thu Feb 11 16:21:57 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java Thu Feb 11 16:23:38 2016 +0100
@@ -24,17 +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 void setWertId(Integer wertId) {
+ this.wertId = wertId;
+ }
+
+ public Integer getStufeId() {
+ return this.stufeId;
+ }
+
+ public void setStufeId(Integer stufeId) {
+ this.stufeId = stufeId;
}
public Integer getCurStufe() {
@@ -53,12 +74,4 @@
this.curWert = curWert;
}
- public Integer getWertId() {
- return this.wertId;
- }
-
- public void setWertId(Integer wertId) {
- this.wertId = wertId;
- }
-
}
diff -r 9cf4b2ac3e2a -r 6bd149c352a9 src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Thu Feb 11 16:21:57 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Thu Feb 11 16:23:38 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(
More information about the Lada-commits
mailing list