Search in sources :

Example 1 with TbUserRole

use of com.netsteadfast.greenstep.po.hbm.TbUserRole in project bamboobsc by billchen198318.

the class RoleLogicServiceImpl method deleteUserRoleByAccount.

private void deleteUserRoleByAccount(AccountVO account) throws ServiceException, Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("account", account.getAccount());
    List<TbUserRole> userRoleList = this.userRoleService.findListByParams(params);
    if (userRoleList == null || userRoleList.size() < 1) {
        return;
    }
    for (TbUserRole userRole : userRoleList) {
        this.userRoleService.delete(userRole);
    }
}
Also used : HashMap(java.util.HashMap) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole)

Example 2 with TbUserRole

use of com.netsteadfast.greenstep.po.hbm.TbUserRole in project bamboobsc by billchen198318.

the class GreenStepBaseAuthorizingLdapRealm method getSimpleAuthorizationInfo.

private SimpleAuthorizationInfo getSimpleAuthorizationInfo(String username) throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("account", username);
    List<TbUserRole> roleList = userRoleService.findListByParams(params);
    if (roleList == null) {
        return null;
    }
    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
    for (TbUserRole userRole : roleList) {
        info.addRole(userRole.getRole());
        params.clear();
        params.put("role", userRole.getRole());
        List<TbRolePermission> rolePermissionList = rolePermissionService.findListByParams(params);
        if (rolePermissionList == null) {
            continue;
        }
        for (TbRolePermission rolePermission : rolePermissionList) {
            info.addStringPermission(rolePermission.getPermission());
        }
    }
    return info;
}
Also used : SimpleAuthorizationInfo(org.apache.shiro.authz.SimpleAuthorizationInfo) HashMap(java.util.HashMap) TbRolePermission(com.netsteadfast.greenstep.po.hbm.TbRolePermission) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole)

Example 3 with TbUserRole

use of com.netsteadfast.greenstep.po.hbm.TbUserRole in project bamboobsc by billchen198318.

the class ReportRoleViewLogicServiceImpl method findForOrganization.

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public List<BbOrganization> findForOrganization(String accountId) throws ServiceException, Exception {
    if (super.isBlank(accountId)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    List<BbOrganization> searchList = new ArrayList<BbOrganization>();
    List<TbUserRole> roles = this.getUserRoles(accountId);
    for (int i = 0; roles != null && i < roles.size(); i++) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("role", roles.get(i).getRole());
        paramMap.put("type", ReportRoleViewTypes.IS_ORGANIZATION);
        List<BbReportRoleView> views = this.reportRoleViewService.findListByParams(paramMap);
        for (int j = 0; views != null && j < views.size(); j++) {
            BbOrganization organization = new BbOrganization();
            organization.setOrgId(views.get(j).getIdName());
            organization = this.getOrganizationService().findByEntityUK(organization);
            if (organization == null) {
                continue;
            }
            boolean isFound = false;
            for (BbOrganization entity : searchList) {
                if (entity.getOid().equals(organization.getOid())) {
                    isFound = true;
                }
            }
            if (!isFound) {
                searchList.add(organization);
            }
        }
    }
    return searchList;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BbOrganization(com.netsteadfast.greenstep.po.hbm.BbOrganization) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 4 with TbUserRole

use of com.netsteadfast.greenstep.po.hbm.TbUserRole in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(EmployeeVO employee) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    employee = this.findEmployeeData(employee.getOid());
    AccountVO account = this.findAccountData(employee.getAccount());
    if (this.isAdministrator(account.getAccount())) {
        throw new ServiceException("Administrator cannot delete!");
    }
    // check account data for other table use.
    this.checkInformationRelated(account, employee);
    this.deleteEmployeeOrganization(employee);
    // delete user role
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("account", account.getAccount());
    List<TbUserRole> userRoles = this.getUserRoleService().findListByParams(params);
    for (int i = 0; userRoles != null && i < userRoles.size(); i++) {
        TbUserRole uRole = userRoles.get(i);
        this.getUserRoleService().delete(uRole);
    }
    // delete BB_REPORT_ROLE_VIEW
    params.clear();
    params.put("idName", account.getAccount());
    List<BbReportRoleView> reportRoleViews = this.reportRoleViewService.findListByParams(params);
    for (int i = 0; reportRoleViews != null && i < reportRoleViews.size(); i++) {
        BbReportRoleView reportRoleView = reportRoleViews.get(i);
        this.reportRoleViewService.delete(reportRoleView);
    }
    // delete from BB_MEASURE_DATA where EMP_ID = :empId
    this.measureDataService.deleteForEmpId(employee.getEmpId());
    this.monitorItemScoreService.deleteForEmpId(employee.getEmpId());
    this.deleteHierarchy(employee);
    this.getAccountService().deleteByPKng(account.getOid());
    return getEmployeeService().deleteObject(employee);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with TbUserRole

use of com.netsteadfast.greenstep.po.hbm.TbUserRole in project bamboobsc by billchen198318.

the class GreenStepBaseAuthorizingRealm method getSimpleAuthorizationInfo.

private SimpleAuthorizationInfo getSimpleAuthorizationInfo(String username) throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("account", username);
    List<TbUserRole> roleList = userRoleService.findListByParams(params);
    if (roleList == null) {
        return null;
    }
    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
    for (TbUserRole userRole : roleList) {
        info.addRole(userRole.getRole());
        params.clear();
        params.put("role", userRole.getRole());
        List<TbRolePermission> rolePermissionList = rolePermissionService.findListByParams(params);
        if (rolePermissionList == null) {
            continue;
        }
        for (TbRolePermission rolePermission : rolePermissionList) {
            info.addStringPermission(rolePermission.getPermission());
        }
    }
    return info;
}
Also used : SimpleAuthorizationInfo(org.apache.shiro.authz.SimpleAuthorizationInfo) HashMap(java.util.HashMap) TbRolePermission(com.netsteadfast.greenstep.po.hbm.TbRolePermission) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole)

Aggregations

TbUserRole (com.netsteadfast.greenstep.po.hbm.TbUserRole)6 HashMap (java.util.HashMap)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)3 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)3 LinkedHashMap (java.util.LinkedHashMap)3 TbRolePermission (com.netsteadfast.greenstep.po.hbm.TbRolePermission)2 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)2 BbEmployee (com.netsteadfast.greenstep.po.hbm.BbEmployee)1 BbOrganization (com.netsteadfast.greenstep.po.hbm.BbOrganization)1 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)1 ArrayList (java.util.ArrayList)1 Transactional (org.springframework.transaction.annotation.Transactional)1