changeset 879:6bd149c352a9

Available status values need to be filtered by the users functions.
author Tom Gottfried <tom@intevation.de>
date Thu, 11 Feb 2016 16:23:38 +0100
parents 9cf4b2ac3e2a
children 2311374cc3e8
files db_schema/stammdaten_schema.sql src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java
diffstat 3 files changed, 40 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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;
-    }
-
 }
--- 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(
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)