Search in sources :

Example 1 with TestAlert

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);
    }
}
Also used : TestPlan(com.ngtesting.platform.entity.TestPlan) TestAlert(com.ngtesting.platform.entity.TestAlert) TestUser(com.ngtesting.platform.entity.TestUser)

Example 2 with TestAlert

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;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestAlert(com.ngtesting.platform.entity.TestAlert) Date(java.util.Date)

Example 3 with TestAlert

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;
}
Also used : TestAlert(com.ngtesting.platform.entity.TestAlert) TestAlertVo(com.ngtesting.platform.vo.TestAlertVo) LinkedList(java.util.LinkedList)

Example 4 with TestAlert

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;
    }
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestAlert(com.ngtesting.platform.entity.TestAlert)

Aggregations

TestAlert (com.ngtesting.platform.entity.TestAlert)4 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)2 TestPlan (com.ngtesting.platform.entity.TestPlan)1 TestUser (com.ngtesting.platform.entity.TestUser)1 TestAlertVo (com.ngtesting.platform.vo.TestAlertVo)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1