public static ims.core.configuration.domain.objects.AppUser extractAppUser(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.admin.vo.AppUserVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_AppUser();
    ims.core.configuration.domain.objects.AppUser domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.configuration.domain.objects.AppUser) domMap.get(valueObject);
      }
      // ims.admin.vo.AppUserVo ID_AppUser field is unknown
      domainObject = new ims.core.configuration.domain.objects.AppUser();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_AppUser());
      if (domMap.get(key) != null) {
        return (ims.core.configuration.domain.objects.AppUser) domMap.get(key);
      }
      domainObject =
          (ims.core.configuration.domain.objects.AppUser)
              domainFactory.getDomainObject(
                  ims.core.configuration.domain.objects.AppUser.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_AppUser());

    domainObject.setRoles(
        ims.admin.vo.domain.AppRoleShortVoAssembler.extractAppRoleSet(
            domainFactory, valueObject.getRoles(), domainObject.getRoles(), domMap));
    domainObject.setMos(
        ims.core.vo.domain.MemberOfStaffShortVoAssembler.extractMemberOfStaff(
            domainFactory, valueObject.getMos(), domMap));
    domainObject.setPreviousPasswords(
        ims.admin.vo.domain.AppUserPasswordVoAssembler.extractAppUserPasswordList(
            domainFactory,
            valueObject.getPreviousPasswords(),
            domainObject.getPreviousPasswords(),
            domMap));
    domainObject.setEmailAccount(
        ims.admin.vo.domain.UserEmailAccountVoAssembler.extractUserEmailAccount(
            domainFactory, valueObject.getEmailAccount(), domMap));
    domainObject.setUseExternalAuthentication(valueObject.getUseExternalAuthentication());
    domainObject.setNotificationDetails(
        ims.admin.vo.domain.UserNotificationDetailsVoAssembler.extractUserNotificationDetails(
            domainFactory, valueObject.getNotificationDetails(), domMap));
    // 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.getSecretKey() != null && valueObject.getSecretKey().equals("")) {
      valueObject.setSecretKey(null);
    }
    domainObject.setSecretKey(valueObject.getSecretKey());
    // 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.getSdsUserId() != null && valueObject.getSdsUserId().equals("")) {
      valueObject.setSdsUserId(null);
    }
    domainObject.setSdsUserId(valueObject.getSdsUserId());
    // 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.getUsername() != null && valueObject.getUsername().equals("")) {
      valueObject.setUsername(null);
    }
    domainObject.setUsername(valueObject.getUsername());
    // 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.getPassword() != null && valueObject.getPassword().equals("")) {
      valueObject.setPassword(null);
    }
    domainObject.setPassword(valueObject.getPassword());
    // 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.getEncodedPassword() != null && valueObject.getEncodedPassword().equals("")) {
      valueObject.setEncodedPassword(null);
    }
    domainObject.setEncodedPassword(valueObject.getEncodedPassword());
    // 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.getTheme() != null && valueObject.getTheme().equals("")) {
      valueObject.setTheme(null);
    }
    domainObject.setTheme(valueObject.getTheme());
    ims.framework.utils.DateTime dateTime13 = valueObject.getPwdExpDate();
    java.util.Date value13 = null;
    if (dateTime13 != null) {
      value13 = dateTime13.getJavaDate();
    }
    domainObject.setPwdExpDate(value13);
    ims.framework.utils.DateTime dateTime14 = valueObject.getEffectiveFrom();
    java.util.Date value14 = null;
    if (dateTime14 != null) {
      value14 = dateTime14.getJavaDate();
    }
    domainObject.setEffectiveFrom(value14);
    ims.framework.utils.DateTime dateTime15 = valueObject.getEffectiveTo();
    java.util.Date value15 = null;
    if (dateTime15 != null) {
      value15 = dateTime15.getJavaDate();
    }
    domainObject.setEffectiveTo(value15);
    domainObject.setIsActive(valueObject.getIsActive());
    domainObject.setDebugMode(valueObject.getDebugMode());
    // 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.getLDAPUsername() != null && valueObject.getLDAPUsername().equals("")) {
      valueObject.setLDAPUsername(null);
    }
    domainObject.setLDAPUsername(valueObject.getLDAPUsername());
    // 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.getLDAPPassword() != null && valueObject.getLDAPPassword().equals("")) {
      valueObject.setLDAPPassword(null);
    }
    domainObject.setLDAPPassword(valueObject.getLDAPPassword());
    domainObject.setLocked(valueObject.getLocked());

    return domainObject;
  }