BrightSide Workbench Full Report + Source Code
org.turro.zkoss.print.ReportPrint Class Reference
Inheritance diagram for org.turro.zkoss.print.ReportPrint:
Collaboration diagram for org.turro.zkoss.print.ReportPrint:

Public Member Functions

 ReportPrint () throws InterruptedException
 
 ReportPrint (String title, String border, boolean closable) throws InterruptedException
 
Jasperreport getReport ()
 
void setReport (Jasperreport report)
 
- Public Member Functions inherited from org.turro.elephant.zkoss.ModalWindow
 ModalWindow (String title, String border, boolean closable)
 
 ModalWindow ()
 
int getResult ()
 
void setResult (int result)
 
Object getResultValue ()
 
void setResultValue (Object resultValue)
 
void show (Page page, Command command)
 

Static Public Member Functions

static void print (String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore) throws JRException
 
static void print (String title, JRDataSource dataSource, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore) throws JRException
 
static void send (String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore, Collection< IContact > contacts, String comment, Collection< MailAttachment > attachments, Consumer onFinish) throws JRException
 
static void send (String title, JRDataSource dataSource, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore, Collection< IContact > contacts, String comment, Collection< MailAttachment > attachments, Consumer onFinish) throws JRException
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.elephant.zkoss.ModalWindow
int result
 
Object resultValue
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file ReportPrint.java.

Constructor & Destructor Documentation

◆ ReportPrint() [1/2]

org.turro.zkoss.print.ReportPrint.ReportPrint ( ) throws InterruptedException

Definition at line 48 of file ReportPrint.java.

48  {
49  super();
50  }
Here is the caller graph for this function:

◆ ReportPrint() [2/2]

org.turro.zkoss.print.ReportPrint.ReportPrint ( String  title,
String  border,
boolean  closable 
) throws InterruptedException

Definition at line 52 of file ReportPrint.java.

52  {
53  super(title, border, closable);
54  }

Member Function Documentation

◆ getReport()

Jasperreport org.turro.zkoss.print.ReportPrint.getReport ( )

Definition at line 56 of file ReportPrint.java.

56  {
57  return report;
58  }
Here is the caller graph for this function:

◆ print() [1/2]

static void org.turro.zkoss.print.ReportPrint.print ( String  title,
Collection  collection,
Map  parameters,
String  jasperFile,
String  defaultFile,
String  type,
String  certificateStore 
) throws JRException
static

Definition at line 64 of file ReportPrint.java.

65  {
66  print(title, new JRBeanCollectionDataSource(collection), parameters, jasperFile, defaultFile, type, certificateStore);
67  }
static void print(String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore)
Here is the caller graph for this function:

◆ print() [2/2]

static void org.turro.zkoss.print.ReportPrint.print ( String  title,
JRDataSource  dataSource,
Map  parameters,
String  jasperFile,
String  defaultFile,
String  type,
String  certificateStore 
) throws JRException
static

Definition at line 69 of file ReportPrint.java.

70  {
71  ReportPrint reportView = (ReportPrint) Modal.getModal("/WEB-INF/_zul/www/report.zul");
72  reportView.setTitle(title);
73  if(reportView.getReport() instanceof SignedReport) {
74  ((SignedReport) reportView.getReport()).setCertificateStore(certificateStore);
75  }
76  if (new File(ElephantContext.getRealPath(jasperFile)).exists()) {
77  reportView.getReport().setSrc(jasperFile);
78  } else {
79  reportView.getReport().setSrc(defaultFile);
80  }
81  reportView.getReport().setParameters(parameters);
82  reportView.getReport().setDatasource(dataSource);
83  reportView.getReport().setType(type);
84  Modal.doModal(reportView, null);
85  }
Here is the call graph for this function:

◆ send() [1/2]

static void org.turro.zkoss.print.ReportPrint.send ( String  title,
Collection  collection,
Map  parameters,
String  jasperFile,
String  defaultFile,
String  type,
String  certificateStore,
Collection< IContact contacts,
String  comment,
Collection< MailAttachment attachments,
Consumer  onFinish 
) throws JRException
static

Definition at line 87 of file ReportPrint.java.

89  {
90  send(title, new JRBeanCollectionDataSource(collection), parameters, jasperFile, defaultFile,
91  type, certificateStore, contacts, comment, attachments, onFinish);
92  }
static void send(String title, Collection collection, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore, Collection< IContact > contacts, String comment, Collection< MailAttachment > attachments, Consumer onFinish)
Here is the caller graph for this function:

◆ send() [2/2]

static void org.turro.zkoss.print.ReportPrint.send ( String  title,
JRDataSource  dataSource,
Map  parameters,
String  jasperFile,
String  defaultFile,
String  type,
String  certificateStore,
Collection< IContact contacts,
String  comment,
Collection< MailAttachment attachments,
Consumer  onFinish 
) throws JRException
static

Definition at line 94 of file ReportPrint.java.

96  {
97  try {
98  if(contacts == null) return;
99  Application app = Application.getApplication();
100  SignedReport sr = new SignedReport();
101  sr.setCertificateStore(certificateStore);
102  if(new File(ElephantContext.getRealPath(jasperFile)).exists()) {
103  sr.setSrc(jasperFile);
104  } else {
105  sr.setSrc(defaultFile);
106  }
107  sr.setParameters(parameters);
108  sr.setDatasource(dataSource);
109  sr.setType(type);
110  File attach = File.createTempFile("attach_", "_mail");
111  FileOutputStream fos = new FileOutputStream(attach);
112  InputStream is = sr.getReport().getStreamData();
113  int read;
114  byte[] bytes = new byte[1024];
115  while ((read = is.read(bytes)) != -1) {
116  fos.write(bytes, 0, read);
117  }
118  is.close();
119  fos.flush();
120  fos.close();
121  MailAttachment ma = new MailAttachment(attach.getAbsolutePath(), title + ".pdf", null);
122  ma.attachment = attach;
123  attachments.add(ma);
124  MailSenders.getPool()
125  .setRoot("/financials")
126  .addContacts(contacts)
127  .addMailAttachments(attachments)
128  .onFinish(onFinish)
129  .put("comment", comment)
130  .put("title", title)
131  .put("mas", attachments)
132  .sendTemplate("document", ElephantContext.getSiteName() + ": " + title);
133  } catch (Exception ex) {
134  Logger.getLogger(ReportPrint.class.getName()).log(Level.SEVERE, ElephantContext.logMsg("Sending mails"), ex);
135  }
136  }
Here is the call graph for this function:

◆ setReport()

void org.turro.zkoss.print.ReportPrint.setReport ( Jasperreport  report)

Definition at line 60 of file ReportPrint.java.

60  {
61  this.report = report;
62  }

The documentation for this class was generated from the following file: