Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-directcontrolservlet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
8cf89907
authored
2015-02-04 20:28:13 -0600
by
Ean Schuessler
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'BF-4909' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet
2 parents
de2aadd0
115554f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
8cf8990
...
...
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.Cookie
;
import
org.ofbiz.base.util.Debug
;
import
org.ofbiz.base.util.GroovyUtil
;
...
...
@@ -290,6 +291,52 @@ public class DirectControlServlet extends HttpServlet {
writer
.
close
();
}
if
(
"CSV"
.
equals
(
outputHandler
))
{
response
.
setContentType
(
"text/csv"
);
// Find the first list
List
resList
=
null
;
for
(
Object
o
:
result
.
values
())
{
if
(
o
instanceof
List
)
{
resList
=
(
List
)
o
;
break
;
}
}
if
(
resList
!=
null
)
{
PrintWriter
writer
=
response
.
getWriter
();
List
<
Map
>
data
=
null
;
if
(
resList
.
get
(
1
)
instanceof
List
)
{
data
=
(
List
<
Map
>)(
resList
.
get
(
1
));
}
else
{
data
=
resList
;
}
if
(
data
.
size
()
>
0
)
{
Iterator
hi
=
((
Map
)
data
.
get
(
0
)).
keySet
().
iterator
();
StringBuffer
csvBuf
=
new
StringBuffer
();
while
(
hi
.
hasNext
())
{
csvBuf
.
append
(
hi
.
next
());
if
(
hi
.
hasNext
())
csvBuf
.
append
(
","
);
}
writer
.
println
(
csvBuf
);
for
(
Map
row
:
data
)
{
Iterator
i
=
row
.
values
().
iterator
();
csvBuf
=
new
StringBuffer
();
while
(
i
.
hasNext
())
{
csvBuf
.
append
(
i
.
next
());
if
(
i
.
hasNext
())
csvBuf
.
append
(
","
);
}
writer
.
println
(
csvBuf
);
}
}
writer
.
flush
();
writer
.
close
();
}
}
if
(
"PDF"
.
equals
(
outputHandler
))
{
LibreOfficeRenderer
.
service
(
request
,
response
,
result
);
}
...
...
Please
register
or
sign in
to post a comment