Search in sources :

Example 1 with BbReportRoleView

use of com.netsteadfast.greenstep.po.hbm.BbReportRoleView 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 2 with BbReportRoleView

use of com.netsteadfast.greenstep.po.hbm.BbReportRoleView 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 3 with BbReportRoleView

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

the class OrganizationLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(OrganizationVO organization) throws ServiceException, Exception {
    if (organization == null || super.isBlank(organization.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    organization = this.findOrganizationData(organization.getOid());
    if (this.foundChild(organization)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orgId", organization.getOrgId());
    if (this.employeeOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.kpiOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaOrgaService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.pdcaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    if (this.tsaMeasureFreqService.countByParams(params) > 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
    }
    this.deleteParent(organization);
    this.swotService.deleteForOrgId(organization.getOrgId());
    // delete BB_REPORT_ROLE_VIEW
    params.clear();
    params.put("idName", organization.getOrgId());
    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 ORG_ID = :orgId
    this.measureDataService.deleteForOrgId(organization.getOrgId());
    this.monitorItemScoreService.deleteForOrgId(organization.getOrgId());
    return this.getOrganizationService().deleteObject(organization);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with BbReportRoleView

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

the class ReportRoleViewLogicServiceImpl method findForEmployeeMap.

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public Map<String, String> findForEmployeeMap(boolean pleaseSelect, String accountId) throws ServiceException, Exception {
    if (super.isBlank(accountId)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    Map<String, String> dataMap = new LinkedHashMap<String, String>();
    if (pleaseSelect) {
        dataMap.put(Constants.HTML_SELECT_NO_SELECT_ID, Constants.HTML_SELECT_NO_SELECT_NAME);
    }
    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_EMPLOYEE);
        List<BbReportRoleView> views = this.reportRoleViewService.findListByParams(paramMap);
        for (int j = 0; views != null && j < views.size(); j++) {
            paramMap.clear();
            paramMap.put("account", views.get(j).getIdName());
            List<BbEmployee> employees = this.getEmployeeService().findListByParams(paramMap);
            for (int e = 0; employees != null && e < employees.size(); e++) {
                BbEmployee employee = employees.get(e);
                if (dataMap.get(employee.getOid()) != null) {
                    continue;
                }
                dataMap.put(employee.getOid(), employee.getFullName());
            }
        }
    }
    return dataMap;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole) LinkedHashMap(java.util.LinkedHashMap) BbEmployee(com.netsteadfast.greenstep.po.hbm.BbEmployee) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)4 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 TbUserRole (com.netsteadfast.greenstep.po.hbm.TbUserRole)3 Transactional (org.springframework.transaction.annotation.Transactional)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