Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9fcd6a9d
authored
Dec 22, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lisätty CSV exporttiin käyttäjän paikka.
1 parent
dd3cb56c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserCartView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserCartView.java
View file @
9fcd6a9
...
...
@@ -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"
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment