public static ims.nursing.careplans.domain.objects.CarePlanTemplate extractCarePlanTemplate(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.nursing.vo.CarePlanTemplateTitle valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CarePlanTemplate();
    ims.nursing.careplans.domain.objects.CarePlanTemplate domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.nursing.careplans.domain.objects.CarePlanTemplate) domMap.get(valueObject);
      }
      // ims.nursing.vo.CarePlanTemplateTitle ID_CarePlanTemplate field is unknown
      domainObject = new ims.nursing.careplans.domain.objects.CarePlanTemplate();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_CarePlanTemplate());
      if (domMap.get(key) != null) {
        return (ims.nursing.careplans.domain.objects.CarePlanTemplate) domMap.get(key);
      }
      domainObject =
          (ims.nursing.careplans.domain.objects.CarePlanTemplate)
              domainFactory.getDomainObject(
                  ims.nursing.careplans.domain.objects.CarePlanTemplate.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_CarePlanTemplate());

    java.util.Date value1 = null;
    ims.framework.utils.Date date1 = valueObject.getCreationDate();
    if (date1 != null) {
      value1 = date1.getDate();
    }
    domainObject.setCreationDate(value1);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value2 = null;
    if (null != valueObject.getAssessmentComponent()) {
      value2 = domainFactory.getLookupInstance(valueObject.getAssessmentComponent().getID());
    }
    domainObject.setAssessmentComponent(value2);
    // 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.getTitle() != null && valueObject.getTitle().equals("")) {
      valueObject.setTitle(null);
    }
    domainObject.setTitle(valueObject.getTitle());
    domainObject.setActive(valueObject.getActive());

    return domainObject;
  }
 /**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.nursing.vo.CarePlanTemplateTitle copy(
     ims.nursing.vo.CarePlanTemplateTitle valueObjectDest,
     ims.nursing.vo.CarePlanTemplateTitle valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_CarePlanTemplate(valueObjectSrc.getID_CarePlanTemplate());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // CreationDate
   valueObjectDest.setCreationDate(valueObjectSrc.getCreationDate());
   // AssessmentComponent
   valueObjectDest.setAssessmentComponent(valueObjectSrc.getAssessmentComponent());
   // Title
   valueObjectDest.setTitle(valueObjectSrc.getTitle());
   // Active
   valueObjectDest.setActive(valueObjectSrc.getActive());
   return valueObjectDest;
 }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.nursing.careplans.domain.objects.CarePlanTemplate
   */
  public static ims.nursing.vo.CarePlanTemplateTitle insert(
      DomainObjectMap map,
      ims.nursing.vo.CarePlanTemplateTitle valueObject,
      ims.nursing.careplans.domain.objects.CarePlanTemplate domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // CreationDate
    java.util.Date CreationDate = domainObject.getCreationDate();
    if (null != CreationDate) {
      valueObject.setCreationDate(new ims.framework.utils.Date(CreationDate));
    }
    // AssessmentComponent
    ims.domain.lookups.LookupInstance instance2 = domainObject.getAssessmentComponent();
    if (null != instance2) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance2.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance2.getImage().getImageId(), instance2.getImage().getImagePath());
      }
      color = instance2.getColor();
      if (color != null) color.getValue();

      ims.nursing.vo.lookups.AssessmentComponentType voLookup2 =
          new ims.nursing.vo.lookups.AssessmentComponentType(
              instance2.getId(), instance2.getText(), instance2.isActive(), null, img, color);
      ims.nursing.vo.lookups.AssessmentComponentType parentVoLookup2 = voLookup2;
      ims.domain.lookups.LookupInstance parent2 = instance2.getParent();
      while (parent2 != null) {
        if (parent2.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent2.getImage().getImageId(), parent2.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent2.getColor();
        if (color != null) color.getValue();
        parentVoLookup2.setParent(
            new ims.nursing.vo.lookups.AssessmentComponentType(
                parent2.getId(), parent2.getText(), parent2.isActive(), null, img, color));
        parentVoLookup2 = parentVoLookup2.getParent();
        parent2 = parent2.getParent();
      }
      valueObject.setAssessmentComponent(voLookup2);
    }
    // Title
    valueObject.setTitle(domainObject.getTitle());
    // Active
    valueObject.setActive(domainObject.isActive());
    return valueObject;
  }