private void listAllergenReactions(AllergenType allergenType) { AllergenTypeReactionsCollection voCollAllergenTypeReactions = domain.listAllergenTypeReactions(allergenType); if (voCollAllergenTypeReactions == null) return; for (int i = 0; i < voCollAllergenTypeReactions.size(); i++) { AllergenTypeReactions reaction = voCollAllergenTypeReactions.get(i); GenForm.grdAllergenReactionsRow row = form.grdAllergenReactions().getRowByValue(reaction.getReaction()); if (row != null) row.setcolSelected(true); } }
public AllergenTypeReactionsCollection saveAllergenTypeReaction(ims.core.vo.lookups.AllergenType allergenType, AllergenTypeReactionsCollection allergenTypeReactions) throws ForeignKeyViolationException, StaleObjectException { if (!allergenTypeReactions.isValidated()) { throw new DomainRuntimeException("Allergen Type Reaction Collection has not been validated"); } //Quicker and easier to delete all existing reactions for a type, and re-insert them. //Will ensure the uniqueness of AllergenType + Reaction is maintained DomainFactory factory = getDomainFactory(); String hql1 = " from AllergenTypeReaction r " + " where r.allergenType.id = " + allergenType.getId(); factory.delete(hql1); for (int i = 0; i < allergenTypeReactions.size(); i++) { AllergenTypeReactions reaction = allergenTypeReactions.get(i); if (!reaction.getAllergenType().equals(allergenType)) { throw new DomainRuntimeException("All reactions in an AllergenTypeReaction Collection must be for the same Allergen Type "); } reaction.setID_AllergenTypeReaction(null); AllergenTypeReaction domAllergenTypeReaction = AllergenTypeReactionsAssembler.extractAllergenTypeReaction(factory, reaction); factory.save(domAllergenTypeReaction); reaction.setID_AllergenTypeReaction(domAllergenTypeReaction.getId()); } return allergenTypeReactions; }
protected void onBtnSaveClick() throws ims.framework.exceptions.PresentationLogicException { AllergenTypeReactionsCollection voCollAllergenTypeReactions = new AllergenTypeReactionsCollection(); for (int i = 0; i < form.grdAllergenReactions().getRows().size(); i++) { GenForm.grdAllergenReactionsRow row = form.grdAllergenReactions().getRows().get(i); if (row.getcolSelected()) { AllergenTypeReactions reaction = new AllergenTypeReactions(); reaction.setAllergenType(form.grdAllergenType().getValue()); reaction.setReaction(row.getValue()); reaction.setIsActive(Boolean.TRUE); voCollAllergenTypeReactions.add(reaction); } } String[] arrErrors = voCollAllergenTypeReactions.validate(); if (arrErrors != null) { engine.showErrors("Validation Errors", arrErrors); return; } try { domain.saveAllergenTypeReaction(form.grdAllergenType().getValue(), voCollAllergenTypeReactions); } catch (StaleObjectException e) { engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); open(); return; } catch (ForeignKeyViolationException e1) { engine.showMessage("There are data items in the system referencing this item - delete access denied"); open(); return; } open(); }