From 768d3ee874b62864197115a2c2b60d9c3fb48715 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 8 Sep 2015 22:22:23 +0200 Subject: [PATCH] =?UTF-8?q?Opraveno=20duplicitn=C3=AD=20vkl=C3=A1d=C3=A1n?= =?UTF-8?q?=C3=AD=20z=C3=A1znam=C5=AF=20do=20agendy=20Fakturace=20po=C5=BE?= =?UTF-8?q?adavk=C5=AF,=20v=20p=C5=99=C3=ADpad=C4=9B,=20=C5=BEe=20se=20po?= =?UTF-8?q?=C5=BEadavek=20uprav=C3=AD=20a=20znovu=20schv=C3=A1l=C3=AD.=20c?= =?UTF-8?q?loses=20#252?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../info/bukova/isspst/data/Invoicing.java | 11 +++++----- .../services/invoicing/InvoicingService.java | 3 +++ .../invoicing/InvoicingServiceImpl.java | 17 ++++++++++++---- .../requirement/RequirementServiceImpl.java | 20 +++++++++++++------ 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/main/java/info/bukova/isspst/data/Invoicing.java b/src/main/java/info/bukova/isspst/data/Invoicing.java index f6d81b8c..19dfdfb5 100644 --- a/src/main/java/info/bukova/isspst/data/Invoicing.java +++ b/src/main/java/info/bukova/isspst/data/Invoicing.java @@ -1,7 +1,7 @@ package info.bukova.isspst.data; -import java.math.BigDecimal; -import java.util.List; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -11,16 +11,15 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; - -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; +import java.math.BigDecimal; +import java.util.List; @Entity @Table(name = "INVOICING") public class Invoicing extends BaseData implements Cloneable { - @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "REQUIREMENT_ID") private Requirement requirement; diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java index 84583cc9..414ed36f 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java @@ -1,6 +1,7 @@ package info.bukova.isspst.services.invoicing; import info.bukova.isspst.data.Invoicing; +import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.services.Service; @@ -20,4 +21,6 @@ public interface InvoicingService extends Service { public List getPendingList(); public List getArchiveList(); + + public Invoicing getForRequirement(Requirement req); } diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index 98124d3d..7386188c 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -2,18 +2,18 @@ package info.bukova.isspst.services.invoicing; import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.InvoicingItem; +import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.LazyLoader; - -import java.math.BigDecimal; -import java.util.List; - import org.hibernate.Hibernate; import org.hibernate.Query; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.List; + public class InvoicingServiceImpl extends AbstractOwnedService implements InvoicingService { @@ -92,4 +92,13 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where inv.completed = true order by rq.numser"); return q.list(); } + + @Override + @Transactional + public Invoicing getForRequirement(Requirement req) { + Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId"); + query.setParameter("reqId", req.getId()); + + return (Invoicing) query.uniqueResult(); + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index 857857b0..a1dc8aa5 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -11,8 +11,8 @@ import info.bukova.isspst.data.Workflow; import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.invoicing.InvoicingService; import org.hibernate.Hibernate; -import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; @@ -244,11 +244,19 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl