Search in sources :

Example 1 with DataQueryMapperVO

use of com.netsteadfast.greenstep.vo.DataQueryMapperVO in project bamboobsc by billchen198318.

the class DataQueryMapperSaveOrUpdateAction method update.

private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    DataQueryMapperVO queryMapper = new DataQueryMapperVO();
    this.transformFields2ValueObject(queryMapper, new String[] { "oid", "name", "description" });
    DefaultResult<DataQueryMapperVO> result = this.dataQueryMapperLogicService.updateMapper(queryMapper, this.fillFieldsMapperData());
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : DataQueryMapperVO(com.netsteadfast.greenstep.vo.DataQueryMapperVO)

Example 2 with DataQueryMapperVO

use of com.netsteadfast.greenstep.vo.DataQueryMapperVO in project bamboobsc by billchen198318.

the class DataQueryMapperLogicServiceImpl method updateMapper.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<DataQueryMapperVO> updateMapper(DataQueryMapperVO queryMapper, List<Map<String, String>> fieldsData) throws ServiceException, Exception {
    if (null == queryMapper || super.isBlank(queryMapper.getOid()) || null == fieldsData || fieldsData.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    // name 是 UK , 修改之前要檢查是否重復
    DataQueryMapperVO checkQueryMapper = new DataQueryMapperVO();
    checkQueryMapper.setName(queryMapper.getName());
    DefaultResult<DataQueryMapperVO> checkResult = this.dataQueryMapperService.findByUK(checkQueryMapper);
    if (checkResult.getValue() != null) {
        checkQueryMapper = checkResult.getValue();
        if (!checkQueryMapper.getOid().equals(queryMapper.getOid())) {
            // 有別筆資料的 name (UK) 相同
            throw new ServiceException("Please change name!");
        }
    }
    this.deleteMapperSet(queryMapper);
    this.createMapperSet(queryMapper, fieldsData);
    return this.dataQueryMapperService.updateObject(queryMapper);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DataQueryMapperVO(com.netsteadfast.greenstep.vo.DataQueryMapperVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DataQueryMapperVO

use of com.netsteadfast.greenstep.vo.DataQueryMapperVO in project bamboobsc by billchen198318.

the class ChartsDataUtils method getHighchartsSeriesData.

/*
	public static List<String> getHighchartsBarCategories(String dataQueryMapperSetOid, 
			List<Map<String, Object>> searchDatas) throws ServiceException, Exception {
		if (StringUtils.isBlank(dataQueryMapperSetOid)) {
			throw new Exception("Mapper config is required!");
		}
		List<String> data = new LinkedList<String>();
		if (null==searchDatas || searchDatas.size()<1) {
			return data;
		}
		DataQueryMapperSetVO mapperSet = new DataQueryMapperSetVO();
		mapperSet.setOid(dataQueryMapperSetOid);
		DefaultResult<DataQueryMapperSetVO> result = dataQueryMapperSetService.findObjectByOid(mapperSet);
		if (result.getValue()==null) {
			throw new ServiceException(result.getSystemMessage().getValue());
		}
		mapperSet = result.getValue();
		for (Map<String, Object> searchDataMap : searchDatas) {
			String label = (String)searchDataMap.get( mapperSet.getLabelField() );
			if (StringUtils.isBlank(label)) {
				throw new Exception("Mapper label field not found!");
			}
			data.add(label);
		}		
		return data;
	}
	*/
public static List<Map<String, Object>> getHighchartsSeriesData(String dataQueryMapperOid, List<String> categories, List<Map<String, Object>> searchDatas) throws ServiceException, Exception {
    if (StringUtils.isBlank(dataQueryMapperOid)) {
        throw new Exception("Mapper config is required!");
    }
    List<Map<String, Object>> data = new LinkedList<Map<String, Object>>();
    if (null == searchDatas || searchDatas.size() < 1 || null == categories || categories.size() < 1) {
        return data;
    }
    DataQueryMapperVO mapper = new DataQueryMapperVO();
    mapper.setOid(dataQueryMapperOid);
    DefaultResult<DataQueryMapperVO> result = dataQueryMapperService.findObjectByOid(mapper);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    mapper = result.getValue();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("mapperOid", mapper.getOid());
    List<QcDataQueryMapperSet> mapperSets = dataQueryMapperSetService.findListByParams(paramMap);
    if (null == mapperSets || mapperSets.size() < 1) {
        throw new Exception("Mapper config is required!");
    }
    for (QcDataQueryMapperSet mapperSet : mapperSets) {
        List<Object> values = new LinkedList<Object>();
        Map<String, Object> item = new HashMap<String, Object>();
        item.put("name", mapperSet.getValueField());
        item.put("data", values);
        for (Map<String, Object> searchDataMap : searchDatas) {
            for (String categorie : categories) {
                String label = (String) searchDataMap.get(mapperSet.getLabelField());
                if (!categorie.equals(label)) {
                    continue;
                }
                Object value = searchDataMap.get(mapperSet.getValueField());
                if (value == null) {
                    value = new Integer(0);
                }
                if (!isChartsValue(value)) {
                    throw new Exception("Mapper value field must be numeric!");
                }
                values.add(value);
            }
        }
        data.add(item);
    }
    return data;
}
Also used : HashMap(java.util.HashMap) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) LinkedList(java.util.LinkedList) DataQueryMapperVO(com.netsteadfast.greenstep.vo.DataQueryMapperVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) QcDataQueryMapperSet(com.netsteadfast.greenstep.po.hbm.QcDataQueryMapperSet) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with DataQueryMapperVO

use of com.netsteadfast.greenstep.vo.DataQueryMapperVO in project bamboobsc by billchen198318.

the class ChartsDataUtils method getHighchartsSeriesCategories.

public static List<String> getHighchartsSeriesCategories(String dataQueryMapperOid, List<Map<String, Object>> searchDatas) throws ServiceException, Exception {
    if (StringUtils.isBlank(dataQueryMapperOid)) {
        throw new Exception("Mapper config is required!");
    }
    List<String> data = new LinkedList<String>();
    if (null == searchDatas || searchDatas.size() < 1) {
        return data;
    }
    DataQueryMapperVO mapper = new DataQueryMapperVO();
    mapper.setOid(dataQueryMapperOid);
    DefaultResult<DataQueryMapperVO> result = dataQueryMapperService.findObjectByOid(mapper);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    mapper = result.getValue();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("mapperOid", mapper.getOid());
    List<QcDataQueryMapperSet> mapperSets = dataQueryMapperSetService.findListByParams(paramMap);
    if (null == mapperSets || mapperSets.size() < 1) {
        throw new Exception("Mapper config is required!");
    }
    for (QcDataQueryMapperSet mapperSet : mapperSets) {
        for (Map<String, Object> searchDataMap : searchDatas) {
            String label = (String) searchDataMap.get(mapperSet.getLabelField());
            if (StringUtils.isBlank(label)) {
                throw new Exception("Mapper label field not found!");
            }
            if (!data.contains(label)) {
                data.add(label);
            }
        }
    }
    return data;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) QcDataQueryMapperSet(com.netsteadfast.greenstep.po.hbm.QcDataQueryMapperSet) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) LinkedList(java.util.LinkedList) DataQueryMapperVO(com.netsteadfast.greenstep.vo.DataQueryMapperVO)

Example 5 with DataQueryMapperVO

use of com.netsteadfast.greenstep.vo.DataQueryMapperVO in project bamboobsc by billchen198318.

the class DataQueryMapperSaveOrUpdateAction method delete.

private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    DataQueryMapperVO queryMapper = new DataQueryMapperVO();
    this.transformFields2ValueObject(queryMapper, new String[] { "oid" });
    DefaultResult<Boolean> result = this.dataQueryMapperLogicService.deleteMapper(queryMapper);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null && result.getValue()) {
        this.success = IS_YES;
    }
}
Also used : DataQueryMapperVO(com.netsteadfast.greenstep.vo.DataQueryMapperVO)

Aggregations

DataQueryMapperVO (com.netsteadfast.greenstep.vo.DataQueryMapperVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 QcDataQueryMapperSet (com.netsteadfast.greenstep.po.hbm.QcDataQueryMapperSet)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 Map (java.util.Map)1 Transactional (org.springframework.transaction.annotation.Transactional)1