Search in sources :

Example 46 with ServiceException

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

the class SystemJreportLogicServiceImpl method createParam.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysJreportParamVO> createParam(SysJreportParamVO reportParam, String reportOid) throws ServiceException, Exception {
    if (reportParam == null || super.isBlank(reportOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysJreportVO> mResult = this.sysJreportService.findForSimple(reportOid);
    if (mResult.getValue() == null) {
        throw new ServiceException(mResult.getSystemMessage().getValue());
    }
    SysJreportVO report = mResult.getValue();
    reportParam.setReportId(report.getReportId());
    return this.sysJreportParamService.saveObject(reportParam);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysJreportVO(com.netsteadfast.greenstep.vo.SysJreportVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 47 with ServiceException

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

the class ApplicationSystemLogicServiceImpl method update.

/**
	 * 更新 TB_SYS 資料
	 * 
	 * @param sys
	 * @param iconOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysVO> update(SysVO sys, String iconOid) throws ServiceException, Exception {
    if (null == sys || StringUtils.isBlank(sys.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysIconVO sysIcon = new SysIconVO();
    sysIcon.setOid(iconOid);
    DefaultResult<SysIconVO> iconResult = this.sysIconService.findObjectByOid(sysIcon);
    if (iconResult.getValue() == null) {
        throw new ServiceException(iconResult.getSystemMessage().getValue());
    }
    sys.setIcon(iconResult.getValue().getIconId());
    return this.sysService.updateObject(sys);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysIconVO(com.netsteadfast.greenstep.vo.SysIconVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 48 with ServiceException

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

the class RoleLogicServiceImpl method findForProgramRoleEnableAndAll.

/**
	 * 找出全部的role與某程式menu所屬的role
	 * 
	 * map 中的  key 
	 * enable	- 程式menu的role
	 * all	- 所有role
	 * 
	 * @param programOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@Override
public Map<String, List<RoleVO>> findForProgramRoleEnableAndAll(String programOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(programOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysProgVO sysProg = new SysProgVO();
    sysProg.setOid(programOid);
    DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
    if (spResult.getValue() == null) {
        throw new ServiceException(spResult.getSystemMessage().getValue());
    }
    sysProg = spResult.getValue();
    Map<String, List<RoleVO>> roleMap = new HashMap<String, List<RoleVO>>();
    List<RoleVO> enableRole = this.roleService.findForProgram(sysProg.getProgId());
    List<RoleVO> allRole = this.roleService.findForAll();
    roleMap.put("enable", enableRole);
    roleMap.put("all", allRole);
    return roleMap;
}
Also used : UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) List(java.util.List)

Example 49 with ServiceException

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

the class RoleLogicServiceImpl method copyAsNew.

/**
	 * 拷備一份role
	 * 
	 * @param fromRoleOid
	 * @param role
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<RoleVO> copyAsNew(String fromRoleOid, RoleVO role) throws ServiceException, Exception {
    if (role == null || super.isBlank(role.getRole()) || super.isBlank(fromRoleOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    super.setStringValueMaxLength(role, "description", MAX_DESCRIPTION_LENGTH);
    DefaultResult<RoleVO> result = this.roleService.saveObject(role);
    RoleVO oldRole = new RoleVO();
    oldRole.setOid(fromRoleOid);
    DefaultResult<RoleVO> fromResult = this.roleService.findObjectByOid(oldRole);
    if (fromResult.getValue() == null) {
        throw new ServiceException(fromResult.getSystemMessage().getValue());
    }
    oldRole = fromResult.getValue();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("role", oldRole.getRole());
    List<TbRolePermission> permissions = this.rolePermissionService.findListByParams(paramMap);
    for (int i = 0; permissions != null && i < permissions.size(); i++) {
        RolePermissionVO permission = new RolePermissionVO();
        this.rolePermissionService.fillToValueObject(permission, permissions.get(i));
        permission.setOid(null);
        permission.setRole(result.getValue().getRole());
        this.rolePermissionService.saveObject(permission);
    }
    // 選單menu role 也copy一份
    List<TbSysMenuRole> menuRoles = this.sysMenuRoleService.findListByParams(paramMap);
    for (int i = 0; menuRoles != null && i < menuRoles.size(); i++) {
        SysMenuRoleVO menuRole = new SysMenuRoleVO();
        this.sysMenuRoleService.fillToValueObject(menuRole, menuRoles.get(i));
        menuRole.setOid(null);
        menuRole.setRole(result.getValue().getRole());
        this.sysMenuRoleService.saveObject(menuRole);
    }
    return result;
}
Also used : SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) TbSysMenuRole(com.netsteadfast.greenstep.po.hbm.TbSysMenuRole) HashMap(java.util.HashMap) TbRolePermission(com.netsteadfast.greenstep.po.hbm.TbRolePermission) RolePermissionVO(com.netsteadfast.greenstep.vo.RolePermissionVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 50 with ServiceException

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

the class RoleLogicServiceImpl method getDefaultUserRole.

/**
	 * 使用者設的role-id(角色), 它設定在 tb_sys_code中
	 * 
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
public String getDefaultUserRole() throws ServiceException, Exception {
    String role = "";
    SysCodeVO sysCode = new SysCodeVO();
    sysCode.setType(DEFAULT_ROLE_CODE_TYPE);
    sysCode.setCode(DEFAULT_ROLE_CODE);
    DefaultResult<SysCodeVO> result = this.sysCodeService.findByUK(sysCode);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    sysCode = result.getValue();
    role = sysCode.getParam1();
    if (super.isBlank(role)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("role", role);
    if (this.roleService.countByParams(params) != 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    return role;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) SysCodeVO(com.netsteadfast.greenstep.vo.SysCodeVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

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