/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.icp.vo.ICPPhaseListVo copy(
     ims.icp.vo.ICPPhaseListVo valueObjectDest, ims.icp.vo.ICPPhaseListVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_ICPPhase(valueObjectSrc.getID_ICPPhase());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // Name
   valueObjectDest.setName(valueObjectSrc.getName());
   // Description
   valueObjectDest.setDescription(valueObjectSrc.getDescription());
   // Status
   valueObjectDest.setStatus(valueObjectSrc.getStatus());
   return valueObjectDest;
 }
  public static ims.icps.configuration.domain.objects.ICPPhase extractICPPhase(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.icp.vo.ICPPhaseListVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_ICPPhase();
    ims.icps.configuration.domain.objects.ICPPhase domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(valueObject);
      }
      // ims.icp.vo.ICPPhaseListVo ID_ICPPhase field is unknown
      domainObject = new ims.icps.configuration.domain.objects.ICPPhase();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_ICPPhase());
      if (domMap.get(key) != null) {
        return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(key);
      }
      domainObject =
          (ims.icps.configuration.domain.objects.ICPPhase)
              domainFactory.getDomainObject(
                  ims.icps.configuration.domain.objects.ICPPhase.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_ICPPhase());

    // 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.getName() != null && valueObject.getName().equals("")) {
      valueObject.setName(null);
    }
    domainObject.setName(valueObject.getName());
    // 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.getDescription() != null && valueObject.getDescription().equals("")) {
      valueObject.setDescription(null);
    }
    domainObject.setDescription(valueObject.getDescription());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value3 = null;
    if (null != valueObject.getStatus()) {
      value3 = domainFactory.getLookupInstance(valueObject.getStatus().getID());
    }
    domainObject.setStatus(value3);

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

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

    // Name
    valueObject.setName(domainObject.getName());
    // Description
    valueObject.setDescription(domainObject.getDescription());
    // Status
    ims.domain.lookups.LookupInstance instance3 = domainObject.getStatus();
    if (null != instance3) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance3.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance3.getImage().getImageId(), instance3.getImage().getImagePath());
      }
      color = instance3.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.PreActiveActiveInactiveStatus voLookup3 =
          new ims.core.vo.lookups.PreActiveActiveInactiveStatus(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.PreActiveActiveInactiveStatus parentVoLookup3 = voLookup3;
      ims.domain.lookups.LookupInstance parent3 = instance3.getParent();
      while (parent3 != null) {
        if (parent3.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent3.getImage().getImageId(), parent3.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent3.getColor();
        if (color != null) color.getValue();
        parentVoLookup3.setParent(
            new ims.core.vo.lookups.PreActiveActiveInactiveStatus(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setStatus(voLookup3);
    }
    return valueObject;
  }