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

Public Member Functions

 IMailRecipients (Collection< IContact > recipients)
 
Collection< IContactgetRecipients ()
 
- Public Member Functions inherited from org.turro.zkoss.layout.GridLayout
 GridLayout ()
 
 GridLayout (int columns)
 
 GridLayout (String hflexs)
 
void setColumns (int columns)
 
void setColumns (String hflexs)
 
void setColCaptions (String captions)
 
void setColCaptions (String[] captions)
 
void clearRows ()
 
GridLayout addGroup (String title, boolean open)
 
GridLayout addRow ()
 
GridLayout insertBeforeRow (Row row)
 
GridLayout addCaption (String label)
 
GridLayout addValue (String value)
 
GridLayout addBoldValue (String value)
 
GridLayout addComponent (HtmlBasedComponent comp)
 
GridLayout addSpannedComponent (HtmlBasedComponent comp, int cols)
 
GridLayout addRowSpannedComponent (HtmlBasedComponent comp, int rows)
 
GridLayout addSpace ()
 
Row getCurrentRow ()
 
Rows getRows (boolean create)
 
Object getData ()
 
void setData (Object data)
 

Static Public Member Functions

static void selectRecipients (Collection< IContact > recipients, Command command)
 
static String getComment ()
 
static void send (String title, JRDataSource dataSource, Map parameters, String jasperFile, String defaultFile, String type, String certificateStore, Collection< IContact > contacts) throws JRException
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.zkoss.layout.GridLayout
Row currentRow
 

Detailed Description

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

Definition at line 56 of file IMailRecipients.java.

Constructor & Destructor Documentation

◆ IMailRecipients()

org.turro.zkoss.contact.IMailRecipients.IMailRecipients ( Collection< IContact recipients)

Definition at line 62 of file IMailRecipients.java.

62  {
63  if(recipients != null) {
64  this.recipients.addAll(recipients);
65  }
66  setColumns("350px,40px");
67  addRecipients();
68  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ getComment()

static String org.turro.zkoss.contact.IMailRecipients.getComment ( )
static

Definition at line 80 of file IMailRecipients.java.

80  {
81  return comment;
82  }
Here is the caller graph for this function:

◆ getRecipients()

Collection<IContact> org.turro.zkoss.contact.IMailRecipients.getRecipients ( )

Definition at line 191 of file IMailRecipients.java.

191  {
192  recipients = new ArrayList<IContact>();
193  for(Object o : getRows().getChildren()) {
194  if(o instanceof Row) {
195  if(((Row) o).getValue() instanceof IContact) {
196  recipients.add((IContact) ((Row) o).getValue());
197  }
198  }
199  }
200  return recipients;
201  }
Rows getRows(boolean create)
Here is the caller graph for this function:

◆ selectRecipients()

static void org.turro.zkoss.contact.IMailRecipients.selectRecipients ( Collection< IContact recipients,
Command  command 
)
static

Definition at line 70 of file IMailRecipients.java.

70  {
71  comment = null;
72  IMailRecipients mr = new IMailRecipients(recipients);
73  mr.setStyle("overflow:auto;");
74  SelectionDialog.getComponent(
75  Framework.getCurrent().getPage(),
76  I_.get("Recipients"),
77  mr, "425px", "350px", command);
78  }
IMailRecipients(Collection< IContact > recipients)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send()

static void org.turro.zkoss.contact.IMailRecipients.send ( String  title,
JRDataSource  dataSource,
Map  parameters,
String  jasperFile,
String  defaultFile,
String  type,
String  certificateStore,
Collection< IContact contacts 
) throws JRException
static

Definition at line 84 of file IMailRecipients.java.

85  {
86  try {
87  if(contacts == null) return;
88  Application app = Application.getApplication();
89  SignedReport sr = new SignedReport();
90  sr.setCertificateStore(certificateStore);
91  if(new File(ElephantContext.getRealPath(jasperFile)).exists()) {
92  sr.setSrc(jasperFile);
93  } else {
94  sr.setSrc(defaultFile);
95  }
96  sr.setParameters(parameters);
97  sr.setDatasource(dataSource);
98  sr.setType(type);
99  File attach = File.createTempFile("attach_", "_mail");
100  FileOutputStream fos = new FileOutputStream(attach);
101  InputStream is = sr.getReport().getStreamData();
102  int read;
103  byte[] bytes = new byte[1024];
104  while ((read = is.read(bytes)) != -1) {
105  fos.write(bytes, 0, read);
106  }
107  is.close();
108  fos.flush();
109  fos.close();
110  StringBuilder sb = new StringBuilder();
111  for(IContact c : contacts) {
112  String email = c.getConnector(IUser.CONNECTOR_EMAIL);
113  if(Contacts.isValidEmail(email)) {
114  MailPool mp = (MailPool) app.getImplementation("IMailPool_" + certificateStore);
115  MailMessage mm = new MailMessage(
116  (String) mp.getAttributes().get("mailhost"),
117  (String) mp.getAttributes().get("user"),
118  (String) mp.getAttributes().get("password"));
119  mm.addTo(email, c.getName());
120  sb.append(email).append(": ").append(c.getName()).append("\n");
121  mm.setFrom((String) mp.getAttributes().get("from"), ElephantContext.getSiteName());
122  mm.setSubject(ElephantContext.getSiteName() + ": " + title);
123  mm.setMessage(
124  "<p><i>" + I_.get("Automatically generated") + "</i></p>" +
125  "<p><b>" + ElephantContext.getSiteName() + "</b>: " + I_.get("Document") + "</p>");
126  mm.attach(attach.getAbsolutePath(), ElephantContext.getSiteName() + " " + I_.get("Document"), title + ".pdf");
127  mm.send();
128  }
129  }
130  attach.delete();
131  if(sb.length() > 0) {
132  ZkossUtils.showMessage(I_.get("Send documents"),
133  I_.get("Sent") + "\n\n" + sb.toString());
134  }
135  } catch (Exception ex) {
136  }
137  }
Here is the call graph for this function:

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