/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.admin.vo.ServiceForElectiveListConfigVo copy(
     ims.admin.vo.ServiceForElectiveListConfigVo valueObjectDest,
     ims.admin.vo.ServiceForElectiveListConfigVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_Service(valueObjectSrc.getID_Service());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // ServiceName
   valueObjectDest.setServiceName(valueObjectSrc.getServiceName());
   // ServiceDescription
   valueObjectDest.setServiceDescription(valueObjectSrc.getServiceDescription());
   // ServiceCategory
   valueObjectDest.setServiceCategory(valueObjectSrc.getServiceCategory());
   // Specialty
   valueObjectDest.setSpecialty(valueObjectSrc.getSpecialty());
   // isActive
   valueObjectDest.setIsActive(valueObjectSrc.getIsActive());
   // UpperName
   valueObjectDest.setUpperName(valueObjectSrc.getUpperName());
   return valueObjectDest;
 }
  public static ims.core.clinical.domain.objects.Service extractService(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.admin.vo.ServiceForElectiveListConfigVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Service();
    ims.core.clinical.domain.objects.Service domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.clinical.domain.objects.Service) domMap.get(valueObject);
      }
      // ims.admin.vo.ServiceForElectiveListConfigVo ID_Service field is unknown
      domainObject = new ims.core.clinical.domain.objects.Service();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Service());
      if (domMap.get(key) != null) {
        return (ims.core.clinical.domain.objects.Service) domMap.get(key);
      }
      domainObject =
          (ims.core.clinical.domain.objects.Service)
              domainFactory.getDomainObject(ims.core.clinical.domain.objects.Service.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_Service());

    // 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.getServiceName() != null && valueObject.getServiceName().equals("")) {
      valueObject.setServiceName(null);
    }
    domainObject.setServiceName(valueObject.getServiceName());
    // 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.getServiceDescription() != null
        && valueObject.getServiceDescription().equals("")) {
      valueObject.setServiceDescription(null);
    }
    domainObject.setServiceDescription(valueObject.getServiceDescription());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value3 = null;
    if (null != valueObject.getServiceCategory()) {
      value3 = domainFactory.getLookupInstance(valueObject.getServiceCategory().getID());
    }
    domainObject.setServiceCategory(value3);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value4 = null;
    if (null != valueObject.getSpecialty()) {
      value4 = domainFactory.getLookupInstance(valueObject.getSpecialty().getID());
    }
    domainObject.setSpecialty(value4);
    domainObject.setIsActive(valueObject.getIsActive());
    // 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.getUpperName() != null && valueObject.getUpperName().equals("")) {
      valueObject.setUpperName(null);
    }
    domainObject.setUpperName(valueObject.getUpperName());

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

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

    // ServiceName
    valueObject.setServiceName(domainObject.getServiceName());
    // ServiceDescription
    valueObject.setServiceDescription(domainObject.getServiceDescription());
    // ServiceCategory
    ims.domain.lookups.LookupInstance instance3 = domainObject.getServiceCategory();
    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.ServiceCategory voLookup3 =
          new ims.core.vo.lookups.ServiceCategory(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.ServiceCategory 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.ServiceCategory(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setServiceCategory(voLookup3);
    }
    // Specialty
    ims.domain.lookups.LookupInstance instance4 = domainObject.getSpecialty();
    if (null != instance4) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance4.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance4.getImage().getImageId(), instance4.getImage().getImagePath());
      }
      color = instance4.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.Specialty voLookup4 =
          new ims.core.vo.lookups.Specialty(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.core.vo.lookups.Specialty parentVoLookup4 = voLookup4;
      ims.domain.lookups.LookupInstance parent4 = instance4.getParent();
      while (parent4 != null) {
        if (parent4.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent4.getImage().getImageId(), parent4.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent4.getColor();
        if (color != null) color.getValue();
        parentVoLookup4.setParent(
            new ims.core.vo.lookups.Specialty(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setSpecialty(voLookup4);
    }
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // UpperName
    valueObject.setUpperName(domainObject.getUpperName());
    return valueObject;
  }