use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.
the class BaseDAO method findPageQueryResult.
/**
* 頁面查詢grid資料用
*
* map 放入 key為 persisent obj 欄位名稱
*
*/
@SuppressWarnings("unchecked")
public <RO extends QueryResult<List<VO>>, VO extends java.io.Serializable> QueryResult<List<VO>> findPageQueryResult(String findHQL, String countHQL, Map<String, Object> params, int offset, int limit) throws Exception {
QueryResult<List<VO>> result = new QueryResult<List<VO>>();
List<VO> list = null;
long count = 0L;
Session hbmSession = this.getCurrentSession();
try {
Query query = hbmSession.createQuery(countHQL);
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (entry.getKey().equals(Constants._RESERVED_PARAM_NAME_QUERY_ORDER_BY) || entry.getKey().equals(Constants._RESERVED_PARAM_NAME_QUERY_SORT_TYPE)) {
continue;
}
this.setQueryParams(query, entry.getKey(), entry.getValue());
}
}
count = ((Long) query.uniqueResult()).longValue();
int newOffset = offset;
if (count > 0) {
if (offset >= count) {
// 改掉原本頁面上一次查詢的欄位值 , 2014-10-08 offset>count
newOffset = (int) (count - Long.valueOf(limit));
if (newOffset < 0) {
newOffset = 0;
}
}
query = hbmSession.createQuery(findHQL);
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
if (entry.getKey().equals(Constants._RESERVED_PARAM_NAME_QUERY_ORDER_BY) || entry.getKey().equals(Constants._RESERVED_PARAM_NAME_QUERY_SORT_TYPE)) {
continue;
}
this.setQueryParams(query, entry.getKey(), entry.getValue());
}
}
//offset
query.setFirstResult(newOffset);
query.setMaxResults(limit);
list = (List<VO>) query.list();
}
result.setRowCount(count);
// 2017-06-30 bug fix, result.setOffset(offset);
result.setOffset(newOffset);
result.setLimit(limit);
result.setFindHQL(findHQL);
result.setCountHQL(countHQL);
if (list != null && list.size() > 0) {
result.setValue(list);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
} catch (Exception e) {
e.printStackTrace();
result.setSystemMessage(new SystemMessage(e.getMessage()));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.
the class BaseService method ibatisSelectListByParams.
// ------------------------------------------------------------------------------------
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<List<E>> ibatisSelectListByParams(Map<String, Object> params) throws ServiceException, Exception {
if (params == null) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
DefaultResult<List<E>> result = new DefaultResult<List<E>>();
List<E> searchList = (List<E>) this.getBaseDataAccessObject().ibatisSelectListByParams(params);
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.base.model.SystemMessage in project bamboobsc by billchen198318.
the class BaseService method deleteObject.
@SuppressWarnings({ "unchecked", "rawtypes" })
@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
public DefaultResult<Boolean> deleteObject(T object) throws ServiceException, Exception {
if (object == null || !(object instanceof BaseValueObj)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
Class<E> entityObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject = entityObjectClass.newInstance();
((BaseEntity) entityObject).setOid(((BaseValueObj) object).getOid());
boolean status = false;
if (this.countByOid(entityObject) > 0) {
this.delete(entityObject);
status = true;
}
result.setValue(status);
if (status) {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_SUCCESS)));
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_FAIL)));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.
the class DegreeFeedbackScoreServiceImpl method findResultsByProjectAndOwner.
@Override
public DefaultResult<List<BbDegreeFeedbackScore>> findResultsByProjectAndOwner(String projectOid, String ownerId) throws Exception {
if (StringUtils.isBlank(projectOid) || StringUtils.isBlank(ownerId)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
List<BbDegreeFeedbackScore> searchList = this.degreeFeedbackScoreDAO.findForListByProjectAndOwner(projectOid, ownerId);
DefaultResult<List<BbDegreeFeedbackScore>> result = new DefaultResult<List<BbDegreeFeedbackScore>>();
if (null != searchList && searchList.size() > 0) {
result.setValue(searchList);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.SystemMessage 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;
}
Aggregations