changeset 745:e2a78d5afaaa

Updated model and services for the new status workflow.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 27 Oct 2015 09:58:25 +0100
parents 7e6a0227428d
children 9f3029b5fc90
files src/main/java/de/intevation/lada/model/Messung.java src/main/java/de/intevation/lada/model/Status.java src/main/java/de/intevation/lada/model/StatusProtokoll.java src/main/java/de/intevation/lada/model/bund/Status.java src/main/java/de/intevation/lada/model/bund/StatusProtokoll.java src/main/java/de/intevation/lada/model/land/LStatus.java src/main/java/de/intevation/lada/model/land/LStatusProtokoll.java src/main/java/de/intevation/lada/rest/MessungService.java src/main/java/de/intevation/lada/rest/StatusService.java
diffstat 9 files changed, 229 insertions(+), 223 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/model/Messung.java	Tue Oct 27 09:56:16 2015 +0100
+++ b/src/main/java/de/intevation/lada/model/Messung.java	Tue Oct 27 09:58:25 2015 +0100
@@ -47,6 +47,9 @@
     @Column(name="probe_id")
     private Integer probeId;
 
+    @Column(name="status")
+    private Integer status;
+
     @Transient
     private boolean owner;
 
@@ -112,6 +115,14 @@
         this.probeId = probeId;
     }
 
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
     public boolean isOwner() {
         return owner;
     }
