private String getAppropriateResultValue(List<Result> results) { Result result = results.get(0); if (ResultType.DICTIONARY.matches(result.getResultType())) { Dictionary dictionary = dictionaryDAO.getDictionaryById(result.getValue()); if (dictionary != null) { return dictionary.getLocalizedName(); } } else if (ResultType.isMultiSelectVariant(result.getResultType())) { Dictionary dictionary = new Dictionary(); StringBuilder multiResult = new StringBuilder(); for (Result subResult : results) { dictionary.setId(subResult.getValue()); dictionaryDAO.getData(dictionary); if (dictionary.getId() != null) { multiResult.append(dictionary.getLocalizedName()); multiResult.append(", "); } } if (multiResult.length() > 0) { multiResult.setLength(multiResult.length() - 2); // remove last ", " } return multiResult.toString(); } else { String resultValue = GenericValidator.isBlankOrNull(result.getValue()) ? "" : result.getValue(); if (!GenericValidator.isBlankOrNull(resultValue) && result.getAnalysis().getTest().getUnitOfMeasure() != null) { resultValue += " " + result.getAnalysis().getTest().getUnitOfMeasure().getName(); } return resultValue; } return ""; }
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 TestAnalyte. // If there is a parameter present, we should bring up an existing // TestAnalyte to edit. TestAnalyteTestResultActionForm dynaForm = (TestAnalyteTestResultActionForm) form; String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "false"); request.setAttribute(PREVIOUS_DISABLED, "true"); request.setAttribute(NEXT_DISABLED, "true"); // CHANGED // String selectedTestId = (String) request.getParameter("Test"); List methods = new ArrayList(); MethodDAO methodDAO = new MethodDAOImpl(); methods = methodDAO.getAllMethods(); // Get tests/testsections by user system id // bugzilla 2160 UserTestSectionDAO userTestSectionDAO = new UserTestSectionDAOImpl(); List testSections = userTestSectionDAO.getAllUserTestSections(request); // bugzilla 2291 List tests = userTestSectionDAO.getAllUserTests(request, false); List selectedAnalyteTypes = new ArrayList(); // bugzilla 1870 List selectedAnalyteIsReportables = new ArrayList(); List selectedAnalyteResultGroups = new ArrayList(); List selectedAnalyteIds = new ArrayList(); List selectedAnalyteNames = new ArrayList(); List selectedTestAnalyteIds = new ArrayList(); List testAnalyteLastupdatedList = new ArrayList(); List testResultResultGroups = new ArrayList(); List testResultResultGroupTypes = new ArrayList(); List testResultValueList = new ArrayList(); List dictionaryEntryIdList = new ArrayList(); List flagsList = new ArrayList(); // bugzilla 1845 add testResult sortOrder List sortList = new ArrayList(); List significantDigitsList = new ArrayList(); List quantLimitList = new ArrayList(); List testResultIdList = new ArrayList(); List testResultLastupdatedList = new ArrayList(); Test test = new Test(); // FIXED BUG - NEED TO REFRESH SELECTIONS ON GOING INTO FORM // get 3 drop down selections so we can repopulate // String selectedTestSectionId = (String) dynaForm // .get("selectedTestSectionId"); // String selectedMethodId = (String) dynaForm.get("selectedMethodId"); // String selectedTestId = (String) dynaForm.get("selectedTestId"); String selectedTestId = null; String selectedTestSectionId = null; String selectedMethodId = null; // END BUG FIX // initialize the form dynaForm.initialize(mapping); dynaForm.resetLists(); // bugzilla 1350 need to check if test has been selected so stray // components don't display if (!StringUtil.isNullorNill(selectedTestId)) { // if test is selected enable the save button request.setAttribute(ALLOW_EDITS_KEY, "true"); test.setId(selectedTestId); TestDAO testDAO = new TestDAOImpl(); testDAO.getData(test); TestAnalyteDAO testAnalyteDAO = new TestAnalyteDAOImpl(); List testAnalytes = testAnalyteDAO.getAllTestAnalytesPerTest(test); TestResultDAO testResultDAO = new TestResultDAOImpl(); List testResults = testResultDAO.getAllActiveTestResultsPerTest(test); DictionaryDAO dictDAO = new DictionaryDAOImpl(); if (testAnalytes != null && testAnalytes.size() > 0) { for (int i = 0; i < testAnalytes.size(); i++) { TestAnalyte ta = (TestAnalyte) testAnalytes.get(i); selectedAnalyteTypes.add(ta.getTestAnalyteType()); // bugzilla 1870 selectedAnalyteIsReportables.add(ta.getIsReportable()); if (ta.getResultGroup() != null) { selectedAnalyteResultGroups.add(ta.getResultGroup()); } else { selectedAnalyteResultGroups.add(""); } selectedAnalyteIds.add(ta.getAnalyte().getId()); selectedAnalyteNames.add(ta.getAnalyte().getAnalyteName()); selectedTestAnalyteIds.add(ta.getId()); } if (testResults != null && testResults.size() > 0) { for (int i = 0; i < testResults.size(); i++) { TestResult tr = (TestResult) testResults.get(i); testResultIdList.add(tr.getId()); testResultLastupdatedList.add(tr.getLastupdated()); testResultResultGroups.add(tr.getResultGroup()); testResultResultGroupTypes.add(tr.getTestResultType()); if (tr.getTestResultType() .equals(SystemConfiguration.getInstance().getDictionaryType())) { dictionaryEntryIdList.add(tr.getValue()); Dictionary dict = new Dictionary(); dict.setId(tr.getValue()); dictDAO.getData(dict); // bugzilla 1847: use dictEntryDisplayValue testResultValueList.add(dict.getDictEntryDisplayValue()); } else { dictionaryEntryIdList.add(""); testResultValueList.add(tr.getValue()); } if (tr.getFlags() == null) { flagsList.add(""); } else { flagsList.add(tr.getFlags()); } // bugzilla 1845 add testResult sortOrder if (tr.getSortOrder() == null) { sortList.add(""); } else { sortList.add(tr.getSortOrder()); } if (tr.getSignificantDigits() == null) { significantDigitsList.add(""); } else { significantDigitsList.add(tr.getSignificantDigits()); } if (tr.getQuantLimit() == null) { quantLimitList.add(""); } else { quantLimitList.add(tr.getQuantLimit()); } } } isNew = false; } else { isNew = true; } } else { isNew = true; } PropertyUtils.setProperty(dynaForm, "selectedAnalyteTypes", selectedAnalyteTypes); // bugzilla 1870 PropertyUtils.setProperty( dynaForm, "selectedAnalyteIsReportables", selectedAnalyteIsReportables); PropertyUtils.setProperty(dynaForm, "selectedAnalyteResultGroups", selectedAnalyteResultGroups); PropertyUtils.setProperty(dynaForm, "selectedAnalyteIds", selectedAnalyteIds); PropertyUtils.setProperty(dynaForm, "selectedTestAnalyteIds", selectedTestAnalyteIds); PropertyUtils.setProperty(dynaForm, "testAnalyteLastupdatedList", testAnalyteLastupdatedList); PropertyUtils.setProperty(dynaForm, "selectedAnalyteNames", selectedAnalyteNames); PropertyUtils.setProperty(dynaForm, "testResultResultGroups", testResultResultGroups); PropertyUtils.setProperty(dynaForm, "testResultResultGroupTypes", testResultResultGroupTypes); PropertyUtils.setProperty(dynaForm, "testResultValueList", testResultValueList); PropertyUtils.setProperty(dynaForm, "testResultIdList", testResultIdList); PropertyUtils.setProperty(dynaForm, "testResultLastupdatedList", testResultLastupdatedList); PropertyUtils.setProperty(dynaForm, "dictionaryEntryIdList", dictionaryEntryIdList); PropertyUtils.setProperty(dynaForm, "flagsList", flagsList); // bugzilla 1845 add testResult sortOrder PropertyUtils.setProperty(dynaForm, "sortList", sortList); PropertyUtils.setProperty(dynaForm, "significantDigitsList", significantDigitsList); PropertyUtils.setProperty(dynaForm, "quantLimitList", quantLimitList); PropertyUtils.setProperty(dynaForm, "test", (test == null ? new Test() : test)); // sort three drop down lists Collections.sort(testSections, TestSectionComparator.NAME_COMPARATOR); // bugzilla 1844 - no longer sort by name but by description Collections.sort(tests, TestComparator.DESCRIPTION_COMPARATOR); Collections.sort(methods, MethodComparator.NAME_COMPARATOR); PropertyUtils.setProperty(dynaForm, "testSections", testSections); PropertyUtils.setProperty(dynaForm, "methods", methods); PropertyUtils.setProperty(dynaForm, "tests", tests); PropertyUtils.setProperty(dynaForm, "selectedTestSectionId", selectedTestSectionId); PropertyUtils.setProperty(dynaForm, "selectedMethodId", selectedMethodId); PropertyUtils.setProperty(dynaForm, "selectedTestId", selectedTestId); return mapping.findForward(forward); }