/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.ocs_if.vo.OrderChangeResponseVo copy(
     ims.ocs_if.vo.OrderChangeResponseVo valueObjectDest,
     ims.ocs_if.vo.OrderChangeResponseVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_OrderChangeResponseQueue(valueObjectSrc.getID_OrderChangeResponseQueue());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // ProviderSystem
   valueObjectDest.setProviderSystem(valueObjectSrc.getProviderSystem());
   // wasProcessed
   valueObjectDest.setWasProcessed(valueObjectSrc.getWasProcessed());
   // wasDiscarded
   valueObjectDest.setWasDiscarded(valueObjectSrc.getWasDiscarded());
   // msgText
   valueObjectDest.setMsgText(valueObjectSrc.getMsgText());
   // ackText
   valueObjectDest.setAckText(valueObjectSrc.getAckText());
   // failureMsg
   valueObjectDest.setFailureMsg(valueObjectSrc.getFailureMsg());
   // messageStatus
   valueObjectDest.setMessageStatus(valueObjectSrc.getMessageStatus());
   // msgType
   valueObjectDest.setMsgType(valueObjectSrc.getMsgType());
   // queueType
   valueObjectDest.setQueueType(valueObjectSrc.getQueueType());
   // Investigation
   valueObjectDest.setInvestigation(valueObjectSrc.getInvestigation());
   // StatusReason
   valueObjectDest.setStatusReason(valueObjectSrc.getStatusReason());
   // CausingStatus
   valueObjectDest.setCausingStatus(valueObjectSrc.getCausingStatus());
   // systemInformation
   valueObjectDest.setSystemInformation(valueObjectSrc.getSystemInformation());
   return valueObjectDest;
 }
  public static ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue
      extractOrderChangeResponseQueue(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.ocs_if.vo.OrderChangeResponseVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_OrderChangeResponseQueue();
    ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue)
            domMap.get(valueObject);
      }
      // ims.ocs_if.vo.OrderChangeResponseVo ID_OrderChangeResponseQueue field is unknown
      domainObject = new ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_OrderChangeResponseQueue());
      if (domMap.get(key) != null) {
        return (ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue) domMap.get(key);
      }
      domainObject =
          (ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue)
              domainFactory.getDomainObject(
                  ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue.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_OrderChangeResponseQueue());

    domainObject.setProviderSystem(
        ims.ocrr.vo.domain.ProviderSystemVoAssembler.extractProviderSystem(
            domainFactory, valueObject.getProviderSystem(), domMap));
    domainObject.setWasProcessed(valueObject.getWasProcessed());
    domainObject.setWasDiscarded(valueObject.getWasDiscarded());
    // 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.getMsgText() != null && valueObject.getMsgText().equals("")) {
      valueObject.setMsgText(null);
    }
    domainObject.setMsgText(valueObject.getMsgText());
    // 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.getAckText() != null && valueObject.getAckText().equals("")) {
      valueObject.setAckText(null);
    }
    domainObject.setAckText(valueObject.getAckText());
    // 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.getFailureMsg() != null && valueObject.getFailureMsg().equals("")) {
      valueObject.setFailureMsg(null);
    }
    domainObject.setFailureMsg(valueObject.getFailureMsg());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value7 = null;
    if (null != valueObject.getMessageStatus()) {
      value7 = domainFactory.getLookupInstance(valueObject.getMessageStatus().getID());
    }
    domainObject.setMessageStatus(value7);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value8 = null;
    if (null != valueObject.getMsgType()) {
      value8 = domainFactory.getLookupInstance(valueObject.getMsgType().getID());
    }
    domainObject.setMsgType(value8);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value9 = null;
    if (null != valueObject.getQueueType()) {
      value9 = domainFactory.getLookupInstance(valueObject.getQueueType().getID());
    }
    domainObject.setQueueType(value9);
    ims.ocrr.orderingresults.domain.objects.OrderInvestigation value10 = null;
    if (null != valueObject.getInvestigation()) {
      if (valueObject.getInvestigation().getBoId() == null) {
        if (domMap.get(valueObject.getInvestigation()) != null) {
          value10 =
              (ims.ocrr.orderingresults.domain.objects.OrderInvestigation)
                  domMap.get(valueObject.getInvestigation());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
                 // BO field
      {
        value10 = domainObject.getInvestigation();
      } else {
        value10 =
            (ims.ocrr.orderingresults.domain.objects.OrderInvestigation)
                domainFactory.getDomainObject(
                    ims.ocrr.orderingresults.domain.objects.OrderInvestigation.class,
                    valueObject.getInvestigation().getBoId());
      }
    }
    domainObject.setInvestigation(value10);
    // 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.getStatusReason() != null && valueObject.getStatusReason().equals("")) {
      valueObject.setStatusReason(null);
    }
    domainObject.setStatusReason(valueObject.getStatusReason());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value12 = null;
    if (null != valueObject.getCausingStatus()) {
      value12 = domainFactory.getLookupInstance(valueObject.getCausingStatus().getID());
    }
    domainObject.setCausingStatus(value12);

    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.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue
   */
  public static ims.ocs_if.vo.OrderChangeResponseVo insert(
      DomainObjectMap map,
      ims.ocs_if.vo.OrderChangeResponseVo valueObject,
      ims.ocrr.orderingresults.domain.objects.OrderChangeResponseQueue domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // ProviderSystem
    valueObject.setProviderSystem(
        ims.ocrr.vo.domain.ProviderSystemVoAssembler.create(map, domainObject.getProviderSystem()));
    // wasProcessed
    valueObject.setWasProcessed(domainObject.isWasProcessed());
    // wasDiscarded
    valueObject.setWasDiscarded(domainObject.isWasDiscarded());
    // msgText
    valueObject.setMsgText(domainObject.getMsgText());
    // ackText
    valueObject.setAckText(domainObject.getAckText());
    // failureMsg
    valueObject.setFailureMsg(domainObject.getFailureMsg());
    // messageStatus
    ims.domain.lookups.LookupInstance instance7 = domainObject.getMessageStatus();
    if (null != instance7) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance7.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance7.getImage().getImageId(), instance7.getImage().getImagePath());
      }
      color = instance7.getColor();
      if (color != null) color.getValue();

      ims.ocrr.vo.lookups.OrderMessageStatus voLookup7 =
          new ims.ocrr.vo.lookups.OrderMessageStatus(
              instance7.getId(), instance7.getText(), instance7.isActive(), null, img, color);
      ims.ocrr.vo.lookups.OrderMessageStatus parentVoLookup7 = voLookup7;
      ims.domain.lookups.LookupInstance parent7 = instance7.getParent();
      while (parent7 != null) {
        if (parent7.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent7.getImage().getImageId(), parent7.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent7.getColor();
        if (color != null) color.getValue();
        parentVoLookup7.setParent(
            new ims.ocrr.vo.lookups.OrderMessageStatus(
                parent7.getId(), parent7.getText(), parent7.isActive(), null, img, color));
        parentVoLookup7 = parentVoLookup7.getParent();
        parent7 = parent7.getParent();
      }
      valueObject.setMessageStatus(voLookup7);
    }
    // msgType
    ims.domain.lookups.LookupInstance instance8 = domainObject.getMsgType();
    if (null != instance8) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance8.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance8.getImage().getImageId(), instance8.getImage().getImagePath());
      }
      color = instance8.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.MsgEventType voLookup8 =
          new ims.core.vo.lookups.MsgEventType(
              instance8.getId(), instance8.getText(), instance8.isActive(), null, img, color);
      ims.core.vo.lookups.MsgEventType parentVoLookup8 = voLookup8;
      ims.domain.lookups.LookupInstance parent8 = instance8.getParent();
      while (parent8 != null) {
        if (parent8.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent8.getImage().getImageId(), parent8.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent8.getColor();
        if (color != null) color.getValue();
        parentVoLookup8.setParent(
            new ims.core.vo.lookups.MsgEventType(
                parent8.getId(), parent8.getText(), parent8.isActive(), null, img, color));
        parentVoLookup8 = parentVoLookup8.getParent();
        parent8 = parent8.getParent();
      }
      valueObject.setMsgType(voLookup8);
    }
    // queueType
    ims.domain.lookups.LookupInstance instance9 = domainObject.getQueueType();
    if (null != instance9) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance9.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance9.getImage().getImageId(), instance9.getImage().getImagePath());
      }
      color = instance9.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.QueueType voLookup9 =
          new ims.core.vo.lookups.QueueType(
              instance9.getId(), instance9.getText(), instance9.isActive(), null, img, color);
      ims.core.vo.lookups.QueueType parentVoLookup9 = voLookup9;
      ims.domain.lookups.LookupInstance parent9 = instance9.getParent();
      while (parent9 != null) {
        if (parent9.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent9.getImage().getImageId(), parent9.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent9.getColor();
        if (color != null) color.getValue();
        parentVoLookup9.setParent(
            new ims.core.vo.lookups.QueueType(
                parent9.getId(), parent9.getText(), parent9.isActive(), null, img, color));
        parentVoLookup9 = parentVoLookup9.getParent();
        parent9 = parent9.getParent();
      }
      valueObject.setQueueType(voLookup9);
    }
    // Investigation
    if (domainObject.getInvestigation() != null) {
      if (domainObject.getInvestigation()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
                          // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getInvestigation();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setInvestigation(
            new ims.ocrr.orderingresults.vo.OrderInvestigationRefVo(id, -1));
      } else {
        valueObject.setInvestigation(
            new ims.ocrr.orderingresults.vo.OrderInvestigationRefVo(
                domainObject.getInvestigation().getId(),
                domainObject.getInvestigation().getVersion()));
      }
    }
    // StatusReason
    valueObject.setStatusReason(domainObject.getStatusReason());
    // CausingStatus
    ims.domain.lookups.LookupInstance instance12 = domainObject.getCausingStatus();
    if (null != instance12) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance12.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance12.getImage().getImageId(), instance12.getImage().getImagePath());
      }
      color = instance12.getColor();
      if (color != null) color.getValue();

      ims.ocrr.vo.lookups.OrderInvStatus voLookup12 =
          new ims.ocrr.vo.lookups.OrderInvStatus(
              instance12.getId(), instance12.getText(), instance12.isActive(), null, img, color);
      ims.ocrr.vo.lookups.OrderInvStatus parentVoLookup12 = voLookup12;
      ims.domain.lookups.LookupInstance parent12 = instance12.getParent();
      while (parent12 != null) {
        if (parent12.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent12.getImage().getImageId(), parent12.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent12.getColor();
        if (color != null) color.getValue();
        parentVoLookup12.setParent(
            new ims.ocrr.vo.lookups.OrderInvStatus(
                parent12.getId(), parent12.getText(), parent12.isActive(), null, img, color));
        parentVoLookup12 = parentVoLookup12.getParent();
        parent12 = parent12.getParent();
      }
      valueObject.setCausingStatus(voLookup12);
    }
    // systemInformation
    // set system information
    valueObject.setSystemInformation(
        ims.vo.domain.SystemInformationAssembler.create(domainObject.getSystemInformation()));
    return valueObject;
  }