@Override public void processRequest() throws Exception { FormProcessor fp = new FormProcessor(request); StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource()); // YW << StudyDAO stdao = new StudyDAO(sm.getDataSource()); int parentStudyId = currentStudy.getParentStudyId(); ArrayList groups = new ArrayList(); if (parentStudyId > 0) { StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId); groups = sgcdao.findAllByStudy(parentStudy); } else { groups = sgcdao.findAllByStudy(currentStudy); } // YW >> String isReadOnly = request.getParameter("read"); StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource()); for (int i = 0; i < groups.size(); i++) { StudyGroupClassBean group = (StudyGroupClassBean) groups.get(i); ArrayList studyGroups = sgdao.findAllByGroupClass(group); group.setStudyGroups(studyGroups); } EntityBeanTable table = fp.getEntityBeanTable(); ArrayList allGroupRows = StudyGroupClassRow.generateRowsFromBeans(groups); boolean isParentStudy = currentStudy.getParentStudyId() > 0 ? false : true; request.setAttribute("isParentStudy", isParentStudy); String[] columns = { resword.getString("subject_group_class"), resword.getString("type"), resword.getString("subject_assignment"), resword.getString("study_name"), resword.getString("subject_groups"), resword.getString("status"), resword.getString("actions") }; table.setColumns(new ArrayList(Arrays.asList(columns))); table.hideColumnLink(4); table.hideColumnLink(6); table.setQuery("ListSubjectGroupClass", new HashMap()); // if (isParentStudy && (!currentStudy.getStatus().isLocked())) { // table.addLink(resword.getString("create_a_subject_group_class"), // "CreateSubjectGroupClass"); // } table.setRows(allGroupRows); table.computeDisplay(); request.setAttribute("table", table); if (request.getParameter("read") != null && request.getParameter("read").equals("true")) { request.setAttribute("readOnly", true); } forwardPage(Page.SUBJECT_GROUP_CLASS_LIST); }
public void processRequest() throws Exception { String action = request.getParameter("action"); FormProcessor fp = new FormProcessor(request); int classId = fp.getInt("id"); if (classId == 0) { addPageMessage("Please choose a subject group class to remove."); forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET); } else { StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource()); StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource()); SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource()); if (action.equalsIgnoreCase("confirm")) { StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId); if (sgcb.getStatus().equals(Status.DELETED)) { addPageMessage("This subject group class has been deleted already."); forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET); return; } ArrayList groups = sgdao.findAllByGroupClass(sgcb); for (int i = 0; i < groups.size(); i++) { StudyGroupBean sg = (StudyGroupBean) groups.get(i); ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId()); sg.setSubjectMaps(subjectMaps); } session.setAttribute("group", sgcb); session.setAttribute("studyGroups", groups); forwardPage(Page.REMOVE_SUBJECT_GROUP_CLASS); } else if (action.equalsIgnoreCase("submit")) { StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group"); group.setStatus(Status.DELETED); group.setUpdater(ub); sgcdao.update(group); ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassId(group.getId()); for (int i = 0; i < subjectMaps.size(); i++) { SubjectGroupMapBean sgmb = (SubjectGroupMapBean) subjectMaps.get(i); sgmb.setStatus(Status.DELETED); sgmb.setUpdater(ub); sgmdao.update(sgmb); } addPageMessage("This subject group class was removed successfully."); forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET); } else { addPageMessage("No action specified."); forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET); } } }
@RequestMapping(method = RequestMethod.GET) public ModelMap handleMainPage(HttpServletRequest request) { ModelMap map = new ModelMap(); // setUpSidebar(request); StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study"); eventDefinitionCRFDao = new EventDefinitionCRFDAO(dataSource); studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource); crfDao = new CRFDAO(dataSource); studyGroupClassDao = new StudyGroupClassDAO(dataSource); studyDao = new StudyDAO(dataSource); userDao = new UserAccountDAO(dataSource); ruleDao = new RuleDAO(dataSource); StudyModuleStatus sms = studyModuleStatusDao.findByStudyId(currentStudy.getId()); if (sms == null) { sms = new StudyModuleStatus(); sms.setStudyId(currentStudy.getId()); } int crfCount = crfDao.findAllByStudy(currentStudy.getId()).size(); int crfWithEventDefinition = crfDao.findAllActiveByDefinitions(currentStudy.getId()).size(); int totalCrf = crfCount + crfWithEventDefinition; // int eventDefinitionCount = eventDefinitionCRFDao.findAllActiveByStudy(currentStudy).size(); int eventDefinitionCount = studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size(); int subjectGroupCount = studyGroupClassDao.findAllActiveByStudy(currentStudy).size(); List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByStudy(currentStudy); ruleSets = ruleSetService.filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets); int ruleCount = ruleSets != null ? ruleSets.size() : 0; int siteCount = studyDao.findOlnySiteIdsByStudy(currentStudy).size(); int userCount = userDao.findAllUsersByStudy(currentStudy.getId()).size(); Collection childStudies = studyDao.findAllByParent(currentStudy.getId()); Map childStudyUserCount = new HashMap(); for (Object sb : childStudies) { StudyBean childStudy = (StudyBean) sb; childStudyUserCount.put( childStudy.getName(), userDao.findAllUsersByStudy(childStudy.getId()).size()); } if (sms.getCrf() == 0) { sms.setCrf(StudyModuleStatus.NOT_STARTED); } if (sms.getCrf() != 3 && totalCrf > 0) { sms.setCrf(StudyModuleStatus.IN_PROGRESS); } if (sms.getEventDefinition() == 0) { sms.setEventDefinition(StudyModuleStatus.NOT_STARTED); } if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) { sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS); } if (sms.getSubjectGroup() == 0) { sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED); } if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) { sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS); } if (sms.getRule() == 0) { sms.setRule(StudyModuleStatus.NOT_STARTED); } if (sms.getRule() != 3 && ruleCount > 0) { sms.setRule(StudyModuleStatus.IN_PROGRESS); } if (sms.getSite() == 0) { sms.setSite(StudyModuleStatus.NOT_STARTED); } if (sms.getSite() != 3 && siteCount > 0) { sms.setSite(StudyModuleStatus.IN_PROGRESS); } if (sms.getUsers() == 0) { sms.setUsers(StudyModuleStatus.NOT_STARTED); } if (sms.getUsers() != 3 && userCount > 0) { sms.setUsers(StudyModuleStatus.IN_PROGRESS); } map.addObject(sms); map.addAttribute("crfCount", totalCrf); map.addAttribute("eventDefinitionCount", eventDefinitionCount); map.addAttribute("subjectGroupCount", subjectGroupCount); map.addAttribute("ruleCount", ruleCount); map.addAttribute("siteCount", siteCount); map.addAttribute("userCount", userCount); map.addAttribute("childStudyUserCount", childStudyUserCount); map.addAttribute("studyId", currentStudy.getId()); map.addAttribute("currentStudy", currentStudy); UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean"); request.setAttribute("userBean", userBean); request.setAttribute("statusMap", Status.toStudyUpdateMembersList()); ArrayList pageMessages = new ArrayList(); if (request.getSession().getAttribute("pageMessages") != null) { pageMessages.addAll((ArrayList) request.getSession().getAttribute("pageMessages")); request.setAttribute("pageMessages", pageMessages); request.getSession().removeAttribute("pageMessages"); } return map; }