List of usage examples for org.apache.commons.beanutils PropertyUtils copyProperties
public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via BeanInfo
classes).
For more details see PropertyUtilsBean
.
From source file:us.mn.state.health.lims.result.daoimpl.ResultDAOImpl.java
public void getData(Result result) throws LIMSRuntimeException { try {/*w w w . ja va 2s . com*/ Result re = (Result) HibernateUtil.getSession().get(Result.class, result.getId()); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); if (re != null) { PropertyUtils.copyProperties(result, re); } else { result.setId(null); } } catch (Exception e) { LogEvent.logError("ResultDAOImpl", "getData()", e.toString()); throw new LIMSRuntimeException("Error in Result getData()", e); } }
From source file:us.mn.state.health.lims.result.daoimpl.ResultDAOImpl.java
public void getResultByAnalysisAndAnalyte(Result result, Analysis analysis, TestAnalyte ta) throws LIMSRuntimeException { List results;//from w w w . ja v a 2 s . c om try { Analyte analyte = ta.getAnalyte(); String sql = "from Result r where r.analysis = :analysisId and r.analyte = :analyteId"; org.hibernate.Query query = HibernateUtil.getSession().createQuery(sql); query.setInteger("analysisId", Integer.parseInt(analysis.getId())); query.setInteger("analyteId", Integer.parseInt(analyte.getId())); results = query.list(); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); Result thisResult; if (results != null && results.size() > 0) { thisResult = (Result) results.get(0); } else { thisResult = null; } if (thisResult != null) { PropertyUtils.copyProperties(result, thisResult); } else { result.setId(null); } } catch (Exception e) { LogEvent.logError("ResultDAOImpl", "getResultByAnalysisAndAnalyte()", e.toString()); throw new LIMSRuntimeException("Error in Result getResultByAnalysisAndAnalyte()", e); } }
From source file:us.mn.state.health.lims.result.daoimpl.ResultDAOImpl.java
public void getResultByTestResult(Result result, TestResult testResult) throws LIMSRuntimeException { List results;//from ww w . j a v a 2 s . com try { String sql = "from Result r where r.testResult = :testResultId"; org.hibernate.Query query = HibernateUtil.getSession().createQuery(sql); query.setInteger("testResultId", Integer.parseInt(testResult.getId())); results = query.list(); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); Result thisResult; if (results != null && results.size() > 0) { thisResult = (Result) results.get(0); } else { thisResult = null; } if (thisResult != null) { PropertyUtils.copyProperties(result, thisResult); } else { result.setId(null); } } catch (Exception e) { LogEvent.logError("ResultDAOImpl", "getResultByTestResult()", e.toString()); throw new LIMSRuntimeException("Error in Result getResultByTestResult()", e); } }
From source file:us.mn.state.health.lims.result.daoimpl.ResultInventoryDAOImpl.java
public void getData(ResultInventory resultInventory) throws LIMSRuntimeException { try {//from ww w . j av a 2 s .c om ResultInventory tmpResultInventory = (ResultInventory) HibernateUtil.getSession() .get(ResultInventory.class, resultInventory.getId()); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); if (tmpResultInventory != null) { PropertyUtils.copyProperties(resultInventory, tmpResultInventory); } else { resultInventory.setId(null); } } catch (Exception e) { LogEvent.logError("ResultInventoryDAOImpl", "getData()", e.toString()); throw new LIMSRuntimeException("Error in ResultInventory getData()", e); } }
From source file:us.mn.state.health.lims.result.daoimpl.ResultSignatureDAOImpl.java
public void getData(ResultSignature resultSignature) throws LIMSRuntimeException { try {//w ww . j a va 2s . c o m ResultSignature tmpResultSignature = (ResultSignature) HibernateUtil.getSession() .get(ResultSignature.class, resultSignature.getId()); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); if (tmpResultSignature != null) { PropertyUtils.copyProperties(resultSignature, tmpResultSignature); } else { resultSignature.setId(null); } } catch (Exception e) { LogEvent.logError("ResultSignatureDAOImpl", "getData()", e.toString()); throw new LIMSRuntimeException("Error in ResultSignature getData()", e); } }
From source file:us.mn.state.health.lims.resultlimits.daoimpl.ResultLimitDAOImpl.java
public void getData(ResultLimit resultLimit) throws LIMSRuntimeException { try {// w ww .ja v a 2 s. c o m ResultLimit tmpLimit = (ResultLimit) HibernateUtil.getSession().get(ResultLimit.class, resultLimit.getId()); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); if (tmpLimit != null) { PropertyUtils.copyProperties(resultLimit, tmpLimit); } else { resultLimit.setId(null); } } catch (Exception e) { LogEvent.logError("ResultLimitsDAOImpl", "getData()", e.toString()); throw new LIMSRuntimeException("Error in ResultLimit getData()", e); } }
From source file:us.mn.state.health.lims.role.daoimpl.RoleDAOImpl.java
public void getData(Role role) throws LIMSRuntimeException { try {//from ww w . ja v a2s.c o m Role tmpRole = (Role) HibernateUtil.getSession().get(Role.class, role.getId()); HibernateUtil.getSession().flush(); HibernateUtil.getSession().clear(); if (tmpRole != null) { PropertyUtils.copyProperties(role, tmpRole); } else { role.setId(null); } } catch (Exception e) { LogEvent.logError("RolesDAOImpl", "getData()", e.toString()); throw new LIMSRuntimeException("Error in Role getData()", e); } }
From source file:us.mn.state.health.lims.sample.action.HumanSampleOneAction.java
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // this is a new sample String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "false"); BaseActionForm dynaForm = (BaseActionForm) form; // initialize the form dynaForm.initialize(mapping);/* w ww.j a v a 2 s .co m*/ Sample sample = new Sample(); Patient patient = new Patient(); Person person = new Person(); // this is a new sample // default received date and entered date to today's date Date today = Calendar.getInstance().getTime(); Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE"); String dateAsText = DateUtil.formatDateAsText(today, locale); sample.setReceivedDateForDisplay(dateAsText); sample.setEnteredDateForDisplay(dateAsText); sample.setReferredCultureFlag( SystemConfiguration.getInstance().getHumanSampleOneDefaultReferredCultureFlag()); sample.setStickerReceivedFlag( SystemConfiguration.getInstance().getHumanSampleOneDefaultStickerReceivedFlag()); // default nextItemSequence to 1 (for clinical - always 1) sample.setNextItemSequence(SystemConfiguration.getInstance().getHumanSampleOneDefaultNextItemSequence()); // revision is set to 0 on insert sample.setRevision(SystemConfiguration.getInstance().getHumanSampleOneDefaultRevision()); sample.setCollectionTimeForDisplay( SystemConfiguration.getInstance().getHumanSampleOneDefaultCollectionTimeForDisplay()); if (sample.getId() != null && !sample.getId().equals("0")) { request.setAttribute(ID, sample.getId()); } patient.setGender(SystemConfiguration.getInstance().getHumanSampleOneDefaultPatientGender()); // populate form from valueholder PropertyUtils.copyProperties(form, sample); PropertyUtils.copyProperties(form, person); PropertyUtils.copyProperties(form, patient); SystemUserDAO sysUserDAO = new SystemUserDAOImpl(); SampleDomainDAO sampleDomainDAO = new SampleDomainDAOImpl(); GenderDAO genderDAO = new GenderDAOImpl(); TypeOfSampleDAO typeOfSampleDAO = new TypeOfSampleDAOImpl(); SourceOfSampleDAO sourceOfSampleDAO = new SourceOfSampleDAOImpl(); List sysUsers = sysUserDAO.getAllSystemUsers(); List sampleDomains = sampleDomainDAO.getAllSampleDomains(); List genders = genderDAO.getAllGenders(); List typeOfSamples = typeOfSampleDAO.getAllTypeOfSamples(); List sourceOfSamples = sourceOfSampleDAO.getAllSourceOfSamples(); //pdf if (SystemConfiguration.getInstance().getEnabledSamplePdf().equals(YES)) { String status = SystemConfiguration.getInstance().getSampleStatusQuickEntryComplete(); //status = 1 String humanDomain = SystemConfiguration.getInstance().getHumanDomain(); UserTestSectionDAO userTestSectionDAO = new UserTestSectionDAOImpl(); List accessionNumberListOne = userTestSectionDAO.getSamplePdfList(request, locale, status, humanDomain); PropertyUtils.setProperty(form, "accessionNumberListOne", accessionNumberListOne); } PropertyUtils.setProperty(form, "sysUsers", sysUsers); PropertyUtils.setProperty(form, "sampleDomains", sampleDomains); PropertyUtils.setProperty(form, "genders", genders); PropertyUtils.setProperty(form, "typeOfSamples", typeOfSamples); PropertyUtils.setProperty(form, "sourceOfSamples", sourceOfSamples); PropertyUtils.setProperty(form, "currentDate", dateAsText); request.setAttribute("menuDefinition", "HumanSampleOneDefinition"); return mapping.findForward(forward); }
From source file:us.mn.state.health.lims.sample.action.HumanSampleOneUpdateAction.java
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 Sample. // If there is a parameter present, we should bring up an existing // Sample to edit. String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); String id = request.getParameter(ID); if (StringUtil.isNullorNill(id) || "0".equals(id)) { isNew = true;/*w w w . j a v a 2s. c o m*/ } else { isNew = false; } BaseActionForm dynaForm = (BaseActionForm) form; // server-side validation (validation.xml) ActionMessages errors = dynaForm.validate(mapping, request); // validate on server-side patient city/zip combination /* * String city = (String) dynaForm.get("city"); String zipCode = * (String) dynaForm.get("zipCode"); if (!StringUtil.isNullorNill(city) && * !StringUtil.isNullorNill(zipCode)) { try { errors = * validateZipCity(errors, zipCode, city); } catch (Exception e) { * ActionError error = new ActionError( "errors.ValidationException", * null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } } */ try { errors = validateAll(request, errors, dynaForm); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("HumanSampleOneUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } // end of zip/city combination check if (errors != null && errors.size() > 0) { // System.out.println("saveing errors " + errors.size()); saveErrors(request, errors); // since we forward to jsp - not Action we don't need to repopulate // the lists here return mapping.findForward(FWD_FAIL); } String start = (String) request.getParameter("startingRecNo"); Patient patient = new Patient(); Person person = new Person(); Provider provider = new Provider(); Person providerPerson = new Person(); Sample sample = new Sample(); SampleHuman sampleHuman = new SampleHuman(); SampleOrganization sampleOrganization = new SampleOrganization(); List sampleProjects = new ArrayList(); SampleItem sampleItem = new SampleItem(); sampleItem.setStatusId(StatusService.getInstance().getStatusID(SampleStatus.Entered)); // bugzilla 1926 get sysUserId from login module UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); String sysUserId = String.valueOf(usd.getSystemUserId()); // String typeOfSampleId = (String) dynaForm.get("typeOfSampleId"); String typeOfSample = (String) dynaForm.get("typeOfSampleDesc"); // String sourceOfSampleId = (String) dynaForm.get("sourceOfSampleId"); //bugzilla 2470, unused // String sourceOfSample = (String) dynaForm.get("sourceOfSampleDesc"); List sysUsers = new ArrayList(); List sampleDomains = new ArrayList(); List typeOfSamples = new ArrayList(); List sourceOfSamples = new ArrayList(); if (dynaForm.get("sysUsers") != null) { sysUsers = (List) dynaForm.get("sysUsers"); } else { SystemUserDAO sysUserDAO = new SystemUserDAOImpl(); sysUsers = sysUserDAO.getAllSystemUsers(); } if (dynaForm.get("sampleDomains") != null) { sampleDomains = (List) dynaForm.get("sampleDomains"); } else { SampleDomainDAO sampleDomainDAO = new SampleDomainDAOImpl(); sampleDomains = sampleDomainDAO.getAllSampleDomains(); } if (dynaForm.get("typeOfSamples") != null) { typeOfSamples = (List) dynaForm.get("typeOfSamples"); } else { TypeOfSampleDAO typeOfSampleDAO = new TypeOfSampleDAOImpl(); typeOfSamples = typeOfSampleDAO.getAllTypeOfSamples(); } if (dynaForm.get("sourceOfSamples") != null) { sourceOfSamples = (List) dynaForm.get("sourceOfSamples"); } else { SourceOfSampleDAO sourceOfSampleDAO = new SourceOfSampleDAOImpl(); sourceOfSamples = sourceOfSampleDAO.getAllSourceOfSamples(); } String stringOfTestIds = (String) dynaForm.get("selectedTestIds"); String projectIdOrName = (String) dynaForm.get("projectIdOrName"); String project2IdOrName = (String) dynaForm.get("project2IdOrName"); String projectNameOrId = (String) dynaForm.get("projectNameOrId"); String project2NameOrId = (String) dynaForm.get("project2NameOrId"); // get the numeric projectId either from projectIdOrName or from // projectNameOrId String projectId = null; String project2Id = null; //bugzilla 2318 if (!StringUtil.isNullorNill(projectIdOrName) && !StringUtil.isNullorNill(projectNameOrId)) { try { Integer i = Integer.valueOf(projectIdOrName); projectId = projectIdOrName; //bugzilla 2154 LogEvent.logDebug("HumanSampleOneUpdateAction", "performAction()", "Parsed integer value of projectIdOrName: " + projectIdOrName + " projectNameOrId: " + projectNameOrId); } catch (NumberFormatException nfe) { projectId = projectNameOrId; //bugzilla 2154 LogEvent.logError("HumanSampleOneUpdateAction", "performAction()", "Error parsing integer value of projectIdOrName: " + projectIdOrName + " " + nfe.toString()); } } //bugzilla 2318 if (!StringUtil.isNullorNill(project2IdOrName) && !StringUtil.isNullorNill(project2NameOrId)) { try { Integer i = Integer.valueOf(project2IdOrName); project2Id = project2IdOrName; //bugzilla 2154 LogEvent.logDebug("HumanSampleOneUpdateAction", "performAction()", "Parsed integer value of project2IdOrName: " + project2IdOrName + " project2NameOrId: " + project2NameOrId); } catch (NumberFormatException nfe) { project2Id = project2NameOrId; //bugzilla 2154 LogEvent.logError("HumanSampleOneUpdateAction", "performAction()", "Error parsing integer value of project2IdOrName: " + project2IdOrName + " " + nfe.toString()); } } String[] listOfTestIds = stringOfTestIds.split(SystemConfiguration.getInstance().getDefaultIdSeparator(), -1); List analyses = new ArrayList(); for (int i = 0; i < listOfTestIds.length; i++) { if (!StringUtil.isNullorNill(listOfTestIds[i])) { Analysis analysis = new Analysis(); Test test = new Test(); String testId = (String) listOfTestIds[i]; test.setId(testId); TestDAO testDAO = new TestDAOImpl(); testDAO.getData(test); analysis.setTest(test); // TODO: need to populate this with actual data!!! analysis.setAnalysisType("TEST"); analyses.add(analysis); } } SystemUser sysUser = null; for (int i = 0; i < sysUsers.size(); i++) { SystemUser su = (SystemUser) sysUsers.get(i); if (su.getId().equals(sysUserId)) { sysUser = su; break; } } TypeOfSample typeOfSamp = null; // get the right typeOfSamp to update sampleitem with for (int i = 0; i < typeOfSamples.size(); i++) { TypeOfSample s = (TypeOfSample) typeOfSamples.get(i); // if (s.getId().equals(typeOfSampleId)) { if (s.getDescription().equalsIgnoreCase(typeOfSample)) { typeOfSamp = s; break; } } // fixed in bugzilla 2470, unused //SourceOfSample sourceOfSamp = null; /* // get the right sourceOfSamp to update sampleitem with for (int i = 0; i < sourceOfSamples.size(); i++) { SourceOfSample s = (SourceOfSample) sourceOfSamples.get(i); // if (s.getId().equals(sourceOfSampleId)) { if (s.getDescription().equalsIgnoreCase(sourceOfSample)) { sourceOfSamp = s; break; } } */ // populate valueholder from form PropertyUtils.copyProperties(sample, dynaForm); PropertyUtils.copyProperties(person, dynaForm); PropertyUtils.copyProperties(patient, dynaForm); PropertyUtils.copyProperties(provider, dynaForm); PropertyUtils.copyProperties(sampleHuman, dynaForm); PropertyUtils.copyProperties(sampleOrganization, dynaForm); PropertyUtils.copyProperties(sampleItem, dynaForm); Organization o = new Organization(); //bugzilla 2069 o.setOrganizationLocalAbbreviation((String) dynaForm.get("organizationLocalAbbreviation")); OrganizationDAO organizationDAO = new OrganizationDAOImpl(); o = organizationDAO.getOrganizationByLocalAbbreviation(o, true); sampleOrganization.setOrganization(o); // if there was a first sampleProject id entered if (!StringUtil.isNullorNill(projectId)) { SampleProject sampleProject = new SampleProject(); Project p = new Project(); //bugzilla 2438 p.setLocalAbbreviation(projectId); ProjectDAO projectDAO = new ProjectDAOImpl(); p = projectDAO.getProjectByLocalAbbreviation(p, true); sampleProject.setProject(p); sampleProject.setIsPermanent(NO); sampleProjects.add(sampleProject); } // in case there was a second sampleProject id entered if (!StringUtil.isNullorNill(project2Id)) { SampleProject sampleProject2 = new SampleProject(); Project p2 = new Project(); //bugzilla 2438 p2.setLocalAbbreviation(project2Id); ProjectDAO projectDAO = new ProjectDAOImpl(); p2 = projectDAO.getProjectByLocalAbbreviation(p2, true); sampleProject2.setProject(p2); sampleProject2.setIsPermanent(NO); sampleProjects.add(sampleProject2); } // set the provider person manually as we have two Person valueholders // to populate and copyProperties() can only handle one per form providerPerson.setFirstName((String) dynaForm.get("providerFirstName")); providerPerson.setLastName((String) dynaForm.get("providerLastName")); // format workPhone for storage String workPhone = (String) dynaForm.get("providerWorkPhone"); String ext = (String) dynaForm.get("providerWorkPhoneExtension"); String formattedPhone = StringUtil.formatPhone(workPhone, ext); // phone is stored as 999/999-9999.9999 // area code/phone - number.extension providerPerson.setWorkPhone(formattedPhone); //bugzilla 1701 blank out provider.externalId - this is copied from patient //externalId which is not related...and we currently don't enter an externalId for //provider on this screen provider.setExternalId(BLANK); // set collection time String time = (String) dynaForm.get("collectionTimeForDisplay"); if (StringUtil.isNullorNill(time)) { time = "00:00"; } sample.setCollectionTimeForDisplay(time); // AIS - bugzilla 1408 - Start String accessionNumberOne = (String) dynaForm.get("accessionNumber"); sample.setAccessionNumber(accessionNumberOne); SampleDAO sampleDAO = new SampleDAOImpl(); sampleDAO.getSampleByAccessionNumber(sample); String stickerReceivedFlag = (String) dynaForm.get("stickerReceivedFlag"); String referredCultureFlag = (String) dynaForm.get("referredCultureFlag"); sample.setStickerReceivedFlag(stickerReceivedFlag); sample.setReferredCultureFlag(referredCultureFlag); String date = (String) dynaForm.get("collectionDateForDisplay"); // bgm - bugzilla 1586 check for null collection date //db bugzilla 1765 - noticed that error occurs - need to check // also that date is not nill as well as not null if (!StringUtil.isNullorNill(date)) { sample.setCollectionDateForDisplay(date); // AIS - bugzilla 1408 - End Timestamp d = sample.getCollectionDate(); //bugzilla 1857 deprecated date stuff Calendar cal = Calendar.getInstance(); cal.setTime(d); if (null != d) if (time.indexOf(":") > 0) { cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(time.substring(0, 2)).intValue()); //d.setHours(Integer.valueOf(time.substring(0, 2)).intValue()); cal.set(Calendar.MINUTE, Integer.valueOf(time.substring(3, 5)).intValue()); //d.setMinutes(Integer.valueOf(time.substring(3, 5)).intValue()); d = new Timestamp(cal.getTimeInMillis()); sample.setCollectionDate(d); } } // sampleItem sampleItem.setSortOrder("1"); // set the typeOfSample sampleItem.setTypeOfSample(typeOfSamp); // sampleItem.setTypeOfSample(typeOfSample); // set the sourceOfSample // fixed in bugzilla 2470 unused //sampleItem.setSourceOfSample(sourceOfSamp); // sampleItem.setSourceOfSample(sourceOfSample); // set the system user sample.setSystemUser(sysUser); //bugzilla 2112 sample.setSysUserId(sysUserId); //bugzilla 1926 sampleItem.setSysUserId(sysUserId); sampleOrganization.setSysUserId(sysUserId); sampleHuman.setSysUserId(sysUserId); patient.setSysUserId(sysUserId); person.setSysUserId(sysUserId); provider.setSysUserId(sysUserId); providerPerson.setSysUserId(sysUserId); //bugzilla 2169 - undo bugzilla 1408 logic to copy externalId into sample client_reference if clientRef# is blank if (!StringUtil.isNullorNill((String) dynaForm.get("clientReference"))) { sample.setClientReference((String) dynaForm.get("clientReference")); } //bugzilla 1761 (get status code and domain from SystemConfiguration) sample.setStatus(SystemConfiguration.getInstance().getSampleStatusEntry1Complete()); sample.setDomain(SystemConfiguration.getInstance().getHumanDomain()); sample.setSampleProjects(sampleProjects); org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction(); try { // HumanSampleOneDAO humanSampleOneDAO = new // HumanSampleOneDAOImpl(); PersonDAO personDAO = new PersonDAOImpl(); PatientDAO patientDAO = new PatientDAOImpl(); ProviderDAO providerDAO = new ProviderDAOImpl(); // AIS - bugzilla 1408 ( already declared..) // SampleDAO sampleDAO = new SampleDAOImpl(); SampleItemDAO sampleItemDAO = new SampleItemDAOImpl(); SampleProjectDAO sampleProjectDAO = new SampleProjectDAOImpl(); SampleHumanDAO sampleHumanDAO = new SampleHumanDAOImpl(); SampleOrganizationDAO sampleOrganizationDAO = new SampleOrganizationDAOImpl(); AnalysisDAO analysisDAO = new AnalysisDAOImpl(); // why does it only work if sample is the first insert (not when // person is first insert?) // AIS - bugzilla 1408 // sampleDAO.insertData(sample); //bugzilla 2154 LogEvent.logDebug("HumanSampleOneUpdateAction", "performAction()", "About to sampleDAO.updateData() status code: " + sample.getStatus()); sampleDAO.updateData(sample); personDAO.insertData(person); patient.setPerson(person); patientDAO.insertData(patient); personDAO.insertData(providerPerson); provider.setPerson(providerPerson); providerDAO.insertData(provider); for (int i = 0; i < sampleProjects.size(); i++) { SampleProject sampleProject = (SampleProject) sampleProjects.get(i); sampleProject.setSample(sample); // sampleProject.setProject(prClone); //bugzilla 2112 sampleProject.setSysUserId(sysUserId); sampleProjectDAO.insertData(sampleProject); } sampleHuman.setSampleId(sample.getId()); sampleHuman.setPatientId(patient.getId()); sampleHuman.setProviderId(provider.getId()); sampleHumanDAO.insertData(sampleHuman); sampleOrganization.setSampleId(sample.getId()); sampleOrganization.setSample(sample); sampleOrganizationDAO.insertData(sampleOrganization); //bugzilla 1773 need to store sample not sampleId for use in sorting sampleItem.setSample(sample); // AIS - bugzilla 1408 // sampleItemDAO.insertData(sampleItem); //bugzilla 2113 SampleItem si = new SampleItem(); si.setSample(sample); sampleItemDAO.getDataBySample(si); sampleItem.setId(si.getId()); //bugzilla 2470 sampleItem.setSourceOfSampleId(si.getSourceOfSampleId()); sampleItem.setSourceOther(si.getSourceOther()); sampleItem.setLastupdated(si.getLastupdated()); sampleItemDAO.updateData(sampleItem); // Analysis table if (analyses != null) { for (int i = 0; i < analyses.size(); i++) { Analysis analysis = (Analysis) analyses.get(i); analysis.setSampleItem(sampleItem); //bugzilla 2064 analysis.setRevision(SystemConfiguration.getInstance().getAnalysisDefaultRevision()); //bugzilla 2013 added duplicateCheck parameter analysisDAO.insertData(analysis, false); } } // insert humanSampleOne // humanSampleOneDAO.insertData(patient, person, provider, // providerPerson, sample, sampleHuman, sampleOrganization, // sampleItem, analyses); tx.commit(); } catch (LIMSRuntimeException lre) { //bugzilla 2154 LogEvent.logError("HumanSampleOneUpdateAction", "performAction()", lre.toString()); tx.rollback(); errors = new ActionMessages(); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { // how can I get popup instead of struts error at the top of // page? // ActionMessages errors = dynaForm.validate(mapping, request); error = new ActionError("errors.OptimisticLockException", null, null); } else { //lre.printStackTrace(); error = new ActionError("errors.UpdateException", null, null); } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); request.setAttribute(ALLOW_EDITS_KEY, "false"); forward = FWD_FAIL; } finally { HibernateUtil.closeSession(); } if (forward.equals(FWD_FAIL)) return mapping.findForward(forward); // initialize the form dynaForm.initialize(mapping); // repopulate the form from valueholder PropertyUtils.copyProperties(dynaForm, sample); // PropertyUtils.setProperty(dynaForm, "parentSamples", samps); PropertyUtils.setProperty(dynaForm, "sysUsers", sysUsers); PropertyUtils.setProperty(dynaForm, "sampleDomains", sampleDomains); if ("true".equalsIgnoreCase(request.getParameter("close"))) { forward = FWD_CLOSE; } if (sample.getId() != null && !sample.getId().equals("0")) { request.setAttribute(ID, sample.getId()); } if (forward.equals(FWD_SUCCESS)) { request.setAttribute("menuDefinition", "default"); } // TODO: temporary code to forward with accessionNumber (remove the // overriding getForward in this class String accessionNumber = sample.getAccessionNumber(); // return getForward(mapping.findForward(forward), id, start); return getForward(mapping.findForward(forward), id, start, accessionNumber); }
From source file:us.mn.state.health.lims.sample.action.HumanSampleTwoUpdateAction.java
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 Sample. // If there is a parameter present, we should bring up an existing // Sample to edit. String forward = FWD_SUCCESS; request.setAttribute(ALLOW_EDITS_KEY, "true"); String id = request.getParameter(ID); if (StringUtil.isNullorNill(id) || "0".equals(id)) { isNew = true;//from w w w. ja va 2 s .c o m } else { isNew = false; } BaseActionForm dynaForm = (BaseActionForm) form; // first get the accessionNumber and whether we are on blank page or not String accessionNumber = (String) dynaForm.get("accessionNumber"); String blankscreen = (String) dynaForm.get("blankscreen"); String start = (String) request.getParameter("startingRecNo"); String typeOfSample = (String) dynaForm.get("typeOfSampleDesc"); //bugzilla 2470, unused //String sourceOfSample = (String) dynaForm.get("sourceOfSampleDesc"); List typeOfSamples = new ArrayList(); List sourceOfSamples = new ArrayList(); if (dynaForm.get("typeOfSamples") != null) { typeOfSamples = (List) dynaForm.get("typeOfSamples"); } else { TypeOfSampleDAO typeOfSampleDAO = new TypeOfSampleDAOImpl(); typeOfSamples = typeOfSampleDAO.getAllTypeOfSamples(); } if (dynaForm.get("sourceOfSamples") != null) { sourceOfSamples = (List) dynaForm.get("sourceOfSamples"); } else { SourceOfSampleDAO sourceOfSampleDAO = new SourceOfSampleDAOImpl(); sourceOfSamples = sourceOfSampleDAO.getAllSourceOfSamples(); } HashMap humanSampleOneMap = new HashMap(); if (dynaForm.get("humanSampleOneMap") != null) { humanSampleOneMap = (HashMap) dynaForm.get("humanSampleOneMap"); } String projectIdOrName = (String) dynaForm.get("projectIdOrName"); String project2IdOrName = (String) dynaForm.get("project2IdOrName"); String projectNameOrId = (String) dynaForm.get("projectNameOrId"); String project2NameOrId = (String) dynaForm.get("project2NameOrId"); String projectId = null; String project2Id = null; if (projectIdOrName != null && projectNameOrId != null) { try { Integer i = Integer.valueOf(projectIdOrName); projectId = projectIdOrName; } catch (NumberFormatException nfe) { //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", nfe.toString()); projectId = projectNameOrId; } } if (project2IdOrName != null && project2NameOrId != null) { try { Integer i = Integer.valueOf(project2IdOrName); project2Id = project2IdOrName; } catch (NumberFormatException nfe) { //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", nfe.toString()); project2Id = project2NameOrId; } } //bugzilla 2028 //bugzilla 2069 String submitterNumber = (String) dynaForm.get("organizationLocalAbbreviation"); // set current date for validation of dates Date today = Calendar.getInstance().getTime(); Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE"); String dateAsText = DateUtil.formatDateAsText(today, locale); PersonDAO personDAO = new PersonDAOImpl(); PatientDAO patientDAO = new PatientDAOImpl(); ProviderDAO providerDAO = new ProviderDAOImpl(); SampleDAO sampleDAO = new SampleDAOImpl(); SampleItemDAO sampleItemDAO = new SampleItemDAOImpl(); SampleHumanDAO sampleHumanDAO = new SampleHumanDAOImpl(); SampleOrganizationDAO sampleOrganizationDAO = new SampleOrganizationDAOImpl(); AnalysisDAO analysisDAO = new AnalysisDAOImpl(); SampleProjectDAO sampleProjectDAO = new SampleProjectDAOImpl(); ProjectDAO projectDAO = new ProjectDAOImpl(); AnalysisQaEventDAO analysisQaEventDAO = new AnalysisQaEventDAOImpl(); QaEventDAO qaEventDAO = new QaEventDAOImpl(); Patient patient = new Patient(); Person person = new Person(); Provider provider = new Provider(); Person providerPerson = new Person(); Sample sample = new Sample(); SampleHuman sampleHuman = new SampleHuman(); SampleOrganization sampleOrganization = new SampleOrganization(); List oldSampleProjects = new ArrayList(); List newSampleProjects = new ArrayList(); SampleItem sampleItem = new SampleItem(); sampleItem.setStatusId(StatusService.getInstance().getStatusID(SampleStatus.Entered)); // TODO need to populate this with tests entered in HSE I List analyses = new ArrayList(); ActionMessages errors = null; // validate on server-side sample accession number try { errors = new ActionMessages(); errors = validateAccessionNumber(request, errors, dynaForm); // System.out.println("Just validated accessionNumber"); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } // System.out.println("This is errors after validation of accn Number " // + errors); if (errors != null && errors.size() > 0) { saveErrors(request, errors); // initialize the form but retain the invalid accessionNumber dynaForm.initialize(mapping); dynaForm.set("accessionNumber", accessionNumber); // repopulate lists PropertyUtils.setProperty(dynaForm, "typeOfSamples", typeOfSamples); PropertyUtils.setProperty(dynaForm, "sourceOfSamples", sourceOfSamples); PropertyUtils.setProperty(dynaForm, "blankscreen", "true"); request.setAttribute(ALLOW_EDITS_KEY, "false"); return mapping.findForward(FWD_FAIL); } // System.out.println("Now try to get data for accession number "); errors = dynaForm.validate(mapping, request); try { errors = validateAll(request, errors, dynaForm, humanSampleOneMap); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", e.toString()); ActionError error = new ActionError("errors.ValidationException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } // end of zip/city combination check if (errors != null && errors.size() > 0) { saveErrors(request, errors); // since we forward to jsp - not Action we don't need to // repopulate // the lists here return mapping.findForward(FWD_FAIL); } // GET ORIGINAL DATA try { sample.setAccessionNumber(accessionNumber); sampleDAO.getSampleByAccessionNumber(sample); if (!StringUtil.isNullorNill(sample.getId())) { sampleHuman.setSampleId(sample.getId()); sampleHumanDAO.getDataBySample(sampleHuman); sampleOrganization.setSampleId(sample.getId()); sampleOrganizationDAO.getDataBySample(sampleOrganization); //bugzilla 1773 need to store sample not sampleId for use in sorting sampleItem.setSample(sample); sampleItemDAO.getDataBySample(sampleItem); patient.setId(sampleHuman.getPatientId()); patientDAO.getData(patient); person = patient.getPerson(); personDAO.getData(person); provider.setId(sampleHuman.getProviderId()); providerDAO.getData(provider); providerPerson = provider.getPerson(); personDAO.getData(providerPerson); //bugzilla 2227 analyses = analysisDAO.getMaxRevisionAnalysesBySample(sampleItem); oldSampleProjects = sample.getSampleProjects(); } } catch (LIMSRuntimeException lre) { // if error then forward to fail and don't update to blank page // = false //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", lre.toString()); errors = new ActionMessages(); ActionError error = null; error = new ActionError("errors.GetException", null, null); errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); request.setAttribute(ALLOW_EDITS_KEY, "false"); return mapping.findForward(FWD_FAIL); } TypeOfSample typeOfSamp = null; // get the right typeOfSamp to update sampleitem with for (int i = 0; i < typeOfSamples.size(); i++) { TypeOfSample s = (TypeOfSample) typeOfSamples.get(i); // if (s.getId().equals(typeOfSampleId)) { if (s.getDescription().equalsIgnoreCase(typeOfSample)) { typeOfSamp = s; break; } } // fixed in bugzilla 2470, unused //SourceOfSample sourceOfSamp = null; /* // get the right sourceOfSamp to update sampleitem with for (int i = 0; i < sourceOfSamples.size(); i++) { SourceOfSample s = (SourceOfSample) sourceOfSamples.get(i); // if (s.getId().equals(sourceOfSampleId)) { if (s.getDescription().equalsIgnoreCase(sourceOfSample)) { sourceOfSamp = s; break; } } */ // System.out.println("This is entered date before update from form // " // + sample.getEnteredDate() // + sample.getEnteredDateForDisplay()); // UPDATE DATA FROM FORM // populate valueholder from form PropertyUtils.copyProperties(sample, dynaForm); PropertyUtils.copyProperties(person, dynaForm); PropertyUtils.copyProperties(patient, dynaForm); PropertyUtils.copyProperties(provider, dynaForm); PropertyUtils.copyProperties(sampleHuman, dynaForm); PropertyUtils.copyProperties(sampleOrganization, dynaForm); PropertyUtils.copyProperties(sampleItem, dynaForm); Organization org = new Organization(); org.setOrganizationLocalAbbreviation((String) dynaForm.get("organizationLocalAbbreviation")); OrganizationDAO organizationDAO = new OrganizationDAOImpl(); org = organizationDAO.getOrganizationByLocalAbbreviation(org, true); sampleOrganization.setOrganization(org); // if there was a first sampleProject id entered // if there was a first sampleProject id entered if (!StringUtil.isNullorNill(projectId)) { SampleProject sampleProject = new SampleProject(); Project p = new Project(); //bugzilla 2438 p.setLocalAbbreviation(projectId); p = projectDAO.getProjectByLocalAbbreviation(p, true); sampleProject.setProject(p); sampleProject.setSample(sample); sampleProject.setIsPermanent(NO); newSampleProjects.add(sampleProject); } // in case there was a second sampleProject id entered if (!StringUtil.isNullorNill(project2Id)) { SampleProject sampleProject2 = new SampleProject(); Project p2 = new Project(); //bugzilla 2438 p2.setLocalAbbreviation(project2Id); p2 = projectDAO.getProjectByLocalAbbreviation(p2, true); sampleProject2.setProject(p2); sampleProject2.setSample(sample); sampleProject2.setIsPermanent(NO); newSampleProjects.add(sampleProject2); } // set the provider person manually as we have two Person // valueholders // to populate and copyProperties() can only handle one per form providerPerson.setFirstName((String) dynaForm.get("providerFirstName")); providerPerson.setLastName((String) dynaForm.get("providerLastName")); // format workPhone for storage String workPhone = (String) dynaForm.get("providerWorkPhone"); String ext = (String) dynaForm.get("providerWorkPhoneExtension"); String formattedPhone = StringUtil.formatPhone(workPhone, ext); // phone is stored as 999/999-9999.9999 // area code/phone - number.extension providerPerson.setWorkPhone(formattedPhone); //bugzilla 1701 blank out provider.externalId - this is copied from patient //externalId which is not related...and we currently don't enter an externalId for //provider on this screen provider.setExternalId(BLANK); // set collection time String time = (String) dynaForm.get("collectionTimeForDisplay"); if (StringUtil.isNullorNill(time)) { time = "00:00"; } sample.setCollectionTimeForDisplay(time); Timestamp d = sample.getCollectionDate(); //bgm - bugzilla 1586 check for null date if (null != d) { if (time.indexOf(":") > 0) { //bugzilla 1857 deprecated stuff Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(time.substring(0, 2)).intValue()); cal.set(Calendar.MINUTE, Integer.valueOf(time.substring(3, 5)).intValue()); //d.setHours(Integer.valueOf(time.substring(0, 2)).intValue()); //d.setMinutes(Integer.valueOf(time.substring(3, 5)).intValue()); d = new Timestamp(cal.getTimeInMillis()); sample.setCollectionDate(d); } } // sampleItem sampleItem.setSortOrder("1"); // set the typeOfSample sampleItem.setTypeOfSample(typeOfSamp); // set the sourceOfSample // fixed in bugzilla 2470 unused //sampleItem.setSourceOfSample(sourceOfSamp); sample.setSampleProjects(newSampleProjects); // get entered by through system (when we have login functionality) // removed per Christina 3/03/2006 // sample.setEnteredBy("diane"); //get sysUserId from login module UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); String sysUserId = String.valueOf(usd.getSystemUserId()); org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction(); List newIds = new ArrayList(); List oldIds = new ArrayList(); if (newSampleProjects != null) { for (int i = 0; i < newSampleProjects.size(); i++) { SampleProject sp = (SampleProject) newSampleProjects.get(i); newIds.add(sp.getId()); } } if (oldSampleProjects != null) { List listOfOldOnesToRemove = new ArrayList(); for (int i = 0; i < oldSampleProjects.size(); i++) { SampleProject sp = (SampleProject) oldSampleProjects.get(i); oldIds.add(sp.getId()); if (!newIds.contains(sp.getId())) { // remove ones that are to be deleted listOfOldOnesToRemove.add(new Integer(i)); } } int decreaseOSPIndexBy = 0; int decreaseOIIndexBy = 0; List listOfSampleProjectObjectsToDelete = new ArrayList(); for (int i = 0; i < listOfOldOnesToRemove.size(); i++) { SampleProject sp = (SampleProject) oldSampleProjects .remove(((Integer) listOfOldOnesToRemove.get(i)).intValue() - decreaseOSPIndexBy++); //bugzilla 1926 sp.setSysUserId(sysUserId); listOfSampleProjectObjectsToDelete.add(sp); oldIds.remove(((Integer) listOfOldOnesToRemove.get(i)).intValue() - decreaseOIIndexBy++); } sampleProjectDAO.deleteData(listOfSampleProjectObjectsToDelete); } if (newSampleProjects != null) { for (int j = 0; j < newSampleProjects.size(); j++) { SampleProject saPr = (SampleProject) newSampleProjects.get(j); int index = oldIds.indexOf(saPr.getId()); if (index >= 0) { SampleProject sampleProjectClone = (SampleProject) oldSampleProjects.get(index); PropertyUtils.copyProperties(sampleProjectClone, saPr); Sample smplClone = (Sample) sampleProjectClone.getSample(); sampleProjectClone.setSample(smplClone); Project pClone = (Project) sampleProjectClone.getProject(); sampleProjectClone.setProject(pClone); PropertyUtils.setProperty(sampleProjectClone, "lastupdated", (Timestamp) dynaForm.get("sampleProject1Lastupdated")); sampleProjectClone.setSysUserId(sysUserId); sampleProjectDAO.updateData(sampleProjectClone); oldSampleProjects.set(index, sampleProjectClone); } else { SampleProject sampleProjectClone = new SampleProject(); PropertyUtils.copyProperties(sampleProjectClone, saPr); Sample smplClone = (Sample) sampleProjectClone.getSample(); sampleProjectClone.setSample(smplClone); Project pClone = (Project) sampleProjectClone.getProject(); sampleProjectClone.setProject(pClone); PropertyUtils.setProperty(sampleProjectClone, "lastupdated", (Timestamp) dynaForm.get("sampleProject2Lastupdated")); //bugzilla 1926 sampleProjectClone.setSysUserId(sysUserId); sampleProjectDAO.insertData(sampleProjectClone); oldSampleProjects.add(sampleProjectClone); } } } sample.setSampleProjects(oldSampleProjects); // END DIANE try { // set last updated from form PropertyUtils.setProperty(person, "lastupdated", (Timestamp) dynaForm.get("personLastupdated")); PropertyUtils.setProperty(patient, "lastupdated", (Timestamp) dynaForm.get("patientLastupdated")); PropertyUtils.setProperty(sample, "lastupdated", (Timestamp) dynaForm.get("lastupdated")); PropertyUtils.setProperty(providerPerson, "lastupdated", (Timestamp) dynaForm.get("providerPersonLastupdated")); PropertyUtils.setProperty(provider, "lastupdated", (Timestamp) dynaForm.get("providerLastupdated")); PropertyUtils.setProperty(sampleItem, "lastupdated", (Timestamp) dynaForm.get("sampleItemLastupdated")); PropertyUtils.setProperty(sampleHuman, "lastupdated", (Timestamp) dynaForm.get("sampleHumanLastupdated")); PropertyUtils.setProperty(sampleOrganization, "lastupdated", (Timestamp) dynaForm.get("sampleOrganizationLastupdated")); //System.out.println("This is person ts " + person.getLastupdated().toLocaleString()); person.setSysUserId(sysUserId); patient.setSysUserId(sysUserId); providerPerson.setSysUserId(sysUserId); provider.setSysUserId(sysUserId); sample.setSysUserId(sysUserId); sampleHuman.setSysUserId(sysUserId); sampleOrganization.setSysUserId(sysUserId); sampleItem.setSysUserId(sysUserId); personDAO.updateData(person); patient.setPerson(person); //System.out.println("This is patient ts " + patient.getLastupdated().toLocaleString()); patientDAO.updateData(patient); personDAO.updateData(providerPerson); provider.setPerson(providerPerson); providerDAO.updateData(provider); sampleHuman.setSampleId(sample.getId()); sampleHuman.setPatientId(patient.getId()); sampleHuman.setProviderId(provider.getId()); sampleHumanDAO.updateData(sampleHuman); sampleOrganization.setSampleId(sample.getId()); sampleOrganization.setSample(sample); sampleOrganizationDAO.updateData(sampleOrganization); //bugzilla 2470 SampleItem si = new SampleItem(); si.setSample(sample); sampleItemDAO.getDataBySample(si); sampleItem.setId(si.getId()); sampleItem.setSourceOfSampleId(si.getSourceOfSampleId()); sampleItem.setSourceOther(si.getSourceOther()); //bugzilla 1773 need to store sample not sampleId for use in sorting sampleItem.setSample(sample); sampleItemDAO.updateData(sampleItem); boolean allAnalysesReleased = true; //bugzilla 2028 get the possible qa events QaEvent qaEventForNoCollectionDate = new QaEvent(); qaEventForNoCollectionDate .setQaEventName(SystemConfiguration.getInstance().getQaEventCodeForRequestNoCollectionDate()); qaEventForNoCollectionDate = qaEventDAO.getQaEventByName(qaEventForNoCollectionDate); QaEvent qaEventForNoSampleType = new QaEvent(); qaEventForNoSampleType .setQaEventName(SystemConfiguration.getInstance().getQaEventCodeForRequestNoSampleType()); qaEventForNoSampleType = qaEventDAO.getQaEventByName(qaEventForNoSampleType); QaEvent qaEventForUnknownSubmitter = new QaEvent(); qaEventForUnknownSubmitter .setQaEventName(SystemConfiguration.getInstance().getQaEventCodeForRequestUnknownSubmitter()); qaEventForUnknownSubmitter = qaEventDAO.getQaEventByName(qaEventForUnknownSubmitter); //end bugzilla 2028 // Analysis table for (int i = 0; i < analyses.size(); i++) { Analysis analysis = (Analysis) analyses.get(i); //bugzilla 1942: if all analyses for this sample have already gone through results verification and analysis.status is released // then change sample.status to released also if (StringUtil.isNullorNill(analysis.getStatus()) || !analysis.getStatus() .equals(SystemConfiguration.getInstance().getAnalysisStatusReleased())) { allAnalysesReleased = false; } analysis.setSampleItem(sampleItem); analysis.setSysUserId(sysUserId); //bugzilla 2028 QA_EVENT COLLECTIONDATE if (sample.getCollectionDate() == null) { AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForNoCollectionDate); analysisQaEvent = analysisQaEventDAO.getAnalysisQaEventByAnalysisAndQaEvent(analysisQaEvent); if (analysisQaEvent == null) { analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForNoCollectionDate); analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.insertData(analysisQaEvent); } else { if (analysisQaEvent.getCompletedDate() != null) { analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.updateData(analysisQaEvent); } } } //bugzilla 2028 QA_EVENT SAMPLETYPE if (typeOfSample.equals(SAMPLE_TYPE_NOT_GIVEN)) { AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForNoSampleType); analysisQaEvent = analysisQaEventDAO.getAnalysisQaEventByAnalysisAndQaEvent(analysisQaEvent); if (analysisQaEvent == null) { analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForNoSampleType); analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.insertData(analysisQaEvent); } else { if (analysisQaEvent.getCompletedDate() != null) { analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.updateData(analysisQaEvent); } } } //bugzilla 2028 QA_EVENT UNKNOWN SUBMITTER if (submitterNumber .equals(SystemConfiguration.getInstance().getUnknownSubmitterNumberForQaEvent())) { AnalysisQaEvent analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForUnknownSubmitter); analysisQaEvent = analysisQaEventDAO.getAnalysisQaEventByAnalysisAndQaEvent(analysisQaEvent); if (analysisQaEvent == null) { analysisQaEvent = new AnalysisQaEvent(); analysisQaEvent.setAnalysis(analysis); analysisQaEvent.setQaEvent(qaEventForUnknownSubmitter); analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.insertData(analysisQaEvent); } else { if (analysisQaEvent.getCompletedDate() != null) { analysisQaEvent.setCompletedDate(null); analysisQaEvent.setSysUserId(sysUserId); analysisQaEventDAO.updateData(analysisQaEvent); } } } analysisDAO.updateData(analysis); } //bugzilla 1942 if (analyses.size() > 0 && allAnalysesReleased) { sample.setStatus(SystemConfiguration.getInstance().getSampleStatusReleased()); sample.setReleasedDateForDisplay(dateAsText); } else { sample.setStatus(SystemConfiguration.getInstance().getSampleStatusEntry2Complete()); } sampleDAO.updateData(sample); tx.commit(); // done updating return to menu blankscreen = "false"; forward = FWD_CLOSE; } catch (LIMSRuntimeException lre) { //bugzilla 2154 LogEvent.logError("HumanSampleTwoUpdateAction", "performAction()", lre.toString()); tx.rollback(); // if error then forward to fail and don't update to blank page // = false errors = new ActionMessages(); ActionError error = null; if (lre.getException() instanceof org.hibernate.StaleObjectStateException) { // how can I get popup instead of struts error at the top of // page? // ActionMessages errors = dynaForm.validate(mapping, // request); error = new ActionError("errors.OptimisticLockException", null, null); } else { error = new ActionError("errors.UpdateException", null, null); } errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); request.setAttribute(ALLOW_EDITS_KEY, "false"); forward = FWD_FAIL; } finally { HibernateUtil.closeSession(); } if (forward.equals(FWD_FAIL)) return mapping.findForward(FWD_FAIL); PropertyUtils.setProperty(dynaForm, "typeOfSamples", typeOfSamples); PropertyUtils.setProperty(dynaForm, "sourceOfSamples", sourceOfSamples); PropertyUtils.setProperty(dynaForm, "humanSampleOneMap", humanSampleOneMap); if ("true".equalsIgnoreCase(request.getParameter("close"))) { forward = FWD_CLOSE; } if (sample.getId() != null && !sample.getId().equals("0")) { request.setAttribute(ID, sample.getId()); } if (forward.equals(FWD_SUCCESS)) { request.setAttribute("menuDefinition", "default"); } // return getForward(mapping.findForward(forward), id, start); return mapping.findForward(forward); }