public static ims.core.configuration.domain.objects.DrawingGraphicGroup
      extractDrawingGraphicGroup(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.core.vo.GraphicGroupVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_DrawingGraphicGroup();
    ims.core.configuration.domain.objects.DrawingGraphicGroup domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.configuration.domain.objects.DrawingGraphicGroup) domMap.get(valueObject);
      }
      // ims.core.vo.GraphicGroupVo ID_DrawingGraphicGroup field is unknown
      domainObject = new ims.core.configuration.domain.objects.DrawingGraphicGroup();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_DrawingGraphicGroup());
      if (domMap.get(key) != null) {
        return (ims.core.configuration.domain.objects.DrawingGraphicGroup) domMap.get(key);
      }
      domainObject =
          (ims.core.configuration.domain.objects.DrawingGraphicGroup)
              domainFactory.getDomainObject(
                  ims.core.configuration.domain.objects.DrawingGraphicGroup.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_DrawingGraphicGroup());

    domainObject.setGroupID(valueObject.getGroupID());
    // 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.getGroupName() != null && valueObject.getGroupName().equals("")) {
      valueObject.setGroupName(null);
    }
    domainObject.setGroupName(valueObject.getGroupName());
    domainObject.setAreaCollection(
        ims.core.vo.domain.GraphicAreaVoAssembler.extractDrawingGraphicAreaSet(
            domainFactory,
            valueObject.getAreaCollection(),
            domainObject.getAreaCollection(),
            domMap));
    domainObject.setChildGroups(
        ims.core.vo.domain.GraphicGroupVoAssembler.extractDrawingGraphicGroupSet(
            domainFactory, valueObject.getChildGroups(), domainObject.getChildGroups(), domMap));

    return domainObject;
  }
  /**
   * 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.DrawingGraphicGroup
   */
  public static ims.core.vo.GraphicGroupVo insert(
      DomainObjectMap map,
      ims.core.vo.GraphicGroupVo valueObject,
      ims.core.configuration.domain.objects.DrawingGraphicGroup domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // groupID
    valueObject.setGroupID(domainObject.getGroupID());
    // groupName
    valueObject.setGroupName(domainObject.getGroupName());
    // areaCollection
    valueObject.setAreaCollection(
        ims.core.vo.domain.GraphicAreaVoAssembler
            .createGraphicAreaVoCollectionFromDrawingGraphicArea(
                map, domainObject.getAreaCollection()));
    // childGroups
    valueObject.setChildGroups(
        ims.core.vo.domain.GraphicGroupVoAssembler
            .createGraphicGroupVoCollectionFromDrawingGraphicGroup(
                map, domainObject.getChildGroups()));
    return valueObject;
  }
  public static java.util.Set extractDrawingGraphicAreaSet(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.GraphicAreaVoCollection voCollection,
      java.util.Set domainObjectSet,
      HashMap domMap) {
    int size = (null == voCollection) ? 0 : voCollection.size();
    if (domainObjectSet == null) {
      domainObjectSet = new java.util.HashSet();
    }
    java.util.Set newSet = new java.util.HashSet();
    for (int i = 0; i < size; i++) {
      ims.core.vo.GraphicAreaVo vo = voCollection.get(i);
      ims.core.configuration.domain.objects.DrawingGraphicArea domainObject =
          GraphicAreaVoAssembler.extractDrawingGraphicArea(domainFactory, vo, domMap);

      // TODO: This can only occur in the situation of a stale object exception. For now leave it to
      // the Interceptor to handle it.
      if (domainObject == null) {
        continue;
      }

      // Trying to avoid the hibernate collection being marked as dirty via its public interface
      // methods. (like add)
      if (!domainObjectSet.contains(domainObject)) domainObjectSet.add(domainObject);
      newSet.add(domainObject);
    }
    java.util.Set removedSet = new java.util.HashSet();
    java.util.Iterator iter = domainObjectSet.iterator();
    // Find out which objects need to be removed
    while (iter.hasNext()) {
      ims.domain.DomainObject o = (ims.domain.DomainObject) iter.next();
      if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue())
          && !newSet.contains(o)) {
        removedSet.add(o);
      }
    }
    iter = removedSet.iterator();
    // Remove the unwanted objects
    while (iter.hasNext()) {
      domainObjectSet.remove(iter.next());
    }
    return domainObjectSet;
  }
  public static java.util.List extractDrawingGraphicAreaList(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.GraphicAreaVoCollection voCollection,
      java.util.List domainObjectList,
      HashMap domMap) {
    int size = (null == voCollection) ? 0 : voCollection.size();
    if (domainObjectList == null) {
      domainObjectList = new java.util.ArrayList();
    }
    for (int i = 0; i < size; i++) {
      ims.core.vo.GraphicAreaVo vo = voCollection.get(i);
      ims.core.configuration.domain.objects.DrawingGraphicArea domainObject =
          GraphicAreaVoAssembler.extractDrawingGraphicArea(domainFactory, vo, domMap);

      // TODO: This can only occur in the situation of a stale object exception. For now leave it to
      // the Interceptor to handle it.
      if (domainObject == null) {
        continue;
      }

      int domIdx = domainObjectList.indexOf(domainObject);
      if (domIdx == -1) {
        domainObjectList.add(i, domainObject);
      } else if (i != domIdx && i < domainObjectList.size()) {
        Object tmp = domainObjectList.get(i);
        domainObjectList.set(i, domainObjectList.get(domIdx));
        domainObjectList.set(domIdx, tmp);
      }
    }

    // Remove all ones in domList where index > voCollection.size() as these should
    // now represent the ones removed from the VO collection. No longer referenced.
    int i1 = domainObjectList.size();
    while (i1 > size) {
      domainObjectList.remove(i1 - 1);
      i1 = domainObjectList.size();
    }
    return domainObjectList;
  }