Search in sources :

Example 96 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<EmployeeVO> update(EmployeeVO employee, List<String> organizationOid) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    EmployeeVO dbEmployee = this.findEmployeeData(employee.getOid());
    this.deleteEmployeeOrganization(dbEmployee);
    employee.setAccount(dbEmployee.getAccount());
    employee.setEmpId(dbEmployee.getEmpId());
    DefaultResult<EmployeeVO> result = this.getEmployeeService().updateObject(employee);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.createEmployeeOrganization(result.getValue(), organizationOid);
    return result;
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 97 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class EmployeeLogicServiceImpl method updateSupervisor.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> updateSupervisor(EmployeeVO employee, String supervisorOid) throws ServiceException, Exception {
    if (employee == null || super.isBlank(employee.getOid()) || super.isBlank(supervisorOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.FALSE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    employee = this.findEmployeeData(employee.getOid());
    this.deleteHierarchy(employee);
    if ("root".equals(supervisorOid) || "r".equals(supervisorOid)) {
        this.createHierarchy(employee, BscConstants.EMPLOYEE_HIER_ZERO_OID);
    } else {
        EmployeeVO newHierEmployee = this.findEmployeeData(supervisorOid);
        // 找當前員工的的資料, 不因該存在要update的新關聯主管
        if (this.foundChild(employee.getOid(), newHierEmployee.getOid())) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        this.createHierarchy(employee, newHierEmployee.getOid());
    }
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 98 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException 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 99 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class PdcaLogicServiceImpl method createDocuments.

private void createDocuments(PdcaVO pdca, List<String> attachment) throws ServiceException, Exception {
    if (attachment == null || attachment.size() < 1) {
        return;
    }
    for (String oid : attachment) {
        SysUploadVO upload = this.findUploadDataForNoByteContent(oid);
        if (!(upload.getSystem().equals(Constants.getSystem()) && upload.getType().equals(UploadTypes.IS_TEMP))) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        PdcaDocVO pdcaDoc = new PdcaDocVO();
        pdcaDoc.setPdcaOid(pdca.getOid());
        pdcaDoc.setUploadOid(upload.getOid());
        pdcaDoc.setViewMode(UploadSupportUtils.getViewMode(upload.getShowName()));
        DefaultResult<PdcaDocVO> result = this.pdcaDocService.saveObject(pdcaDoc);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        UploadSupportUtils.updateType(oid, UploadTypes.IS_PDCA_DOCUMENT);
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) PdcaDocVO(com.netsteadfast.greenstep.vo.PdcaDocVO) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO)

Example 100 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class PdcaLogicServiceImpl method findPdca.

private PdcaVO findPdca(String oid) throws ServiceException, Exception {
    PdcaVO pdca = new PdcaVO();
    pdca.setOid(oid);
    DefaultResult<PdcaVO> result = this.pdcaService.findObjectByOid(pdca);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    pdca = result.getValue();
    return pdca;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) PdcaVO(com.netsteadfast.greenstep.vo.PdcaVO)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)291 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)91 Transactional (org.springframework.transaction.annotation.Transactional)89 HashMap (java.util.HashMap)65 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)49 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)48 SysVO (com.netsteadfast.greenstep.vo.SysVO)30 IOException (java.io.IOException)24 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)20 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)19 List (java.util.List)19 Map (java.util.Map)19 ArrayList (java.util.ArrayList)17 LinkedHashMap (java.util.LinkedHashMap)17 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)16 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)15 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)15 SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)14 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)13 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)12