private boolean save() { AppFormListVo selectedRecord = populateDataFromScreen(form.getLocalContext().getSelectedRecord()); String[] err = selectedRecord.validate(); if (err != null && err.length > 0) { engine.showErrors(err); return false; } try { selectedRecord = domain.saveForm(selectedRecord); } catch (StaleObjectException e) { engine.showErrors(new String[] { ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue() }); return false; } form.getLocalContext().setSelectedRecord(domain.getAppFormList(selectedRecord.getFormId())); return true; }
public AppFormListVo getAppFormListByTaxonomyType(String extId, TaxonomyType taxonomyType) { if (extId == null || taxonomyType == null) return null; DomainFactory factory = (DomainFactory) this.getDomainFactory(); String hql = " from AppForm af join af.codeMappings as cm where cm.taxonomyName = :taxType and cm.taxonomyCode = :extId "; List appFormList = factory.find(hql,new String[]{"taxType", "extId"}, new Object[]{getDomLookup(taxonomyType),extId}); if (appFormList != null && appFormList.size() == 1) return AppFormListVoAssembler.create((AppForm) appFormList.get(0)); else if (appFormList != null && appFormList.size() > 1) throw new DomainRuntimeException("Non unique hit on AppForm by TaxonomyType " + taxonomyType.getText() + " and code " + extId); return null; }
private AppFormListVo populateDataFromScreen(IAppForm selectedRecord) { if (selectedRecord == null) return null; AppFormListVo appFormListVo = domain.getAppFormList(selectedRecord.getFormId()); if (appFormListVo != null) { appFormListVo.setCodeMappings(form.lyrDetails().tabDetails().ccMappings().getValue()); return appFormListVo; } return null; }
private void displaySelectedRecord(IAppForm selectedForm) { if (selectedForm == null) return; clearDetails(); AppFormListVo appFormListVo = domain.getAppFormList(selectedForm.getFormId()); if (appFormListVo != null) { form.lyrDetails().tabDetails().lblName().setValue(appFormListVo.getName()); form.lyrDetails().tabDetails().lblCaption().setValue(appFormListVo.getCaption()); form.lyrDetails().tabDetails().txtDescription().setValue(appFormListVo.getDescription()); if (appFormListVo.getImage() != null) { form.lyrDetails().tabDetails().imgImage().setVisible(true); form.lyrDetails().tabDetails().imgImage().setValue(appFormListVo.getImage()); } else { form.lyrDetails().tabDetails().imgImage().setVisible(false); form.lyrDetails().tabDetails().imgImage().setValue(null); } if (appFormListVo.getLookupsIsNotNull()) { FormLookupVoCollection lookups = appFormListVo.getLookups(); populateLookupsGrid(lookups); } form.lyrDetails().tabDetails().ccMappings().setValue(appFormListVo.getCodeMappings()); } }
public AppFormListVo getAppFormList(Integer id) { if(id == null) throw new CodingRuntimeException("AppForm id is null"); DomainFactory factory = (DomainFactory) getDomainFactory(); return AppFormListVoAssembler.create((AppForm)factory.getDomainObject(AppForm.class,id)); }
public AppFormListVo saveForm(AppFormListVo listFormVo) throws StaleObjectException { if (Boolean.FALSE.equals(listFormVo.isValidated())) throw new DomainRuntimeException("AppFormListVo was not validated!"); DomainFactory factory = (DomainFactory) this.getDomainFactory(); AppForm dom = AppFormListVoAssembler.extractAppForm(factory, listFormVo); factory.save(dom); return AppFormListVoAssembler.create(dom); }