BrightSide Workbench Full Report + Source Code
org.turro.mail.queue.ContactQueueSender Class Reference
Inheritance diagram for org.turro.mail.queue.ContactQueueSender:
Collaboration diagram for org.turro.mail.queue.ContactQueueSender:

Public Member Functions

 ContactQueueSender (IConstructor constructor, QueueManager manager, QueuePeriod period, CategoryMap cm)
 
String getSubject (String category)
 
boolean isReasonDifferent (MailItem mailItem)
 
String getReason (MailItem mailItem)
 
boolean isSubjectDifferent (MailItem mailItem)
 
- Public Member Functions inherited from org.turro.mail.queue.QueuedSender
 QueuedSender ()
 
void send ()
 
void pause ()
 
void run ()
 

Protected Member Functions

void doSend ()
 

Additional Inherited Members

- Static Public Member Functions inherited from org.turro.mail.queue.QueuedSender
static AtomicCounter getCounter ()
 

Detailed Description

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

Definition at line 47 of file ContactQueueSender.java.

Constructor & Destructor Documentation

◆ ContactQueueSender()

org.turro.mail.queue.ContactQueueSender.ContactQueueSender ( IConstructor  constructor,
QueueManager  manager,
QueuePeriod  period,
CategoryMap  cm 
)

Definition at line 54 of file ContactQueueSender.java.

54  {
55  this.constructor = constructor;
56  this.manager = manager;
57  this.period = period;
58  this.cm = cm;
59  }

Member Function Documentation

◆ doSend()

void org.turro.mail.queue.ContactQueueSender.doSend ( )
protected

Reimplemented from org.turro.mail.queue.QueuedSender.

Definition at line 62 of file ContactQueueSender.java.

62  {
63  IAgreements agreements = Plugins.loadImplementation(IAgreements.class, "agreements");
64  for(String category : cm.keySet()) {
65  NotificationCategory nc = Notifications.getCategory(category);
66  agreements.setContact(cm.getIContact());
67  if(agreements.canSendEmails(nc)) {
68  try {
69  IContact contact = cm.getIContact();
70  MailItemSet mis = cm.get(category);
71  MailMessagePool pool = MailProviders.instance().getPool(constructor, Strings.isBlank(mis.getPoolName(), MailProviders.GENERIC));
72  if(pool != null) {
73  MailMessageTemplate mmt = MailMessageTemplate.of(pool.getProvider());
74  mmt.setRoot("/queue");
75  mmt.addTo(contact.getConnector(IUser.CONNECTOR_EMAIL), contact.getName());
76  mmt.setSubject(getSubject(mis.getCategory()));
77  ElephantMarker em = new ElephantMarker(constructor, true);
78  em.put("contact", contact);
79  em.put("messages", mis);
80  em.put("notifier", this);
81  mmt.setMessage(em, "messages", contact);
82  pool.addToPool(mmt);
83  pool.sendPool();
84  pause();
85  }
86  } catch (EmailException | NullPointerException ex) {
87  Logger.getLogger(ContactQueueSender.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
88  }
89  manager.removeMails(period, cm.getIContact().getId(), category);
90  } else {
91  agreements.sendIfNecessary(constructor);
92  if(agreements.declinedNotifications()) {
93  manager.removeMails(period, cm.getIContact().getId(), category);
94  }
95  }
96  }
97  }
ContactQueueSender(IConstructor constructor, QueueManager manager, QueuePeriod period, CategoryMap cm)
void removeMails(QueuePeriod period, String idContact, String idCategory)
Here is the call graph for this function:

◆ getReason()

String org.turro.mail.queue.ContactQueueSender.getReason ( MailItem  mailItem)

Definition at line 116 of file ContactQueueSender.java.

116  {
117  return !Strings.isBlank(mailItem.getReason()) ? mailItem.getReason() : I_.get("Others");
118  }
Here is the call graph for this function:

◆ getSubject()

String org.turro.mail.queue.ContactQueueSender.getSubject ( String  category)

Definition at line 99 of file ContactQueueSender.java.

99  {
100  return "[" + I_.get(category) + " " + ElephantContext.getSiteName() + "]";
101  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isReasonDifferent()

boolean org.turro.mail.queue.ContactQueueSender.isReasonDifferent ( MailItem  mailItem)

Definition at line 106 of file ContactQueueSender.java.

106  {
107  int result = CompareUtil.compare(reason, mailItem.getReason());
108  reason = mailItem.getReason();
109  if(result != 0) {
110  itemDate = null;
111  subject = null;
112  }
113  return result != 0;
114  }
Here is the call graph for this function:

◆ isSubjectDifferent()

boolean org.turro.mail.queue.ContactQueueSender.isSubjectDifferent ( MailItem  mailItem)

Definition at line 120 of file ContactQueueSender.java.

120  {
121  int result = CompareUtil.compareDate(itemDate, mailItem.getItemDate());
122  if(result == 0) {
123  result = CompareUtil.compare(subject, mailItem.getSubject());
124  }
125  itemDate = mailItem.getItemDate();
126  subject = mailItem.getSubject();
127  return result != 0;
128  }
Here is the call graph for this function:

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