コード例 #1
0
  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;
  }
コード例 #2
0
  /**
   * 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.assessment.domain.objects.EatingComponent
   */
  public static ims.coe.vo.AssessmentEatingAndDrinking insert(
      DomainObjectMap map,
      ims.coe.vo.AssessmentEatingAndDrinking valueObject,
      ims.nursing.assessment.domain.objects.EatingComponent domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // NutritionalMethod
    java.util.List listNutritionalMethod = domainObject.getNutritionalMethod();
    ims.nursing.vo.lookups.NutritionalMethodCollection NutritionalMethod =
        new ims.nursing.vo.lookups.NutritionalMethodCollection();
    for (java.util.Iterator iterator = listNutritionalMethod.iterator(); iterator.hasNext(); ) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;

      ims.domain.lookups.LookupInstance instance =
          (ims.domain.lookups.LookupInstance) iterator.next();
      if (instance.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance.getImage().getImageId(), instance.getImage().getImagePath());
      } else {
        img = null;
      }
      color = instance.getColor();
      if (color != null) color.getValue();
      ims.nursing.vo.lookups.NutritionalMethod voInstance =
          new ims.nursing.vo.lookups.NutritionalMethod(
              instance.getId(), instance.getText(), instance.isActive(), null, img, color);
      ims.nursing.vo.lookups.NutritionalMethod parentVoInstance = voInstance;
      ims.domain.lookups.LookupInstance parent = instance.getParent();
      while (parent != null) {
        if (parent.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent.getImage().getImageId(), parent.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent.getColor();
        if (color != null) color.getValue();
        parentVoInstance.setParent(
            new ims.nursing.vo.lookups.NutritionalMethod(
                parent.getId(), parent.getText(), parent.isActive(), null, img, color));
        parentVoInstance = parentVoInstance.getParent();
        parent = parent.getParent();
      }
      NutritionalMethod.add(voInstance);
    }
    valueObject.setNutritionalMethod(NutritionalMethod);
    // OralAssessment
    valueObject.setOralAssessment(
        ims.nursing.vo.domain.OralAssessmentAssembler
            .createOralAssessmentCollectionFromEatingOralAssessment(
                map, domainObject.getOralAssessment()));
    // DifficultiesWithSwallowing
    ims.domain.lookups.LookupInstance instance3 = domainObject.getDifficultiesWithSwallowing();
    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.YesNoUnknown voLookup3 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.YesNoUnknown(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setDifficultiesWithSwallowing(voLookup3);
    }
    // Swallowing
    valueObject.setSwallowing(
        ims.coe.vo.domain.SwallowingAssessmentAssembler
            .createSwallowingAssessmentCollectionFromEatingSwallowingDetails(
                map, domainObject.getSwallowing()));
    // ManualDexterity
    valueObject.setManualDexterity(
        ims.coe.vo.domain.ManualDexterityAssembler
            .createManualDexterityCollectionFromEatingManualDexterity(
                map, domainObject.getManualDexterity()));
    // DescribeAppetite
    ims.domain.lookups.LookupInstance instance6 = domainObject.getDescribeAppetite();
    if (null != instance6) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance6.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance6.getImage().getImageId(), instance6.getImage().getImagePath());
      }
      color = instance6.getColor();
      if (color != null) color.getValue();

      ims.coe.vo.lookups.DescribeAppetite voLookup6 =
          new ims.coe.vo.lookups.DescribeAppetite(
              instance6.getId(), instance6.getText(), instance6.isActive(), null, img, color);
      ims.coe.vo.lookups.DescribeAppetite parentVoLookup6 = voLookup6;
      ims.domain.lookups.LookupInstance parent6 = instance6.getParent();
      while (parent6 != null) {
        if (parent6.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent6.getImage().getImageId(), parent6.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent6.getColor();
        if (color != null) color.getValue();
        parentVoLookup6.setParent(
            new ims.coe.vo.lookups.DescribeAppetite(
                parent6.getId(), parent6.getText(), parent6.isActive(), null, img, color));
        parentVoLookup6 = parentVoLookup6.getParent();
        parent6 = parent6.getParent();
      }
      valueObject.setDescribeAppetite(voLookup6);
    }
    // AnySpecialDiet
    ims.domain.lookups.LookupInstance instance7 = domainObject.getAnySpecialDiet();
    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.core.vo.lookups.YesNoUnknown voLookup7 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance7.getId(), instance7.getText(), instance7.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.core.vo.lookups.YesNoUnknown(
                parent7.getId(), parent7.getText(), parent7.isActive(), null, img, color));
        parentVoLookup7 = parentVoLookup7.getParent();
        parent7 = parent7.getParent();
      }
      valueObject.setAnySpecialDiet(voLookup7);
    }
    // SpecialDiet
    ims.domain.lookups.LookupInstance instance8 = domainObject.getSpecialDiet();
    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.nursing.vo.lookups.SpecialDiet voLookup8 =
          new ims.nursing.vo.lookups.SpecialDiet(
              instance8.getId(), instance8.getText(), instance8.isActive(), null, img, color);
      ims.nursing.vo.lookups.SpecialDiet 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.nursing.vo.lookups.SpecialDiet(
                parent8.getId(), parent8.getText(), parent8.isActive(), null, img, color));
        parentVoLookup8 = parentVoLookup8.getParent();
        parent8 = parent8.getParent();
      }
      valueObject.setSpecialDiet(voLookup8);
    }
    // FoodPatientLikes
    valueObject.setFoodPatientLikes(domainObject.getFoodPatientLikes());
    // FoodPatientDislikes
    valueObject.setFoodPatientDislikes(domainObject.getFoodPatientDislikes());
    // FoodPatientFavourite
    valueObject.setFoodPatientFavourite(domainObject.getFoodPatientFavourite());
    // RequireAssistance
    ims.domain.lookups.LookupInstance instance12 = domainObject.getRequireAssistance();
    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.core.vo.lookups.YesNoUnknown voLookup12 =
          new ims.core.vo.lookups.YesNoUnknown(
              instance12.getId(), instance12.getText(), instance12.isActive(), null, img, color);
      ims.core.vo.lookups.YesNoUnknown 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.core.vo.lookups.YesNoUnknown(
                parent12.getId(), parent12.getText(), parent12.isActive(), null, img, color));
        parentVoLookup12 = parentVoLookup12.getParent();
        parent12 = parent12.getParent();
      }
      valueObject.setRequireAssistance(voLookup12);
    }
    // MiniNutritionalAssessment
    valueObject.setMiniNutritionalAssessment(
        ims.nursing.vo.domain.MiniNutritionalAssessmentAssembler.create(
            map, domainObject.getMiniNutritionalAssessment()));
    // MNAScore
    valueObject.setMNAScore(domainObject.getMNAScore());
    // isComplete
    valueObject.setIsComplete(domainObject.isIsComplete());
    // AssessmentInfo
    valueObject.setAssessmentInfo(
        ims.nursing.vo.domain.AssessmentInfoAssembler
            .createAssessmentInfoCollectionFromAssessmentInfo(
                map, domainObject.getAssessmentInfo()));
    // Copy
    valueObject.setCopy(domainObject.isCopy());
    // ComponentType
    ims.domain.lookups.LookupInstance instance18 = domainObject.getComponentType();
    if (null != instance18) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance18.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance18.getImage().getImageId(), instance18.getImage().getImagePath());
      }
      color = instance18.getColor();
      if (color != null) color.getValue();

      ims.nursing.vo.lookups.AssessmentComponentType voLookup18 =
          new ims.nursing.vo.lookups.AssessmentComponentType(
              instance18.getId(), instance18.getText(), instance18.isActive(), null, img, color);
      ims.nursing.vo.lookups.AssessmentComponentType parentVoLookup18 = voLookup18;
      ims.domain.lookups.LookupInstance parent18 = instance18.getParent();
      while (parent18 != null) {
        if (parent18.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent18.getImage().getImageId(), parent18.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent18.getColor();
        if (color != null) color.getValue();
        parentVoLookup18.setParent(
            new ims.nursing.vo.lookups.AssessmentComponentType(
                parent18.getId(), parent18.getText(), parent18.isActive(), null, img, color));
        parentVoLookup18 = parentVoLookup18.getParent();
        parent18 = parent18.getParent();
      }
      valueObject.setComponentType(voLookup18);
    }
    // CarePlanTemplate
    valueObject.setCarePlanTemplate(
        ims.nursing.vo.domain.CarePlanTemplateAssembler
            .createCarePlanTemplateCollectionFromCarePlanTemplate(
                map, domainObject.getCarePlanTemplate()));
    // CarePlans
    valueObject.setCarePlans(
        ims.nursing.vo.domain.CarePlanAssembler.createCarePlanCollectionFromCarePlan(
            map, domainObject.getCarePlans()));
    return valueObject;
  }