private void newInstance() { if (allowNew()) { // initalise the screen for a new record form.getLocalContext().setWheelchairDetailsVo(new WheelchairDetailsVo()); clearInstanceControls(); form.ctnDetails().setCollapsed(false); //set the form mode form.setMode(FormMode.EDIT); //set any control status specific this form form.ctnDetails().dtimRecording().setEnabled(true); form.ctnDetails().qmbHCP().setEnabled(true); form.ctnDetails().cmbModel().setEnabled(false); setDefaultValues(); } }
/** * gather screen data into local context vo and save updating the local context vo * returns true for successful save * @return boolean * @throws PresentationLogicException */ private boolean save() { if (form.ctnDetails().dteStart()!=null) { if (form.ctnDetails().dteStart().getValue()!=null) if (form.ctnDetails().dteEnd()!=null) if (form.ctnDetails().dteEnd().getValue()!=null) if (form.ctnDetails().dteStart().getValue().compareTo(form.ctnDetails().dteEnd().getValue())>0) { ArrayList<String> errors=new ArrayList<String>(); errors.add("Date End cannot be before Date Start"); engine.showErrors(errors.toArray(new String [0])); return false; } } WheelchairDetailsVo voWheelchairDetails = populateInstanceData(); //set clinical contact if (!voWheelchairDetails.getClinicalContactIsNotNull()) voWheelchairDetails.setClinicalContact(form.getGlobalContext().Core.getCurrentClinicalContact()); //set Care Context if (!voWheelchairDetails.getCareContextIsNotNull()) voWheelchairDetails.setCareContext(form.getGlobalContext().Core.getCurrentCareContext()); //validate Vo String[] arrErrors = voWheelchairDetails.validate(); if(arrErrors != null) { engine.showErrors(arrErrors); return false; } try { form.getLocalContext().setWheelchairDetailsVo(domain.save(voWheelchairDetails)); } catch(StaleObjectException e) { engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); open(); return false; } return true; }
/** * displays the Wheelchair Details record specified by WheelchairDetailsVo * @param voFamHist */ private void populateInstanceControl(WheelchairDetailsVo voWheelchairDetails) { clearInstanceControls(); if(voWheelchairDetails!=null){ form.getLocalContext().setWheelchairDetailsVo(voWheelchairDetails); if(voWheelchairDetails.getAuthoringDateTimeIsNotNull()) form.ctnDetails().dtimRecording().setValue(voWheelchairDetails.getAuthoringDateTime()); if(voWheelchairDetails.getAuthoringHCPIsNotNull()){ form.ctnDetails().qmbHCP().newRow(voWheelchairDetails.getAuthoringHCP(), voWheelchairDetails.getAuthoringHCP().getName().toString()); form.ctnDetails().qmbHCP().setValue(voWheelchairDetails.getAuthoringHCP()); } if(voWheelchairDetails.getWheelchairTypeIsNotNull()){ form.ctnDetails().cmbType().setValue(voWheelchairDetails.getWheelchairType()); try { onCmbTypeValueChanged(); } catch (PresentationLogicException e) { engine.showMessage("Failed to populate combo with child instances."); } } if(voWheelchairDetails.getWheelchairModelIsNotNull()) form.ctnDetails().cmbModel().setValue(voWheelchairDetails.getWheelchairModel()); if(voWheelchairDetails.getWheelchairFrameIsNotNull()) form.ctnDetails().cmbFrame().setValue(voWheelchairDetails.getWheelchairFrame()); if(voWheelchairDetails.getWheelchairFootplatesIsNotNull()) form.ctnDetails().cmbFootplates().setValue(voWheelchairDetails.getWheelchairFootplates()); if(voWheelchairDetails.getSeatWidthIsNotNull()) form.ctnDetails().intSeatWidth().setValue(voWheelchairDetails.getSeatWidth()); if(voWheelchairDetails.getSeatDepthIsNotNull()) form.ctnDetails().intSeatDepth().setValue(voWheelchairDetails.getSeatDepth()); if(voWheelchairDetails.getSeatOverallWidthIsNotNull()) form.ctnDetails().intOverallWidth().setValue(voWheelchairDetails.getSeatOverallWidth()); if(voWheelchairDetails.getTrialStartDateIsNotNull()) form.ctnDetails().dteStart().setValue(voWheelchairDetails.getTrialStartDate()); if(voWheelchairDetails.getTrialEndDateIsNotNull()) form.ctnDetails().dteEnd().setValue(voWheelchairDetails.getTrialEndDate()); if(voWheelchairDetails.getWheelchairAccessoriesIsNotNull()) form.ctnDetails().txtAccessories().setValue(voWheelchairDetails.getWheelchairAccessories()); if(voWheelchairDetails.getWheelchairCommentsIsNotNull()) form.ctnDetails().txtComments().setValue(voWheelchairDetails.getWheelchairComments()); form.ctnDetails().setCollapsed(false); } }
public WheelchairDetailsVo save(WheelchairDetailsVo voWheelchairDetails) throws StaleObjectException { DomainFactory factory = getDomainFactory(); if (!voWheelchairDetails.isValidated()) { throw new DomainRuntimeException("This WheelchairDetailsVo has not been validated"); } WheelchairDetails domWheelchairDetail = WheelchairDetailsVoAssembler.extractWheelchairDetails(factory, voWheelchairDetails); factory.save(domWheelchairDetail); return WheelchairDetailsVoAssembler.create(domWheelchairDetail); }