use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.
the class AggregationMethodLogicServiceImpl method delete.
@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(AggregationMethodVO aggregationMethod) throws ServiceException, Exception {
if (null == aggregationMethod || super.isBlank(aggregationMethod.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AggregationMethodVO oldAggregationMethod = AggregationMethodUtils.findSimpleByOid(aggregationMethod.getOid());
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("cal", oldAggregationMethod.getAggrId());
if (this.kpiService.countByParams(paramMap) > 0) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE));
}
return this.aggregationMethodService.deleteObject(aggregationMethod);
}
use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.
the class AggregationMethodServiceImpl method findSimpleByOid.
@Override
public DefaultResult<AggregationMethodVO> findSimpleByOid(String aggrOid) throws ServiceException, Exception {
if (StringUtils.isBlank(aggrOid) || super.isNoSelectId(aggrOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AggregationMethodVO aggr = this.aggregationMethodDAO.findSimpleByOid(aggrOid);
DefaultResult<AggregationMethodVO> result = new DefaultResult<AggregationMethodVO>();
if (aggr != null && !StringUtils.isBlank(aggr.getOid())) {
result.setValue(aggr);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.
the class AggregationMethodServiceImpl method findForSimple.
@Override
public DefaultResult<List<AggregationMethodVO>> findForSimple() throws ServiceException, Exception {
DefaultResult<List<AggregationMethodVO>> result = new DefaultResult<List<AggregationMethodVO>>();
List<AggregationMethodVO> searchList = this.aggregationMethodDAO.findForSimple();
if (searchList != null && searchList.size() > 0) {
result.setValue(searchList);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.
the class AggregationMethodLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<AggregationMethodVO> update(AggregationMethodVO aggregationMethod) throws ServiceException, Exception {
if (null == aggregationMethod || super.isBlank(aggregationMethod.getName()) || super.isBlank(aggregationMethod.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AggregationMethodVO oldAggregationMethod = AggregationMethodUtils.findSimpleByOid(aggregationMethod.getOid());
// ID 是 UK 不能改
aggregationMethod.setAggrId(oldAggregationMethod.getAggrId());
long countName1 = 0;
long countName2 = 0;
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("name", aggregationMethod.getName());
countName1 = this.aggregationMethodService.countByParams(paramMap);
paramMap.put("aggrId", aggregationMethod.getAggrId());
countName2 = this.aggregationMethodService.countByParams(paramMap);
if (countName1 > 0 && countName2 == 0) {
// 有別筆資料名稱是一樣的
throw new ServiceException("Please change another name!");
}
this.setStringValueMaxLength(aggregationMethod, "description", MAX_DESCRIPTION_LENGTH);
return this.aggregationMethodService.updateObject(aggregationMethod);
}
use of com.netsteadfast.greenstep.vo.AggregationMethodVO in project bamboobsc by billchen198318.
the class AggregationMethodUtils method findAggregationMethodByUK.
private static AggregationMethodVO findAggregationMethodByUK(String id) throws ServiceException, Exception {
Map<String, AggregationMethodVO> datas = aggrMethodUkThreadLocal.get();
if (datas != null) {
if (datas.get(id) != null) {
return datas.get(id);
}
}
AggregationMethodVO aggr = new AggregationMethodVO();
aggr.setAggrId(id);
DefaultResult<AggregationMethodVO> result = aggregationMethodService.findByUK(aggr);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
aggr = result.getValue();
aggrMethodUkThreadLocal.get().put(id, aggr);
return aggr;
}
Aggregations