Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 9c27721e
authored
Oct 26, 2012
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of codecrew.fi:bortal
2 parents
3fab346e
863ff474
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
36 deletions
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/card/CardMassPrintView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/card/CardMassPrintView.java
View file @
9c27721
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
card
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
...
...
@@ -17,25 +22,19 @@ import fi.insomnia.bortal.util.MassPrintResult;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
import
fi.insomnia.bortal.web.cdiview.user.UserCartView
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
@Named
@ConversationScoped
public
class
CardMassPrintView
extends
GenericCDIView
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1017243588290663967L
;
@Inject
private
UserCartView
userCartView
;
@EJB
private
CardPrintBeanLocal
cardPrintBean
;
@Inject
private
UserCartView
userCartView
;
@EJB
private
CardPrintBeanLocal
cardPrintBean
;
private
File
file
;
private
StreamedContent
streamedFile
;
private
MassPrintResult
mpr
=
null
;
private
boolean
waitForAcceptance
=
true
;
...
...
@@ -43,40 +42,45 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
// TODO Auto-generated constructor stub
}
public
void
initView
()
{
public
void
initView
()
{
List
<
EventUser
>
eventUsers
=
userCartView
.
getUsercart
();
ArrayList
<
Integer
>
userIdList
=
new
ArrayList
<
Integer
>();
for
(
EventUser
eu
:
eventUsers
)
{
for
(
EventUser
eu
:
eventUsers
)
{
userIdList
.
add
(
eu
.
getId
());
}
file
=
null
;
try
{
mpr
=
cardPrintBean
.
getUserCardsAsPrintablePdf
(
userIdList
);
waitForAcceptance
=
true
;
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
FileOutputStream
fostream
=
new
FileOutputStream
(
file
);
fostream
.
write
(
mpr
.
getPdf
());
fostream
.
close
();
setStreamedFile
(
new
DefaultStreamedContent
(
new
FileInputStream
(
this
.
file
)));
}
catch
(
Exception
e
)
{
ByteArrayInputStream
pdfstream
=
new
ByteArrayInputStream
(
mpr
.
getPdf
());
//
// file = File.createTempFile("cardprintout",null);
// FileOutputStream fostream = new FileOutputStream(file);
// fostream.write(mpr.getPdf());
// fostream.close();
// setStreamedFile(new DefaultStreamedContent(new
// FileInputStream(this.file)));
setStreamedFile
(
new
DefaultStreamedContent
(
pdfstream
));
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
}
}
public
String
acceptPrintout
()
{
if
(
mpr
!=
null
&&
waitForAcceptance
)
{
if
(
mpr
!=
null
&&
waitForAcceptance
)
{
waitForAcceptance
=
false
;
cardPrintBean
.
acceptMassPrintResult
(
mpr
);
}
userCartView
.
setUsercart
(
new
ArrayList
<
EventUser
>());
return
"accepted"
;
}
public
UserCartView
getUserCartView
()
{
return
userCartView
;
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
View file @
9c27721
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
user
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
...
...
@@ -166,11 +165,15 @@ public class UserView extends GenericCDIView {
try
{
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
this
.
user
.
getId
());
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
FileOutputStream
fostream
=
new
FileOutputStream
(
file
);
fostream
.
write
(
mpr
.
getPdf
());
fostream
.
close
();
setStreamedFile
(
new
DefaultStreamedContent
(
new
FileInputStream
(
this
.
file
)));
ByteArrayInputStream
pdfstream
=
new
ByteArrayInputStream
(
mpr
.
getPdf
());
// file = File.createTempFile("cardprintout", null);
// FileOutputStream fostream = new FileOutputStream(file);
// fostream.write(mpr.getPdf());
// fostream.close();
// setStreamedFile(new DefaultStreamedContent(new
// FileInputStream(this.file)));
setStreamedFile
(
new
DefaultStreamedContent
(
pdfstream
));
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
}
...
...
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