public Boolean isStale(BedAvailabilityVo bedAvailabilityToSave) { if (bedAvailabilityToSave == null || bedAvailabilityToSave.getID_BedAvailability() == null) { throw new CodingRuntimeException("Cannot get BedAvailabilityVo on null Id "); } DomainFactory factory = getDomainFactory(); BedAvailability domainBedAvailability = (BedAvailability) factory.getDomainObject(BedAvailability.class, bedAvailabilityToSave.getID_BedAvailability()); if (domainBedAvailability == null) { return true; } if (domainBedAvailability.getVersion() > bedAvailabilityToSave.getVersion_BedAvailability()) { return true; } return false; }
private void addBedAvailabilityTimeRowToGrid(BedAvailabilityVo bedAvailabilityVo) { if(bedAvailabilityVo == null) return; grdBedRow newrow = form.ctnTimes().grdBed().getRows().newRow(); if(bedAvailabilityVo.getWard() != null) { newrow.setColWard(bedAvailabilityVo.getWard().getName()); } if (bedAvailabilityVo.getAvailableDateTime() != null) { newrow.setColAvailableDate(bedAvailabilityVo.getAvailableDateTime().toString()); } if(bedAvailabilityVo.getAwaitingDateTime() != null) { newrow.setColAwaitingDate(bedAvailabilityVo.getAwaitingDateTime().toString()); } newrow.setValue(bedAvailabilityVo); }
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 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; }
private void populateScreenFromData(BedAvailabilityVo bedAvailabilityVo) { clearScreen(); if(bedAvailabilityVo == null) return; form.txtWard().setValue(bedAvailabilityVo.getWard() != null ? bedAvailabilityVo.getWard().getName() : null); form.dtimAvailable().setValue(bedAvailabilityVo.getAvailableDateTime()); form.dtimAwaiting().setValue(bedAvailabilityVo.getAwaitingDateTime()); }
private boolean save() { BedAvailabilityVo record = populateDataFromScreen(form.getLocalContext().getCurrentRecord()); String[] errors = validateUIRules(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } errors = record.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } try { domain.save(record); } catch (StaleObjectException e) { e.printStackTrace(); engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); engine.close(DialogResult.ABORT); return false; } return true; }
private BedAvailabilityVo populateDataFromScreen(BedAvailabilityVo currentRecord) { if(currentRecord == null) { engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); engine.close(DialogResult.ABORT); } currentRecord.setAwaitingDateTime(form.dtimAwaiting().getValue()); currentRecord.setAvailableDateTime(form.dtimAvailable().getValue()); return currentRecord; }