コード例 #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
 /**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.core.vo.CareContextSmallVo copy(
     ims.core.vo.CareContextSmallVo valueObjectDest,
     ims.core.vo.CareContextSmallVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_CareContext(valueObjectSrc.getID_CareContext());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // Context
   valueObjectDest.setContext(valueObjectSrc.getContext());
   // StartDateTime
   valueObjectDest.setStartDateTime(valueObjectSrc.getStartDateTime());
   // EndDateTime
   valueObjectDest.setEndDateTime(valueObjectSrc.getEndDateTime());
   // CareContextHistory
   valueObjectDest.setCareContextHistory(valueObjectSrc.getCareContextHistory());
   return valueObjectDest;
 }
コード例 #3
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.CareContextSmallVo insert(
      DomainObjectMap map,
      ims.core.vo.CareContextSmallVo 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;

    // Context
    ims.domain.lookups.LookupInstance instance1 = domainObject.getContext();
    if (null != instance1) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance1.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance1.getImage().getImageId(), instance1.getImage().getImagePath());
      }
      color = instance1.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.ContextType voLookup1 =
          new ims.core.vo.lookups.ContextType(
              instance1.getId(), instance1.getText(), instance1.isActive(), null, img, color);
      ims.core.vo.lookups.ContextType parentVoLookup1 = voLookup1;
      ims.domain.lookups.LookupInstance parent1 = instance1.getParent();
      while (parent1 != null) {
        if (parent1.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent1.getImage().getImageId(), parent1.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent1.getColor();
        if (color != null) color.getValue();
        parentVoLookup1.setParent(
            new ims.core.vo.lookups.ContextType(
                parent1.getId(), parent1.getText(), parent1.isActive(), null, img, color));
        parentVoLookup1 = parentVoLookup1.getParent();
        parent1 = parent1.getParent();
      }
      valueObject.setContext(voLookup1);
    }
    // StartDateTime
    java.util.Date StartDateTime = domainObject.getStartDateTime();
    if (null != StartDateTime) {
      valueObject.setStartDateTime(new ims.framework.utils.DateTime(StartDateTime));
    }
    // EndDateTime
    java.util.Date EndDateTime = domainObject.getEndDateTime();
    if (null != EndDateTime) {
      valueObject.setEndDateTime(new ims.framework.utils.DateTime(EndDateTime));
    }
    // CareContextHistory
    valueObject.setCareContextHistory(
        ims.core.vo.domain.CareContextHistVoAssembler
            .createCareContextHistVoCollectionFromCareContextHistory(
                map, domainObject.getCareContextHistory()));
    return valueObject;
  }