|
|
|
@ -34,11 +34,7 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> 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<Workgroup> 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<Workgroup> 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;
|
|
|
|
|