コード例 #1
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.core.admin.domain.objects.CareContext
   */
  public static ims.core.vo.CareContextMinVo insert(
      DomainObjectMap map,
      ims.core.vo.CareContextMinVo valueObject,
      ims.core.admin.domain.objects.CareContext domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // EpisodeOfCare
    valueObject.setEpisodeOfCare(
        ims.core.vo.domain.EpisodeOfCareForPatientDocumentsVoAssembler.create(
            map, domainObject.getEpisodeOfCare()));
    // StartDateTime
    java.util.Date StartDateTime = domainObject.getStartDateTime();
    if (null != StartDateTime) {
      valueObject.setStartDateTime(new ims.framework.utils.DateTime(StartDateTime));
    }
    // ResponsibleHCP
    if (domainObject.getResponsibleHCP() != null) {
      if (domainObject.getResponsibleHCP()
          instanceof
          HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the
      // id already.
      {
        HibernateProxy p = (HibernateProxy) domainObject.getResponsibleHCP();
        int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());
        valueObject.setResponsibleHCP(new ims.core.resource.people.vo.HcpRefVo(id, -1));
      } else {
        valueObject.setResponsibleHCP(
            new ims.core.resource.people.vo.HcpRefVo(
                domainObject.getResponsibleHCP().getId(),
                domainObject.getResponsibleHCP().getVersion()));
      }
    }
    return valueObject;
  }
コード例 #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;
  }