Oprevaná chyba v metodě pro získání rolí s určitým oprávněním. Nešly

otevřít Procesy schválení.
multitenant
Josef Rokos 10 years ago
parent 803bebeb88
commit 9f8eba2cb4

@ -12,8 +12,8 @@ public interface RoleService extends Service<Role> {
public Role getRoleByAuthority(String authority); public Role getRoleByAuthority(String authority);
public List<Role> getWorkgroupRoles(); public List<Role> getWorkgroupRoles();
public List<Role> getCentreRoles(); public List<Role> getCentreRoles();
public List<Role> getRolesWithPermission(Permission perm, boolean centre); public List<Role> getRolesWithPermission(Permission perm, String modileId, boolean centre);
public List<Role> getRolesWithPermission(String authority, boolean centre); public List<Role> getRolesWithPermission(String authority, String modileId, boolean centre);
public boolean canChangeCenter(Role role); public boolean canChangeCenter(Role role);
public boolean canChangeWorkgroup(Role role); public boolean canChangeWorkgroup(Role role);
public boolean isInWorkflow(Role role); public boolean isInWorkflow(Role role);

@ -35,7 +35,7 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@Transactional @Transactional
public List<Role> getRolesWithPermission(Permission perm, boolean centre) { public List<Role> getRolesWithPermission(Permission perm, String moduleId, boolean centre) {
String wgClausule; String wgClausule;
if (centre) { if (centre) {
wgClausule = "centre"; wgClausule = "centre";
@ -44,17 +44,18 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
} }
Set<Permission> perms = new HashSet<Permission>(); Set<Permission> perms = new HashSet<Permission>();
perms.add(perm); 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.setParameterList("perms", perms);
q.setParameter("module", moduleId);
return q.list(); return q.list();
} }
@Override @Override
@Transactional @Transactional
public List<Role> getRolesWithPermission(String authority, boolean centre) { public List<Role> getRolesWithPermission(String authority, String moduleId, boolean centre) {
Query q = dao.getQuery("from Permission where authority = '" + authority + "'"); Query q = dao.getQuery("from Permission where authority = '" + authority + "' and module = '" + moduleId + "'");
Permission p = (Permission) q.uniqueResult(); Permission p = (Permission) q.uniqueResult();
return getRolesWithPermission(p, centre); return getRolesWithPermission(p, moduleId, centre);
} }
@Override @Override

@ -44,8 +44,21 @@ public class RequirementTypesVM {
} }
private void initRoles() { private void initRoles() {
centreRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, true)); String moduleId;
workgroupRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, false));
if (selected != null) {
if (selected.getType().equals(Constants.REQTYPE_BUSINESSTRIP)) {
moduleId = Constants.MOD_TRIPREQUIREMENTS;
} else {
moduleId = Constants.MOD_REQUIREMENTS;
}
centreRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, moduleId, true));
workgroupRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, moduleId, false));
} else {
centreRoles = null;
workgroupRoles = null;
}
} }
@Command @Command
@ -196,6 +209,8 @@ public class RequirementTypesVM {
return; return;
} }
this.selected = selected;
initRoles(); initRoles();
for (Workflow w : selected.getWorkflow()) { for (Workflow w : selected.getWorkflow()) {
@ -205,8 +220,6 @@ public class RequirementTypesVM {
workgroupRoles.remove(w.getRole()); workgroupRoles.remove(w.getRole());
} }
} }
this.selected = selected;
} }
@Command @Command

@ -1,7 +1,8 @@
<?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?> <?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?>
<zk> <zk>
<window border="normal" apply="org.zkoss.bind.BindComposer" <window border="normal" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementTypesVM')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementTypesVM')"
vflex="1">
<caption zclass="form-caption" label="${labels.AgendaWorkflow}" /> <caption zclass="form-caption" label="${labels.AgendaWorkflow}" />
<vbox> <vbox>
<hbox> <hbox>

Loading…
Cancel
Save