public BalanceActivitiesVo getBalanceActivitiesByClinicalContact(ClinicalContactRefVo voClinicalContactRef) { if (voClinicalContactRef == null) throw new RuntimeException("Cannot get Balance Activity for null Clinical Contact"); StringBuffer query = new StringBuffer("from BalanceActivities as b1_1 where b1_1.clinicalContact.id = :CCID order by b1_1.systemInformation.creationDateTime desc"); //wdev-13637 List list = getDomainFactory().find(query.toString(), "CCID", voClinicalContactRef.getID_ClinicalContact()); if (list == null || list.size() == 0) return null; BalanceActivitiesVoCollection voColl = BalanceActivitiesVoAssembler.createBalanceActivitiesVoCollectionFromBalanceActivities(list); if (voColl != null && voColl.size() > 0) { return voColl.get(0); } return null; }
public BalanceActivitiesVoCollection getBalanceActivitiesByCareContext(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from BalanceActivities b "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (voCareContextRef != null) { hql.append(andStr + " b.clinicalContact.careContext.id = :id_CareContext"); markers.add("id_CareContext"); values.add(voCareContextRef.getID_CareContext()); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); List driving = factory.find(query, markers, values); return BalanceActivitiesVoAssembler.createBalanceActivitiesVoCollectionFromBalanceActivities(driving); }
public void saveBalanceActivities(BalanceActivitiesVo voBalanceActivities) throws StaleObjectException, UniqueKeyViolationException { if(!voBalanceActivities.isValidated()) throw new DomainRuntimeException("These Balance Activites have not been validated"); if (voBalanceActivities.getID_BalanceActivities() == null && getBalanceActivitiesByClinicalContact(voBalanceActivities.getClinicalContact()) != null) throw new StaleObjectException(null, "A Balance Activities record already exists for this Care Context, the screen will be refreshed."); DomainFactory factory = getDomainFactory(); BalanceActivities doBalAct = BalanceActivitiesVoAssembler.extractBalanceActivities(factory, voBalanceActivities); factory.save(doBalAct); }