From f26e5e12c9706ac27b389b57ace45eaeec1de0eb Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sat, 9 Aug 2014 14:11:59 +0200 Subject: [PATCH] =?UTF-8?q?Refaktorov=C3=A1no=20p=C5=99id=C3=A1v=C3=A1n?= =?UTF-8?q?=C3=AD=20z=C3=A1znam=C5=AF=20po=C5=BEadavk=C5=AF.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../requirement/RequirementBaseServiceImpl.java | 11 +++++++++++ .../services/requirement/RequirementServiceImpl.java | 1 - .../requirement/TripRequirementServiceImpl.java | 9 --------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index d4ade762..12158718 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -45,7 +45,18 @@ public abstract class RequirementBaseServiceImpl exte @Override @Transactional + @PreAuthorize("hasPermission(this, 'PERM_ADD')") public void add(T entity) { + Workgroup reqWorkgroup = null; + for (Workgroup w : workgroupService.getUserWorkgroups(getLoggedInUser())) { + if (workgroupService.getMembers(entity.getCentre()).contains(w)) { + reqWorkgroup = w; + } + } + + entity.setWorkgroup(reqWorkgroup); + entity.setNumser(this.getNumberSerie()); + super.add(entity); this.sendToApprovers(entity); 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 dbb0c5f9..32a5e245 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -33,7 +33,6 @@ public class RequirementServiceImpl extends @Transactional @PreAuthorize("hasPermission(this, 'PERM_ADD')") public void add(Requirement entity) { - entity.setNumser(this.getNumberSerie()); super.add(entity); } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java index e13f6c72..2f001ca3 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -3,7 +3,6 @@ package info.bukova.isspst.services.requirement; import info.bukova.isspst.Constants; import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.TripRequirement; -import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.workgroups.WorkgroupService; @@ -36,14 +35,6 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl