Search in sources :

Example 81 with ServiceException

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

the class OrganizationLogicServiceImpl method getOrgChartData.

/**
	 * 這個 Method 的 ServiceMethodAuthority 權限給查詢狀態
	 * 這裡的 basePath 只是要取 getTreeData 時參數要用, 再這是沒有用處的
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public DefaultResult<Map<String, Object>> getOrgChartData(String basePath, OrganizationVO currentOrganization) throws ServiceException, Exception {
    if (null != currentOrganization && !super.isBlank(currentOrganization.getOid())) {
        currentOrganization = this.findOrganizationData(currentOrganization.getOid());
    }
    List<Map<String, Object>> treeMap = this.getTreeData(basePath, false, "");
    if (null == treeMap || treeMap.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    this.resetTreeMapContentForOrgChartData(treeMap, currentOrganization);
    Map<String, Object> rootMap = new HashMap<String, Object>();
    rootMap.put("name", "Organization / Department hierarchy");
    rootMap.put("title", "hierarchy structure");
    rootMap.put("children", treeMap);
    DefaultResult<Map<String, Object>> result = new DefaultResult<Map<String, Object>>();
    result.setValue(rootMap);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 82 with ServiceException

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

the class ImportDataLogicServiceImpl method importMeasureData.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importMeasureData(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN005");
    if (csvResults.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    boolean success = false;
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    StringBuilder msg = new StringBuilder();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String kpiId = data.get("KPI_ID");
        String date = data.get("DATE");
        String target = data.get("TARGET");
        String actual = data.get("ACTUAL");
        String frequency = data.get("FREQUENCY");
        String orgId = data.get("ORG_ID");
        String empId = data.get("EMP_ID");
        if (super.isBlank(kpiId)) {
            msg.append("row: " + row + " kpi id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(date)) {
            msg.append("row: " + row + " date is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(target)) {
            msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(actual)) {
            msg.append("row: " + row + " actual is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(frequency)) {
            msg.append("row: " + row + " frequency is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(orgId)) {
            msg.append("row: " + row + " organization-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(empId)) {
            msg.append("row: " + row + " employee-no is blank." + Constants.HTML_BR);
            continue;
        }
        if (!SimpleUtils.isDate(date)) {
            msg.append("row: " + row + " is not date " + date + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(target)) {
            msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(actual)) {
            msg.append("row: " + row + " actual is not number." + Constants.HTML_BR);
            continue;
        }
        if (BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) == null) {
            msg.append("row: " + row + " frequency is not found." + Constants.HTML_BR);
            continue;
        }
        paramMap.clear();
        paramMap.put("id", kpiId);
        if (this.kpiService.countByParams(paramMap) < 1) {
            msg.append("row: " + row + " KPI is not found " + kpiId + Constants.HTML_BR);
            continue;
        }
        if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId)) {
            paramMap.clear();
            paramMap.put("orgId", orgId);
            if (this.organizationService.countByParams(paramMap) < 1) {
                msg.append("row: " + row + " organization-id is not found " + orgId + Constants.HTML_BR);
                continue;
            }
        }
        if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId)) {
            paramMap.clear();
            paramMap.put("empId", empId);
            if (this.employeeService.countByParams(paramMap) < 1) {
                msg.append("row: " + row + " employee-no is not found " + empId + Constants.HTML_BR);
                continue;
            }
        }
        MeasureDataVO measureData = new MeasureDataVO();
        measureData.setKpiId(kpiId);
        measureData.setDate(date);
        measureData.setTarget(Float.valueOf(target));
        measureData.setActual(Float.valueOf(actual));
        measureData.setFrequency(frequency);
        measureData.setOrgId(orgId);
        measureData.setEmpId(empId);
        DefaultResult<MeasureDataVO> oldResult = this.measureDataService.findByUK(measureData);
        if (oldResult.getValue() != null) {
            // update
            measureData.setOid(oldResult.getValue().getOid());
            this.measureDataService.updateObject(measureData);
        } else {
            // insert
            this.measureDataService.saveObject(measureData);
        }
        success = true;
    }
    if (msg.length() > 0) {
        result.setSystemMessage(new SystemMessage(msg.toString()));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    }
    result.setValue(success);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) HashMap(java.util.HashMap) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) MeasureDataVO(com.netsteadfast.greenstep.vo.MeasureDataVO) Map(java.util.Map) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 83 with ServiceException

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

the class KpiLogicServiceImpl method findKpis.

/**
	 * for TEST
	 * 這是測試 WS REST 用的  metod , 暴露 KPIs 主檔資料
	 * 
	 * rest address: http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/
	 * 
	 * json:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/json
	 * 
	 * xml:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/xml
	 * 
	 * @param format			example:	xml / json
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@WebMethod
@GET
@Path("/kpis/{format}")
@Override
public String findKpis(@WebParam(name = "format") @PathParam("format") String format) throws ServiceException, Exception {
    List<KpiVO> kpis = null;
    try {
        kpis = this.kpiService.findListVOByParams(null);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (null == kpis) {
            kpis = new ArrayList<KpiVO>();
        }
    }
    if ("json".equals(format)) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("KPIS", kpis);
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(paramMap);
    }
    XStream xstream = new XStream();
    //xstream.registerConverter( new DateConverter() );
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("KPIS", List.class);
    xstream.alias("KPI", KpiVO.class);
    return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xstream.toXML(kpis);
}
Also used : HashMap(java.util.HashMap) XStream(com.thoughtworks.xstream.XStream) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 84 with ServiceException

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

the class PerspectiveLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<PerspectiveVO> update(PerspectiveVO perspective, String visionOid) throws ServiceException, Exception {
    if (null == perspective || super.isBlank(perspective.getOid()) || super.isBlank(visionOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<PerspectiveVO> oldResult = this.perspectiveService.findObjectByOid(perspective);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    DefaultResult<VisionVO> vResult = this.visionService.findForSimple(visionOid);
    if (vResult.getValue() == null) {
        throw new ServiceException(vResult.getSystemMessage().getValue());
    }
    VisionVO vision = vResult.getValue();
    perspective.setVisId(vision.getVisId());
    perspective.setPerId(oldResult.getValue().getPerId());
    this.setStringValueMaxLength(perspective, "description", MAX_DESCRIPTION_LENGTH);
    return this.perspectiveService.updateObject(perspective);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 85 with ServiceException

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

the class ReportRoleViewLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> create(String roleOid, List<String> emplOids, List<String> orgaOids) throws ServiceException, Exception {
    if (super.isNoSelectId(roleOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    RoleVO role = new RoleVO();
    role.setOid(roleOid);
    DefaultResult<RoleVO> rResult = this.getRoleService().findObjectByOid(role);
    if (rResult.getValue() == null) {
        throw new ServiceException(rResult.getSystemMessage().getValue());
    }
    role = rResult.getValue();
    this.deleteByRole(role.getRole());
    for (int i = 0; emplOids != null && i < emplOids.size(); i++) {
        EmployeeVO employee = this.findEmployeeData(emplOids.get(i));
        this.createReportRoleView(role.getRole(), ReportRoleViewTypes.IS_EMPLOYEE, employee.getAccount());
    }
    for (int i = 0; orgaOids != null && i < orgaOids.size(); i++) {
        OrganizationVO organization = this.findOrganizationData(orgaOids.get(i));
        this.createReportRoleView(role.getRole(), ReportRoleViewTypes.IS_ORGANIZATION, organization.getOrgId());
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    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) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

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