public void processRequest() throws Exception { FormProcessor fp = new FormProcessor(request); int itemId = fp.getInt(ITEM_ID); ItemDAO idao = new ItemDAO(sm.getDataSource()); ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource()); CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource()); CRFDAO cdao = new CRFDAO(sm.getDataSource()); if (itemId == 0) { addPageMessage("Please choose an item first."); forwardPage(Page.ITEM_DETAIL); return; } ItemBean item = (ItemBean) idao.findByPK(itemId); ArrayList versions = idao.findAllVersionsByItemId(item.getId()); ArrayList versionItems = new ArrayList(); // finds each item metadata for each version for (int i = 0; i < versions.size(); i++) { Integer versionId = (Integer) versions.get(i); CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId.intValue()); if (versionId != null && versionId.intValue() > 0) { ItemFormMetadataBean imfBean = ifmdao.findByItemIdAndCRFVersionId(item.getId(), versionId.intValue()); imfBean.setCrfVersionName(version.getName()); CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId()); imfBean.setCrfName(crf.getName()); versionItems.add(imfBean); } } request.setAttribute(VERSION_ITEMS, versionItems); request.setAttribute(ITEM_BEAN, item); forwardPage(Page.ITEM_DETAIL); }
@Override public void processRequest() throws Exception { resetPanel(); panel.setStudyInfoShown(false); panel.setOrderedData(true); panel.setSubmitDataModule(false); panel.setExtractData(false); panel.setCreateDataset(false); setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering")); setToPanel( resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading")); setToPanel( resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version")); setToPanel( resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from")); setToPanel( resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from")); FormProcessor fp = new FormProcessor(request); // checks which module the requests are from, manage or admin String module = fp.getString(MODULE); request.setAttribute(MODULE, module); int crfId = fp.getInt(CRF_ID); if (crfId == 0) { addPageMessage(respage.getString("please_choose_a_CRF_to_view")); forwardPage(Page.CRF_LIST); } else { CRFDAO cdao = new CRFDAO(sm.getDataSource()); CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource()); CRFBean crf = (CRFBean) cdao.findByPK(crfId); ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId); crf.setVersions(versions); // Collection<RuleSetBean> items = // getRuleSetService().getRuleSetsByCrf(crf); Collection<TableColumnHolder> items = populate(crf, versions); TableFacade tableFacade = createTableFacade("rules", request); tableFacade.setItems(items); // set the items tableFacade.setExportTypes(response, CSV, JEXCEL); tableFacade.setStateAttr("restore"); Limit limit = tableFacade.getLimit(); if (limit.isExported()) { export(tableFacade); // return null; // In Spring returning null tells the controller // not to do anything. } String html = html(tableFacade); request.setAttribute("rules", html); // Set the Html in the // request for the JSP. request.setAttribute(CRF, crf); forwardPage(Page.VIEW_CRF); } }
private ArrayList<StudyEventDefinitionBean> initDefinitions(StudyBean site) { ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>(); StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource()); EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource()); CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource()); CRFDAO cdao = new CRFDAO(sm.getDataSource()); StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId()); seds = sedDao.findAllByStudy(parentStudy); int start = 0; for (StudyEventDefinitionBean sed : seds) { int defId = sed.getId(); ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId( defId, site.getId(), parentStudy.getId()); ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>(); // sed.setCrfNum(edcs.size()); for (EventDefinitionCRFBean edcBean : edcs) { int edcStatusId = edcBean.getStatus().getId(); CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId()); int crfStatusId = crf.getStatusId(); if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) { } else { ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId()); edcBean.setVersions(versions); edcBean.setCrfName(crf.getName()); CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId()); edcBean.setDefaultVersionName(defaultVersion.getName()); String sversionIds = edcBean.getSelectedVersionIds(); ArrayList<Integer> idList = new ArrayList<Integer>(); if (sversionIds.length() > 0) { String[] ids = sversionIds.split("\\,"); for (String id : ids) { idList.add(Integer.valueOf(id)); } } edcBean.setSelectedVersionIdList(idList); defCrfs.add(edcBean); ++start; } } logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size()); sed.setCrfs(defCrfs); sed.setCrfNum(defCrfs.size()); } return seds; }
// testUpdate public void testUpdateSuccess() throws Exception { CRFBean sb = (CRFBean) cdao.findByPK(1); String keepName = sb.getName(); sb.setName("new name"); UserAccountBean ub = new UserAccountBean(); ub.setId(1); sb.setUpdater(ub); sb.setStatus(Status.AVAILABLE); sb = (CRFBean) cdao.update(sb); sb.setName(keepName); CRFBean sbs = (CRFBean) cdao.update(sb); assertNotNull("test update", sbs); }
public void testUpdateFail() throws Exception { CRFBean sb = (CRFBean) cdao.findByPK(1000); String keepName = sb.getName(); sb.setName("new name"); UserAccountBean ub = new UserAccountBean(); ub.setId(2); sb.setUpdater(ub); sb.setStatus(Status.AVAILABLE); sb = (CRFBean) cdao.update(sb); sb.setName(keepName); CRFBean sbs = (CRFBean) cdao.update(sb); assertNotNull("test update", sbs); assertEquals("check primarykey", sb.getId(), 0); }
public void testFindByPKFail() throws Exception { CRFBean sb = (CRFBean) cdao.findByPK(-1); assertNotNull("findbypk", sb); assertTrue("inactive object", !sb.isActive()); }
// testFindByPK public void testFindByPKSuccess() throws Exception { CRFBean sb = (CRFBean) cdao.findByPK(1); assertNotNull("findbypk", sb); assertTrue("active object", sb.isActive()); assertEquals("correct object", sb.getId(), 1); }