public static ims.core.domain.objects.TransportBooking extractTransportBooking( ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.TransportBookingShortVo valueObject, HashMap domMap) { if (null == valueObject) { return null; } Integer id = valueObject.getID_TransportBooking(); ims.core.domain.objects.TransportBooking domainObject = null; if (null == id) { if (domMap.get(valueObject) != null) { return (ims.core.domain.objects.TransportBooking) domMap.get(valueObject); } // ims.RefMan.vo.TransportBookingShortVo ID_TransportBooking field is unknown domainObject = new ims.core.domain.objects.TransportBooking(); domMap.put(valueObject, domainObject); } else { String key = (valueObject.getClass().getName() + "__" + valueObject.getID_TransportBooking()); if (domMap.get(key) != null) { return (ims.core.domain.objects.TransportBooking) domMap.get(key); } domainObject = (ims.core.domain.objects.TransportBooking) domainFactory.getDomainObject(ims.core.domain.objects.TransportBooking.class, id); // TODO: Not sure how this should be handled. Effectively it must be a staleobject exception, // but maybe should be handled as that further up. if (domainObject == null) return null; domMap.put(key, domainObject); } domainObject.setVersion(valueObject.getVersion_TransportBooking()); ims.scheduling.vo.Booking_AppointmentRefVoCollection refCollection1 = valueObject.getAppointments(); int size1 = (null == refCollection1) ? 0 : refCollection1.size(); java.util.Set domainAppointments1 = domainObject.getAppointments(); if (domainAppointments1 == null) { domainAppointments1 = new java.util.HashSet(); } java.util.Set newSet1 = new java.util.HashSet(); for (int i = 0; i < size1; i++) { ims.scheduling.vo.Booking_AppointmentRefVo vo = refCollection1.get(i); ims.scheduling.domain.objects.Booking_Appointment dom = null; if (null != vo) { if (vo.getBoId() == null) { if (domMap.get(vo) != null) { dom = (ims.scheduling.domain.objects.Booking_Appointment) domMap.get(vo); } } else { dom = (ims.scheduling.domain.objects.Booking_Appointment) domainFactory.getDomainObject( ims.scheduling.domain.objects.Booking_Appointment.class, vo.getBoId()); } } // Trying to avoid the hibernate collection being marked as dirty via its public interface // methods. (like add) if (!domainAppointments1.contains(dom)) { domainAppointments1.add(dom); } newSet1.add(dom); } java.util.Set removedSet1 = new java.util.HashSet(); java.util.Iterator iter1 = domainAppointments1.iterator(); // Find out which objects need to be removed while (iter1.hasNext()) { ims.domain.DomainObject o = (ims.domain.DomainObject) iter1.next(); if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue()) && !newSet1.contains(o)) { removedSet1.add(o); } } iter1 = removedSet1.iterator(); // Remove the unwanted objects while (iter1.hasNext()) { domainAppointments1.remove(iter1.next()); } domainObject.setAppointments(domainAppointments1); java.util.Date value2 = null; ims.framework.utils.Date date2 = valueObject.getDateBooked(); if (date2 != null) { value2 = date2.getDate(); } domainObject.setDateBooked(value2); // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty // string correctly // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them // consistent at least. if (valueObject.getBookingReference() != null && valueObject.getBookingReference().equals("")) { valueObject.setBookingReference(null); } domainObject.setBookingReference(valueObject.getBookingReference()); ims.core.admin.domain.objects.CareContext value5 = null; if (null != valueObject.getCareContext()) { if (valueObject.getCareContext().getBoId() == null) { if (domMap.get(valueObject.getCareContext()) != null) { value5 = (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject.getCareContext()); } } else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the // BO field { value5 = domainObject.getCareContext(); } else { value5 = (ims.core.admin.domain.objects.CareContext) domainFactory.getDomainObject( ims.core.admin.domain.objects.CareContext.class, valueObject.getCareContext().getBoId()); } } domainObject.setCareContext(value5); return domainObject; }