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 List<Role> getWorkgroupRoles();
public List<Role> getCentreRoles();
public List<Role> getRolesWithPermission(Permission perm, boolean centre);
public List<Role> getRolesWithPermission(String authority, boolean centre);
public List<Role> getRolesWithPermission(Permission perm, String modileId, boolean centre);
public List<Role> getRolesWithPermission(String authority, String modileId, boolean centre);
public boolean canChangeCenter(Role role);
public boolean canChangeWorkgroup(Role role);
public boolean isInWorkflow(Role role);

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

@ -44,8 +44,21 @@ public class RequirementTypesVM {
}
private void initRoles() {
centreRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, true));
workgroupRoles = new ArrayList<Role>(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<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
@ -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

@ -1,7 +1,8 @@
<?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?>
<zk>
<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}" />
<vbox>
<hbox>

Loading…
Cancel
Save