Commit 76ed1caf by Tuomas Riihimäki

Merge branch 'devel'

2 parents 9440f9c7 9fcd6a9d
......@@ -16,12 +16,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class UserCartView extends GenericCDIView {
private static final String CSV_SEPARATOR = ";";
private static final long serialVersionUID = 5294631925744474031L;
private static final Charset UTF8 = Charset.forName("UTF-8");
......@@ -38,25 +41,34 @@ public class UserCartView extends GenericCDIView {
public StreamedContent getDownloadCsv() {
StringBuilder sb = new StringBuilder();
sb.append("firstname").append(";");
sb.append("lastname").append(";");
sb.append("nick").append(";");
sb.append("login").append(";");
sb.append("birthday").append(";");
sb.append("phone").append(";");
sb.append("email").append(";");
sb.append("firstname").append(CSV_SEPARATOR);
sb.append("lastname").append(CSV_SEPARATOR);
sb.append("nick").append(CSV_SEPARATOR);
sb.append("login").append(CSV_SEPARATOR);
sb.append("birthday").append(CSV_SEPARATOR);
sb.append("phone").append(CSV_SEPARATOR);
sb.append("email").append(CSV_SEPARATOR);
sb.append("places").append(CSV_SEPARATOR);
sb.append("\n");
for (EventUser uc : usercart)
{
sb.append(uc.getFirstnames()).append(";");
sb.append(uc.getLastname()).append(";");
sb.append(uc.getNick()).append(";");
sb.append(uc.getLogin()).append(";");
sb.append(uc.getBirthday() != null ? dateformat.format(uc.getBirthday()) : "").append(";");
sb.append(uc.getPhone()).append(";");
sb.append(uc.getEmail()).append(";");
sb.append("\n");
sb.append(uc.getFirstnames()).append(CSV_SEPARATOR);
sb.append(uc.getLastname()).append(CSV_SEPARATOR);
sb.append(uc.getNick()).append(CSV_SEPARATOR);
sb.append(uc.getLogin()).append(CSV_SEPARATOR);
sb.append(uc.getBirthday() != null ? dateformat.format(uc.getBirthday()) : "").append(CSV_SEPARATOR);
sb.append(uc.getPhone()).append(CSV_SEPARATOR);
sb.append(uc.getEmail()).append(CSV_SEPARATOR);
for (GroupMembership gm : uc.getGroupMemberships())
{
if (gm.getPlaceReservation() != null)
{
sb.append(gm.getPlaceReservation().getName()).append(", ");
}
}
sb.append(CSV_SEPARATOR);
sb.append("\n");
}
DefaultStreamedContent ret = new DefaultStreamedContent(new ByteArrayInputStream(sb.toString().getBytes(UTF8)));
ret.setContentType("text/csv");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!