Search in sources :

Example 1 with TestCaseType

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

the class CasePropertyServiceImpl method getTypeMap.

@Override
public Map<String, String> getTypeMap(Long orgId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestCaseType.class);
    dc.add(Restrictions.eq("orgId", orgId));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.addOrder(Order.asc("displayOrder"));
    List<TestCaseType> ls = findAllByCriteria(dc);
    Map<String, String> map = new LinkedHashMap();
    for (TestCaseType item : ls) {
        map.put(item.getCode(), item.getName());
    }
    return map;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestCaseType(com.ngtesting.platform.entity.TestCaseType) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with TestCaseType

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

the class CaseTypeServiceImpl method delete.

@Override
public boolean delete(Long id) {
    TestCaseType po = (TestCaseType) get(TestCaseType.class, id);
    po.setDeleted(true);
    saveOrUpdate(po);
    return true;
}
Also used : TestCaseType(com.ngtesting.platform.entity.TestCaseType)

Example 3 with TestCaseType

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

the class CaseTypeServiceImpl method setDefaultPers.

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

Example 4 with TestCaseType

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

the class CaseTypeServiceImpl method changeOrderPers.

@Override
public boolean changeOrderPers(Long id, String act, Long orgId) {
    TestCaseType type = (TestCaseType) get(TestCaseType.class, id);
    String hql = "from TestCaseType tp 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;
    }
    TestCaseType neighbor = (TestCaseType) getFirstByHql(hql, orgId, type.getDisplayOrder());
    Integer order = type.getDisplayOrder();
    type.setDisplayOrder(neighbor.getDisplayOrder());
    neighbor.setDisplayOrder(order);
    saveOrUpdate(type);
    saveOrUpdate(neighbor);
    return true;
}
Also used : TestCaseType(com.ngtesting.platform.entity.TestCaseType)

Example 5 with TestCaseType

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

the class CaseTypeAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long id = json.getLong("id");
    if (id == null) {
        ret.put("data", new CaseTypeVo());
        ret.put("code", Constant.RespCode.SUCCESS.getCode());
        return ret;
    }
    TestCaseType po = (TestCaseType) caseTypeService.get(TestCaseType.class, id);
    CaseTypeVo vo = caseTypeService.genVo(po);
    ret.put("data", vo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) CaseTypeVo(com.ngtesting.platform.vo.CaseTypeVo) HashMap(java.util.HashMap) TestCaseType(com.ngtesting.platform.entity.TestCaseType) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TestCaseType (com.ngtesting.platform.entity.TestCaseType)8 CaseTypeVo (com.ngtesting.platform.vo.CaseTypeVo)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