/**
   * Fetches the value of the attribute {@code ATTR_USER_OU} for the provided user account.
   *
   * @param userAccount The user account to fetch the value from.
   * @param getChildren if also children of userAccountous are to be fetched.
   * @return Returns the attribute value in an {@code EvaluationResult}.
   * @throws de.escidoc.core.common.exceptions.system.SystemException
   */
  private EvaluationResult fetchUserAccountOus(
      final UserAccount userAccount, final boolean getChildren) throws SystemException {

    final String ouAttributeName =
        EscidocConfiguration.getInstance()
            .get(EscidocConfiguration.ESCIDOC_CORE_AA_OU_ATTRIBUTE_NAME);
    if (ouAttributeName == null || ouAttributeName.length() == 0) {
      return CustomEvaluationResultBuilder.createEmptyEvaluationResult();
    }
    final List<UserAttribute> attributes =
        userAccountDao.retrieveAttributes(userAccount, ouAttributeName);
    final EvaluationResult result;
    if (attributes == null || attributes.isEmpty()) {
      result = CustomEvaluationResultBuilder.createEmptyEvaluationResult();
    } else {
      final List<StringAttribute> results = new ArrayList<StringAttribute>();
      final Collection<String> ouIds = new ArrayList<String>();
      for (final UserAttribute attribute : attributes) {
        results.add(new StringAttribute(attribute.getValue()));
        if (getChildren) {
          ouIds.add(attribute.getValue());
        }
      }
      if (getChildren) {
        final List<String> childOus =
            tripleStoreUtility.getChildrenPath(ouIds, new ArrayList<String>());
        if (childOus != null) {
          for (final String childOu : childOus) {
            results.add(new StringAttribute(childOu));
          }
        }
      }

      result = new EvaluationResult(new BagAttribute(Constants.URI_XMLSCHEMA_STRING, results));
    }
    return result;
  }