changeset 231:9dae52dd8157

Use the readonly flag in LProbeInfo to define a probe as readonly.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 05 Jul 2013 13:23:02 +0200
parents 82f34d52be0b
children d8a3d188046f
files src/main/java/de/intevation/lada/model/LProbeInfo.java src/main/java/de/intevation/lada/rest/LProbeService.java
diffstat 2 files changed, 23 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/model/LProbeInfo.java	Fri Jul 05 13:21:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/model/LProbeInfo.java	Fri Jul 05 13:23:02 2013 +0200
@@ -89,6 +89,12 @@
 	@Column(name="messmethode")
 	private String messmethode;
 
+	@Column(name="fertig")
+	private Boolean fertig;
+
+	@Column(name="readonly")
+	private Boolean readonly;
+
 	public LProbeInfo() {
 	}
 
@@ -284,6 +290,22 @@
         this.messmethode = messmethode;
     }
 
+    public Boolean getFertig() {
+        return fertig;
+    }
+
+    public void setFertig(Boolean fertig) {
+        this.fertig = fertig;
+    }
+
+    public Boolean getReadonly() {
+        return readonly;
+    }
+
+    public void setReadonly(Boolean readonly) {
+        this.readonly = readonly;
+    }
+
     public LProbe toLProbe() {
         LProbe probe = new LProbe();
         probe.setMstId(mstId);
--- a/src/main/java/de/intevation/lada/rest/LProbeService.java	Fri Jul 05 13:21:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/LProbeService.java	Fri Jul 05 13:23:02 2013 +0200
@@ -90,7 +90,6 @@
             String mstId = probe.get(0).getMstId();
             if (auth.getNetzbetreiber().contains(nbId)) {
                 if (auth.getMst().contains(mstId)) {
-                    response.setReadonly(isReadOnly(id));
                     return response;
                 }
                 response.setReadonly(true);
@@ -130,6 +129,7 @@
                     repository.getEntityManager(),
                     LProbeInfo.class);
             builder.or("netzbetreiberId", auth.getNetzbetreiber());
+            builder.or("fertig", Boolean.TRUE);
             MultivaluedMap<String, String> params = info.getQueryParameters();
             if (params.isEmpty()) {
                 return repository.filter(builder.getQuery());
@@ -213,28 +213,4 @@
             return new Response(false, 699, new ArrayList<LProbeInfo>());
         }
     }
-
-    /**
-     * Determine if the LProbe identified by probeId is writeable for the user.
-     *
-     * @param probeId   The probe id.
-     */
-    public boolean isReadOnly(String probeId) {
-        QueryBuilder<LMessung> builder =
-            new QueryBuilder<LMessung>(
-                repository.getEntityManager(),
-                LMessung.class);
-        builder.and("probeId", probeId);
-        Response response = messungRepository.filter(builder.getQuery());
-        List<LMessung> messungen = (List<LMessung>) response.getData();
-        if (messungen.isEmpty()) {
-            return false;
-        }
-        for(LMessung messung : messungen) {
-            if (messung.isFertig()) {
-                return true;
-            }
-        }
-        return false;
-    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)