public WheelchairSkillsVo saveWheelchairSkills(WheelchairSkillsVo wheelchairSkills) throws StaleObjectException, UniqueKeyViolationException { if (wheelchairSkills == null) throw new CodingRuntimeException("This WheelchairSkillsVo is null"); if (!wheelchairSkills.isValidated()) throw new DomainRuntimeException("This WheelchairSkillsVo has not been validated"); DomainFactory factory = getDomainFactory(); if (wheelchairSkills.getID_WheelchairSkills() == null)//Inserting a record { WheelchairSkillsVo voWS = getWheelchairSkillsByClinicalContact(wheelchairSkills.getClinicalContact()); if(voWS != null) throw new UniqueKeyViolationException("A record exists for this clinical contact, the screen will be refreshed"); } WheelchairSkills domWheelchairSkills = WheelchairSkillsVoAssembler.extractWheelchairSkills(factory, wheelchairSkills); factory.save(domWheelchairSkills); return WheelchairSkillsVoAssembler.create(domWheelchairSkills); }
public WheelchairSkillsVo getWheelchairSkillsByClinicalContact(ClinicalContactRefVo voClinicalContactRef) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from WheelchairSkills w "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (voClinicalContactRef != null) { hql.append(andStr + " w.clinicalContact.id = :id_ClinicalContact"); markers.add("id_ClinicalContact"); values.add(voClinicalContactRef.getID_ClinicalContact()); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); query += " order by w.id desc"; //wdev-13637 List skills = factory.find(query, markers, values); WheelchairSkillsVoCollection collWheelchairSkillsVo = WheelchairSkillsVoAssembler.createWheelchairSkillsVoCollectionFromWheelchairSkills(skills); if(collWheelchairSkillsVo!=null && collWheelchairSkillsVo.size()>0) return collWheelchairSkillsVo.get(0); return null; }