/**
   * Create the ValueObject collection to hold the set of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectSet - Set of ims.core.configuration.domain.objects.DrawingGraphicArea
   *     objects.
   */
  public static ims.core.vo.GraphicAreaVoCollection
      createGraphicAreaVoCollectionFromDrawingGraphicArea(
          DomainObjectMap map, java.util.Set domainObjectSet) {
    ims.core.vo.GraphicAreaVoCollection voList = new ims.core.vo.GraphicAreaVoCollection();
    if (null == domainObjectSet) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    java.util.Iterator iterator = domainObjectSet.iterator();
    while (iterator.hasNext()) {
      ims.core.configuration.domain.objects.DrawingGraphicArea domainObject =
          (ims.core.configuration.domain.objects.DrawingGraphicArea) iterator.next();
      ims.core.vo.GraphicAreaVo 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.core.configuration.domain.objects.DrawingGraphicArea
   *     objects.
   */
  public static ims.core.vo.GraphicAreaVoCollection
      createGraphicAreaVoCollectionFromDrawingGraphicArea(
          DomainObjectMap map, java.util.List domainObjectList) {
    ims.core.vo.GraphicAreaVoCollection voList = new ims.core.vo.GraphicAreaVoCollection();
    if (null == domainObjectList) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    for (int i = 0; i < domainObjectList.size(); i++) {
      ims.core.configuration.domain.objects.DrawingGraphicArea domainObject =
          (ims.core.configuration.domain.objects.DrawingGraphicArea) domainObjectList.get(i);
      ims.core.vo.GraphicAreaVo 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;
  }
  public static ims.core.configuration.domain.objects.DrawingGraphicArea extractDrawingGraphicArea(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.GraphicAreaVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_DrawingGraphicArea();
    ims.core.configuration.domain.objects.DrawingGraphicArea domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.configuration.domain.objects.DrawingGraphicArea) domMap.get(valueObject);
      }
      // ims.core.vo.GraphicAreaVo ID_DrawingGraphicArea field is unknown
      domainObject = new ims.core.configuration.domain.objects.DrawingGraphicArea();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_DrawingGraphicArea());
      if (domMap.get(key) != null) {
        return (ims.core.configuration.domain.objects.DrawingGraphicArea) domMap.get(key);
      }
      domainObject =
          (ims.core.configuration.domain.objects.DrawingGraphicArea)
              domainFactory.getDomainObject(
                  ims.core.configuration.domain.objects.DrawingGraphicArea.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_DrawingGraphicArea());

    domainObject.setAreaID(valueObject.getAreaID());
    // 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.getAreaName() != null && valueObject.getAreaName().equals("")) {
      valueObject.setAreaName(null);
    }
    domainObject.setAreaName(valueObject.getAreaName());
    // 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.getAreaVectors() != null && valueObject.getAreaVectors().equals("")) {
      valueObject.setAreaVectors(null);
    }
    domainObject.setAreaVectors(valueObject.getAreaVectors());

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

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

    // areaID
    valueObject.setAreaID(domainObject.getAreaID());
    // areaName
    valueObject.setAreaName(domainObject.getAreaName());
    // areaVectors
    valueObject.setAreaVectors(domainObject.getAreaVectors());
    return valueObject;
  }