/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.coe.vo.AssessmentEatingAndDrinking copy(
     ims.coe.vo.AssessmentEatingAndDrinking valueObjectDest,
     ims.coe.vo.AssessmentEatingAndDrinking valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_AssessmentComponent(valueObjectSrc.getID_AssessmentComponent());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // NutritionalMethod
   valueObjectDest.setNutritionalMethod(valueObjectSrc.getNutritionalMethod());
   // OralAssessment
   valueObjectDest.setOralAssessment(valueObjectSrc.getOralAssessment());
   // DifficultiesWithSwallowing
   valueObjectDest.setDifficultiesWithSwallowing(valueObjectSrc.getDifficultiesWithSwallowing());
   // Swallowing
   valueObjectDest.setSwallowing(valueObjectSrc.getSwallowing());
   // ManualDexterity
   valueObjectDest.setManualDexterity(valueObjectSrc.getManualDexterity());
   // DescribeAppetite
   valueObjectDest.setDescribeAppetite(valueObjectSrc.getDescribeAppetite());
   // AnySpecialDiet
   valueObjectDest.setAnySpecialDiet(valueObjectSrc.getAnySpecialDiet());
   // SpecialDiet
   valueObjectDest.setSpecialDiet(valueObjectSrc.getSpecialDiet());
   // FoodPatientLikes
   valueObjectDest.setFoodPatientLikes(valueObjectSrc.getFoodPatientLikes());
   // FoodPatientDislikes
   valueObjectDest.setFoodPatientDislikes(valueObjectSrc.getFoodPatientDislikes());
   // FoodPatientFavourite
   valueObjectDest.setFoodPatientFavourite(valueObjectSrc.getFoodPatientFavourite());
   // RequireAssistance
   valueObjectDest.setRequireAssistance(valueObjectSrc.getRequireAssistance());
   // MiniNutritionalAssessment
   valueObjectDest.setMiniNutritionalAssessment(valueObjectSrc.getMiniNutritionalAssessment());
   // MNAScore
   valueObjectDest.setMNAScore(valueObjectSrc.getMNAScore());
   // isComplete
   valueObjectDest.setIsComplete(valueObjectSrc.getIsComplete());
   // AssessmentInfo
   valueObjectDest.setAssessmentInfo(valueObjectSrc.getAssessmentInfo());
   // Copy
   valueObjectDest.setCopy(valueObjectSrc.getCopy());
   // ComponentType
   valueObjectDest.setComponentType(valueObjectSrc.getComponentType());
   // CarePlanTemplate
   valueObjectDest.setCarePlanTemplate(valueObjectSrc.getCarePlanTemplate());
   // CarePlans
   valueObjectDest.setCarePlans(valueObjectSrc.getCarePlans());
   return valueObjectDest;
 }
  public static ims.nursing.assessment.domain.objects.EatingComponent extractEatingComponent(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.coe.vo.AssessmentEatingAndDrinking valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_AssessmentComponent();
    ims.nursing.assessment.domain.objects.EatingComponent domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.nursing.assessment.domain.objects.EatingComponent) domMap.get(valueObject);
      }
      // ims.coe.vo.AssessmentEatingAndDrinking ID_EatingComponent field is unknown
      domainObject = new ims.nursing.assessment.domain.objects.EatingComponent();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_AssessmentComponent());
      if (domMap.get(key) != null) {
        return (ims.nursing.assessment.domain.objects.EatingComponent) domMap.get(key);
      }
      domainObject =
          (ims.nursing.assessment.domain.objects.EatingComponent)
              domainFactory.getDomainObject(
                  ims.nursing.assessment.domain.objects.EatingComponent.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_AssessmentComponent());

    ims.nursing.vo.lookups.NutritionalMethodCollection collection1 =
        valueObject.getNutritionalMethod();
    java.util.List domainNutritionalMethod = domainObject.getNutritionalMethod();
    ;
    int collection1Size = 0;
    if (collection1 == null) {
      domainNutritionalMethod = new java.util.ArrayList(0);
    } else {
      collection1Size = collection1.size();
    }

    for (int i = 0; i < collection1Size; i++) {
      int instanceId = collection1.get(i).getID();
      ims.domain.lookups.LookupInstanceRef dom =
          new ims.domain.lookups.LookupInstanceRef(domainFactory.getLookupInstance(instanceId));

      int domIdx = domainNutritionalMethod.indexOf(dom);
      if (domIdx == -1) {
        domainNutritionalMethod.add(i, dom);
      } else if (i != domIdx && i < domainNutritionalMethod.size()) {
        Object tmp = domainNutritionalMethod.get(i);
        domainNutritionalMethod.set(i, domainNutritionalMethod.get(domIdx));
        domainNutritionalMethod.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 j1 = domainNutritionalMethod.size();
    while (j1 > collection1Size) {
      domainNutritionalMethod.remove(j1 - 1);
      j1 = domainNutritionalMethod.size();
    }

    domainObject.setNutritionalMethod(domainNutritionalMethod);
    domainObject.setOralAssessment(
        ims.nursing.vo.domain.OralAssessmentAssembler.extractEatingOralAssessmentSet(
            domainFactory,
            valueObject.getOralAssessment(),
            domainObject.getOralAssessment(),
            domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value3 = null;
    if (null != valueObject.getDifficultiesWithSwallowing()) {
      value3 = domainFactory.getLookupInstance(valueObject.getDifficultiesWithSwallowing().getID());
    }
    domainObject.setDifficultiesWithSwallowing(value3);
    domainObject.setSwallowing(
        ims.coe.vo.domain.SwallowingAssessmentAssembler.extractEatingSwallowingDetailsSet(
            domainFactory, valueObject.getSwallowing(), domainObject.getSwallowing(), domMap));
    domainObject.setManualDexterity(
        ims.coe.vo.domain.ManualDexterityAssembler.extractEatingManualDexteritySet(
            domainFactory,
            valueObject.getManualDexterity(),
            domainObject.getManualDexterity(),
            domMap));
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value6 = null;
    if (null != valueObject.getDescribeAppetite()) {
      value6 = domainFactory.getLookupInstance(valueObject.getDescribeAppetite().getID());
    }
    domainObject.setDescribeAppetite(value6);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value7 = null;
    if (null != valueObject.getAnySpecialDiet()) {
      value7 = domainFactory.getLookupInstance(valueObject.getAnySpecialDiet().getID());
    }
    domainObject.setAnySpecialDiet(value7);
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value8 = null;
    if (null != valueObject.getSpecialDiet()) {
      value8 = domainFactory.getLookupInstance(valueObject.getSpecialDiet().getID());
    }
    domainObject.setSpecialDiet(value8);
    // 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.getFoodPatientLikes() != null && valueObject.getFoodPatientLikes().equals("")) {
      valueObject.setFoodPatientLikes(null);
    }
    domainObject.setFoodPatientLikes(valueObject.getFoodPatientLikes());
    // 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.getFoodPatientDislikes() != null
        && valueObject.getFoodPatientDislikes().equals("")) {
      valueObject.setFoodPatientDislikes(null);
    }
    domainObject.setFoodPatientDislikes(valueObject.getFoodPatientDislikes());
    // 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.getFoodPatientFavourite() != null
        && valueObject.getFoodPatientFavourite().equals("")) {
      valueObject.setFoodPatientFavourite(null);
    }
    domainObject.setFoodPatientFavourite(valueObject.getFoodPatientFavourite());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value12 = null;
    if (null != valueObject.getRequireAssistance()) {
      value12 = domainFactory.getLookupInstance(valueObject.getRequireAssistance().getID());
    }
    domainObject.setRequireAssistance(value12);
    domainObject.setMiniNutritionalAssessment(
        ims.nursing.vo.domain.MiniNutritionalAssessmentAssembler.extractMiniNutritionalAssessment(
            domainFactory, valueObject.getMiniNutritionalAssessment(), domMap));
    domainObject.setMNAScore(valueObject.getMNAScore());
    domainObject.setIsComplete(valueObject.getIsComplete());
    domainObject.setAssessmentInfo(
        ims.nursing.vo.domain.AssessmentInfoAssembler.extractAssessmentInfoList(
            domainFactory,
            valueObject.getAssessmentInfo(),
            domainObject.getAssessmentInfo(),
            domMap));
    domainObject.setCopy(valueObject.getCopy());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value18 = null;
    if (null != valueObject.getComponentType()) {
      value18 = domainFactory.getLookupInstance(valueObject.getComponentType().getID());
    }
    domainObject.setComponentType(value18);
    domainObject.setCarePlanTemplate(
        ims.nursing.vo.domain.CarePlanTemplateAssembler.extractCarePlanTemplateSet(
            domainFactory,
            valueObject.getCarePlanTemplate(),
            domainObject.getCarePlanTemplate(),
            domMap));
    domainObject.setCarePlans(
        ims.nursing.vo.domain.CarePlanAssembler.extractCarePlanSet(
            domainFactory, valueObject.getCarePlans(), domainObject.getCarePlans(), domMap));

    return domainObject;
  }