public AllergenVo saveAllergenVo(AllergenVo allergenVo) throws StaleObjectException, UniqueKeyViolationException { AllergenDetails detVo = new AllergenDetails(allergenVo.getID_Allergen(), allergenVo.getVersion_Allergen()); detVo.setAllergenName(allergenVo.getAllergenName()); detVo.setAllergenType(allergenVo.getAllergenType()); detVo.setIsActive(allergenVo.getIsActive()); detVo.setIsRIE(allergenVo.getIsRIE()); String[] arrErrors = detVo.validate(); if( arrErrors != null) { throw new DomainRuntimeException("Error saving Allergen - Allergen not vlaidated correctly"); } return saveAllergenDetails(detVo); }
public AllergenDetails saveAllergenDetails(AllergenDetails allergenDetails) throws StaleObjectException, UniqueKeyViolationException { if (!allergenDetails.isValidated()) { throw new DomainRuntimeException("Allergen Details VO has not be validated."); } DomainFactory factory = getDomainFactory(); Allergen domAllergen = AllergenDetailsAssembler.extractAllergen(factory, allergenDetails); domAllergen.setKeywords(Keywords.setupKeyWords(domAllergen.getKeywords(), domAllergen.getAllergenName())); try { factory.save(domAllergen); } catch (UnqViolationUncheckedException e) { //check which constraint was violated (name/taxononmy map) //name Allergen allergen = Allergen.getAllergenFromAllergenName(factory, allergenDetails.getAllergenName()); if (allergen != null && allergen.getId() != null && !(allergen.getId().equals(allergenDetails.getID_Allergen()))) { throw new UniqueKeyViolationException("Allergen record called \"" + allergenDetails.getAllergenName() + "\" already exists. Duplicates not allowed.", e); } //taxonomy map String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domAllergen, allergenDetails.getTaxonomyMap(), "getAllergenName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); throw (e); } return AllergenDetailsAssembler.create(domAllergen); }
public void newInstance() throws PresentationLogicException { String searchString = form.txtSpecifySearch().getValue(); form.getLocalContext().setallergenDetails(new AllergenDetails()); form.grdAllergen().setValue(null); clearInstanceControls(); form.chkActive().setValue(true); form.txtAllergen().setValue(searchString); if (form.grdAllergen().getRows().size() > 0) form.txtAllergen().setValue(null); form.txtAllergen().setFocus(); form.setMode(FormMode.EDIT); }
public AllergenDetails getAllergenDetails(AllergenRefVo refVo) { DomainFactory factory = getDomainFactory(); Allergen allergen = (Allergen) factory.getDomainObject(Allergen.class, refVo.getID_Allergen()); return (AllergenDetailsAssembler.create(allergen)); }