/**
   * Create the ValueObject from the ims.core.domain.objects.TransportBooking object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param domainObject
   */
  public static ims.RefMan.vo.TransportBookingShortVo create(
      DomainObjectMap map, ims.core.domain.objects.TransportBooking domainObject) {
    if (null == domainObject) {
      return null;
    }
    // check if the domainObject already has a valueObject created for it
    ims.RefMan.vo.TransportBookingShortVo valueObject =
        (ims.RefMan.vo.TransportBookingShortVo)
            map.getValueObject(domainObject, ims.RefMan.vo.TransportBookingShortVo.class);
    if (null == valueObject) {
      valueObject =
          new ims.RefMan.vo.TransportBookingShortVo(
              domainObject.getId(), domainObject.getVersion());
      map.addValueObject(domainObject, valueObject);

      valueObject = insert(map, valueObject, domainObject);
    }
    return valueObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.domain.objects.TransportBooking
   */
  public static ims.RefMan.vo.TransportBookingShortVo insert(
      DomainObjectMap map,
      ims.RefMan.vo.TransportBookingShortVo valueObject,
      ims.core.domain.objects.TransportBooking domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_TransportBooking(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // Appointments
    ims.scheduling.vo.Booking_AppointmentRefVoCollection Appointments =
        new ims.scheduling.vo.Booking_AppointmentRefVoCollection();
    for (java.util.Iterator iterator = domainObject.getAppointments().iterator();
        iterator.hasNext(); ) {
      ims.scheduling.domain.objects.Booking_Appointment tmp =
          (ims.scheduling.domain.objects.Booking_Appointment) iterator.next();
      if (tmp != null)
        Appointments.add(
            new ims.scheduling.vo.Booking_AppointmentRefVo(tmp.getId(), tmp.getVersion()));
    }
    valueObject.setAppointments(Appointments);
    // DateBooked
    java.util.Date DateBooked = domainObject.getDateBooked();
    if (null != DateBooked) {
      valueObject.setDateBooked(new ims.framework.utils.Date(DateBooked));
    }
    // BookingReference
    valueObject.setBookingReference(domainObject.getBookingReference());
    // SysInfo
    // set system information
    valueObject.setSysInfo(
        ims.vo.domain.SystemInformationAssembler.create(domainObject.getSystemInformation()));
    // CareContext
    if (domainObject.getCareContext() != null) {
      if (domainObject.getCareContext()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getCareContext();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setCareContext(new ims.core.admin.vo.CareContextRefVo(id, -1));
      } else {
        valueObject.setCareContext(
            new ims.core.admin.vo.CareContextRefVo(
                domainObject.getCareContext().getId(), domainObject.getCareContext().getVersion()));
      }
    }
    return valueObject;
  }