Search in sources :

Example 6 with TestProjectVo

use of com.ngtesting.platform.vo.TestProjectVo in project ngtesting-platform by aaronchen2k.

the class ProjectServiceImpl method listProjectGroups.

@Override
public List<TestProjectVo> listProjectGroups(Long orgId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestProject.class);
    dc.add(Restrictions.eq("orgId", orgId));
    dc.add(Restrictions.eq("type", ProjectType.group));
    dc.add(Restrictions.eq("disabled", false));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.addOrder(Order.asc("id"));
    List<TestProject> pos = findAllByCriteria(dc);
    List<TestProjectVo> vos = this.genGroupVos(pos);
    return vos;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 7 with TestProjectVo

use of com.ngtesting.platform.vo.TestProjectVo in project ngtesting-platform by aaronchen2k.

the class ProjectServiceImpl method genVos.

@Override
public List<TestProjectVo> genVos(List<TestProject> pos, String keywords, String disabled) {
    List<TestProjectVo> voList = new LinkedList<TestProjectVo>();
    for (TestProject po : pos) {
        TestProjectVo vo = genVo(po);
        voList.add(vo);
        List<TestProjectVo> voList2 = new LinkedList<TestProjectVo>();
        List<TestProject> children = po.getChildren();
        for (TestProject child : children) {
            if ((StringUtil.IsEmpty(keywords) || child.getName().toLowerCase().indexOf(keywords.toLowerCase()) > -1) && (StringUtil.IsEmpty(disabled) || child.getDisabled() == Boolean.valueOf(disabled))) {
                TestProjectVo childVo = genVo(child);
                voList2.add(childVo);
            }
        }
        vo.setChildrenNumb(voList2.size());
        voList.addAll(voList2);
    }
    return voList;
}
Also used : TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) TestProject(com.ngtesting.platform.entity.TestProject) LinkedList(java.util.LinkedList)

Example 8 with TestProjectVo

use of com.ngtesting.platform.vo.TestProjectVo in project ngtesting-platform by aaronchen2k.

the class ProjectServiceImpl method viewPers.

@Override
public TestProjectVo viewPers(Long projectId, UserVo userVo) {
    TestProject project = getDetail(projectId);
    getHistoryPers(project.getOrgId(), userVo.getId(), projectId, project.getName());
    TestUser userPo = (TestUser) get(TestUser.class, userVo.getId());
    userPo.setDefaultPrjId(projectId);
    saveOrUpdate(userPo);
    userVo.setDefaultPrjId(projectId);
    userVo.setDefaultPrjName(project.getName());
    TestProjectVo vo = genVo(project);
    return vo;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) TestUser(com.ngtesting.platform.entity.TestUser)

Example 9 with TestProjectVo

use of com.ngtesting.platform.vo.TestProjectVo 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)

Aggregations

TestProjectVo (com.ngtesting.platform.vo.TestProjectVo)9 TestProject (com.ngtesting.platform.entity.TestProject)6 TestCustomField (com.ngtesting.platform.entity.TestCustomField)4 LinkedList (java.util.LinkedList)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 CustomFieldVo (com.ngtesting.platform.vo.CustomFieldVo)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 TestUser (com.ngtesting.platform.entity.TestUser)1 List (java.util.List)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1