From 2b24f30fb45687f867a34b828956307fbea05839 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Tue, 19 Aug 2014 13:13:14 +0200 Subject: [PATCH] =?UTF-8?q?Opravena=20kontrola=20=C4=8Dlenstv=C3=AD=20?= =?UTF-8?q?=C4=8Dlen=C5=AF=20komise=20p=C5=99i=C5=99azovan=C3=A9=20do=20st?= =?UTF-8?q?=C5=99ediska.=20closes=20#123?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workgroups/WorkgroupServiceImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/info/bukova/isspst/services/workgroups/WorkgroupServiceImpl.java b/src/main/java/info/bukova/isspst/services/workgroups/WorkgroupServiceImpl.java index faf8c8ee..90b87a9d 100644 --- a/src/main/java/info/bukova/isspst/services/workgroups/WorkgroupServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/workgroups/WorkgroupServiceImpl.java @@ -34,11 +34,7 @@ public class WorkgroupServiceImpl extends AbstractOwnedService implem if (!checkGroups(workgroup, member)) { throw new WorkgroupException(WorkgroupException.CYCLIC_MEMBER); } - - if (!member.isPerson() && !checkGroups((Workgroup)member, workgroup)) { - throw new WorkgroupException(WorkgroupException.CYCLIC_MEMBER); - } - + JobMapping mapping = new JobMapping(member, role); if (!workgroup.getMembers().contains(mapping)) { workgroup.getMembers().add(mapping); @@ -86,6 +82,7 @@ public class WorkgroupServiceImpl extends AbstractOwnedService implem return false; } + // check, jestli nahodou nekdo z komise neni clemen strediska, do nehoz se komise pridava private boolean checkGroups(Workgroup workgroup, Member member) { if (member.equals(workgroup)) { return false; @@ -94,12 +91,15 @@ public class WorkgroupServiceImpl extends AbstractOwnedService implem if (member.isPerson()) { return true; } - - Workgroup toAdd = Workgroup.class.cast(member); + + Workgroup toAdd = Workgroup.class.cast(member); for (JobMapping jm : toAdd.getMembers()) { - if (!jm.getMember().isPerson() && !checkGroups(workgroup, jm.getMember())) { - return false; + for (JobMapping wJm : workgroup.getMembers()) { + if (jm.getMember().equals(wJm.getMember())) { + return false; + } } + } return true;