@Test public void create_panel_without_tests() throws Exception { panelService.createOrUpdate(referenceDataPanel); Panel savedPanel = panelDAO.getPanelByName("Panel Name"); assertNotNull(savedPanel); assertEquals("Panel Name", savedPanel.getDescription()); List panelTestAssoc = panelItemDAO.getPanelItemsForPanel(savedPanel.getId()); assertEquals(0, panelTestAssoc.size()); }
@Test public void associate_tests_with_panel() throws Exception { testService.createOrUpdate(referenceDataTest); us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name"); assertEquals("Test Name", savedTest.getTestName()); assertEquals("New", savedTest.getTestSection().getTestSectionName()); referenceDataPanel.addTest( new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName())); panelService.createOrUpdate(referenceDataPanel); Panel savedPanel = panelDAO.getPanelByName("Panel Name"); assertNotNull(savedPanel); assertEquals("Panel Name", savedPanel.getDescription()); List panelTestAssoc = panelItemDAO.getPanelItemsForPanel(savedPanel.getId()); assertNotNull(panelTestAssoc); assertEquals(1, panelTestAssoc.size()); PanelItem panelItem = (PanelItem) panelTestAssoc.get(0); assertEquals(savedTest.getId(), panelItem.getTest().getId()); }
@Test public void sample_save_should_form_panel_to_sample_associations() throws Exception { testService.createOrUpdate(referenceDataTest); panelService.createOrUpdate(referenceDataPanel); us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name"); assertEquals("Test Name", savedTest.getTestName()); assertEquals("New", savedTest.getTestSection().getTestSectionName()); Panel savedPanel = panelDAO.getPanelByName("Panel Name"); assertEquals("Panel Name", savedPanel.getPanelName()); referenceDataSample.addTest( new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName())); referenceDataSample.addPanel( new MinimalResource(referenceDataPanel.getId(), referenceDataPanel.getName())); typeOfSampleService.createOrUpdate(referenceDataSample); TypeOfSample savedSample = typeOfSampleDAO.getTypeOfSampleByUUID(sampleUuid); assertEquals("Sample Name", savedSample.getDescription()); assertEquals("Sample Name", savedSample.getLocalAbbreviation()); TypeOfSampleTest sampleTestAssoc = typeOfSampleTestDAO.getTypeOfSampleTestForTest(savedTest.getId()); assertNotNull(sampleTestAssoc); assertEquals(savedTest.getId(), sampleTestAssoc.getTestId()); assertEquals(savedSample.getId(), sampleTestAssoc.getTypeOfSampleId()); TypeOfSamplePanel samplePanelAssoc = typeOfSamplePanelDao.getTypeOfSamplePanelForPanel(savedPanel.getId()); assertNotNull(samplePanelAssoc); assertEquals(savedPanel.getId(), samplePanelAssoc.getPanelId()); assertEquals(savedSample.getId(), samplePanelAssoc.getTypeOfSampleId()); }
protected ActionForward performAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // The first job is to determine if we are coming to this action with an // ID parameter in the request. If there is no parameter, we are // creating a new Analyte. // If there is a parameter present, we should bring up an existing // Analyte to edit. String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); request.setAttribute(PREVIOUS_DISABLED, "false"); request.setAttribute(NEXT_DISABLED, "false"); String id = request.getParameter(ID); if (StringUtil.isNullorNill(id) || "0".equals(id)) { isNew = true; } else { isNew = false; } BaseActionForm dynaForm = (BaseActionForm) form; String start = (String) request.getParameter("startingRecNo"); String direction = (String) request.getParameter("direction"); // System.out.println("This is ID from request " + id); Panel panel = new Panel(); panel.setId(id); try { PanelDAO panelDAO = new PanelDAOImpl(); // retrieve analyte by id since the name may have changed panelDAO.getData(panel); if (FWD_NEXT.equals(direction)) { // bugzilla 1427 pass in name not id List panels = panelDAO.getNextPanelRecord(panel.getPanelName()); if (panels != null && panels.size() > 0) { panel = (Panel) panels.get(0); panelDAO.getData(panel); if (panels.size() < 2) { // disable next button request.setAttribute(NEXT_DISABLED, "true"); } id = panel.getId(); } else { // just disable next button request.setAttribute(NEXT_DISABLED, "true"); } } if (FWD_PREVIOUS.equals(direction)) { // bugzilla 1427 pass in name not id List panels = panelDAO.getPreviousPanelRecord(panel.getPanelName()); if (panels != null && panels.size() > 0) { panel = (Panel) panels.get(0); panelDAO.getData(panel); if (panels.size() < 2) { // disable previous button request.setAttribute(PREVIOUS_DISABLED, "true"); } id = panel.getId(); } else { // just disable next button request.setAttribute(PREVIOUS_DISABLED, "true"); } } } catch (LIMSRuntimeException lre) { // bugzilla 2154 LogEvent.logError("PanelNextPreviousAction", "performAction()", lre.toString()); request.setAttribute(ALLOW_EDITS_KEY, "false"); // disable previous and next request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); forward = FWD_FAIL; } if (forward.equals(FWD_FAIL)) return mapping.findForward(forward); if (panel.getId() != null && !panel.getId().equals("0")) { request.setAttribute(ID, panel.getId()); } return getForward(mapping.findForward(forward), id, start); }