Search in sources :

Example 6 with TestCustomField

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

the class CustomFieldServiceImpl method genVos.

@Override
public List<CustomFieldVo> genVos(List<TestCustomField> pos) {
    List<CustomFieldVo> vos = new LinkedList<CustomFieldVo>();
    for (TestCustomField po : pos) {
        CustomFieldVo vo = genVo(po);
        vos.add(vo);
    }
    return vos;
}
Also used : CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo) TestCustomField(com.ngtesting.platform.entity.TestCustomField) LinkedList(java.util.LinkedList)

Example 7 with TestCustomField

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

the class CustomFieldServiceImpl method listProjectsForField.

@Override
public List<TestProjectVo> listProjectsForField(Long orgId, Long fieldId) {
    List<TestProject> allProjects = projectService.list(orgId, null, null);
    Set<TestProject> projectsForField;
    if (fieldId == null) {
        projectsForField = new HashSet<TestProject>();
    } else {
        TestCustomField field = (TestCustomField) get(TestCustomField.class, fieldId);
        projectsForField = field.getProjectSet();
    }
    List<TestProjectVo> vos = new LinkedList<TestProjectVo>();
    for (TestProject po1 : allProjects) {
        TestProjectVo vo = projectService.genVo(po1);
        vo.setSelected(false);
        vo.setSelecting(false);
        for (TestProject item : projectsForField) {
            if (po1.getId().longValue() == item.getId().longValue()) {
                vo.setSelected(true);
                vo.setSelecting(true);
            }
        }
        vos.add(vo);
        for (TestProject child : po1.getChildren()) {
            TestProjectVo childVo = projectService.genVo(child);
            for (TestProject item : projectsForField) {
                if (child.getId().longValue() == item.getId().longValue()) {
                    childVo.setSelected(true);
                    childVo.setSelecting(true);
                }
            }
            vos.add(childVo);
        }
    }
    return vos;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) TestCustomField(com.ngtesting.platform.entity.TestCustomField) LinkedList(java.util.LinkedList)

Example 8 with TestCustomField

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

the class CustomFieldServiceImpl method delete.

@Override
public boolean delete(Long id) {
    TestCustomField po = (TestCustomField) get(TestCustomField.class, id);
    po.getProjectSet().clear();
    getDao().delete(po);
    return true;
}
Also used : TestCustomField(com.ngtesting.platform.entity.TestCustomField)

Example 9 with TestCustomField

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

the class CustomFieldServiceImpl method changeOrderPers.

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

Aggregations

TestCustomField (com.ngtesting.platform.entity.TestCustomField)9 CustomFieldVo (com.ngtesting.platform.vo.CustomFieldVo)4 TestProjectVo (com.ngtesting.platform.vo.TestProjectVo)4 TestProject (com.ngtesting.platform.entity.TestProject)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 LinkedList (java.util.LinkedList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 List (java.util.List)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1