use of com.ngtesting.platform.entity.TestAlert in project ngtesting-platform by aaronchen2k.
the class AlertServiceImpl method saveAlert.
@Override
public void saveAlert(TestRun run) {
for (TestUser user : run.getAssignees()) {
TestAlert po = getByRun(run.getId());
;
if (po == null) {
po = new TestAlert();
}
po.setType("run");
po.setDescr(run.getDescr());
po.setEntityId(run.getId());
po.setEntityName(run.getName());
po.setStatus(run.getStatus().toString());
po.setRead(false);
po.setUserId(run.getUserId());
po.setAssigneeId(user.getId());
TestPlan plan = run.getPlan();
if (plan == null || plan.getId() == null) {
plan = (TestPlan) get(TestPlan.class, run.getPlanId());
}
po.setStartTime(plan.getStartTime());
po.setEndTime(plan.getEndTime());
saveOrUpdate(po);
}
}
use of com.ngtesting.platform.entity.TestAlert in project ngtesting-platform by aaronchen2k.
the class AlertServiceImpl method scanTestAlert.
@Override
public List<TestAlert> scanTestAlert(Long userId) {
DetachedCriteria dc = DetachedCriteria.forClass(TestAlert.class);
Date now = new Date();
Date startTimeOfToday = DateUtils.GetStartTimeOfDay(now);
Date endTimeOfToday = DateUtils.GetEndTimeOfDay(now);
dc.add(Restrictions.or(// 今天开始
Restrictions.and(Restrictions.isNotNull("startTime"), Restrictions.ge("startTime", startTimeOfToday), Restrictions.le("startTime", endTimeOfToday)), // 今天结束
Restrictions.and(Restrictions.isNotNull("endTime"), Restrictions.ge("endTime", startTimeOfToday), Restrictions.le("endTime", endTimeOfToday))));
dc.add(Restrictions.eq("userId", userId));
// dc.add(Restrictions.eq("isRead", false));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.add(Restrictions.eq("disabled", Boolean.FALSE));
dc.addOrder(Order.asc("startTime"));
List<TestAlert> pos = findAllByCriteria(dc);
return pos;
}
use of com.ngtesting.platform.entity.TestAlert in project ngtesting-platform by aaronchen2k.
the class AlertServiceImpl method genVos.
@Override
public List<TestAlertVo> genVos(List<TestAlert> pos) {
List<TestAlertVo> vos = new LinkedList<>();
for (TestAlert run : pos) {
TestAlertVo vo = genVo(run);
vos.add(vo);
}
return vos;
}
use of com.ngtesting.platform.entity.TestAlert in project ngtesting-platform by aaronchen2k.
the class AlertServiceImpl method getByRun.
@Override
public TestAlert getByRun(Long id) {
DetachedCriteria dc = DetachedCriteria.forClass(TestAlert.class);
dc.add(Restrictions.eq("type", "run"));
dc.add(Restrictions.eq("entityId", id));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.add(Restrictions.eq("disabled", Boolean.FALSE));
dc.addOrder(Order.asc("id"));
List<TestAlert> pos = findAllByCriteria(dc);
if (pos.size() > 0) {
return pos.get(0);
} else {
return null;
}
}
Aggregations