Uživatele a komisi nelze smazat, pokud jsou členem některého střediska,
nebo komise. closes #178
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package info.bukova.isspst.services.users;
|
||||
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
|
||||
public class DeleteUserException extends IsspstException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5326664758639660224L;
|
||||
|
||||
public DeleteUserException(String message) {
|
||||
super(message);
|
||||
setReason(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import info.bukova.isspst.services.AbstractService;
|
||||
import info.bukova.isspst.services.StringXmlMarshaller;
|
||||
//import info.bukova.isspst.services.LazyLoader;
|
||||
|
||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -35,6 +36,8 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
private PasswordEncoder encoder;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private WorkgroupService workgroupService;
|
||||
private StringXmlMarshaller<UserSettingsData> marshaller;
|
||||
private AuthMethod authMethod;
|
||||
|
||||
@@ -216,4 +219,15 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
return authMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(User entity) {
|
||||
workgroupService.loadParents(entity);
|
||||
|
||||
if (entity.getParents().isEmpty()) {
|
||||
super.delete(entity);
|
||||
} else {
|
||||
throw new DeleteUserException("UserIsInWorkgroup");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ public class WorkgroupException extends IsspstException {
|
||||
public final static String MSUT_HAS_CENTER = "RoleMustHasCentre";
|
||||
public final static String MUST_HAS_WORKGROUP = "WorkgroupMustHasCentre";
|
||||
public final static String CYCLIC_MEMBER = "CyclicMembership";
|
||||
public final static String HAS_PARENT = "WorkgroupIsInWorkgroup";
|
||||
|
||||
public WorkgroupException(String message) {
|
||||
super(message);
|
||||
setReason(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -248,6 +248,11 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_DELETE')")
|
||||
public void delete(Workgroup entity) {
|
||||
Workgroup dbWg = dao.getById(entity.getId());
|
||||
if (!dbWg.getParents().isEmpty()) {
|
||||
throw new WorkgroupException(WorkgroupException.HAS_PARENT);
|
||||
}
|
||||
|
||||
loadMembers(entity);
|
||||
for (JobMapping m : entity.getMembers()) {
|
||||
loadParents(m.getMember());
|
||||
|
||||
@@ -3,6 +3,7 @@ package info.bukova.isspst.ui;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.filters.Filter;
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -202,6 +203,18 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
||||
BindUtils.postNotifyChange(null, null,
|
||||
ListViewModel.this, "dataBean");
|
||||
BindUtils.postGlobalCommand(null, null, "reloadRelated", null);
|
||||
} catch (IsspstException e) {
|
||||
if (e.getReason() != null) {
|
||||
Messagebox.show(
|
||||
StringUtils.localize(e.getReason()),
|
||||
StringUtils.localize("Error"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
} else {
|
||||
Messagebox.show(
|
||||
StringUtils.localize("DbSaveError"),
|
||||
StringUtils.localize("Error"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
}
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
Messagebox.show(StringUtils.localize("DbCannotDelete"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR);
|
||||
} catch (AccessDeniedException e) {
|
||||
|
||||
@@ -117,6 +117,7 @@ UsersGridColumnLogin=Login
|
||||
UsersGridColumnPersonalID=Osobní číslo
|
||||
UsersGridColumnFirstName=Jméno
|
||||
UsersGridColumnSureName=Příjmení
|
||||
UserIsInWorkgroup=Uživatele nelze smazat, protože je členem některé pracovní skupiny
|
||||
|
||||
AgendaMaterial=Skupiny materiálu
|
||||
MaterialFormTitle=Skupina materiálu
|
||||
@@ -354,3 +355,4 @@ WorkgroupFormMemberIsCenterMember=Některý ze členů přidávané komise je č
|
||||
WorkgroupFormCannotAddUser=Uživatele nelze přidat
|
||||
WorkgroupFormCannotAddWorkgroup=Komisi nelze přidat
|
||||
WorkgroupFormOrderLimit=Limit nákupů
|
||||
WorkgroupIsInWorkgroup=Komisi nelze smazat, protože je členem některého střediska
|
||||
|
||||
Reference in New Issue
Block a user