Mercurial > lada > lada-server
changeset 29:c5930d01e0ab
Package renaming and code cosmetics.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 22 May 2013 13:19:26 +0200 |
parents | 0a3b95d7bf63 |
children | c11b0df06151 |
files | src/main/java/de/intevation/data/LProbeRepository.java src/main/java/de/intevation/lada/data/LProbeRepository.java src/main/java/de/intevation/lada/model/LProbe.java src/main/java/de/intevation/lada/rest/JaxRsActivator.java src/main/java/de/intevation/lada/rest/LProbeRESTService.java src/main/java/de/intevation/lada/rest/RESTService.java src/main/java/de/intevation/lada/service/LProbeService.java src/main/java/de/intevation/model/LProbe.java src/main/java/de/intevation/rest/JaxRsActivator.java src/main/java/de/intevation/rest/LProbeRESTService.java src/main/java/de/intevation/rest/RESTService.java src/main/java/de/intevation/service/LProbeService.java |
diffstat | 12 files changed, 497 insertions(+), 521 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/data/LProbeRepository.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual - * contributors by the @authors tag. See the copyright.txt in the - * distribution for a full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.intevation.data; - -import javax.ejb.TransactionManagement; -import javax.ejb.TransactionManagementType; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import java.util.List; - -import de.intevation.model.LProbe; -import de.intevation.service.LProbeService; - -@ApplicationScoped -public class LProbeRepository { - - @Inject - private EntityManager em; - - @Inject - private LProbeService service; - - public LProbe findById(Long id) { - return em.find(LProbe.class, id); - } - - - public void delete(LProbe item) { - try { - service.delete(item.getProbeId()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - //public LProbe findByEmail(String email) { - // CriteriaBuilder cb = em.getCriteriaBuilder(); - // CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); - // Root<LProbe> member = criteria.from(LProbe.class); - // // Swap criteria statements if you would like to try out type-safe criteria queries, a new - // // feature in JPA 2.0 - // // criteria.select(member).where(cb.equal(member.get(LProbe_.name), email)); - // criteria.select(member).where(cb.equal(member.get("email"), email)); - // return em.createQuery(criteria).getSingleResult(); - //} - - public List<LProbe> findAll() { - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); - Root<LProbe> member = criteria.from(LProbe.class); - // Swap criteria statements if you would like to try out type-safe criteria queries, a new - // feature in JPA 2.0 - // criteria.select(member).orderBy(cb.asc(member.get(LProbe_.name))); - //criteria.select(member).orderBy(cb.asc(member.get("name"))); - criteria.select(member); - return em.createQuery(criteria).getResultList(); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,79 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +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.LProbe; +import de.intevation.lada.service.LProbeService; + +@ApplicationScoped +public class LProbeRepository { + + @Inject + @PersistenceContext(type=PersistenceContextType.EXTENDED) + private EntityManager em; + + @Inject + private LProbeService service; + + public LProbe findById(Long id) { + return em.find(LProbe.class, id); + } + + public void delete(LProbe item) { + try { + service.delete(item.getProbeId()); + } + catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //public LProbe findByEmail(String email) { + // CriteriaBuilder cb = em.getCriteriaBuilder(); + // CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); + // Root<LProbe> member = criteria.from(LProbe.class); + // // Swap criteria statements if you would like to try out type-safe criteria queries, a new + // // feature in JPA 2.0 + // // criteria.select(member).where(cb.equal(member.get(LProbe_.name), email)); + // criteria.select(member).where(cb.equal(member.get("email"), email)); + // return em.createQuery(criteria).getSingleResult(); + //} + + public List<LProbe> findAll() { + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); + Root<LProbe> member = criteria.from(LProbe.class); + // Swap criteria statements if you would like to try out type-safe criteria queries, a new + // feature in JPA 2.0 + // criteria.select(member).orderBy(cb.asc(member.get(LProbe_.name))); + //criteria.select(member).orderBy(cb.asc(member.get("name"))); + criteria.select(member); + return em.createQuery(criteria).getResultList(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/model/LProbe.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,235 @@ +package de.intevation.lada.model; + +// Generated 21.05.2013 16:58:30 by Hibernate Tools 3.4.0.CR1 + +import java.util.Date; +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.Temporal; +import javax.persistence.TemporalType; + +/** + * LProbe generated by hbm2java + */ +@Entity +@Table(name = "l_probe", schema = "public") +public class LProbe implements java.io.Serializable { + + private String probeId; + private boolean test; + private String hauptprobenNr; + private String baId; + private String mediaDesk; + private String media; + private Date probeentnahmeBeginn; + private Date probeentnahmeEnde; + private Long mittelungsdauer; + private Date letzteAenderung; + private Integer erzeugerId; + private Integer probeNehmerId; + private Character mpKat; + private String mplId; + private Integer mprId; + private Date solldatumBeginn; + private Date solldatumEnde; + + public LProbe() { + } + + public LProbe(String probeId, boolean test) { + this.probeId = probeId; + this.test = test; + } + + public LProbe(String probeId, boolean test, + String hauptprobenNr, String baId, String mediaDesk, String media, + Date probeentnahmeBeginn, Date probeentnahmeEnde, + Long mittelungsdauer, Date letzteAenderung, Integer erzeugerId, + Integer probeNehmerId, Character mpKat, String mplId, + Integer mprId, Date solldatumBeginn, Date solldatumEnde) { + this.probeId = probeId; + this.test = test; + this.hauptprobenNr = hauptprobenNr; + this.baId = baId; + this.mediaDesk = mediaDesk; + this.media = media; + this.probeentnahmeBeginn = probeentnahmeBeginn; + this.probeentnahmeEnde = probeentnahmeEnde; + this.mittelungsdauer = mittelungsdauer; + this.letzteAenderung = letzteAenderung; + this.erzeugerId = erzeugerId; + this.probeNehmerId = probeNehmerId; + this.mpKat = mpKat; + this.mplId = mplId; + this.mprId = mprId; + this.solldatumBeginn = solldatumBeginn; + this.solldatumEnde = solldatumEnde; + } + + @Id + @Column(name = "probe_id", unique = true, nullable = false, length = 20) + public String getProbeId() { + return this.probeId; + } + + public void setProbeId(String probeId) { + this.probeId = probeId; + } + + @Column(name = "test", nullable = false) + public boolean isTest() { + return this.test; + } + + public void setTest(boolean test) { + this.test = test; + } + + @Column(name = "hauptproben_nr", length = 20) + public String getHauptprobenNr() { + return this.hauptprobenNr; + } + + public void setHauptprobenNr(String hauptprobenNr) { + this.hauptprobenNr = hauptprobenNr; + } + + @Column(name = "ba_id", length = 1) + public String getBaId() { + return this.baId; + } + + public void setBaId(String baId) { + this.baId = baId; + } + + @Column(name = "media_desk", length = 100) + public String getMediaDesk() { + return this.mediaDesk; + } + + public void setMediaDesk(String mediaDesk) { + this.mediaDesk = mediaDesk; + } + + @Column(name = "media", length = 100) + public String getMedia() { + return this.media; + } + + public void setMedia(String media) { + this.media = media; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "probeentnahme_beginn", length = 35) + public Date getProbeentnahmeBeginn() { + return this.probeentnahmeBeginn; + } + + public void setProbeentnahmeBeginn(Date probeentnahmeBeginn) { + this.probeentnahmeBeginn = probeentnahmeBeginn; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "probeentnahme_ende", length = 35) + public Date getProbeentnahmeEnde() { + return this.probeentnahmeEnde; + } + + public void setProbeentnahmeEnde(Date probeentnahmeEnde) { + this.probeentnahmeEnde = probeentnahmeEnde; + } + + @Column(name = "mittelungsdauer") + public Long getMittelungsdauer() { + return this.mittelungsdauer; + } + + public void setMittelungsdauer(Long mittelungsdauer) { + this.mittelungsdauer = mittelungsdauer; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "letzte_aenderung", length = 29) + public Date getLetzteAenderung() { + return this.letzteAenderung; + } + + public void setLetzteAenderung(Date letzteAenderung) { + this.letzteAenderung = letzteAenderung; + } + + @Column(name = "erzeuger_id") + public Integer getErzeugerId() { + return this.erzeugerId; + } + + public void setErzeugerId(Integer erzeugerId) { + this.erzeugerId = erzeugerId; + } + + @Column(name = "probe_nehmer_id") + public Integer getProbeNehmerId() { + return this.probeNehmerId; + } + + public void setProbeNehmerId(Integer probeNehmerId) { + this.probeNehmerId = probeNehmerId; + } + + @Column(name = "mp_kat", length = 1) + public Character getMpKat() { + return this.mpKat; + } + + public void setMpKat(Character mpKat) { + this.mpKat = mpKat; + } + + @Column(name = "mpl_id", length = 3) + public String getMplId() { + return this.mplId; + } + + public void setMplId(String mplId) { + this.mplId = mplId; + } + + @Column(name = "mpr_id") + public Integer getMprId() { + return this.mprId; + } + + public void setMprId(Integer mprId) { + this.mprId = mprId; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "solldatum_beginn", length = 29) + public Date getSolldatumBeginn() { + return this.solldatumBeginn; + } + + public void setSolldatumBeginn(Date solldatumBeginn) { + this.solldatumBeginn = solldatumBeginn; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "solldatum_ende", length = 29) + public Date getSolldatumEnde() { + return this.solldatumEnde; + } + + public void setSolldatumEnde(Date solldatumEnde) { + this.solldatumEnde = solldatumEnde; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/JaxRsActivator.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,18 @@ +package de.intevation.lada.rest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +/** + * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 + * "no XML" approach to activating JAX-RS. + * + * <p> + * Resources are served relative to the servlet path specified in the {@link ApplicationPath} + * annotation. + * </p> + */ +@ApplicationPath("/rest") +public class JaxRsActivator extends Application { + /* class body intentionally left blank */ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/LProbeRESTService.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,82 @@ +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.Produces; + +import de.intevation.lada.data.LProbeRepository; +import de.intevation.lada.model.LProbe; +import de.intevation.lada.service.LProbeService; + +/** + * JAX-RS Example + * + * This class produces a RESTful service to read the contents of the members table. +*/ + +@Path("/proben") +@RequestScoped +public class LProbeRESTService { + + @Inject + private LProbeRepository repository; + + @Inject + private Logger log; + + @GET + @Produces("text/json") + public List<LProbe> listAllMembers() { + final List<LProbe> result = repository.findAll(); + return result; + } + + @GET + @Path("/{id:[0-9][0-9]*}") + @Produces("text/plain") + public String loadById() { + return "Eine Probe!"; + } + + @GET + @Path("/deleteLast") + @Produces("text/plain") + public String deleteLast() { + final List<LProbe> result = repository.findAll(); + LProbe last_element = result.get(result.size()-1); + repository.delete(last_element); + return "Gelöscht id" + last_element.getProbeId(); + } + + @GET + @Path("/new") + @Produces("text/plain") + public String create() { + return "Neu"; + } + //@GET + //@Produces("text/xml") + //public List<Member> listAllMembers() { + // // Us @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of + // // this query + // @SuppressWarnings("unchecked") + // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on + // // the @Entity class + // // as described in the named query blueprint: + // // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html + // final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList(); + // return results; + //} + + //@GET + //@Path("/{id:[0-9][0-9]*}") + //@Produces("text/xml") + //public Member lookupMemberById(@PathParam("id") long id) { + // return em.find(Member.class, id); + //} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/RESTService.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,51 @@ +package de.intevation.lada.rest; + +import javax.enterprise.context.RequestScoped; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path("/default") +@RequestScoped +public class RESTService { + + @GET + @Produces("text/plain") + public String listAll() { + return "Hallo Welt!"; + } +} + +/** + * JAX-RS Example + * + * This class produces a RESTful service to read the contents of the members table. + +@Path("/members") +@RequestScoped +public class MemberResourceRESTService { + @Inject + private EntityManager em; + + @GET + @Produces("text/xml") + public List<Member> listAllMembers() { + // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of + // this query + @SuppressWarnings("unchecked") + // We recommend centralizing inline queries such as this one into @NamedQuery annotations on + // the @Entity class + // as described in the named query blueprint: + // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html + final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList(); + return results; + } + + @GET + @Path("/{id:[0-9][0-9]*}") + @Produces("text/xml") + public Member lookupMemberById(@PathParam("id") long id) { + return em.find(Member.class, id); + } +} +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/service/LProbeService.java Wed May 22 13:19:26 2013 +0200 @@ -0,0 +1,32 @@ +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.LProbe; + +@Stateless +public class LProbeService { + + @Inject + private Logger log; + + @Inject + private EntityManager em; + +// @Inject +// private Event<Member> memberEventSrc; + + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void delete(String id) throws Exception { + LProbe probe = em.find(LProbe.class, id); + log.info("Deleting " + probe.getProbeId()); + em.remove(probe); + //memberEventSrc.fire(member); + } +} \ No newline at end of file
--- a/src/main/java/de/intevation/model/LProbe.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,260 +0,0 @@ -package de.intevation.model; - -import java.io.Serializable; -import javax.persistence.*; -import java.sql.Timestamp; -import java.util.List; - - -/** - * The persistent class for the l_probe database table. - * - */ -@Entity -@Table(name="l_probe") -public class LProbe implements Serializable { - private static final long serialVersionUID = 1L; - private String probeId; - private String baId; - private Integer datenbasisId; - private Integer erzeugerId; - private String hauptprobenNr; - private Timestamp letzteAenderung; - private String media; - private String mediaDesk; - private Long mittelungsdauer; - private String mpKat; - private String mplId; - private Integer mprId; - private String mstId; - private String netzbetreiberId; - private Integer probeNehmerId; - private Timestamp probeentnahmeBeginn; - private Timestamp probeentnahmeEnde; - private Integer probenartId; - private Timestamp solldatumBeginn; - private Timestamp solldatumEnde; - private Boolean test; - private String umwId; - - public LProbe() { - } - - - @Id - @Column(name="probe_id") - public String getProbeId() { - return this.probeId; - } - - public void setProbeId(String probeId) { - this.probeId = probeId; - } - - - @Column(name="ba_id") - public String getBaId() { - return this.baId; - } - - public void setBaId(String baId) { - this.baId = baId; - } - - - @Column(name="datenbasis_id") - public Integer getDatenbasisId() { - return this.datenbasisId; - } - - public void setDatenbasisId(Integer datenbasisId) { - this.datenbasisId = datenbasisId; - } - - - @Column(name="erzeuger_id") - public Integer getErzeugerId() { - return this.erzeugerId; - } - - public void setErzeugerId(Integer erzeugerId) { - this.erzeugerId = erzeugerId; - } - - - @Column(name="hauptproben_nr") - public String getHauptprobenNr() { - return this.hauptprobenNr; - } - - public void setHauptprobenNr(String hauptprobenNr) { - this.hauptprobenNr = hauptprobenNr; - } - - - @Column(name="letzte_aenderung") - public Timestamp getLetzteAenderung() { - return this.letzteAenderung; - } - - public void setLetzteAenderung(Timestamp letzteAenderung) { - this.letzteAenderung = letzteAenderung; - } - - - public String getMedia() { - return this.media; - } - - public void setMedia(String media) { - this.media = media; - } - - - @Column(name="media_desk") - public String getMediaDesk() { - return this.mediaDesk; - } - - public void setMediaDesk(String mediaDesk) { - this.mediaDesk = mediaDesk; - } - - - public Long getMittelungsdauer() { - return this.mittelungsdauer; - } - - public void setMittelungsdauer(Long mittelungsdauer) { - this.mittelungsdauer = mittelungsdauer; - } - - - @Column(name="mp_kat") - public String getMpKat() { - return this.mpKat; - } - - public void setMpKat(String mpKat) { - this.mpKat = mpKat; - } - - - @Column(name="mpl_id") - public String getMplId() { - return this.mplId; - } - - public void setMplId(String mplId) { - this.mplId = mplId; - } - - - @Column(name="mpr_id") - public Integer getMprId() { - return this.mprId; - } - - public void setMprId(Integer mprId) { - this.mprId = mprId; - } - - - @Column(name="mst_id") - public String getMstId() { - return this.mstId; - } - - public void setMstId(String mstId) { - this.mstId = mstId; - } - - - @Column(name="netzbetreiber_id") - public String getNetzbetreiberId() { - return this.netzbetreiberId; - } - - public void setNetzbetreiberId(String netzbetreiberId) { - this.netzbetreiberId = netzbetreiberId; - } - - - @Column(name="probe_nehmer_id") - public Integer getProbeNehmerId() { - return this.probeNehmerId; - } - - public void setProbeNehmerId(Integer probeNehmerId) { - this.probeNehmerId = probeNehmerId; - } - - - @Column(name="probeentnahme_beginn") - public Timestamp getProbeentnahmeBeginn() { - return this.probeentnahmeBeginn; - } - - public void setProbeentnahmeBeginn(Timestamp probeentnahmeBeginn) { - this.probeentnahmeBeginn = probeentnahmeBeginn; - } - - - @Column(name="probeentnahme_ende") - public Timestamp getProbeentnahmeEnde() { - return this.probeentnahmeEnde; - } - - public void setProbeentnahmeEnde(Timestamp probeentnahmeEnde) { - this.probeentnahmeEnde = probeentnahmeEnde; - } - - - @Column(name="probenart_id") - public Integer getProbenartId() { - return this.probenartId; - } - - public void setProbenartId(Integer probenartId) { - this.probenartId = probenartId; - } - - - @Column(name="solldatum_beginn") - public Timestamp getSolldatumBeginn() { - return this.solldatumBeginn; - } - - public void setSolldatumBeginn(Timestamp solldatumBeginn) { - this.solldatumBeginn = solldatumBeginn; - } - - - @Column(name="solldatum_ende") - public Timestamp getSolldatumEnde() { - return this.solldatumEnde; - } - - public void setSolldatumEnde(Timestamp solldatumEnde) { - this.solldatumEnde = solldatumEnde; - } - - - public Boolean getTest() { - return this.test; - } - - public void setTest(Boolean test) { - this.test = test; - } - - - @Column(name="umw_id") - public String getUmwId() { - return this.umwId; - } - - public void setUmwId(String umwId) { - this.umwId = umwId; - } -} \ No newline at end of file
--- a/src/main/java/de/intevation/rest/JaxRsActivator.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -package de.intevation.rest; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -/** - * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 - * "no XML" approach to activating JAX-RS. - * - * <p> - * Resources are served relative to the servlet path specified in the {@link ApplicationPath} - * annotation. - * </p> - */ -@ApplicationPath("/rest") -public class JaxRsActivator extends Application { - /* class body intentionally left blank */ -}
--- a/src/main/java/de/intevation/rest/LProbeRESTService.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -package de.intevation.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.Produces; - -import de.intevation.data.LProbeRepository; -import de.intevation.model.LProbe; -import de.intevation.service.LProbeService; - -/** - * JAX-RS Example - * - * This class produces a RESTful service to read the contents of the members table. -*/ - -@Path("/proben") -@RequestScoped -public class LProbeRESTService { - - @Inject - private LProbeRepository repository; - - @Inject - private Logger log; - - @GET - @Produces("text/json") - public List<LProbe> listAllMembers() { - final List<LProbe> result = repository.findAll(); - return result; - } - - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/plain") - public String loadById() { - return "Eine Probe!"; - } - - @GET - @Path("/deleteLast") - @Produces("text/plain") - public String deleteLast() { - final List<LProbe> result = repository.findAll(); - LProbe last_element = result.get(result.size()-1); - repository.delete(last_element); - return "Gelöscht id" + last_element.getProbeId(); - } - - @GET - @Path("/new") - @Produces("text/plain") - public String create() { - return "Neu"; - } - //@GET - //@Produces("text/xml") - //public List<Member> listAllMembers() { - // // Us @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of - // // this query - // @SuppressWarnings("unchecked") - // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on - // // the @Entity class - // // as described in the named query blueprint: - // // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html - // final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList(); - // return results; - //} - - //@GET - //@Path("/{id:[0-9][0-9]*}") - //@Produces("text/xml") - //public Member lookupMemberById(@PathParam("id") long id) { - // return em.find(Member.class, id); - //} -}
--- a/src/main/java/de/intevation/rest/RESTService.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -package de.intevation.rest; - -import javax.enterprise.context.RequestScoped; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -@Path("/default") -@RequestScoped -public class RESTService { - - @GET - @Produces("text/plain") - public String listAll() { - return "Hallo Welt!"; - } -} - -/** - * JAX-RS Example - * - * This class produces a RESTful service to read the contents of the members table. - -@Path("/members") -@RequestScoped -public class MemberResourceRESTService { - @Inject - private EntityManager em; - - @GET - @Produces("text/xml") - public List<Member> listAllMembers() { - // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of - // this query - @SuppressWarnings("unchecked") - // We recommend centralizing inline queries such as this one into @NamedQuery annotations on - // the @Entity class - // as described in the named query blueprint: - // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html - final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList(); - return results; - } - - @GET - @Path("/{id:[0-9][0-9]*}") - @Produces("text/xml") - public Member lookupMemberById(@PathParam("id") long id) { - return em.find(Member.class, id); - } -} -*/
--- a/src/main/java/de/intevation/service/LProbeService.java Wed May 08 13:47:25 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -package de.intevation.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.model.LProbe; - -@Stateless -public class LProbeService { - - @Inject - private Logger log; - - @Inject - private EntityManager em; - -// @Inject -// private Event<Member> memberEventSrc; - - @TransactionAttribute(TransactionAttributeType.REQUIRED) - public void delete(String id) throws Exception { - LProbe probe = em.find(LProbe.class, id); - log.info("Deleting " + probe.getProbeId()); - em.remove(probe); - //memberEventSrc.fire(member); - } -} \ No newline at end of file