|
MailItem | addToQueue (NotificationCategory category, IContact contact, MailMessage mmt, String reason, String poolName) |
|
MailItem | addToQueue (NotificationCategory category, IContact contact, String subject, String message, String reason, String poolName) |
|
void | checkConfiguration (IContact contact, String idCategory, QueuePeriod queuePeriod) |
|
void | setPeriod (IContact contact, String idCategory, QueuePeriod queuePeriod, boolean override) |
|
void | subscribeDefaults (ConstraintKeys keys) |
|
QueueOptions | getConfiguration (IContact contact, String idCategory) |
|
QueueOptions | configQueue (QueueOptions qo) |
|
boolean | contactWants (IContact contact, String idCategory) |
|
boolean | contactMayWant (IContact contact, String idCategory) |
|
List< MailItem > | getPending (QueuePeriod period) |
|
ContactMap | getContactMap (List< MailItem > list) |
|
void | removeUniquesFor (String idCategory, String idContact) |
|
void | removeMails (QueuePeriod period, String idContact, String idCategory) |
|
void | removeContactMails (String idContact) |
|
void | removeWithoutOptions () |
|
void | removeOldsByPeriod () |
|
void | removeOptions (String idCategory) |
|
void | setPeriodToAll (String idCategory, QueuePeriod period) |
|
void | checkConstraints (String idCategory) |
|
Collection< QueueOptions > | getSubcribers (String idCategory) |
|
Collection< Long > | getSubcribersId (String idCategory) |
|
void | createBulk () |
|
void | removeMail (MailItem mi) |
|
void | removeOptions (QueueOptions qo) |
|
Collection< QueueOptions > | getSubcribersByRoot (String root) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 48 of file QueueManager.java.
◆ addToQueue() [1/2]
Definition at line 67 of file QueueManager.java.
69 if(contact.isWebUser()) {
70 MailItem mi =
new MailItem();
71 mi.setIdCategory(category.getIdCategory());
72 mi.setCategory(category.getCategory());
73 mi.setDescription(category.getDescription());
74 mi.setIContact(contact);
75 mi.setItemDate(mmt.getSentDate());
76 mi.setSubject(mmt.getSubject());
77 mi.setMessage(mmt.getMessage());
78 mi.setReason(cleanSubject(reason));
79 mi.setPoolName(poolName);
80 if(category.isUnique()) {
84 return getDao().saveObject(mi);
void checkConfiguration(IContact contact, String idCategory, QueuePeriod queuePeriod)
void removeUniquesFor(String idCategory, String idContact)
◆ addToQueue() [2/2]
Definition at line 89 of file QueueManager.java.
91 if(contact.isWebUser()) {
92 MailItem mi =
new MailItem();
93 mi.setIdCategory(category.getIdCategory());
94 mi.setCategory(category.getCategory());
95 mi.setDescription(category.getDescription());
96 mi.setIContact(contact);
97 mi.setItemDate(
new Date());
98 mi.setSubject(subject);
99 mi.setMessage(message);
100 mi.setReason(cleanSubject(reason));
101 mi.setPoolName(poolName);
102 if(category.isUnique()) {
106 return getDao().saveObject(mi);
◆ checkConfiguration()
void org.turro.mail.queue.QueueManager.checkConfiguration |
( |
IContact |
contact, |
|
|
String |
idCategory, |
|
|
QueuePeriod |
queuePeriod |
|
) |
| |
Definition at line 111 of file QueueManager.java.
114 qo =
new QueueOptions();
115 qo.setIdCategory(idCategory);
116 qo.setIdContact(contact.getId());
117 qo.setPeriod(queuePeriod);
118 qo.setSingleMail(
true);
QueueOptions configQueue(QueueOptions qo)
QueueOptions getConfiguration(IContact contact, String idCategory)
◆ checkConstraints()
void org.turro.mail.queue.QueueManager.checkConstraints |
( |
String |
idCategory | ) |
|
Definition at line 290 of file QueueManager.java.
291 NotificationCategory nc = Notifications.getCategory(idCategory);
292 if(nc.getConstraints().isRestricted()) {
293 List<QueueOptions> toDelete =
new ArrayList<>();
294 SqlClause.select(
"o").from(
"QueueOptions o")
295 .where().equal(
"o.idCategory", idCategory)
297 .resultList(QueueOptions.class)
299 IContact contact = Contacts.getContactById(o.getIdContact());
300 if(contact.isValid()) {
301 ConstraintKeys keys = ConstraintKeys.from(contact);
302 if(!nc.strongBond(keys)) {
void deleteCollection(Collection objs)
◆ configQueue()
◆ contactMayWant()
boolean org.turro.mail.queue.QueueManager.contactMayWant |
( |
IContact |
contact, |
|
|
String |
idCategory |
|
) |
| |
Definition at line 165 of file QueueManager.java.
167 return qo ==
null || !QueuePeriod.DONT_SEND.equals(qo.getPeriod());
◆ contactWants()
boolean org.turro.mail.queue.QueueManager.contactWants |
( |
IContact |
contact, |
|
|
String |
idCategory |
|
) |
| |
Definition at line 160 of file QueueManager.java.
162 return qo !=
null && !QueuePeriod.DONT_SEND.equals(qo.getPeriod());
◆ createBulk()
void org.turro.mail.queue.QueueManager.createBulk |
( |
| ) |
|
◆ getConfiguration()
QueueOptions org.turro.mail.queue.QueueManager.getConfiguration |
( |
IContact |
contact, |
|
|
String |
idCategory |
|
) |
| |
Definition at line 146 of file QueueManager.java.
147 WhereClause wc =
new WhereClause();
148 wc.addClause(
"select o from QueueOptions o");
149 wc.addClause(
"where o.idContact = :idContact");
150 wc.addClause(
"and o.idCategory = :idCategory");
151 wc.addNamedValue(
"idContact", contact.getId());
152 wc.addNamedValue(
"idCategory", idCategory);
Object getSingleResultOrNull(SqlClause sc)
◆ getContactMap()
Definition at line 181 of file QueueManager.java.
182 ContactMap cm =
new ContactMap();
183 for(MailItem mi : list) {
◆ getPending()
Definition at line 170 of file QueueManager.java.
171 WhereClause wc =
new WhereClause();
172 wc.addClause(
"select m from MailItem m, QueueOptions o");
173 wc.addClause(
"where o.period = :period");
174 wc.addClause(
"and m.idContact = o.idContact");
175 wc.addClause(
"and m.idCategory = o.idCategory");
176 wc.addClause(
"order by m.idContact, m.idCategory");
177 wc.addNamedValue(
"period", period);
178 return getDao().getResultList(wc);
◆ getSubcribers()
Collection<QueueOptions> org.turro.mail.queue.QueueManager.getSubcribers |
( |
String |
idCategory | ) |
|
Definition at line 314 of file QueueManager.java.
315 WhereClause wc =
new WhereClause();
316 wc.addClause(
"select o from QueueOptions o");
317 wc.addClause(
"where o.idCategory = :category");
318 wc.addNamedValue(
"category", idCategory);
319 return getDao().getResultList(wc);
◆ getSubcribersByRoot()
Collection<QueueOptions> org.turro.mail.queue.QueueManager.getSubcribersByRoot |
( |
String |
root | ) |
|
Definition at line 371 of file QueueManager.java.
372 WhereClause wc =
new WhereClause();
373 wc.addClause(
"select o from QueueOptions o");
374 wc.addClause(
"where o.idCategory like :category");
375 wc.addNamedValue(
"category", root +
"/%");
376 return getDao().getResultList(wc);
◆ getSubcribersId()
Collection<Long> org.turro.mail.queue.QueueManager.getSubcribersId |
( |
String |
idCategory | ) |
|
Definition at line 322 of file QueueManager.java.
323 WhereClause wc =
new WhereClause();
324 wc.addClause(
"select o.id from QueueOptions o");
325 wc.addClause(
"where o.idCategory = :category");
326 wc.addNamedValue(
"category", idCategory);
327 return getDao().getResultList(wc);
◆ removeContactMails()
void org.turro.mail.queue.QueueManager.removeContactMails |
( |
String |
idContact | ) |
|
Definition at line 216 of file QueueManager.java.
217 WhereClause wc =
new WhereClause();
218 wc.addClause(
"delete from MailItem m");
219 wc.addClause(
"where m.idContact = :contact");
220 wc.addNamedValue(
"contact", idContact);
int executeUpdate(String query)
◆ removeMail()
void org.turro.mail.queue.QueueManager.removeMail |
( |
MailItem |
mi | ) |
|
◆ removeMails()
void org.turro.mail.queue.QueueManager.removeMails |
( |
QueuePeriod |
period, |
|
|
String |
idContact, |
|
|
String |
idCategory |
|
) |
| |
Definition at line 199 of file QueueManager.java.
200 WhereClause wc =
new WhereClause();
201 wc.addClause(
"delete from MailItem m");
202 wc.addClause(
"where m.idContact = :contact");
203 wc.addClause(
"and m.idCategory = :category");
204 wc.addClause(
"and exists (");
205 wc.addClause(
"select o from QueueOptions o");
206 wc.addClause(
"where o.period = :period");
207 wc.addClause(
"and m.idContact = o.idContact");
208 wc.addClause(
"and m.idCategory = o.idCategory");
210 wc.addNamedValue(
"contact", idContact);
211 wc.addNamedValue(
"category", idCategory);
212 wc.addNamedValue(
"period", period);
◆ removeOldsByPeriod()
void org.turro.mail.queue.QueueManager.removeOldsByPeriod |
( |
| ) |
|
Definition at line 235 of file QueueManager.java.
236 WhereClause wc =
new WhereClause();
237 wc.addClause(
"delete from MailItem m");
238 wc.addClause(
"where exists (");
239 wc.addClause(
"select o from QueueOptions o");
240 wc.addClause(
"where m.idContact = o.idContact");
241 wc.addClause(
"and m.idCategory = o.idCategory");
242 wc.addClause(
"and (");
243 wc.addClause(
"o.period = :dontSend");
244 wc.addClause(
"or (o.period = :asGenerated and m.itemDate < :oneDay)");
245 wc.addClause(
"or (o.period = :daily and m.itemDate < :oneDay)");
246 wc.addClause(
"or (o.period = :weekly and m.itemDate < :oneWeek)");
247 wc.addClause(
"or (o.period = :fortnightly and m.itemDate < :twoWeeks)");
248 wc.addClause(
"or (o.period = :monthly and m.itemDate < :oneMonth)");
249 wc.addClause(
"or (o.period = :quarterly and m.itemDate < :threeMonths)");
250 wc.addClause(
"or (o.period = :everySix and m.itemDate < :sixMonths)");
251 wc.addClause(
"or (o.period = :yearly and m.itemDate < :oneYear)");
253 wc.addNamedValue(
"dontSend", QueuePeriod.DONT_SEND);
254 wc.addNamedValue(
"asGenerated", QueuePeriod.AS_GENERATED);
255 wc.addNamedValue(
"daily", QueuePeriod.DAILY);
256 wc.addNamedValue(
"oneDay",
new CheckDate().addDays(-2).getDate());
257 wc.addNamedValue(
"weekly", QueuePeriod.WEEKLY);
258 wc.addNamedValue(
"oneWeek",
new CheckDate().addWeeks(-1).addDays(-2).getDate());
259 wc.addNamedValue(
"fortnightly", QueuePeriod.FORTNIGHTLY);
260 wc.addNamedValue(
"twoWeeks",
new CheckDate().addWeeks(-2).addDays(-2).getDate());
261 wc.addNamedValue(
"monthly", QueuePeriod.MONTHLY);
262 wc.addNamedValue(
"oneMonth",
new CheckDate().addMonths(-1).addDays(-2).getDate());
263 wc.addNamedValue(
"quarterly", QueuePeriod.QUARTERLY);
264 wc.addNamedValue(
"threeMonths",
new CheckDate().addMonths(-3).addDays(-2).getDate());
265 wc.addNamedValue(
"everySix", QueuePeriod.EVERY_SIX_MONTHS);
266 wc.addNamedValue(
"sixMonths",
new CheckDate().addMonths(-6).addDays(-2).getDate());
267 wc.addNamedValue(
"yearly", QueuePeriod.YEARLY);
268 wc.addNamedValue(
"oneYear",
new CheckDate().addYears(-1).addDays(-2).getDate());
◆ removeOptions() [1/2]
void org.turro.mail.queue.QueueManager.removeOptions |
( |
QueueOptions |
qo | ) |
|
◆ removeOptions() [2/2]
void org.turro.mail.queue.QueueManager.removeOptions |
( |
String |
idCategory | ) |
|
Definition at line 272 of file QueueManager.java.
273 WhereClause wc =
new WhereClause();
274 wc.addClause(
"delete from QueueOptions o");
275 wc.addClause(
"where o.idCategory = :category");
276 wc.addNamedValue(
"category", idCategory);
◆ removeUniquesFor()
void org.turro.mail.queue.QueueManager.removeUniquesFor |
( |
String |
idCategory, |
|
|
String |
idContact |
|
) |
| |
Definition at line 189 of file QueueManager.java.
190 WhereClause wc =
new WhereClause();
191 wc.addClause(
"delete from MailItem m");
192 wc.addClause(
"where m.idContact = :contact");
193 wc.addClause(
"and m.idCategory = :category");
194 wc.addNamedValue(
"contact", idContact);
195 wc.addNamedValue(
"category", idCategory);
◆ removeWithoutOptions()
void org.turro.mail.queue.QueueManager.removeWithoutOptions |
( |
| ) |
|
Definition at line 224 of file QueueManager.java.
225 WhereClause wc =
new WhereClause();
226 wc.addClause(
"delete from MailItem m");
227 wc.addClause(
"where not exists (");
228 wc.addClause(
"select o from QueueOptions o");
229 wc.addClause(
"where m.idContact = o.idContact");
230 wc.addClause(
"and m.idCategory = o.idCategory");
◆ send()
Definition at line 50 of file QueueManager.java.
51 boolean lockAcquired = QUEUEMANAGER_LOCK.tryLock();
54 QueueManager qm =
new QueueManager();
55 qm.removeWithoutOptions();
56 qm.removeOldsByPeriod();
57 ContactMap cm = qm.getContactMap(qm.getPending(period));
58 for(String idContact : cm.keySet()) {
59 new ContactQueueSender(constructor, qm, period, cm.get(idContact)).send();
62 QUEUEMANAGER_LOCK.unlock();
◆ setPeriod()
void org.turro.mail.queue.QueueManager.setPeriod |
( |
IContact |
contact, |
|
|
String |
idCategory, |
|
|
QueuePeriod |
queuePeriod, |
|
|
boolean |
override |
|
) |
| |
Definition at line 123 of file QueueManager.java.
125 if(qo !=
null && !
override)
return;
127 qo =
new QueueOptions();
128 qo.setIdCategory(idCategory);
129 qo.setIdContact(contact.getId());
130 qo.setSingleMail(
true);
132 qo.setPeriod(queuePeriod);
◆ setPeriodToAll()
void org.turro.mail.queue.QueueManager.setPeriodToAll |
( |
String |
idCategory, |
|
|
QueuePeriod |
period |
|
) |
| |
Definition at line 280 of file QueueManager.java.
281 WhereClause wc =
new WhereClause();
282 wc.addClause(
"update QueueOptions o");
283 wc.addClause(
"set o.period = :period");
284 wc.addClause(
"where o.idCategory = :category");
285 wc.addNamedValue(
"period", period);
286 wc.addNamedValue(
"category", idCategory);
◆ subscribeDefaults()
void org.turro.mail.queue.QueueManager.subscribeDefaults |
( |
ConstraintKeys |
keys | ) |
|
Definition at line 136 of file QueueManager.java.
137 for(NotificationCategory nc : Notifications.getCategories()) {
138 if(nc.wideBond(keys)) {
140 }
else if(!nc.strongBond(keys)) {
void removeOptions(String idCategory)
The documentation for this class was generated from the following file: