Search in sources :

Example 6 with TestProject

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

the class CustomFieldServiceImpl method save.

@Override
public TestCustomField save(CustomFieldVo vo, Long orgId) {
    if (vo == null) {
        return null;
    }
    TestCustomField po;
    if (vo.getId() != null) {
        po = (TestCustomField) get(TestCustomField.class, vo.getId());
    } else {
        po = new TestCustomField();
    }
    this.initPo(po, vo);
    po.setApplyTo(TestCustomField.FieldApplyTo.valueOf(vo.getApplyTo()));
    po.setType(TestCustomField.FieldType.valueOf(vo.getType()));
    if (StringUtil.isNotEmpty(vo.getFormat())) {
        po.setFormat(TestCustomField.FieldFormat.valueOf(vo.getFormat()));
    }
    po.setOrgId(orgId);
    if (vo.getId() == null) {
        String hql = "select max(ordr) from TestCustomField";
        Integer maxOrder = (Integer) getByHQL(hql);
        if (maxOrder == null) {
            maxOrder = 0;
        }
        po.setOrdr(maxOrder + 10);
    }
    if (!po.getType().equals(FieldType.text)) {
        po.setRows(0);
        po.setFormat(null);
    }
    if (po.getGlobal() && po.getProjectSet().size() > 0) {
        po.setProjectSet(new HashSet<TestProject>(0));
    }
    saveOrUpdate(po);
    return po;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) TestCustomField(com.ngtesting.platform.entity.TestCustomField)

Example 7 with TestProject

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

the class ProjectAction method saveMembers.

@AuthPassport(validate = true)
@RequestMapping(value = "saveMembers", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> saveMembers(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 orgId = userVo.getDefaultOrgId();
    List<TestRelationProjectRoleEntity> pos = relationProjectRoleEntityService.batchSavePers(json);
    List<RelationProjectRoleEntityVo> entityInRoles = relationProjectRoleEntityService.genVos(pos);
    Long projectId = json.getLong("projectId");
    TestProject project = (TestProject) relationProjectRoleEntityService.get(TestProject.class, projectId);
    historyService.create(project.getId(), userVo, Constant.MsgType.update.msg, TestHistory.TargetType.project_member, project.getId(), project.getName());
    ret.put("entityInRoles", entityInRoles);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) HashMap(java.util.HashMap) TestRelationProjectRoleEntity(com.ngtesting.platform.entity.TestRelationProjectRoleEntity) 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)

Example 8 with TestProject

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

the class ReportAction method project.

@AuthPassport(validate = true)
@RequestMapping(value = "project", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> project(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    Map<String, Object> data = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long id = json.getLong("projectId");
    TestProject prj = (TestProject) reportService.get(TestProject.class, id);
    Map<String, List<Object>> designReport = reportService.chart_design_progress_by_project(id, prj.getType(), 14);
    Map<String, List<Object>> exeReport = reportService.chart_excution_process_by_project(id, prj.getType(), 14);
    data.put("design", designReport);
    data.put("exe", exeReport);
    ret.put("data", data);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) TestProject(com.ngtesting.platform.entity.TestProject) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with TestProject

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

the class ProjectAction 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 orgId = userVo.getDefaultOrgId();
    Long projectId = json.getLong("id");
    if (projectId != null) {
        TestProject project = projectService.getDetail(projectId);
        TestProjectVo vo = projectService.genVo(project);
        if (TestProject.ProjectType.group.equals(project.getType())) {
            vo.setLastestProjectGroup(projectService.isLastestProjectGroup(orgId, projectId));
        }
        ret.put("data", vo);
    }
    List<TestProjectVo> groups = projectService.listProjectGroups(orgId);
    List<ProjectRoleVo> projectRoles = projectRoleService.list(orgId, null, null);
    List<TestRelationProjectRoleEntity> entityInRolesPos = relationProjectRoleEntityService.listByProject(projectId);
    List<RelationProjectRoleEntityVo> entityInRoles = relationProjectRoleEntityService.genVos(entityInRolesPos);
    ret.put("groups", groups);
    ret.put("projectRoles", projectRoles);
    ret.put("entityInRoles", entityInRoles);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) TestProject(com.ngtesting.platform.entity.TestProject) TestRelationProjectRoleEntity(com.ngtesting.platform.entity.TestRelationProjectRoleEntity) 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)

Example 10 with TestProject

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

the class ProjectAction method save.

@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(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 orgId = userVo.getDefaultOrgId();
    Long userId = userVo.getId();
    TestProjectVo vo = json.getObject("model", TestProjectVo.class);
    TestProject po = projectService.save(vo, orgId, userVo);
    if (TestProject.ProjectType.project.equals(po.getType())) {
        projectService.updateNameInHisotyPers(po.getId(), userId);
    }
    pushSettingsService.pushRecentProjects(userVo);
    pushSettingsService.pushPrjSettings(userVo);
    ret.put("data", vo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) HashMap(java.util.HashMap) 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

TestProject (com.ngtesting.platform.entity.TestProject)17 TestProjectVo (com.ngtesting.platform.vo.TestProjectVo)6 JSONObject (com.alibaba.fastjson.JSONObject)4 AuthPassport (com.ngtesting.platform.util.AuthPassport)4 HashMap (java.util.HashMap)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 TestCustomField (com.ngtesting.platform.entity.TestCustomField)3 LinkedList (java.util.LinkedList)3 TestRelationProjectRoleEntity (com.ngtesting.platform.entity.TestRelationProjectRoleEntity)2 Query (org.hibernate.Query)2 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)2 TestUser (com.ngtesting.platform.entity.TestUser)1 UserVo (com.ngtesting.platform.vo.UserVo)1 List (java.util.List)1 Filter (org.hibernate.Filter)1