@Override protected void onBtnSaveClick() throws ims.framework.exceptions.PresentationLogicException { EnvironmentalChecklistVo voEnvironmentalChecklist = populateChecklistDataFromScreen(form.getGlobalContext().COE.getAssessmentMobility().getEnvironmentChecklist()); if (voEnvironmentalChecklist == null) return ; String[] arrErrors = voEnvironmentalChecklist.validate(); if(arrErrors == null) { try { AssessmentMobility comp = form.getGlobalContext().COE.getAssessmentMobility(); comp = domain.saveEnvironmentalChecklist(voEnvironmentalChecklist, comp); if (comp != null) { form.getGlobalContext().COE.setAssessmentMobility(comp); } } catch (StaleObjectException e) { engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); return; } } else { engine.showErrors("Validation Errors", arrErrors); return; } engine.close(DialogResult.OK); }
public AssessmentMobility saveEnvironmentalChecklist(EnvironmentalChecklistVo voEnvironmentalChecklist, AssessmentMobility component) throws StaleObjectException { // Ensure the Value Object was validated if (!voEnvironmentalChecklist.isValidated()) throw new DomainRuntimeException("This has not been validated"); DomainFactory factory = getDomainFactory(); //EnvironmentalChecklist domEnvironmentalChecklist = EnvironmentalChecklistVoAssembler.extractEnvironmentalChecklist(factory, voEnvironmentalChecklist); try { //factory.save(domEnvironmentalChecklist); // If the component is not null if (component != null) { //voEnvironmentalChecklist = EnvironmentalChecklistVoAssembler.create(domEnvironmentalChecklist); component.validate(); component.setEnvironmentChecklist(voEnvironmentalChecklist); MobilityComponent compDO = AssessmentMobilityAssembler.extractMobilityComponent(factory, component); factory.save(compDO); return AssessmentMobilityAssembler.create(compDO); } else { return null; } } catch (DomainException e) { throw new DomainRuntimeException("DomainException occurred.\r\n" + e.getMessage(), e); } }
@Override protected void onFormOpen(Object[] args) throws ims.framework.exceptions.PresentationLogicException { if(form.getGlobalContext().COE.getAssessmentMobility().getIsComplete()) { form.setMode(FormMode.VIEW); } else { form.setMode(FormMode.EDIT); } EnvironmentalChecklistVo voEnvironmentalChecklistVo = form.getGlobalContext().COE.getAssessmentMobility().getEnvironmentChecklist(); form.htmQuestion().setHTML("<h2 style=font-family:verdana align=center>Can you answer YES to all of the above questions?<br> If not, remedy any deficiencies without delay.</h2>"); if(voEnvironmentalChecklistVo == null) { loadChecklistGridFromLookup(); form.dteDate().setValue(new Date()); form.timTime().setValue(new Time()); if(domain.getMosUser() != null) form.txtHcp().setValue(((MemberOfStaffShortVo)domain.getMosUser()).toString()); return; } EnvironmentalChecklistDetailVoCollection collDetails = voEnvironmentalChecklistVo.getChecklistDetails(); //form.getLocalContext().setChecklistItem(voEnvironmentalChecklistVo); //contine here displaying header info then get the details if (voEnvironmentalChecklistVo.getAuthoringInformationIsNotNull()){ if(voEnvironmentalChecklistVo.getAuthoringInformation().getAuthoringDateTimeIsNotNull()){ form.dteDate().setValue(voEnvironmentalChecklistVo.getAuthoringInformation().getAuthoringDateTime().getDate()); form.timTime().setValue(voEnvironmentalChecklistVo.getAuthoringInformation().getAuthoringDateTime().getTime()); } if (voEnvironmentalChecklistVo.getAuthoringInformation().getAuthoringHcpIsNotNull()) form.txtHcp().setValue(voEnvironmentalChecklistVo.getAuthoringInformation().getAuthoringHcp().toString()); } if(collDetails != null) { loadChecklistGridFromLookup(); for(int i=0;i<collDetails.size();i++) { GenForm.grdChecklistRow row = null; int r=0; boolean bChecklistTypeFound = false; for(r=0;r<form.grdChecklist().getRows().size(); r++) { row = form.grdChecklist().getRows().get(r); if(collDetails.get(i).getChecklistType().equals(row.getcolChecklistItem())){ row.setValue(collDetails.get(i)); row.setcolStatus(collDetails.get(i).getAnswer()); bChecklistTypeFound = true; } } if(!bChecklistTypeFound) { row = form.grdChecklist().getRows().newRow(); row.setValue(collDetails.get(i)); row.setcolChecklistItem(collDetails.get(i).getChecklistType()); row.setcolStatus(collDetails.get(i).getAnswer()); } } } }