コード例 #1
0
  public static ims.core.admin.domain.objects.CareContext extractCareContext(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.CareContextSmallVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CareContext();
    ims.core.admin.domain.objects.CareContext domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject);
      }
      // ims.core.vo.CareContextSmallVo ID_CareContext field is unknown
      domainObject = new ims.core.admin.domain.objects.CareContext();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_CareContext());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.CareContext)
              domainFactory.getDomainObject(ims.core.admin.domain.objects.CareContext.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_CareContext());

    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value1 = null;
    if (null != valueObject.getContext()) {
      value1 = domainFactory.getLookupInstance(valueObject.getContext().getID());
    }
    domainObject.setContext(value1);
    ims.framework.utils.DateTime dateTime2 = valueObject.getStartDateTime();
    java.util.Date value2 = null;
    if (dateTime2 != null) {
      value2 = dateTime2.getJavaDate();
    }
    domainObject.setStartDateTime(value2);
    ims.framework.utils.DateTime dateTime3 = valueObject.getEndDateTime();
    java.util.Date value3 = null;
    if (dateTime3 != null) {
      value3 = dateTime3.getJavaDate();
    }
    domainObject.setEndDateTime(value3);

    // SaveAsRefVO treated as RefValueObject
    ims.core.admin.vo.CareContextHistoryRefVoCollection refCollection4 =
        new ims.core.admin.vo.CareContextHistoryRefVoCollection();
    if (valueObject.getCareContextHistory() != null) {
      for (int i4 = 0; i4 < valueObject.getCareContextHistory().size(); i4++) {
        ims.core.admin.vo.CareContextHistoryRefVo ref4 =
            (ims.core.admin.vo.CareContextHistoryRefVo) valueObject.getCareContextHistory().get(i4);
        refCollection4.add(ref4);
      }
    }
    int size4 = (null == refCollection4) ? 0 : refCollection4.size();
    java.util.Set domainCareContextHistory4 = domainObject.getCareContextHistory();
    if (domainCareContextHistory4 == null) {
      domainCareContextHistory4 = new java.util.HashSet();
    }
    java.util.Set newSet4 = new java.util.HashSet();
    for (int i = 0; i < size4; i++) {
      ims.core.admin.vo.CareContextHistoryRefVo vo = refCollection4.get(i);
      ims.core.admin.domain.objects.CareContextHistory dom = null;
      if (null != vo) {
        if (vo.getBoId() == null) {
          if (domMap.get(vo) != null) {
            dom = (ims.core.admin.domain.objects.CareContextHistory) domMap.get(vo);
          }
        } else {
          dom =
              (ims.core.admin.domain.objects.CareContextHistory)
                  domainFactory.getDomainObject(
                      ims.core.admin.domain.objects.CareContextHistory.class, vo.getBoId());
        }
      }

      // Trying to avoid the hibernate collection being marked as dirty via its public interface
      // methods. (like add)
      if (!domainCareContextHistory4.contains(dom)) {
        domainCareContextHistory4.add(dom);
      }
      newSet4.add(dom);
    }
    java.util.Set removedSet4 = new java.util.HashSet();
    java.util.Iterator iter4 = domainCareContextHistory4.iterator();
    // Find out which objects need to be removed
    while (iter4.hasNext()) {
      ims.domain.DomainObject o = (ims.domain.DomainObject) iter4.next();
      if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue())
          && !newSet4.contains(o)) {
        removedSet4.add(o);
      }
    }
    iter4 = removedSet4.iterator();
    // Remove the unwanted objects
    while (iter4.hasNext()) {
      domainCareContextHistory4.remove(iter4.next());
    }

    domainObject.setCareContextHistory(domainCareContextHistory4);

    return domainObject;
  }
コード例 #2
0
  public static ims.core.admin.domain.objects.CareContext extractCareContext(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.CareContextMinVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CareContext();
    ims.core.admin.domain.objects.CareContext domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject);
      }
      // ims.core.vo.CareContextMinVo ID_CareContext field is unknown
      domainObject = new ims.core.admin.domain.objects.CareContext();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_CareContext());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.CareContext)
              domainFactory.getDomainObject(ims.core.admin.domain.objects.CareContext.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_CareContext());

    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.admin.domain.objects.EpisodeOfCare value1 = null;
    if (null != valueObject.getEpisodeOfCare()) {
      if (valueObject.getEpisodeOfCare().getBoId() == null) {
        if (domMap.get(valueObject.getEpisodeOfCare()) != null) {
          value1 =
              (ims.core.admin.domain.objects.EpisodeOfCare)
                  domMap.get(valueObject.getEpisodeOfCare());
        }
      } else {
        value1 =
            (ims.core.admin.domain.objects.EpisodeOfCare)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.EpisodeOfCare.class,
                    valueObject.getEpisodeOfCare().getBoId());
      }
    }
    domainObject.setEpisodeOfCare(value1);
    ims.framework.utils.DateTime dateTime2 = valueObject.getStartDateTime();
    java.util.Date value2 = null;
    if (dateTime2 != null) {
      value2 = dateTime2.getJavaDate();
    }
    domainObject.setStartDateTime(value2);
    ims.core.resource.people.domain.objects.Hcp value3 = null;
    if (null != valueObject.getResponsibleHCP()) {
      if (valueObject.getResponsibleHCP().getBoId() == null) {
        if (domMap.get(valueObject.getResponsibleHCP()) != null) {
          value3 =
              (ims.core.resource.people.domain.objects.Hcp)
                  domMap.get(valueObject.getResponsibleHCP());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
      // BO field
      {
        value3 = domainObject.getResponsibleHCP();
      } else {
        value3 =
            (ims.core.resource.people.domain.objects.Hcp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Hcp.class,
                    valueObject.getResponsibleHCP().getBoId());
      }
    }
    domainObject.setResponsibleHCP(value3);

    return domainObject;
  }