--- a/src/main/java/de/intevation/lada/model/Status.java	Tue Oct 27 09:56:16 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.model;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-import javax.persistence.Column;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-
-
-/**
- * The persistent class for the status database table.
- */
-@MappedSuperclass
-@Table(name="status")
-public class Status implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @Id
-    @GeneratedValue(strategy=GenerationType.IDENTITY)
-    @Column(name="id", nullable=false, insertable=false)
-    private Integer id;
-
-    private String erzeuger;
-
-    @Column(name="messungs_id")
-    private Integer messungsId;
-
-    @Column(name="s_datum")
-    private Timestamp sDatum;
-
-    @Column(name="s_kommentar")
-    private String sKommentar;
-
-    private Integer status;
-
-    @Transient
-    private boolean owner;
-
-    @Transient
-    private boolean readonly;
-
-    public Status() {
-    }
-
-    public Integer getId() {
-        return this.id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getErzeuger() {
-        return this.erzeuger;
-    }
-
-    public void setErzeuger(String erzeuger) {
-        this.erzeuger = erzeuger;
-    }
-
-    public Integer getMessungsId() {
-        return this.messungsId;
-    }
-
-    public void setMessungsId(Integer messungsId) {
-        this.messungsId = messungsId;
-    }
-
-    public Timestamp getSDatum() {
-        return this.sDatum;
-    }
-
-    public void setSDatum(Timestamp sDatum) {
-        this.sDatum = sDatum;
-    }
-
-    public String getSKommentar() {
-        return this.sKommentar;
-    }
-
-    public void setSKommentar(String sKommentar) {
-        this.sKommentar = sKommentar;
-    }
-
-    public Integer getStatus() {
-        return this.status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public boolean isOwner() {
-        return owner;
-    }
-
-    public void setOwner(boolean owner) {
-        this.owner = owner;
-    }
-
-    public boolean isReadonly() {
-        return readonly;
-    }
-
-    public void setReadonly(boolean readonly) {
-        this.readonly = readonly;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/model/StatusProtokoll.java	Tue Oct 27 09:58:25 2015 +0100
@@ -0,0 +1,143 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.model;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+
+/**
+ * The persistent class for the status database table.
+ */
+@MappedSuperclass
+@Table(name="status_protokoll")
+public class StatusProtokoll implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id", nullable=false, insertable=false)
+    private Integer id;
+
+    @Column(name="messungs_id")
+    private Integer messungsId;
+
+    @Column(name="status_stufe")
+    private Integer statusStufe;
+
+    @Column(name="status_wert")
+    private Integer statusWert;
+
+    private String erzeuger;
+
+    @Column(name="datum")
+    private Timestamp datum;
+
+    @Column(name="text")
+    private String text;
+
+    @Column(name="tree_modified")
+    private Timestamp treeModified;
+
+    @Transient
+    private boolean owner;
+
+    @Transient
+    private boolean readonly;
+
+    public StatusProtokoll() {
+    }
+
+    public Integer getId() {
+        return this.id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getStatusStufe() {
+        return this.statusStufe;
+    }
+
+    public void setStatusStufe(Integer statusStufe) {
+        this.statusStufe = statusStufe;
+    }
+
+    public Integer getStatusWert() {
+        return this.statusWert;
+    }
+
+    public void setStatusWert(Integer statusWert) {
+        this.statusWert = statusWert;
+    }
+
+    public String getErzeuger() {
+        return this.erzeuger;
+    }
+
+    public void setErzeuger(String erzeuger) {
+        this.erzeuger = erzeuger;
+    }
+
+    public Integer getMessungsId() {
+        return this.messungsId;
+    }
+
+    public void setMessungsId(Integer messungsId) {
+        this.messungsId = messungsId;
+    }
+
+    public Timestamp getDatum() {
+        return this.datum;
+    }
+
+    public void setDatum(Timestamp datum) {
+        this.datum = datum;
+    }
+
+    public String getText() {
+        return this.text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    public Timestamp getTreeModified() {
+        return treeModified;
+    }
+
+    public void setTreeModified(Timestamp treeModified) {
+        this.treeModified = treeModified;
+    }
+
+    public boolean isOwner() {
+        return owner;
+    }
+
+    public void setOwner(boolean owner) {
+        this.owner = owner;
+    }
+
+    public boolean isReadonly() {
+        return readonly;
+    }
+
+    public void setReadonly(boolean readonly) {
+        this.readonly = readonly;
+    }
+}
--- a/src/main/java/de/intevation/lada/model/bund/Status.java	Tue Oct 27 09:56:16 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.model.bund;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-
-/**
- * The persistent class for the status database table.
- */
-@Entity
-@Table(name="status")
-public class Status extends de.intevation.lada.model.Status {
-    private static final long serialVersionUID = 1L;
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/model/bund/StatusProtokoll.java	Tue Oct 27 09:58:25 2015 +0100
@@ -0,0 +1,17 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.model.bund;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "status_protokoll")
+public class StatusProtokoll extends de.intevation.lada.model.StatusProtokoll {
+    private static final long serialVersionUID = 1L;
+}
--- a/src/main/java/de/intevation/lada/model/land/LStatus.java	Tue Oct 27 09:56:16 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.model.land;
-
-import java.sql.Timestamp;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-
-
-/**
- * The persistent class for the status database table.
- */
-@Entity
-@Table(name="status")
-public class LStatus extends de.intevation.lada.model.Status {
-    private static final long serialVersionUID = 1L;
-
-    @Column(name="tree_modified", insertable=false, updatable=false)
-    private Timestamp treeModified;
-
-    @OneToOne
-    @JoinColumn(name="messungs_id", insertable=false, updatable=false)
-    private LMessung messung;
-
-    @Transient
-    private Timestamp parentModified;
-
-    public Timestamp getTreeModified() {
-        return treeModified;
-    }
-
-    public void setTreeModified(Timestamp treeModified) {
-        this.treeModified = treeModified;
-    }
-
-    public Timestamp getParentModified() {
-        if (this.parentModified == null && this.messung != null) {
-            return this.messung.getTreeModified();
-        }
-        return this.parentModified;
-    }
-
-    public void setParentModified(Timestamp parentModified) {
-        this.parentModified = parentModified;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/model/land/LStatusProtokoll.java	Tue Oct 27 09:58:25 2015 +0100
@@ -0,0 +1,22 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.model.land;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import de.intevation.lada.model.StatusProtokoll;
+
+/**
+ * The persistent class for the probe database table.
+ */
+@Entity
+@Table(name="status_protokoll")
+public class LStatusProtokoll extends StatusProtokoll {
+    private static final long serialVersionUID = 1L;
+}
--- a/src/main/java/de/intevation/lada/rest/MessungService.java	Tue Oct 27 09:56:16 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/MessungService.java	Tue Oct 27 09:58:25 2015 +0100
@@ -33,8 +33,8 @@
 import de.intevation.lada.model.land.LKommentarM;
 import de.intevation.lada.model.land.LMessung;
 import de.intevation.lada.model.land.LMesswert;
-import de.intevation.lada.model.land.LStatus;
 import de.intevation.lada.model.land.MessungTranslation;
+import de.intevation.lada.model.land.LStatusProtokoll;
 import de.intevation.lada.util.annotation.AuthorizationConfig;
 import de.intevation.lada.util.annotation.RepositoryConfig;
 import de.intevation.lada.util.auth.Authorization;
@@ -245,6 +245,17 @@
             created.setWarnings(violation.getWarnings());
         }
 
+        LStatusProtokoll status = new LStatusProtokoll();
+        status.setDatum(new Timestamp(new Date().getTime()));
+        status.setMessungsId(((LMessung)created.getData()).getId());
+        //TODO set the correct value. use the probe to get the "erzeuger"!?
+        status.setErzeuger("11010");
+        status.setStatusStufe(1);
+        status.setStatusWert(1);
+        defaultRepo.create(status, "land");
+        ret.setStatus(status.getId());
+        defaultRepo.update(ret, "land");
+
         return authorization.filter(
             request,
             created,
@@ -359,17 +370,17 @@
             new QueryBuilder<LKommentarM>(
                 defaultRepo.entityManager("land"), LKommentarM.class);
         mkBuilder.and("messungsId", messungObj.getId());
-        QueryBuilder<LStatus> msBuilder =
-            new QueryBuilder<LStatus>(
-                defaultRepo.entityManager("land"), LStatus.class);
+        QueryBuilder<LStatusProtokoll> msBuilder =
+            new QueryBuilder<LStatusProtokoll>(
+                defaultRepo.entityManager("land"), LStatusProtokoll.class);
         msBuilder.and("messungsId", messungObj.getId());
 
         List<LMesswert> messwerte =
             (List<LMesswert>)defaultRepo.filter(mwBuilder.getQuery(), "land").getData();
         List<LKommentarM> kommentare =
             (List<LKommentarM>)defaultRepo.filter(mkBuilder.getQuery(), "land").getData();
-        List<LStatus> status =
-            (List<LStatus>)defaultRepo.filter(msBuilder.getQuery(), "land").getData();
+        List<LStatusProtokoll> status =
+            (List<LStatusProtokoll>)defaultRepo.filter(msBuilder.getQuery(), "land").getData();
 
         if (!messwerte.isEmpty() ||
             !kommentare.isEmpty() ||
--- a/src/main/java/de/intevation/lada/rest/StatusService.java	Tue Oct 27 09:56:16 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java	Tue Oct 27 09:58:25 2015 +0100
@@ -26,7 +26,7 @@
 import de.intevation.lada.lock.LockConfig;
 import de.intevation.lada.lock.LockType;
 import de.intevation.lada.lock.ObjectLocker;
-import de.intevation.lada.model.land.LStatus;
+import de.intevation.lada.model.land.LStatusProtokoll;
 import de.intevation.lada.util.annotation.AuthorizationConfig;
 import de.intevation.lada.util.annotation.RepositoryConfig;
 import de.intevation.lada.util.auth.Authorization;
@@ -116,18 +116,18 @@
     ) {
         MultivaluedMap<String, String> params = info.getQueryParameters();
         if (params.isEmpty() || !params.containsKey("messungsId")) {
-            return defaultRepo.getAll(LStatus.class, "land");
+            return defaultRepo.getAll(LStatusProtokoll.class, "land");
         }
         String messungId = params.getFirst("messungsId");
-        QueryBuilder<LStatus> builder =
-            new QueryBuilder<LStatus>(
+        QueryBuilder<LStatusProtokoll> builder =
+            new QueryBuilder<LStatusProtokoll>(
                 defaultRepo.entityManager("land"),
-                LStatus.class);
+                LStatusProtokoll.class);
         builder.and("messungsId", messungId);
         return authorization.filter(
             request,
             defaultRepo.filter(builder.getQuery(), "land"),
-            LStatus.class);
+            LStatusProtokoll.class);
     }
 
     /**
@@ -149,8 +149,8 @@
     ) {
         return authorization.filter(
             request,
-            defaultRepo.getById(LStatus.class, Integer.valueOf(id), "land"),
-            LStatus.class);
+            defaultRepo.getById(LStatusProtokoll.class, Integer.valueOf(id), "land"),
+            LStatusProtokoll.class);
     }
 
     /**
@@ -181,13 +181,13 @@
     public Response create(
         @Context HttpHeaders headers,
         @Context HttpServletRequest request,
-        LStatus status
+        LStatusProtokoll status
     ) {
         if (!authorization.isAuthorized(
                 request,
                 status,
                 RequestMethod.POST,
-                LStatus.class)
+                LStatusProtokoll.class)
         ) {
             return new Response(false, 699, null);
         }
@@ -195,7 +195,7 @@
         return authorization.filter(
             request,
             defaultRepo.create(status, "land"),
-            LStatus.class);
+            LStatusProtokoll.class);
     }
 
     /**
@@ -226,13 +226,13 @@
     public Response update(
         @Context HttpHeaders headers,
         @Context HttpServletRequest request,
-        LStatus status
+        LStatusProtokoll status
     ) {
         if (!authorization.isAuthorized(
                 request,
                 status,
                 RequestMethod.PUT,
-                LStatus.class)
+                LStatusProtokoll.class)
         ) {
             return new Response(false, 699, null);
         }
@@ -241,12 +241,12 @@
         }
         Response response = defaultRepo.update(status, "land");
         Response updated = defaultRepo.getById(
-            LStatus.class,
-            ((LStatus)response.getData()).getId(), "land");
+            LStatusProtokoll.class,
+            ((LStatusProtokoll)response.getData()).getId(), "land");
         return authorization.filter(
             request,
             updated,
-            LStatus.class);
+            LStatusProtokoll.class);
     }
 
     /**
@@ -268,13 +268,13 @@
     ) {
         /* Get the object by id*/
         Response object =
-            defaultRepo.getById(LStatus.class, Integer.valueOf(id), "land");
-        LStatus obj = (LStatus)object.getData();
+            defaultRepo.getById(LStatusProtokoll.class, Integer.valueOf(id), "land");
+        LStatusProtokoll obj = (LStatusProtokoll)object.getData();
         if (!authorization.isAuthorized(
                 request,
                 obj,
                 RequestMethod.DELETE,
-                LStatus.class)
+                LStatusProtokoll.class)
         ) {
             return new Response(false, 699, null);
         }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)