BrightSide Workbench Full Report + Source Code
org.turro.mail.recipients.IMailRecipients Class Reference
Inheritance diagram for org.turro.mail.recipients.IMailRecipients:
Collaboration diagram for org.turro.mail.recipients.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 57 of file IMailRecipients.java.

Constructor & Destructor Documentation

◆ IMailRecipients()

org.turro.mail.recipients.IMailRecipients.IMailRecipients ( Collection< IContact recipients)

Definition at line 63 of file IMailRecipients.java.

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

Member Function Documentation

◆ getComment()

static String org.turro.mail.recipients.IMailRecipients.getComment ( )
static

Definition at line 81 of file IMailRecipients.java.

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

◆ getRecipients()

Collection<IContact> org.turro.mail.recipients.IMailRecipients.getRecipients ( )

Definition at line 190 of file IMailRecipients.java.

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

◆ selectRecipients()

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

Definition at line 71 of file IMailRecipients.java.

71  {
72  comment = null;
73  IMailRecipients mr = new IMailRecipients(recipients);
74  mr.setStyle("overflow:auto;");
75  SelectionDialog.getComponent(
76  Framework.getCurrent().getPage(),
77  I_.get("Recipients"),
78  mr, "425px", "350px", command);
79  }
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.mail.recipients.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 85 of file IMailRecipients.java.

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

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