public DrivingVo saveDriving(DrivingVo driving) throws StaleObjectException { if (!driving.isValidated()) { throw new DomainRuntimeException("This WheelchairSkillsVo has not been validated"); } if(driving.getID_Driving() == null) { if(driving.getCareContext() != null) { if(driving.getCareContext() != null) { DrivingVoCollection coll = getDrivingByCareContext(driving.getCareContext()); if(coll != null && coll.size()>0) throw new DomainRuntimeException("A Driving record already exists for current CareContext."); } } } DomainFactory factory = getDomainFactory(); Driving domDriving = DrivingVoAssembler.extractDriving(factory, driving); factory.save(domDriving); return DrivingVoAssembler.create(domDriving); }
private void open() { clearFields(); form.setMode(FormMode.VIEW); form.getLocalContext().setDrivingVo(null); form.qmbAuthoringCP().setEnabled(false); form.dtimAuthoring().setEnabled(false); DrivingVo voDriving = null; if(form.getGlobalContext().Core.getCurrentCareContextIsNotNull()){ DrivingVoCollection coll = domain.getDrivingByCareContext(form.getGlobalContext().Core.getCurrentCareContext()); if(coll!=null && coll.size()>0 ) voDriving = coll.get(0); } if(voDriving!=null){ populateScreenFromData(voDriving); form.btnUpdate().setVisible(true); form.btnNew().setVisible(false); } else{ LoadGrid(); form.btnUpdate().setVisible(false); form.btnNew().setVisible(true); } }
private void populateScreenFromData(DrivingVo voDriving) { form.getLocalContext().setDrivingVo(voDriving); if(voDriving.getAuthoringCPIsNotNull()){ form.qmbAuthoringCP().newRow(voDriving.getAuthoringCP(), voDriving.getAuthoringCP().toString()); form.qmbAuthoringCP().setValue(voDriving.getAuthoringCP()); } if(voDriving.getAuthoringDateTimeIsNotNull()) form.dtimAuthoring().setValue(voDriving.getAuthoringDateTime()); GenForm.grdDrivingRow rowDriving = null; if(voDriving.getDrivingAspectIsNotNull()) for (int i = 0; i< voDriving.getDrivingAspect().size(); i++) { DrivingAspectVo voDrivingAspect = voDriving.getDrivingAspect().get(i); rowDriving = form.grdDriving().getRows().newRow(); rowDriving.setColDriving(voDrivingAspect.getAspect()); if(voDrivingAspect.getStatusIsNotNull()) rowDriving.setColStatus(voDrivingAspect.getStatus()); if(voDrivingAspect.getCommentIsNotNull()) rowDriving.setColComments(voDrivingAspect.getComment()); } if(voDriving.getDrivingCommencedDateIsNotNull()) form.pdtDrivingStart().setValue(voDriving.getDrivingCommencedDate()); if(voDriving.getVehicleTypeIsNotNull()) form.txtTypeOfVehicle().setValue(voDriving.getVehicleType()); if(voDriving.getSpecialistInfoEquipIsNotNull()) form.txtSpecialistInfo().setValue(voDriving.getSpecialistInfoEquip()); }
private DrivingVo populateDataFromScreem(DrivingVo voDriving) { if(voDriving.getCareContext() == null) voDriving.setCareContext(form.getGlobalContext().Core.getCurrentCareContext()); voDriving.setAuthoringCP(form.qmbAuthoringCP().getValue()); DateTime dateTime = form.dtimAuthoring().getValue(); if(dateTime!=null){ if(form.dtimAuthoring().getValue().getDate()==null){ engine.showMessage("Please enter Date."); return null; } if(form.dtimAuthoring().getValue().getTime()==null){ engine.showMessage("Please enter Time."); return null; } } voDriving.setAuthoringDateTime(dateTime); DrivingAspectVoCollection collDrivingAspectVo = new DrivingAspectVoCollection(); GenForm.grdDrivingRow rowDriving = null; for (int i = 0; i< form.grdDriving().getRows().size(); i++) { rowDriving = form.grdDriving().getRows().get(i); DrivingAspectVo voDrivingAspect = new DrivingAspectVo(); voDrivingAspect.setAspect(rowDriving.getColDriving()); voDrivingAspect.setStatus(rowDriving.getColStatus()); voDrivingAspect.setComment(rowDriving.getColComments()); collDrivingAspectVo.add(voDrivingAspect); } voDriving.setDrivingAspect(collDrivingAspectVo); voDriving.setDrivingCommencedDate(form.pdtDrivingStart().getValue()); voDriving.setVehicleType(form.txtTypeOfVehicle().getValue()); voDriving.setSpecialistInfoEquip(form.txtSpecialistInfo().getValue()); return voDriving; }