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