changeset 30:c11b0df06151

Added Umwelt-Stammdaten service and data model.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 22 May 2013 13:21:35 +0200
parents c5930d01e0ab
children 4266530e94a8
files src/main/java/de/intevation/lada/data/SUmweltRepository.java src/main/java/de/intevation/lada/model/SMessEinheit.java src/main/java/de/intevation/lada/model/SUmwelt.java src/main/java/de/intevation/lada/rest/SUmweltRESTService.java src/main/java/de/intevation/lada/service/SUmweltService.java
diffstat 5 files changed, 266 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/data/SUmweltRepository.java	Wed May 22 13:21:35 2013 +0200
@@ -0,0 +1,38 @@
+package de.intevation.lada.data;
+
+import java.util.List;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+
+import de.intevation.lada.model.SUmwelt;
+import de.intevation.lada.service.SUmweltService;
+
+@ApplicationScoped
+public class SUmweltRepository {
+
+    @Inject
+    @PersistenceContext(type=PersistenceContextType.EXTENDED)
+    EntityManager em;
+
+    @Inject
+    SUmweltService service;
+
+    public List<SUmwelt> findAll() {
+        CriteriaBuilder builder = em.getCriteriaBuilder();
+        CriteriaQuery<SUmwelt> criteria = builder.createQuery(SUmwelt.class);
+        Root<SUmwelt> member = criteria.from(SUmwelt.class);
+        criteria.select(member);
+        return em.createQuery(criteria).getResultList();
+    }
+
+    public SUmwelt findById(String id) {
+        return em.find(SUmwelt.class, id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/model/SMessEinheit.java	Wed May 22 13:21:35 2013 +0200
@@ -0,0 +1,88 @@
+package de.intevation.lada.model;
+
+// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+/**
+ * SMessEinheit generated by hbm2java
+ */
+@Entity
+@Table(name = "s_mess_einheit", schema = "public")
+public class SMessEinheit implements java.io.Serializable {
+
+	private short mehId;
+	private String beschreibung;
+	private String einheit;
+	private String eudfMesseinheitId;
+	private Long umrechnungsFaktorEudf;
+
+	public SMessEinheit() {
+	}
+
+	public SMessEinheit(short mehId) {
+		this.mehId = mehId;
+	}
+
+	public SMessEinheit(short mehId, String beschreibung, String einheit,
+			String eudfMesseinheitId, Long umrechnungsFaktorEudf) {
+		this.mehId = mehId;
+		this.beschreibung = beschreibung;
+		this.einheit = einheit;
+		this.eudfMesseinheitId = eudfMesseinheitId;
+		this.umrechnungsFaktorEudf = umrechnungsFaktorEudf;
+	}
+
+	@Id
+	@Column(name = "meh_id", unique = true, nullable = false)
+	public short getMehId() {
+		return this.mehId;
+	}
+
+	public void setMehId(short mehId) {
+		this.mehId = mehId;
+	}
+
+	@Column(name = "beschreibung", length = 50)
+	public String getBeschreibung() {
+		return this.beschreibung;
+	}
+
+	public void setBeschreibung(String beschreibung) {
+		this.beschreibung = beschreibung;
+	}
+
+	@Column(name = "einheit", length = 12)
+	public String getEinheit() {
+		return this.einheit;
+	}
+
+	public void setEinheit(String einheit) {
+		this.einheit = einheit;
+	}
+
+	@Column(name = "eudf_messeinheit_id", length = 8)
+	public String getEudfMesseinheitId() {
+		return this.eudfMesseinheitId;
+	}
+
+	public void setEudfMesseinheitId(String eudfMesseinheitId) {
+		this.eudfMesseinheitId = eudfMesseinheitId;
+	}
+
+	@Column(name = "umrechnungs_faktor_eudf")
+	public Long getUmrechnungsFaktorEudf() {
+		return this.umrechnungsFaktorEudf;
+	}
+
+	public void setUmrechnungsFaktorEudf(Long umrechnungsFaktorEudf) {
+		this.umrechnungsFaktorEudf = umrechnungsFaktorEudf;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/model/SUmwelt.java	Wed May 22 13:21:35 2013 +0200
@@ -0,0 +1,82 @@
+package de.intevation.lada.model;
+
+// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+/**
+ * SUmwelt generated by hbm2java
+ */
+@Entity
+@Table(name = "s_umwelt", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "umwelt_bereich"))
+public class SUmwelt implements java.io.Serializable {
+
+	private String umwId;
+	private SMessEinheit SMessEinheit;
+	private String beschreibung;
+	private String umweltBereich;
+
+	public SUmwelt() {
+	}
+
+	public SUmwelt(String umwId, String umweltBereich) {
+		this.umwId = umwId;
+		this.umweltBereich = umweltBereich;
+	}
+
+	public SUmwelt(String umwId, SMessEinheit SMessEinheit,
+			String beschreibung, String umweltBereich) {
+		this.umwId = umwId;
+		this.SMessEinheit = SMessEinheit;
+		this.beschreibung = beschreibung;
+		this.umweltBereich = umweltBereich;
+	}
+
+	@Id
+	@Column(name = "umw_id", unique = true, nullable = false, length = 3)
+	public String getUmwId() {
+		return this.umwId;
+	}
+
+	public void setUmwId(String umwId) {
+		this.umwId = umwId;
+	}
+
+	@ManyToOne(fetch = FetchType.EAGER)
+	@JoinColumn(name = "meh_id")
+	public SMessEinheit getSMessEinheit() {
+		return this.SMessEinheit;
+	}
+
+	public void setSMessEinheit(SMessEinheit SMessEinheit) {
+		this.SMessEinheit = SMessEinheit;
+	}
+
+	@Column(name = "beschreibung", length = 300)
+	public String getBeschreibung() {
+		return this.beschreibung;
+	}
+
+	public void setBeschreibung(String beschreibung) {
+		this.beschreibung = beschreibung;
+	}
+
+	@Column(name = "umwelt_bereich", unique = true, nullable = false, length = 80)
+	public String getUmweltBereich() {
+		return this.umweltBereich;
+	}
+
+	public void setUmweltBereich(String umweltBereich) {
+		this.umweltBereich = umweltBereich;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/rest/SUmweltRESTService.java	Wed May 22 13:21:35 2013 +0200
@@ -0,0 +1,38 @@
+package de.intevation.lada.rest;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import de.intevation.lada.data.SUmweltRepository;
+import de.intevation.lada.model.SUmwelt;
+
+@Path("/uwb")
+@RequestScoped
+public class SUmweltRESTService {
+    @Inject
+    private SUmweltRepository repository;
+
+    @Inject
+    private Logger log;
+
+    @GET
+    @Produces("text/json")
+    public List<SUmwelt> listAllMembers() {
+        final List<SUmwelt> result = repository.findAll();
+        return result;
+    }
+
+    @GET
+    @Path("/{id:[0-9][0-9]*}")
+    @Produces("text/json")
+    public SUmwelt loadById(@PathParam("id") String id) {
+        return repository.findById(id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/service/SUmweltService.java	Wed May 22 13:21:35 2013 +0200
@@ -0,0 +1,20 @@
+package de.intevation.lada.service;
+
+import java.util.logging.Logger;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import de.intevation.lada.model.SUmwelt;
+
+@Stateless
+public class SUmweltService {
+    @Inject
+    private Logger log;
+
+    @Inject
+    private EntityManager em;
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)