public Boolean isStaleTracking(TrackingForBedAvailabilityVo trackingToSave) { if (trackingToSave == null || trackingToSave.getID_Tracking() == null) { throw new CodingRuntimeException("Cannot get TrackingForBedAvailabilityVo on null Id "); } DomainFactory factory = getDomainFactory(); Tracking domainTracking = (Tracking) factory.getDomainObject(Tracking.class, trackingToSave.getID_Tracking()); if (domainTracking == null) { return true; } if (domainTracking.getVersion() > trackingToSave.getVersion_Tracking()) { return true; } return false; }
private void populateScreenFromData(BedAvailabilityVo bedAvailability, TrackingForBedAvailabilityVo tracking) { if (bedAvailability == null) return; form.ccRequestedBy().setValue(bedAvailability.getRequestedBy()); form.dtimAwaitingBed().setValue(bedAvailability.getAwaitingDateTime()); form.cmbDTABedType().setValue(tracking != null && tracking.getAssociatedPendingEmergencyAdmission() != null ? tracking.getAssociatedPendingEmergencyAdmission().getBedTypeRequested() : null); form.dtimAvailableBed().setValue(bedAvailability.getAvailableDateTime()); }
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; }