public RepositioningPlanVoCollection listRepositioningPlanByCareContext(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from RepositioningPlan rp"; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (voCareContextRef != null) { hql.append(andStr + " rp.careContext.id = :id_CareContext"); markers.add("id_CareContext"); values.add(voCareContextRef.getID_CareContext()); andStr = " and "; } hql.append(" order by rp.authoringInformation.authoringDateTime desc"); if (markers.size() > 0) query += " where "; query += hql.toString(); List plan = factory.find(query, markers, values); RepositioningPlanVoCollection collRepositioningPlanVo = RepositioningPlanVoAssembler.createRepositioningPlanVoCollectionFromRepositioningPlan(plan); if(collRepositioningPlanVo != null) return collRepositioningPlanVo.sort(SortOrder.DESCENDING); return null; }
public RepositioningPlanVo getLastCompletedRepositioningPlan(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("from RepositioningPlan rp "); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (voCareContextRef != null) { hql.append(" where "); hql.append(andStr + " rp.careContext.id = :id_CareContext"); markers.add("id_CareContext"); values.add(voCareContextRef.getID_CareContext()); } hql.append(" order by rp.authoringInformation.authoringDateTime desc "); List plan = factory.find(hql.toString(), markers, values); if(plan != null && plan.size() > 1) { Object firstItem = plan.get(0); plan.removeAll(plan); plan.add(firstItem); } RepositioningPlanVoCollection collRepositioningPlanVo = RepositioningPlanVoAssembler.createRepositioningPlanVoCollectionFromRepositioningPlan(plan); if(collRepositioningPlanVo != null && collRepositioningPlanVo.size() > 0) return collRepositioningPlanVo.get(0); return null; }
public RepositioningPlanVo saveRepositioningPlan(RepositioningPlanVo voRepositioningPlan) throws StaleObjectException { if(!voRepositioningPlan.isValidated()) throw new DomainRuntimeException("This Repositioning Plan has not been validated"); DomainFactory factory = getDomainFactory(); RepositioningPlan doRepositioning = RepositioningPlanVoAssembler.extractRepositioningPlan(factory, voRepositioningPlan); factory.save(doRepositioning); return RepositioningPlanVoAssembler.create(doRepositioning); }