public TrackingForBedAvailabilityVo getTracking(TrackingRefVo trackingRef) { if (trackingRef == null || trackingRef.getID_Tracking() == null) { throw new CodingRuntimeException("Cannot get TrackingForBedAvailabilityVo on null Id for Tracking "); } DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(); hql.append("select tracking from Tracking as tracking where tracking.id = :trackingID "); List<?> list = factory.find(hql.toString(), new String[] { "trackingID" }, new Object[] { trackingRef.getID_Tracking() }); return TrackingForBedAvailabilityVoAssembler.createTrackingForBedAvailabilityVoCollectionFromTracking(list).get(0); }
public BedAvailabilityVo save(BedAvailabilityVo bedAvailabilityToSave, TrackingForBedAvailabilityVo trackingToSave) throws StaleObjectException, UniqueKeyViolationException { if (bedAvailabilityToSave == null && trackingToSave == null) throw new CodingRuntimeException("Cannot save null BedAvailability or TrackingForBedAvailability "); DomainFactory factory = getDomainFactory(); if (bedAvailabilityToSave != null && trackingToSave == null) { if (!bedAvailabilityToSave.isValidated()) throw new DomainRuntimeException("BedAvailabilityVo Not Validated."); BedAvailability domainBedAvailability = BedAvailabilityVoAssembler.extractBedAvailability(factory, bedAvailabilityToSave); factory.save(domainBedAvailability); return BedAvailabilityVoAssembler.create(domainBedAvailability); } else if (bedAvailabilityToSave == null && trackingToSave != null) { if (!trackingToSave.isValidated()) throw new DomainRuntimeException("TrackingForBedAvailability Not Validated."); Tracking domainTracking = TrackingForBedAvailabilityVoAssembler.extractTracking(factory, trackingToSave); factory.save(domainTracking); TrackingForBedAvailabilityVo track = TrackingForBedAvailabilityVoAssembler.create(domainTracking); if (track != null) return track.getBedAvailability(); } return null; }