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 2881c83a
authored
Oct 26, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cardprintstuff fileistä muistiin...
1 parent
45ef301c
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 @
2881c83
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
card
;
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.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.context.FacesContext
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
...
@@ -17,25 +22,19 @@ import fi.insomnia.bortal.util.MassPrintResult;
...
@@ -17,25 +22,19 @@ import fi.insomnia.bortal.util.MassPrintResult;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
import
fi.insomnia.bortal.web.cdiview.user.UserCartView
;
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
@Named
@ConversationScoped
@ConversationScoped
public
class
CardMassPrintView
extends
GenericCDIView
implements
Serializable
{
public
class
CardMassPrintView
extends
GenericCDIView
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1017243588290663967L
;
private
static
final
long
serialVersionUID
=
-
1017243588290663967L
;
@Inject
private
UserCartView
userCartView
;
@Inject
private
UserCartView
userCartView
;
@EJB
private
CardPrintBeanLocal
cardPrintBean
;
@EJB
private
CardPrintBeanLocal
cardPrintBean
;
private
File
file
;
private
File
file
;
private
StreamedContent
streamedFile
;
private
StreamedContent
streamedFile
;
private
MassPrintResult
mpr
=
null
;
private
MassPrintResult
mpr
=
null
;
private
boolean
waitForAcceptance
=
true
;
private
boolean
waitForAcceptance
=
true
;
...
@@ -43,40 +42,45 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
...
@@ -43,40 +42,45 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
public
void
initView
()
{
public
void
initView
()
{
List
<
EventUser
>
eventUsers
=
userCartView
.
getUsercart
();
List
<
EventUser
>
eventUsers
=
userCartView
.
getUsercart
();
ArrayList
<
Integer
>
userIdList
=
new
ArrayList
<
Integer
>();
ArrayList
<
Integer
>
userIdList
=
new
ArrayList
<
Integer
>();
for
(
EventUser
eu
:
eventUsers
)
{
for
(
EventUser
eu
:
eventUsers
)
{
userIdList
.
add
(
eu
.
getId
());
userIdList
.
add
(
eu
.
getId
());
}
}
file
=
null
;
file
=
null
;
try
{
try
{
mpr
=
cardPrintBean
.
getUserCardsAsPrintablePdf
(
userIdList
);
mpr
=
cardPrintBean
.
getUserCardsAsPrintablePdf
(
userIdList
);
waitForAcceptance
=
true
;
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
()));
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
}
}
}
}
public
String
acceptPrintout
()
{
public
String
acceptPrintout
()
{
if
(
mpr
!=
null
&&
waitForAcceptance
)
{
if
(
mpr
!=
null
&&
waitForAcceptance
)
{
waitForAcceptance
=
false
;
waitForAcceptance
=
false
;
cardPrintBean
.
acceptMassPrintResult
(
mpr
);
cardPrintBean
.
acceptMassPrintResult
(
mpr
);
}
}
userCartView
.
setUsercart
(
new
ArrayList
<
EventUser
>());
userCartView
.
setUsercart
(
new
ArrayList
<
EventUser
>());
return
"accepted"
;
return
"accepted"
;
}
}
public
UserCartView
getUserCartView
()
{
public
UserCartView
getUserCartView
()
{
return
userCartView
;
return
userCartView
;
}
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/UserView.java
View file @
2881c83
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
user
;
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
user
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
...
@@ -166,11 +165,15 @@ public class UserView extends GenericCDIView {
...
@@ -166,11 +165,15 @@ public class UserView extends GenericCDIView {
try
{
try
{
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
this
.
user
.
getId
());
mpr
=
cardPrintBean
.
getUserCardAsPrintablePdf
(
this
.
user
.
getId
());
file
=
File
.
createTempFile
(
"cardprintout"
,
null
);
ByteArrayInputStream
pdfstream
=
new
ByteArrayInputStream
(
mpr
.
getPdf
());
FileOutputStream
fostream
=
new
FileOutputStream
(
file
);
fostream
.
write
(
mpr
.
getPdf
());
// file = File.createTempFile("cardprintout", null);
fostream
.
close
();
// FileOutputStream fostream = new FileOutputStream(file);
setStreamedFile
(
new
DefaultStreamedContent
(
new
FileInputStream
(
this
.
file
)));
// fostream.write(mpr.getPdf());
// fostream.close();
// setStreamedFile(new DefaultStreamedContent(new
// FileInputStream(this.file)));
setStreamedFile
(
new
DefaultStreamedContent
(
pdfstream
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
FacesMessage
(
e
.
getMessage
()));
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