# HG changeset patch # User Raimund Renkert # Date 1447327212 -3600 # Node ID b55f517124e56d21390d3892d34c717800c13e3c # Parent 95fa207dbd54abc1f8e97a78ecb4ec8c272001ee# Parent ee0ee3c37449d59b5a605d16ae09cb24a76b719c merged. diff -r ee0ee3c37449 -r b55f517124e5 db_schema/lada_schema.sql --- a/db_schema/lada_schema.sql Wed Nov 11 12:07:03 2015 +0100 +++ b/db_schema/lada_schema.sql Thu Nov 12 12:20:12 2015 +0100 @@ -847,7 +847,19 @@ id integer NOT NULL, ldap_group character varying(40) NOT NULL, netzbetreiber_id character varying(2), - mst_id character varying(5) + mst_id character varying(5), + labor_mst_id character varying(5), + funktion_id smallint +); + + +-- +-- Name: auth_funktion; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: +-- + +CREATE TABLE auth_funktion ( + id smallint NOT NULL, + funktion character varying(40) ); @@ -871,6 +883,55 @@ -- +-- Name: auth_id_seq1; Type: SEQUENCE; Schema: stammdaten; Owner: - +-- + +CREATE SEQUENCE auth_id_seq1 + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: auth_id_seq1; Type: SEQUENCE OWNED BY; Schema: stammdaten; Owner: - +-- + +ALTER SEQUENCE auth_id_seq1 OWNED BY auth.id; + + +-- +-- Name: auth_lst_umw; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: +-- + +CREATE TABLE auth_lst_umw ( + id integer NOT NULL, + lst_id character varying(5), + umw_id character varying(3) +); + + +-- +-- Name: auth_lst_umw_id_seq; Type: SEQUENCE; Schema: stammdaten; Owner: - +-- + +CREATE SEQUENCE auth_lst_umw_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: auth_lst_umw_id_seq; Type: SEQUENCE OWNED BY; Schema: stammdaten; Owner: - +-- + +ALTER SEQUENCE auth_lst_umw_id_seq OWNED BY auth_lst_umw.id; + + +-- -- Name: datenbasis; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: -- @@ -1683,6 +1744,44 @@ -- +-- Name: status_kombi; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: +-- + +CREATE TABLE status_kombi ( + id integer NOT NULL, + stufe_id integer, + wert_id integer +); + + +-- +-- Name: status_reihenfolge; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: +-- + +CREATE TABLE status_reihenfolge ( + id integer NOT NULL, + von_id integer, + zu_id integer +); + + +-- +-- Name: status_erreichbar; Type: VIEW; Schema: stammdaten; Owner: - +-- + +CREATE VIEW status_erreichbar AS + SELECT DISTINCT k.wert_id, + j.wert_id AS cur_wert, + j.stufe_id AS cur_stufe + FROM (status_kombi k + JOIN ( SELECT r.zu_id, + kom.wert_id, + kom.stufe_id + FROM (status_reihenfolge r + JOIN status_kombi kom ON ((kom.id = r.von_id)))) j ON ((j.zu_id = k.id))); + + +-- -- Name: status_stufe; Type: TABLE; Schema: stammdaten; Owner: -; Tablespace: -- @@ -2260,6 +2359,14 @@ SET search_path = stammdaten, pg_catalog; -- +-- Name: auth_lst_umw_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY auth_lst_umw + ADD CONSTRAINT auth_lst_umw_pkey PRIMARY KEY (id); + + +-- -- Name: auth_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: -- @@ -2268,6 +2375,14 @@ -- +-- Name: auth_role_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY auth_funktion + ADD CONSTRAINT auth_role_pkey PRIMARY KEY (id); + + +-- -- Name: datenbasis_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: -- @@ -2420,6 +2535,22 @@ -- +-- Name: status_kombi_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY status_kombi + ADD CONSTRAINT status_kombi_pkey PRIMARY KEY (id); + + +-- +-- Name: status_reihenfolge_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY status_reihenfolge + ADD CONSTRAINT status_reihenfolge_pkey PRIMARY KEY (id); + + +-- -- Name: status_stufe_pkey; Type: CONSTRAINT; Schema: stammdaten; Owner: -; Tablespace: -- @@ -2965,6 +3096,38 @@ SET search_path = stammdaten, pg_catalog; -- +-- Name: auth_funktion_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY auth + ADD CONSTRAINT auth_funktion_fkey FOREIGN KEY (funktion_id) REFERENCES auth_funktion(id); + + +-- +-- Name: auth_labor_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY auth + ADD CONSTRAINT auth_labor_fkey FOREIGN KEY (labor_mst_id) REFERENCES mess_stelle(id); + + +-- +-- Name: auth_lst_umw_lst_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY auth_lst_umw + ADD CONSTRAINT auth_lst_umw_lst_fkey FOREIGN KEY (lst_id) REFERENCES mess_stelle(id); + + +-- +-- Name: auth_lst_umw_umw_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY auth_lst_umw + ADD CONSTRAINT auth_lst_umw_umw_fkey FOREIGN KEY (umw_id) REFERENCES umwelt(id); + + +-- -- Name: auth_mst_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - -- @@ -3061,6 +3224,38 @@ -- +-- Name: status_kombi_stufe_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY status_kombi + ADD CONSTRAINT status_kombi_stufe_id_fkey FOREIGN KEY (stufe_id) REFERENCES status_stufe(id); + + +-- +-- Name: status_kombi_wert_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY status_kombi + ADD CONSTRAINT status_kombi_wert_id_fkey FOREIGN KEY (wert_id) REFERENCES status_wert(id); + + +-- +-- Name: status_reihenfolge_von_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY status_reihenfolge + ADD CONSTRAINT status_reihenfolge_von_id_fkey FOREIGN KEY (von_id) REFERENCES status_kombi(id); + + +-- +-- Name: status_reihenfolge_zu_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - +-- + +ALTER TABLE ONLY status_reihenfolge + ADD CONSTRAINT status_reihenfolge_zu_id_fkey FOREIGN KEY (zu_id) REFERENCES status_kombi(id); + + +-- -- Name: umwelt_meh_id_fkey; Type: FK CONSTRAINT; Schema: stammdaten; Owner: - -- diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/Messung.java --- a/src/main/java/de/intevation/lada/model/Messung.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/model/Messung.java Thu Nov 12 12:20:12 2015 +0100 @@ -47,7 +47,6 @@ @Column(name="probe_id") private Integer probeId; - @Column(name="status") private Integer status; @Transient @@ -115,10 +114,16 @@ this.probeId = probeId; } + /** + * @return the status + */ public Integer getStatus() { return status; } + /** + * @param status the status to set + */ public void setStatus(Integer status) { this.status = status; } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/land/LMessung.java --- a/src/main/java/de/intevation/lada/model/land/LMessung.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/model/land/LMessung.java Thu Nov 12 12:20:12 2015 +0100 @@ -45,6 +45,9 @@ private Timestamp treeModified; @Transient + private Boolean statusEdit; + + @Transient private Timestamp parentModified; public LMessung() { @@ -66,6 +69,14 @@ this.treeModified = treeModified; } + public Boolean getStatusEdit() { + return statusEdit; + } + + public void setStatusEdit(Boolean statusEdit) { + this.statusEdit = statusEdit; + } + public Timestamp getParentModified() { if (this.parentModified == null && this.probe != null) { return this.probe.getTreeModified(); @@ -99,4 +110,5 @@ } public void setMessungsIdAlt(Integer messungsIdAlt) {} + } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/Auth.java --- a/src/main/java/de/intevation/lada/model/stamm/Auth.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/model/stamm/Auth.java Thu Nov 12 12:20:12 2015 +0100 @@ -26,14 +26,20 @@ @Id private Integer id; + @Column(name="funktion_id") + private Integer funktionId; + + @Column(name="labor_mst_id") + private String laborMstId; + @Column(name="ldap_group") private String ldapGroup; @Column(name="mst_id") - private String messStelle; + private String mstId; @Column(name="netzbetreiber_id") - private String netzBetreiber; + private String netzbetreiberId; public Auth() { } @@ -46,6 +52,22 @@ this.id = id; } + public Integer getFunktionId() { + return this.funktionId; + } + + public void setFunktionId(Integer funktionId) { + this.funktionId = funktionId; + } + + public String getLaborMstId() { + return this.laborMstId; + } + + public void setLaborMstId(String laborMstId) { + this.laborMstId = laborMstId; + } + public String getLdapGroup() { return this.ldapGroup; } @@ -54,20 +76,20 @@ this.ldapGroup = ldapGroup; } - public String getMessStelle() { - return this.messStelle; + public String getMstId() { + return this.mstId; } - public void setMessStelle(String messStelle) { - this.messStelle = messStelle; + public void setMstId(String mstId) { + this.mstId = mstId; } - public String getNetzBetreiber() { - return this.netzBetreiber; + public String getNetzbetreiberId() { + return this.netzbetreiberId; } - public void setNetzBetreiber(String netzBetreiber) { - this.netzBetreiber = netzBetreiber; + public void setNetzbetreiberId(String netzbetreiberId) { + this.netzbetreiberId = netzbetreiberId; } } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/AuthFunktion.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/stamm/AuthFunktion.java Thu Nov 12 12:20:12 2015 +0100 @@ -0,0 +1,50 @@ +/* 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.stamm; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + + +/** + * The persistent class for the auth_funktion database table. + * + */ +@Entity +@Table(name="auth_funktion") +public class AuthFunktion implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + private Integer id; + + private String funktion; + + public AuthFunktion() { + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFunktion() { + return this.funktion; + } + + public void setFunktion(String funktion) { + this.funktion = funktion; + } + +} diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/AuthLstUmw.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/stamm/AuthLstUmw.java Thu Nov 12 12:20:12 2015 +0100 @@ -0,0 +1,63 @@ +/* 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.stamm; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + + +/** + * The persistent class for the auth_lst_umw database table. + * + */ +@Entity +@Table(name="auth_lst_umw") +public class AuthLstUmw implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + private Integer id; + + @Column(name="lst_id") + private String lstId; + + @Column(name="umw_id") + private String umwId; + + public AuthLstUmw() { + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getLstId() { + return this.lstId; + } + + public void setLstId(String lstId) { + this.lstId = lstId; + } + + public String getUmwId() { + return this.umwId; + } + + public void setUmwId(String umwId) { + this.umwId = umwId; + } + +} diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/SOrt.java --- a/src/main/java/de/intevation/lada/model/stamm/SOrt.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/model/stamm/SOrt.java Thu Nov 12 12:20:12 2015 +0100 @@ -10,12 +10,16 @@ import java.io.Serializable; import java.sql.Timestamp; +import javax.inject.Inject; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Transient; + +import org.apache.log4j.Logger; /** @@ -25,6 +29,9 @@ @Table(name="ort") public class SOrt implements Serializable { private static final long serialVersionUID = 1L; + @Inject + @Transient + private Logger logger = Logger.getLogger(SOrt.class); @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @@ -131,10 +138,12 @@ } public Timestamp getLetzteAenderung() { + logger.debug("get date: " + this.letzteAenderung.toString()); return this.letzteAenderung; } public void setLetzteAenderung(Timestamp letzteAenderung) { + logger.debug("set date: " + letzteAenderung.toString()); this.letzteAenderung = letzteAenderung; } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/stamm/StatusErreichbar.java Thu Nov 12 12:20:12 2015 +0100 @@ -0,0 +1,64 @@ +/* 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.stamm; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + + +/** + * The persistent class for the status_erreichbar database table. + * + */ +@Entity +@Table(name="status_erreichbar") +public class StatusErreichbar implements Serializable { + private static final long serialVersionUID = 1L; + + @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 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 ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/StatusKombi.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/stamm/StatusKombi.java Thu Nov 12 12:20:12 2015 +0100 @@ -0,0 +1,117 @@ +/* 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.stamm; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; + + +/** + * The persistent class for the status_kombi database table. + * + */ +@Entity +@Table(name="status_kombi") +public class StatusKombi implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + private Integer id; + + @Column(name="stufe_id") + private Integer stufeId; + + @Column(name="wert_id") + private Integer wertId; + + //bi-directional many-to-one association to StatusReihenfolge + @OneToMany(mappedBy="von") + private List statusReihenfolges1; + + //bi-directional many-to-one association to StatusReihenfolge + @OneToMany(mappedBy="zu") + private List statusReihenfolges2; + + public StatusKombi() { + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getStufeId() { + return this.stufeId; + } + + public void setStufeId(Integer stufeId) { + this.stufeId = stufeId; + } + + public Integer getWertId() { + return this.wertId; + } + + public void setWertId(Integer wertId) { + this.wertId = wertId; + } + + public List getStatusReihenfolges1() { + return this.statusReihenfolges1; + } + + public void setStatusReihenfolges1(List statusReihenfolges1) { + this.statusReihenfolges1 = statusReihenfolges1; + } + + public StatusReihenfolge addStatusReihenfolges1(StatusReihenfolge statusReihenfolges1) { + getStatusReihenfolges1().add(statusReihenfolges1); + statusReihenfolges1.setVon(this); + + return statusReihenfolges1; + } + + public StatusReihenfolge removeStatusReihenfolges1(StatusReihenfolge statusReihenfolges1) { + getStatusReihenfolges1().remove(statusReihenfolges1); + statusReihenfolges1.setVon(null); + + return statusReihenfolges1; + } + + public List getStatusReihenfolges2() { + return this.statusReihenfolges2; + } + + public void setStatusReihenfolges2(List statusReihenfolges2) { + this.statusReihenfolges2 = statusReihenfolges2; + } + + public StatusReihenfolge addStatusReihenfolges2(StatusReihenfolge statusReihenfolges2) { + getStatusReihenfolges2().add(statusReihenfolges2); + statusReihenfolges2.setZu(this); + + return statusReihenfolges2; + } + + public StatusReihenfolge removeStatusReihenfolges2(StatusReihenfolge statusReihenfolges2) { + getStatusReihenfolges2().remove(statusReihenfolges2); + statusReihenfolges2.setZu(null); + + return statusReihenfolges2; + } + +} diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/model/stamm/StatusReihenfolge.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/stamm/StatusReihenfolge.java Thu Nov 12 12:20:12 2015 +0100 @@ -0,0 +1,67 @@ +/* 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.stamm; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * The persistent class for the status_reihenfolge database table. + * + */ +@Entity +@Table(name="status_reihenfolge") +public class StatusReihenfolge implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + private Integer id; + + //bi-directional many-to-one association to StatusKombi + @ManyToOne + @JoinColumn(name="von_id") + private StatusKombi von; + + //bi-directional many-to-one association to StatusKombi + @ManyToOne + @JoinColumn(name="zu_id") + private StatusKombi zu; + + public StatusReihenfolge() { + } + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public StatusKombi getVon() { + return this.von; + } + + public void setVon(StatusKombi von) { + this.von = von; + } + + public StatusKombi getZu() { + return this.zu; + } + + public void setZu(StatusKombi zu) { + this.zu = zu; + } + +} diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/rest/MessungService.java --- a/src/main/java/de/intevation/lada/rest/MessungService.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/rest/MessungService.java Thu Nov 12 12:20:12 2015 +0100 @@ -9,7 +9,6 @@ import java.sql.Timestamp; import java.util.Date; -import java.util.List; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @@ -30,11 +29,10 @@ import de.intevation.lada.lock.LockConfig; import de.intevation.lada.lock.LockType; import de.intevation.lada.lock.ObjectLocker; -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.LProbe; +import de.intevation.lada.model.land.LStatusProtokoll; 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; @@ -248,10 +246,12 @@ LStatusProtokoll status = new LStatusProtokoll(); status.setDatum(new Timestamp(new Date().getTime())); status.setMessungsId(((LMessung)created.getData()).getId()); + LProbe probe = + defaultRepo.getByIdPlain(LProbe.class, ret.getProbeId(), "land"); //TODO set the correct value. use the probe to get the "erzeuger"!? - status.setErzeuger("11010"); + status.setErzeuger(probe.getMstId()); status.setStatusStufe(1); - status.setStatusWert(1); + status.setStatusWert(0); defaultRepo.create(status, "land"); ret.setStatus(status.getId()); defaultRepo.update(ret, "land"); diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/rest/StatusService.java --- a/src/main/java/de/intevation/lada/rest/StatusService.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/rest/StatusService.java Thu Nov 12 12:20:12 2015 +0100 @@ -32,6 +32,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; @@ -192,11 +193,37 @@ ) { return new Response(false, 699, null); } + UserInfo userInfo = authorization.getInfo(request); + LMessung messung = defaultRepo.getByIdPlain( + LMessung.class, status.getMessungsId(), "land"); + LStatusProtokoll currentStatus = defaultRepo.getByIdPlain( + LStatusProtokoll.class, messung.getStatus(), "land"); + boolean next = false; + boolean change = false; + for (int i = 0; i < userInfo.getFunktionen().size(); i++) { + if (userInfo.getFunktionen().get(i) > currentStatus.getStatusStufe()) { + next = true; + change = false; + break; + } + else if (userInfo.getFunktionen().get(i) == currentStatus.getStatusStufe()) { + change = true; + } + } + if ((change || next) && status.getStatusWert() == 4) { + status.setStatusStufe(1); + } + else if (change) { + status.setStatusStufe(currentStatus.getStatusStufe()); + } + else if (next) { + status.setStatusStufe(currentStatus.getStatusStufe() + 1); + } + else { + return new Response(false, 699, null); + } Response response = defaultRepo.create(status, "land"); LStatusProtokoll created = (LStatusProtokoll)response.getData(); - Response messungResponse = defaultRepo.getById( - LMessung.class, status.getMessungsId(), "land"); - LMessung messung = (LMessung)messungResponse.getData(); messung.setStatus(created.getId()); defaultRepo.update(messung, "land"); /* Persist the new object*/ @@ -247,13 +274,24 @@ if (lock.isLocked(status)) { return new Response(false, 697, null); } - Response response = defaultRepo.update(status, "land"); - Response updated = defaultRepo.getById( - LStatusProtokoll.class, - ((LStatusProtokoll)response.getData()).getId(), "land"); + if (status.getStatusWert() == 0) { + return new Response(false, 699, null); + } + + UserInfo userInfo = authorization.getInfo(request); + if (!userInfo.getMessstellen().contains(status.getErzeuger())) { + return new Response(false, 699, null); + } + LMessung messung = defaultRepo.getByIdPlain( + LMessung.class, status.getMessungsId(), "land"); + Response response = defaultRepo.create(status, "land"); + LStatusProtokoll created = (LStatusProtokoll)response.getData(); + messung.setStatus(created.getId()); + defaultRepo.update(messung, "land"); + return authorization.filter( request, - updated, + response, LStatusProtokoll.class); } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/rest/stamm/LocationService.java --- a/src/main/java/de/intevation/lada/rest/stamm/LocationService.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/rest/stamm/LocationService.java Thu Nov 12 12:20:12 2015 +0100 @@ -99,12 +99,12 @@ if (params.isEmpty() || !params.containsKey("ortId")) { return defaultRepo.getAll(SOrt.class, "stamm"); } - String probeId = params.getFirst("ortId"); + String ortId = params.getFirst("ortId"); QueryBuilder builder = new QueryBuilder( - defaultRepo.entityManager("land"), + defaultRepo.entityManager("stamm"), SOrt.class); - builder.and("probeId", probeId); + builder.and("ortId", ortId); return defaultRepo.filter(builder.getQuery(), "stamm"); } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java --- a/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java Thu Nov 12 12:20:12 2015 +0100 @@ -23,12 +23,20 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; +import org.apache.log4j.Logger; + +import de.intevation.lada.model.bund.StatusProtokoll; +import de.intevation.lada.model.land.LMessung; +import de.intevation.lada.model.stamm.StatusErreichbar; +import de.intevation.lada.model.stamm.StatusKombi; +import de.intevation.lada.model.stamm.StatusReihenfolge; import de.intevation.lada.model.stamm.StatusWert; import de.intevation.lada.util.annotation.AuthorizationConfig; 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; import de.intevation.lada.util.rest.Response; @@ -61,6 +69,8 @@ @RequestScoped public class StatusWertService { + @Inject + private Logger logger = Logger.getLogger(StatusWertService.class); /** * The data repository granting read access. */ @@ -122,8 +132,37 @@ private List getReachable(int messungsId, UserInfo user) { List list = new ArrayList(); - // TODO get reachable status values from db using the current status and - // the user info. + LMessung messung = + defaultRepo.getByIdPlain(LMessung.class, messungsId, "land"); + StatusProtokoll status = defaultRepo.getByIdPlain( + StatusProtokoll.class, + messung.getStatus(), + "land"); + boolean allowed = false; + for (int i = 0; i < user.getFunktionen().size(); i++) { + if (user.getFunktionen().get(i) >= status.getStatusStufe()) { + allowed = true; + break; + } + } + if (!allowed) { + return list; + } + QueryBuilder errFilter = + new QueryBuilder( + defaultRepo.entityManager("stamm"), + StatusErreichbar.class); + errFilter.and("curStufe", status.getStatusStufe()); + errFilter.and("curWert", status.getStatusWert()); + List erreichbare = defaultRepo.filterPlain(errFilter.getQuery(), "stamm"); + QueryBuilder werteFilter = + new QueryBuilder( + defaultRepo.entityManager("stamm"), + StatusWert.class); + for (int i = 0; i < erreichbare.size(); i++) { + werteFilter.or("id", erreichbare.get(i).getWertId()); + } + list = defaultRepo.filterPlain(werteFilter.getQuery(), "stamm"); return list; } } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java --- a/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java Thu Nov 12 12:20:12 2015 +0100 @@ -21,7 +21,9 @@ import de.intevation.lada.model.land.LMessung; import de.intevation.lada.model.land.LProbe; +import de.intevation.lada.model.land.LStatusProtokoll; import de.intevation.lada.model.stamm.Auth; +import de.intevation.lada.model.stamm.AuthLstUmw; import de.intevation.lada.util.annotation.AuthorizationConfig; import de.intevation.lada.util.annotation.RepositoryConfig; import de.intevation.lada.util.data.QueryBuilder; @@ -236,17 +238,25 @@ List auth = (List)response.getData(); List netzbetreiber = new ArrayList(); List messstellen = new ArrayList(); + List funktionen = new ArrayList(); for (Auth a : auth) { - if (a.getNetzBetreiber() != null) { - netzbetreiber.add(a.getNetzBetreiber()); + if (a.getNetzbetreiberId() != null) { + netzbetreiber.add(a.getNetzbetreiberId()); } - if (a.getMessStelle() != null) { - messstellen.add(a.getMessStelle()); + if (a.getMstId() != null) { + messstellen.add(a.getMstId()); + } + if (a.getLaborMstId() != null) { + messstellen.add(a.getLaborMstId()); + } + if (a.getFunktionId() != null) { + funktionen.add(a.getFunktionId()); } } UserInfo userInfo = new UserInfo(); userInfo.setNetzbetreiber(netzbetreiber); userInfo.setMessstellen(messstellen); + userInfo.setFunktionen(funktionen); return userInfo; } @@ -509,7 +519,42 @@ else { messung.setOwner(false); } - messung.setReadonly(messung.getFertig()); + if (messung.getStatus() == null) { + messung.setReadonly(false); + } + else { + LStatusProtokoll status = repository.getByIdPlain( + LStatusProtokoll.class, + messung.getStatus(), + "land"); + messung.setReadonly( + status.getStatusWert() != 0 && status.getStatusWert() != 4); + } + + boolean statusEdit = false; + if (userInfo.getFunktionen().contains(3)) { + QueryBuilder lstFilter = new QueryBuilder( + repository.entityManager("stamm"), + AuthLstUmw.class); + lstFilter.or("lstId", userInfo.getMessstellen()); + List lsts = + repository.filterPlain(lstFilter.getQuery(), "stamm"); + for (int i = 0; i < lsts.size(); i++) { + if (lsts.get(i).getUmwId().equals(probe.getUmwId())) { + statusEdit = true; + } + } + } + else if (userInfo.getFunktionen().contains(2) && + userInfo.getNetzbetreiber().contains(probe.getNetzbetreiberId())) { + statusEdit = true; + } + else if (userInfo.getFunktionen().contains(1) && + userInfo.getMessstellen().contains(probe.getMstId())) { + statusEdit = true; + } + messung.setStatusEdit(statusEdit); + return messung; } @@ -527,14 +572,20 @@ manager, LMessung.class); builder.and("probeId", probeId); - builder.and("fertig", true); Response response = repository.filter(builder.getQuery(), "land"); @SuppressWarnings("unchecked") List messungen = (List) response.getData(); - if (messungen.isEmpty()) { - return false; + for (int i = 0; i < messungen.size(); i++) { + if (messungen.get(i).getStatus() == null) { + return false; + } + LStatusProtokoll status = repository.getByIdPlain( + LStatusProtokoll.class, messungen.get(i).getStatus(), "land"); + if (status.getStatusWert() != 0 && status.getStatusWert() != 4) { + return true; + } } - return true; + return false; } /** diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/util/auth/UserInfo.java --- a/src/main/java/de/intevation/lada/util/auth/UserInfo.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/util/auth/UserInfo.java Thu Nov 12 12:20:12 2015 +0100 @@ -20,6 +20,8 @@ private List messstellen; private List netzbetreiber; private List roles; + private List funktionen; + private Integer statusRole; public UserInfo() { messstellen = new ArrayList(); @@ -81,4 +83,43 @@ public void setRoles(List roles) { this.roles = roles; } + + /** + * @return the funktionen + */ + public List getFunktionen() { + return this.funktionen; + } + + /** + * @return the funktionen + */ + public List getFunktionenAsString() { + List retVal = new ArrayList(); + for (int i = 0; i < this.funktionen.size(); i++) { + retVal.add(this.funktionen.get(i).toString()); + } + return retVal; + } + + /** + * @param funktionen the funktionen to set + */ + public void setFunktionen(List funktionen) { + this.funktionen = funktionen; + } + + /** + * @return the statusRole + */ + public Integer getStatusRole() { + return statusRole; + } + + /** + * @param statusRole the statusRole to set + */ + public void setStatusRole(Integer statusRole) { + this.statusRole = statusRole; + } } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/util/data/ReadOnlyRepository.java --- a/src/main/java/de/intevation/lada/util/data/ReadOnlyRepository.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/util/data/ReadOnlyRepository.java Thu Nov 12 12:20:12 2015 +0100 @@ -151,4 +151,33 @@ public EntityManager entityManager(String dataSource) { return transaction.entityManager(dataSource); } + + @Override + public List filterPlain(CriteriaQuery filter, String dataSource) { + return transaction.entityManager(dataSource).createQuery(filter).getResultList(); + } + + @Override + public List filterPlain(CriteriaQuery filter, int size, + int start, String dataSource) { + List result = + transaction.entityManager(dataSource).createQuery(filter).getResultList(); + if (size > 0 && start > -1) { + return result.subList(start, size + start); + } + return result; + } + + @Override + public List getAllPlain(Class clazz, String dataSource) { + EntityManager manager = transaction.entityManager(dataSource); + QueryBuilder builder = + new QueryBuilder(manager, clazz); + return manager.createQuery(builder.getQuery()).getResultList(); + } + + @Override + public T getByIdPlain(Class clazz, Object id, String dataSource) { + return transaction.entityManager(dataSource).find(clazz, id); + } } diff -r ee0ee3c37449 -r b55f517124e5 src/main/java/de/intevation/lada/util/data/Repository.java --- a/src/main/java/de/intevation/lada/util/data/Repository.java Wed Nov 11 12:07:03 2015 +0100 +++ b/src/main/java/de/intevation/lada/util/data/Repository.java Thu Nov 12 12:20:12 2015 +0100 @@ -7,6 +7,8 @@ */ package de.intevation.lada.util.data; +import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.Query; import javax.persistence.criteria.CriteriaQuery; @@ -29,16 +31,28 @@ public Response filter(CriteriaQuery filter, String dataSource); + public List filterPlain(CriteriaQuery filter, String dataSource); + public Response filter( CriteriaQuery filter, int size, int start, String dataSource); + public List filterPlain( + CriteriaQuery filter, + int size, + int start, + String dataSource); + public Response getAll(Class clazz, String dataSource); + public List getAllPlain(Class clazz, String dataSource); + public Response getById(Class clazz, Object id, String dataSource); + public T getByIdPlain(Class clazz, Object id, String dataSource); + public Query queryFromString(String sql, String dataSource); public EntityManager entityManager(String dataSource);