@Secured({"ROLE_DEVELOPER", "ROLE_TESTER"}) @RequestMapping(value = "showBug/{bugId}.htm", method = RequestMethod.GET) public String showBug(@PathVariable Integer bugId, ModelMap map) { Bug bug = aService.findById(Bug.class, bugId); List<History> histories = aService.queryAllOfCondition( History.class, DetachedCriteria.forClass(History.class) .add(Restrictions.eq("objectType", "bug")) .add(Restrictions.eq("objectId", bug.getBugId())) .addOrder(Order.asc("operateTime"))); List<Resource> resources = aService.queryAllOfCondition( Resource.class, DetachedCriteria.forClass(Resource.class) .add(Restrictions.eq("objectType", "bug")) .add(Restrictions.eq("objectId", bug.getBugId())) .addOrder(Order.asc("resourceId"))); map.put("bug", bug); map.put("histories", histories); map.put("resources", resources); return "bug/showBug"; }
@Secured({"ROLE_DEVELOPER", "ROLE_TESTER"}) @RequestMapping("goAddBug.htm") public ModelAndView goAddBug(HttpServletRequest request) { Company company = (Company) request.getSession().getAttribute("company"); DetachedCriteria dCriteria = DetachedCriteria.forClass(Project.class); dCriteria.add(Restrictions.eq("company", company)); List<Project> projectList = aService.queryAllOfCondition(Project.class, dCriteria); DetachedCriteria dCriteria1 = DetachedCriteria.forClass(Department.class); dCriteria1.add(Restrictions.eq("company", company)); List<Department> deptList = aService.queryAllOfCondition(Department.class, dCriteria1); DetachedCriteria dCriteria2 = DetachedCriteria.forClass(Developer.class); dCriteria2.createCriteria("user").add(Restrictions.in("department", deptList)); List<Developer> userList = aService.queryAllOfCondition(Developer.class, dCriteria2); DetachedCriteria dCriteria3 = DetachedCriteria.forClass(User.class); dCriteria3.add(Restrictions.in("department", deptList)); List<User> userList1 = aService.queryAllOfCondition(User.class, dCriteria3); ModelMap map = new ModelMap(); map.put("projectList", projectList); map.put("userList", userList); map.put("userList1", userList1); return new ModelAndView("/bug/addBug", map); }
@Secured({"ROLE_TESTER"}) @RequestMapping("goBugFromUc.htm") public ModelAndView goBugFromUc(HttpServletRequest request) { String ucId = request.getParameter("usercaseId"); UserCase uc = aService.findById(UserCase.class, Integer.parseInt(ucId)); Company company = (Company) request.getSession().getAttribute("company"); DetachedCriteria dCriteria = DetachedCriteria.forClass(Project.class); dCriteria.add(Restrictions.eq("company", company)); List<Project> projectList = aService.queryAllOfCondition(Project.class, dCriteria); DetachedCriteria dCriteria1 = DetachedCriteria.forClass(Department.class); dCriteria1.add(Restrictions.eq("company", company)); List<Department> deptList = aService.queryAllOfCondition(Department.class, dCriteria1); DetachedCriteria dCriteria2 = DetachedCriteria.forClass(Developer.class); dCriteria2.createCriteria("user").add(Restrictions.in("department", deptList)); List<Developer> userList = aService.queryAllOfCondition(Developer.class, dCriteria2); DetachedCriteria dCriteria3 = DetachedCriteria.forClass(User.class); dCriteria3.add(Restrictions.in("department", deptList)); List<User> userList1 = aService.queryAllOfCondition(User.class, dCriteria3); DetachedCriteria dCriteria4 = DetachedCriteria.forClass(Step.class); dCriteria4.add(Restrictions.eq("userCase", uc)); List<Step> stepList = aService.queryAllOfCondition(Step.class, dCriteria4); ModelMap map = new ModelMap(); map.put("projectList", projectList); map.put("userList", userList); map.put("userList1", userList1); map.put("uc", uc); map.put("stepList", stepList); return new ModelAndView("/usecase/ucToBug", map); }
@RequestMapping("loadVersion.htm") public void loadVersion(HttpServletRequest request, HttpServletResponse response) throws Exception { String projectId = request.getParameter("projectId"); Project project = aService.findById(Project.class, Integer.parseInt(projectId)); DetachedCriteria dCriteria = DetachedCriteria.forClass(Version.class); dCriteria.add(Restrictions.eq("project", project)); List<Version> list = new ArrayList<Version>(); list = aService.queryAllOfCondition(Version.class, dCriteria); System.out.println("version list size " + list.size()); JsonConfig config1 = new JsonConfig(); config1.setExcludes(new String[] {"project", "tasks", "affectedVersions"}); JSONArray json = JSONArray.fromObject(list, config1); PrintWriter pt = response.getWriter(); pt.write(json.toString()); pt.close(); }
@Secured({"ROLE_DEVELOPER", "ROLE_TESTER"}) @RequestMapping("goeditBug.htm") public ModelAndView goeditBug(HttpServletRequest request) { String bugId = request.getParameter("bugId"); Bug bug = aService.findById(Bug.class, Integer.parseInt(bugId)); Project project = bug.getModule().getProject(); List<ModuleBean> modulebean = ModuleUtil.getModuleNameList(aService, project); Company company = (Company) request.getSession().getAttribute("company"); DetachedCriteria dCriteria1 = DetachedCriteria.forClass(Project.class); dCriteria1 .add(Restrictions.eq("company", company)) .add(Restrictions.ne("projectId", project.getProjectId())); List<Project> projectList = aService.queryAllOfCondition(Project.class, dCriteria1); DetachedCriteria dCriteria2 = DetachedCriteria.forClass(Version.class); dCriteria2.add(Restrictions.eq("project", project)); List<Version> versionList = aService.queryAllOfCondition(Version.class, dCriteria2); DetachedCriteria dCriteria3 = DetachedCriteria.forClass(AffectedVersion.class); dCriteria3.add(Restrictions.eq("bug", bug)); List<AffectedVersion> avList = aService.queryAllOfCondition(AffectedVersion.class, dCriteria3); List<Version> aList = new ArrayList<Version>(); for (AffectedVersion aversion : avList) { aList.add(aversion.getVersion()); } DetachedCriteria dCriteria5 = DetachedCriteria.forClass(Department.class); dCriteria5.add(Restrictions.eq("company", company)); List<Department> deptList = aService.queryAllOfCondition(Department.class, dCriteria5); DetachedCriteria dCriteria4 = DetachedCriteria.forClass(Developer.class) .add(Restrictions.ne("developerId", bug.getAssignedTo().getDeveloperId())); dCriteria4.createCriteria("user").add(Restrictions.in("department", deptList)); List<Developer> userList = aService.queryAllOfCondition(Developer.class, dCriteria4); DetachedCriteria dCriteria7 = DetachedCriteria.forClass(History.class); dCriteria7 .add(Restrictions.eq("objectId", bug.getBugId())) .add(Restrictions.eq("objectType", "bug")) .addOrder(Order.asc("operateTime")); List<History> hisList = aService.queryAllOfCondition(History.class, dCriteria7); DetachedCriteria dCriteria6 = DetachedCriteria.forClass(User.class); dCriteria6.add(Restrictions.in("department", deptList)); List<User> userList1 = aService.queryAllOfCondition(User.class, dCriteria6); String mailto = bug.getMailto(); String[] name = mailto.split(";"); List<User> userlist = new ArrayList<User>(); for (int i = 0; i < name.length; i++) { User user1 = new User(); user1.setRealName(name[i]); userlist.add(user1); } ModelMap map = new ModelMap(); map.put("bug", bug); map.put("modulebean", modulebean); map.put("projectList", projectList); map.put("versionList", versionList); map.put("userlist", userlist); map.put("userList", userList); map.put("userList1", userList1); map.put("aList", aList); map.put("hisList", hisList); return new ModelAndView("/bug/editBug", map); }