public HandTestVo saveHandTest(HandTestVo handTest) throws StaleObjectException, UniqueKeyViolationException { if (!handTest.isValidated()) throw new DomainRuntimeException("This Hand Test has not been validated"); DomainFactory factory = getDomainFactory(); if(handTest.getID_HandTest() == null) { if(handTest.getClinicalContactIsNotNull()) { HandTestVoCollection coll = getHandTest(handTest.getClinicalContact().getID_ClinicalContact()); if(coll != null && coll.size()>0) throw new UniqueKeyViolationException("A record exists for this clinical contact, the screen will be refreshed."); } } HandTest doHandTest = HandTestVoAssembler.extractHandTest(factory, handTest); factory.save(doHandTest); return HandTestVoAssembler.create(doHandTest); }
public HandTestVoCollection getHandTest(Integer contactId) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from HandTest h "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Integer> values = new ArrayList<Integer>(); String andStr = " "; if (contactId != null) { hql.append(andStr + " h.clinicalContact.id = :id_ClinicalContact"); markers.add("id_ClinicalContact"); values.add(contactId); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); List skills = factory.find(query, markers, values); HandTestVoCollection collHandTestVo = HandTestVoAssembler.createHandTestVoCollectionFromHandTest(skills); return collHandTestVo; }
protected void onRecbrHandTestsValueChanged() throws PresentationLogicException { ClinicalContactShortVo voClinicalContactShort = form.recbrHandTests().getValue(); form.getLocalContext().setClinicalContact(voClinicalContactShort); HandTestVoCollection voHandTest = domain.getHandTest(voClinicalContactShort.getID_ClinicalContact()); if(voHandTest!=null && voHandTest.size()>0) displayContactAssessment(voHandTest.get(0), voClinicalContactShort); else displayContactAssessment(null, voClinicalContactShort); }