/**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.assessment.configuration.domain.objects.PatientAssessmentFolder
   */
  public static ims.assessment.vo.PatientAssessmentFolderVo insert(
      DomainObjectMap map,
      ims.assessment.vo.PatientAssessmentFolderVo valueObject,
      ims.assessment.configuration.domain.objects.PatientAssessmentFolder domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

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

    // FolderName
    valueObject.setFolderName(domainObject.getFolderName());
    // PatientAssessments
    valueObject.setPatientAssessments(
        ims.assessment.vo.domain.UserAssessmentShortVoAssembler
            .createUserAssessmentShortVoCollectionFromUserAssessment(
                map, domainObject.getPatientAssessments()));
    // GraphicAssessments
    valueObject.setGraphicAssessments(
        ims.assessment.vo.domain.GraphicAssessmentShortVoAssembler
            .createGraphicAssessmentShortVoCollectionFromGraphicAssessment(
                map, domainObject.getGraphicAssessments()));
    return valueObject;
  }
  public static ims.assessment.configuration.domain.objects.PatientAssessmentFolder
      extractPatientAssessmentFolder(
          ims.domain.ILightweightDomainFactory domainFactory,
          ims.assessment.vo.PatientAssessmentFolderVo valueObject,
          HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_PatientAssessmentFolder();
    ims.assessment.configuration.domain.objects.PatientAssessmentFolder domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.assessment.configuration.domain.objects.PatientAssessmentFolder)
            domMap.get(valueObject);
      }
      // ims.assessment.vo.PatientAssessmentFolderVo ID_PatientAssessmentFolder field is unknown
      domainObject = new ims.assessment.configuration.domain.objects.PatientAssessmentFolder();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_PatientAssessmentFolder());
      if (domMap.get(key) != null) {
        return (ims.assessment.configuration.domain.objects.PatientAssessmentFolder)
            domMap.get(key);
      }
      domainObject =
          (ims.assessment.configuration.domain.objects.PatientAssessmentFolder)
              domainFactory.getDomainObject(
                  ims.assessment.configuration.domain.objects.PatientAssessmentFolder.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_PatientAssessmentFolder());

    // 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.getFolderName() != null && valueObject.getFolderName().equals("")) {
      valueObject.setFolderName(null);
    }
    domainObject.setFolderName(valueObject.getFolderName());
    domainObject.setPatientAssessments(
        ims.assessment.vo.domain.UserAssessmentShortVoAssembler.extractUserAssessmentSet(
            domainFactory,
            valueObject.getPatientAssessments(),
            domainObject.getPatientAssessments(),
            domMap));
    domainObject.setGraphicAssessments(
        ims.assessment.vo.domain.GraphicAssessmentShortVoAssembler.extractGraphicAssessmentSet(
            domainFactory,
            valueObject.getGraphicAssessments(),
            domainObject.getGraphicAssessments(),
            domMap));

    return domainObject;
  }