/**
   * Create the ValueObject collection to hold the set of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectSet - Set of ims.therapies.treatment.domain.objects.Mobilisations objects.
   */
  public static ims.therapies.vo.MobilisationsShortVoCollection
      createMobilisationsShortVoCollectionFromMobilisations(
          DomainObjectMap map, java.util.Set domainObjectSet) {
    ims.therapies.vo.MobilisationsShortVoCollection voList =
        new ims.therapies.vo.MobilisationsShortVoCollection();
    if (null == domainObjectSet) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    java.util.Iterator iterator = domainObjectSet.iterator();
    while (iterator.hasNext()) {
      ims.therapies.treatment.domain.objects.Mobilisations domainObject =
          (ims.therapies.treatment.domain.objects.Mobilisations) iterator.next();
      ims.therapies.vo.MobilisationsShortVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }
    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * Create the ValueObject collection to hold the list of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectList - List of ims.therapies.treatment.domain.objects.Mobilisations objects.
   */
  public static ims.therapies.vo.MobilisationsShortVoCollection
      createMobilisationsShortVoCollectionFromMobilisations(
          DomainObjectMap map, java.util.List domainObjectList) {
    ims.therapies.vo.MobilisationsShortVoCollection voList =
        new ims.therapies.vo.MobilisationsShortVoCollection();
    if (null == domainObjectList) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    for (int i = 0; i < domainObjectList.size(); i++) {
      ims.therapies.treatment.domain.objects.Mobilisations domainObject =
          (ims.therapies.treatment.domain.objects.Mobilisations) domainObjectList.get(i);
      ims.therapies.vo.MobilisationsShortVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }

    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * Create the ValueObject from the ims.therapies.treatment.domain.objects.Mobilisations object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param domainObject
   */
  public static ims.therapies.vo.MobilisationsShortVo create(
      DomainObjectMap map, ims.therapies.treatment.domain.objects.Mobilisations domainObject) {
    if (null == domainObject) {
      return null;
    }
    // check if the domainObject already has a valueObject created for it
    ims.therapies.vo.MobilisationsShortVo valueObject =
        (ims.therapies.vo.MobilisationsShortVo)
            map.getValueObject(domainObject, ims.therapies.vo.MobilisationsShortVo.class);
    if (null == valueObject) {
      valueObject =
          new ims.therapies.vo.MobilisationsShortVo(
              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.therapies.treatment.domain.objects.Mobilisations
   */
  public static ims.therapies.vo.MobilisationsShortVo insert(
      DomainObjectMap map,
      ims.therapies.vo.MobilisationsShortVo valueObject,
      ims.therapies.treatment.domain.objects.Mobilisations domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Mobilisations(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;

    // ClinicalContact
    valueObject.setClinicalContact(
        ims.core.vo.domain.ClinicalContactShortVoAssembler.create(
            map, domainObject.getClinicalContact()));
    // AuthoringCP
    valueObject.setAuthoringCP(
        ims.core.vo.domain.HcpAssembler.create(map, domainObject.getAuthoringCP()));
    // AuthoringDateTime
    java.util.Date AuthoringDateTime = domainObject.getAuthoringDateTime();
    if (null != AuthoringDateTime) {
      valueObject.setAuthoringDateTime(new ims.framework.utils.DateTime(AuthoringDateTime));
    }
    return valueObject;
  }
  public static ims.therapies.treatment.domain.objects.Mobilisations extractMobilisations(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.therapies.vo.MobilisationsShortVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Mobilisations();
    ims.therapies.treatment.domain.objects.Mobilisations domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.therapies.treatment.domain.objects.Mobilisations) domMap.get(valueObject);
      }
      // ims.therapies.vo.MobilisationsShortVo ID_Mobilisations field is unknown
      domainObject = new ims.therapies.treatment.domain.objects.Mobilisations();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Mobilisations());
      if (domMap.get(key) != null) {
        return (ims.therapies.treatment.domain.objects.Mobilisations) domMap.get(key);
      }
      domainObject =
          (ims.therapies.treatment.domain.objects.Mobilisations)
              domainFactory.getDomainObject(
                  ims.therapies.treatment.domain.objects.Mobilisations.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_Mobilisations());

    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.admin.domain.objects.ClinicalContact value1 = null;
    if (null != valueObject.getClinicalContact()) {
      if (valueObject.getClinicalContact().getBoId() == null) {
        if (domMap.get(valueObject.getClinicalContact()) != null) {
          value1 =
              (ims.core.admin.domain.objects.ClinicalContact)
                  domMap.get(valueObject.getClinicalContact());
        }
      } else {
        value1 =
            (ims.core.admin.domain.objects.ClinicalContact)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.ClinicalContact.class,
                    valueObject.getClinicalContact().getBoId());
      }
    }
    domainObject.setClinicalContact(value1);
    domainObject.setAuthoringCP(
        ims.core.vo.domain.HcpAssembler.extractHcp(
            domainFactory, valueObject.getAuthoringCP(), domMap));
    ims.framework.utils.DateTime dateTime3 = valueObject.getAuthoringDateTime();
    java.util.Date value3 = null;
    if (dateTime3 != null) {
      value3 = dateTime3.getJavaDate();
    }
    domainObject.setAuthoringDateTime(value3);

    return domainObject;
  }