Search in sources :

Example 6 with TestCasePriority

use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.

the class CasePriorityServiceImpl method save.

@Override
public TestCasePriority save(CasePriorityVo vo, Long orgId) {
    if (vo == null) {
        return null;
    }
    TestCasePriority po;
    if (vo.getId() != null) {
        po = (TestCasePriority) get(TestCasePriority.class, vo.getId());
    } else {
        po = new TestCasePriority();
    }
    BeanUtilEx.copyProperties(po, vo);
    po.setOrgId(orgId);
    if (vo.getId() == null) {
        po.setCode(UUID.randomUUID().toString());
        String hql = "select max(displayOrder) from TestCasePriority pri where pri.orgId=?";
        Integer maxOrder = (Integer) getByHQL(hql, orgId);
        po.setDisplayOrder(maxOrder + 10);
    }
    saveOrUpdate(po);
    return po;
}
Also used : TestCasePriority(com.ngtesting.platform.entity.TestCasePriority)

Example 7 with TestCasePriority

use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.

the class CasePriorityServiceImpl method setDefaultPers.

@Override
public boolean setDefaultPers(Long id, Long orgId) {
    List<TestCasePriority> ls = list(orgId);
    for (TestCasePriority priority : ls) {
        if (priority.getId().longValue() == id.longValue()) {
            priority.setIsDefault(true);
            saveOrUpdate(priority);
        } else if (priority.getIsDefault() != null && priority.getIsDefault()) {
            priority.setIsDefault(false);
            saveOrUpdate(priority);
        }
    }
    return true;
}
Also used : TestCasePriority(com.ngtesting.platform.entity.TestCasePriority)

Example 8 with TestCasePriority

use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.

the class CasePriorityServiceImpl method changeOrderPers.

@Override
public boolean changeOrderPers(Long id, String act, Long orgId) {
    TestCasePriority type = (TestCasePriority) get(TestCasePriority.class, id);
    String hql = "from TestCasePriority tp where where tp.orgId=? and tp.deleted = false and tp.disabled = false ";
    if ("up".equals(act)) {
        hql += "and tp.displayOrder < ? order by displayOrder desc";
    } else if ("down".equals(act)) {
        hql += "and tp.displayOrder > ? order by displayOrder asc";
    } else {
        return false;
    }
    TestCasePriority neighbor = (TestCasePriority) getDao().findFirstByHQL(hql, orgId, type.getDisplayOrder());
    Integer order = type.getDisplayOrder();
    type.setDisplayOrder(neighbor.getDisplayOrder());
    neighbor.setDisplayOrder(order);
    saveOrUpdate(type);
    saveOrUpdate(neighbor);
    return true;
}
Also used : TestCasePriority(com.ngtesting.platform.entity.TestCasePriority)

Aggregations

TestCasePriority (com.ngtesting.platform.entity.TestCasePriority)8 CasePriorityVo (com.ngtesting.platform.vo.CasePriorityVo)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 UserVo (com.ngtesting.platform.vo.UserVo)2 HashMap (java.util.HashMap)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1