package org.xcolab.view.pages.members.users.utils;

import org.xcolab.client.members.pojo.Member;
import org.xcolab.view.util.CsvResponseWriter;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

import javax.servlet.http.HttpServletResponse;

public class MemberListCsvWriter extends CsvResponseWriter {

    private static final List<String> COLUMN_NAMES = Arrays.asList("Screen name", "First name",
            "Last name", "Email address", "Country");
    private static final Function<Member, List<String>> COLUMN_EXTRACTION_FUNCTION
            = (member -> Arrays.asList(
                    member.getScreenName(),
                    member.getFirstName(),
                    member.getLastName(),
                    member.getEmailAddress(),
                    member.getCountry()
            ));

    public MemberListCsvWriter(HttpServletResponse response) throws IOException {
        super("membersList", COLUMN_NAMES, response);
    }

    public void writeMembers(List<Member> members) {
        members.stream()
                .map(COLUMN_EXTRACTION_FUNCTION)
                .forEach(this::writeRow);
    }
}

@@ -509,16 +509,23 @@
 Country%22
+, %22Bio%22
 );%0A    p
@@ -856,16 +856,58 @@
 ountry()
+,%0A                    member.getShortBio()
 %0A       

Add bio to member CSV export