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;
}
}
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);
}
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;
}
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;
}
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;
}
}
Aggregations