19 package org.turro.dossier.issue;
21 import java.net.URLEncoder;
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.HashMap;
25 import java.util.List;
26 import org.amic.util.date.CheckDate;
27 import org.apache.commons.mail.EmailException;
28 import org.turro.action.Actions;
29 import org.turro.commentit.CommentItUtil;
30 import org.turro.dossier.db.DossierPU;
31 import org.turro.dossier.entity.Issue;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.elephant.context.IConstructor;
34 import org.turro.elephant.db.WhereClause;
35 import org.turro.elephant.security.IUser;
36 import org.turro.i18n.I_;
37 import org.turro.jpa.DaoUtil;
38 import org.turro.mail.message.MailMessageTemplate;
39 import org.turro.mail.pool.MailMessagePool;
40 import org.turro.mail.provider.MailProviders;
41 import org.turro.marker.ElephantMarker;
42 import org.turro.plugin.contacts.ContactList;
43 import org.turro.plugin.contacts.IContact;
44 import org.turro.starit.StarItUtil;
45 import org.turro.voteit.VoteItInfo;
46 import org.turro.voteit.VoteItUtil;
55 private final Long category, dossier, days;
56 private final String
template;
59 this.contacts = contacts;
60 this.category = category;
61 this.dossier = dossier;
63 this.
template =
template;
67 List<Issue> issues = getIssues();
68 if(issues !=
null && !issues.isEmpty()) {
76 em.
put(
"issues", issues);
77 em.
put(
"contact", contact);
79 em.
put(
"dateActivity",
new CheckDate().addDays(-days.intValue()).getDate());
90 return create(constructor, issue.getIssueURL(), email);
94 HashMap<String, String> values =
new HashMap<>();
96 values.put(
Actions.REDIR_PAR, URLEncoder.encode(redir,
"UTF-8"));
108 private List<Issue> getIssues() {
109 WhereClause wc =
new WhereClause();
110 wc.addClause(
"select i from Issue as i");
111 wc.addClause(
"where i.publishable = TRUE");
112 boolean condition =
false;
114 wc.addClause(
"and i.dossier.category.id = :catid");
115 wc.addNamedValue(
"catid", category);
119 wc.addClause(
"and i.dossier.id = :dosid");
120 wc.addNamedValue(
"dosid", dossier);
127 List<String> list =
new ArrayList<String>();
128 list.addAll((List<String>) CommentItUtil.paths(
"/issue", days.intValue()));
129 list.addAll((List<String>) VoteItUtil.paths(
"/issue", days.intValue()));
130 list.addAll((List<String>) StarItUtil.paths(
"/issue", days.intValue()));
131 wc.addClause(
"and (");
132 if(!list.isEmpty()) {
133 wc.addClause((condition ?
"or " :
"") +
"i.id in (" + DaoUtil.getInClauseFromPaths(list,
false) +
")");
137 wc.addClause((condition ?
"or " :
""));
138 wc.addClause(
"(i.delivery <= :delivery1 and i.delivery >= :delivery2)");
139 wc.addNamedValue(
"delivery1",
new CheckDate().addDays(days.intValue()).getDate());
140 wc.addNamedValue(
"delivery2",
new Date());
141 wc.addClause(
"or i.solvedDate >= :solved");
142 wc.addNamedValue(
"solved",
new CheckDate().addDays(-days.intValue()).getDate());
143 wc.addClause(
"or i.issueDate >= :created");
144 wc.addNamedValue(
"created",
new CheckDate().addDays(-days.intValue()).getDate());
149 return new DossierPU().getResultList(wc);
static String createAction(String email, String redir)
static final String USER_PAR
static String getObjectPath(Object object)
void sendMail(IConstructor constructor)
VoteItInfo votes(Issue issue, IContact contact)
String create(IConstructor constructor, Issue issue, String email)
String create(IConstructor constructor, String redir, String email)
WebIssuesNotification(ContactList contacts, Long category, Long dossier, Long days, String template)
static String getSiteName()
static String get(String msg)
void setMessage(ElephantMarker marker, IContact contact)
static MailMessageTemplate of(MailProvider provider)
Email addTo(String email, String name)
void setSubject(String subject)
MailMessage addToPool(String from, String to, String cc, String subject, String message)
MailProvider getProvider()
static MailProviders instance()
MailMessagePool getPool(IConstructor constructor, String name)
Object put(Object key, Object value)
static VoteItInfo info(Object entity, IContact contact)
static final String CONNECTOR_EMAIL