diff --git a/src/main/java/info/bukova/isspst/services/users/RoleService.java b/src/main/java/info/bukova/isspst/services/users/RoleService.java index 9b9349f8..014c0dc4 100644 --- a/src/main/java/info/bukova/isspst/services/users/RoleService.java +++ b/src/main/java/info/bukova/isspst/services/users/RoleService.java @@ -12,8 +12,8 @@ public interface RoleService extends Service { public Role getRoleByAuthority(String authority); public List getWorkgroupRoles(); public List getCentreRoles(); - public List getRolesWithPermission(Permission perm, boolean centre); - public List getRolesWithPermission(String authority, boolean centre); + public List getRolesWithPermission(Permission perm, String modileId, boolean centre); + public List getRolesWithPermission(String authority, String modileId, boolean centre); public boolean canChangeCenter(Role role); public boolean canChangeWorkgroup(Role role); public boolean isInWorkflow(Role role); diff --git a/src/main/java/info/bukova/isspst/services/users/RoleServiceImpl.java b/src/main/java/info/bukova/isspst/services/users/RoleServiceImpl.java index 070d6449..0b24be16 100644 --- a/src/main/java/info/bukova/isspst/services/users/RoleServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/users/RoleServiceImpl.java @@ -35,7 +35,7 @@ public class RoleServiceImpl extends AbstractService implements RoleServic @SuppressWarnings("unchecked") @Override @Transactional - public List getRolesWithPermission(Permission perm, boolean centre) { + public List getRolesWithPermission(Permission perm, String moduleId, boolean centre) { String wgClausule; if (centre) { wgClausule = "centre"; @@ -44,17 +44,18 @@ public class RoleServiceImpl extends AbstractService implements RoleServic } Set perms = new HashSet(); perms.add(perm); - Query q = dao.getQuery("select r from Role r join r.permissions p where r." + wgClausule + " = true and p in (:perms)"); + Query q = dao.getQuery("select r from Role r join r.permissions p where r." + wgClausule + " = true and p.module = :module and p in (:perms)"); q.setParameterList("perms", perms); + q.setParameter("module", moduleId); return q.list(); } @Override @Transactional - public List getRolesWithPermission(String authority, boolean centre) { - Query q = dao.getQuery("from Permission where authority = '" + authority + "'"); + public List getRolesWithPermission(String authority, String moduleId, boolean centre) { + Query q = dao.getQuery("from Permission where authority = '" + authority + "' and module = '" + moduleId + "'"); Permission p = (Permission) q.uniqueResult(); - return getRolesWithPermission(p, centre); + return getRolesWithPermission(p, moduleId, centre); } @Override diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java index 4eb86c16..597ecdd8 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java @@ -44,8 +44,21 @@ public class RequirementTypesVM { } private void initRoles() { - centreRoles = new ArrayList(roleService.getRolesWithPermission(Constants.PERM_APPROVE, true)); - workgroupRoles = new ArrayList(roleService.getRolesWithPermission(Constants.PERM_APPROVE, false)); + String moduleId; + + if (selected != null) { + if (selected.getType().equals(Constants.REQTYPE_BUSINESSTRIP)) { + moduleId = Constants.MOD_TRIPREQUIREMENTS; + } else { + moduleId = Constants.MOD_REQUIREMENTS; + } + + centreRoles = new ArrayList(roleService.getRolesWithPermission(Constants.PERM_APPROVE, moduleId, true)); + workgroupRoles = new ArrayList(roleService.getRolesWithPermission(Constants.PERM_APPROVE, moduleId, false)); + } else { + centreRoles = null; + workgroupRoles = null; + } } @Command @@ -196,6 +209,8 @@ public class RequirementTypesVM { return; } + this.selected = selected; + initRoles(); for (Workflow w : selected.getWorkflow()) { @@ -205,8 +220,6 @@ public class RequirementTypesVM { workgroupRoles.remove(w.getRole()); } } - - this.selected = selected; } @Command diff --git a/src/main/webapp/settings/workflow/workflow.zul b/src/main/webapp/settings/workflow/workflow.zul index f10844da..663b06bd 100644 --- a/src/main/webapp/settings/workflow/workflow.zul +++ b/src/main/webapp/settings/workflow/workflow.zul @@ -1,7 +1,8 @@ + viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementTypesVM')" + vflex="1">