Search in sources :

Example 86 with ServiceException

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

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

the class ReportRoleViewLogicServiceImpl method findForOrganizationMap.

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public Map<String, String> findForOrganizationMap(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_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.organizationService.findByEntityUK(organization);
				if ( organization == null ) {
					continue;
				}
				if ( dataMap.get(organization.getOid()) != null ) {
					continue;
				}
				dataMap.put(organization.getOid(), organization.getName());				
			}
		}		
		*/
    List<BbOrganization> organizations = this.findForOrganization(accountId);
    for (BbOrganization entity : organizations) {
        if (dataMap.get(entity.getOid()) != null) {
            continue;
        }
        dataMap.put(entity.getOid(), entity.getName());
    }
    return dataMap;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BbOrganization(com.netsteadfast.greenstep.po.hbm.BbOrganization) LinkedHashMap(java.util.LinkedHashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 88 with ServiceException

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

the class KpiLogicServiceImpl method createKpiAttachment.

private void createKpiAttachment(KpiVO kpi, List<String> attachment) throws ServiceException, Exception {
    if (kpi == null || attachment == null || attachment.size() < 1) {
        return;
    }
    for (String uploadOid : attachment) {
        SysUploadVO upload = this.findUploadDataForNoByteContent(uploadOid);
        if (!(upload.getSystem().equals(Constants.getSystem()) && upload.getType().equals(UploadTypes.IS_TEMP))) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        KpiAttacVO attac = new KpiAttacVO();
        attac.setKpiId(kpi.getId());
        attac.setUploadOid(uploadOid);
        attac.setViewMode(UploadSupportUtils.getViewMode(upload.getShowName()));
        DefaultResult<KpiAttacVO> result = this.kpiAttacService.saveObject(attac);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        //this.sysUploadService.updateTypeOnly(uploadOid, UploadTypes.IS_KPI_DOCUMENT);
        UploadSupportUtils.updateType(uploadOid, UploadTypes.IS_KPI_DOCUMENT);
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) KpiAttacVO(com.netsteadfast.greenstep.vo.KpiAttacVO)

Example 89 with ServiceException

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

the class MeasureDataLogicServiceImpl method saveOrUpdate.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE, ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> saveOrUpdate(String kpiOid, String date, String frequency, String dataFor, String organizationId, String employeeId, List<MeasureDataVO> measureDatas) throws ServiceException, Exception {
    if (super.isBlank(kpiOid) || super.isBlank(date) || super.isBlank(frequency) || super.isBlank(dataFor) || super.isBlank(organizationId) || super.isBlank(employeeId)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    KpiVO kpi = new KpiVO();
    kpi.setOid(kpiOid);
    DefaultResult<KpiVO> kResult = this.kpiService.findObjectByOid(kpi);
    if (kResult.getValue() == null) {
        throw new ServiceException(kResult.getSystemMessage().getValue());
    }
    kpi = kResult.getValue();
    this.getOrganizationId(organizationId);
    this.getEmployeeId(employeeId);
    if (BscConstants.MEASURE_DATA_FOR_ORGANIZATION.equals(dataFor) && BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(organizationId)) {
        throw new ServiceException("organization is required!");
    }
    if (BscConstants.MEASURE_DATA_FOR_EMPLOYEE.equals(dataFor) && BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(employeeId)) {
        throw new ServiceException("employee is required!");
    }
    this.fillMeasureDatas(kpi, organizationId, employeeId, measureDatas);
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    result.setValue(Boolean.FALSE);
    this.delete(kpi, date, frequency, organizationId, employeeId);
    for (MeasureDataVO measureData : measureDatas) {
        this.measureDataService.saveObject(measureData);
    }
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    result.setValue(Boolean.TRUE);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) MeasureDataVO(com.netsteadfast.greenstep.vo.MeasureDataVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 90 with ServiceException

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

the class ObjectiveLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<ObjectiveVO> create(ObjectiveVO objective, String perspectiveOid) throws ServiceException, Exception {
    if (null == objective || super.isBlank(perspectiveOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    PerspectiveVO perspective = new PerspectiveVO();
    perspective.setOid(perspectiveOid);
    DefaultResult<PerspectiveVO> pResult = this.perspectiveService.findObjectByOid(perspective);
    if (pResult.getValue() == null) {
        throw new ServiceException(pResult.getSystemMessage().getValue());
    }
    perspective = pResult.getValue();
    objective.setPerId(perspective.getPerId());
    if (!SimpleUtils.checkBeTrueOf_azAZ09(4, 14, objective.getObjId())) {
        // for import-mode from csv file OBJ_ID is old(before id).
        objective.setObjId(this.findForMaxObjId(SimpleUtils.getStrYMD("")));
    }
    this.setStringValueMaxLength(objective, "description", MAX_DESCRIPTION_LENGTH);
    return this.objectiveService.saveObject(objective);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) 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