Search in sources :

Example 1 with TestProjectPrivilegeDefine

use of com.ngtesting.platform.entity.TestProjectPrivilegeDefine in project ngtesting-platform by aaronchen2k.

the class ProjectPrivilegeServiceImpl method listPrivilegesByOrgAndProjectRole.

@Override
public Map<String, List<ProjectPrivilegeDefineVo>> listPrivilegesByOrgAndProjectRole(Long orgId, Long projectRoleId) {
    List<TestProjectPrivilegeDefine> allPrivileges = listAllProjectPrivileges();
    List<TestProjectRolePriviledgeRelation> projectRolePrivileges;
    if (projectRoleId == null) {
        projectRolePrivileges = new LinkedList();
    } else {
        projectRolePrivileges = listProjectRolePrivileges(projectRoleId);
    }
    Map<String, List<ProjectPrivilegeDefineVo>> map = new LinkedHashMap<String, List<ProjectPrivilegeDefineVo>>();
    for (TestProjectPrivilegeDefine po1 : allPrivileges) {
        String key = po1.getName();
        if (!map.containsKey(key)) {
            List<ProjectPrivilegeDefineVo> vos = new LinkedList();
            map.put(key, vos);
        }
        ProjectPrivilegeDefineVo vo = genVo(orgId, po1);
        vo.setSelected(false);
        vo.setSelecting(false);
        for (TestProjectRolePriviledgeRelation po2 : projectRolePrivileges) {
            if (po1.getId().longValue() == po2.getProjectPrivilegeDefineId().longValue()) {
                vo.setSelected(true);
                vo.setSelecting(true);
                Long relationId = po2.getId();
                vo.setRelationId(relationId);
            }
        }
        map.get(key).add(vo);
    }
    return map;
}
Also used : TestProjectPrivilegeDefine(com.ngtesting.platform.entity.TestProjectPrivilegeDefine) ProjectPrivilegeDefineVo(com.ngtesting.platform.vo.ProjectPrivilegeDefineVo) TestProjectRolePriviledgeRelation(com.ngtesting.platform.entity.TestProjectRolePriviledgeRelation)

Example 2 with TestProjectPrivilegeDefine

use of com.ngtesting.platform.entity.TestProjectPrivilegeDefine in project ngtesting-platform by aaronchen2k.

the class ProjectPrivilegeServiceImpl method listAllProjectPrivileges.

@Override
public List<TestProjectPrivilegeDefine> listAllProjectPrivileges() {
    DetachedCriteria dc = DetachedCriteria.forClass(TestProjectPrivilegeDefine.class);
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.addOrder(Order.asc("id"));
    List<TestProjectPrivilegeDefine> ls = findAllByCriteria(dc);
    return ls;
}
Also used : TestProjectPrivilegeDefine(com.ngtesting.platform.entity.TestProjectPrivilegeDefine) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Aggregations

TestProjectPrivilegeDefine (com.ngtesting.platform.entity.TestProjectPrivilegeDefine)2 TestProjectRolePriviledgeRelation (com.ngtesting.platform.entity.TestProjectRolePriviledgeRelation)1 ProjectPrivilegeDefineVo (com.ngtesting.platform.vo.ProjectPrivilegeDefineVo)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1