BrightSide Workbench Full Report + Source Code
MyIssuesNotifierTask.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
package
org.turro.dossier.issue;
20
21
import
java.util.Date;
22
import
java.util.List;
23
import
org.apache.commons.mail.EmailException;
24
import
org.turro.action.Contacts;
25
import
org.turro.dossier.db.DossierPU;
26
import
org.turro.dossier.entity.IssueStatus;
27
import
org.turro.elephant.db.WhereClause;
28
import
org.turro.i18n.I_;
29
import
org.turro.log.WebLoggers;
30
import
org.turro.plugin.contacts.ContactList;
31
import
org.turro.plugin.contacts.IContact;
32
import
org.turro.scheduler.task.AbstractTask;
33
38
public
class
MyIssuesNotifierTask
extends
AbstractTask
{
39
40
@Override
41
public
void
execute
() {
42
ContactList
list =
new
ContactList
();
43
for
(String idContact : getParticipants()) {
44
IContact
ic =
Contacts
.
getContactById
(idContact);
45
if
(ic.
isValid
() && ic.
isWebUser
()) {
46
list.
add
(ic);
47
}
48
}
49
for
(
IContact
c : list) {
50
try
{
51
new
MyIssuesNotification
(c).
addToQueue
(
getConstructor
());
52
}
catch
(EmailException ex) {
53
WebLoggers
.
severe
(
this
).
exception
(ex).
log
();
54
}
55
}
56
}
57
58
@Override
59
public
boolean
isSystem
() {
60
return
false
;
61
}
62
63
@Override
64
public
String
getName
() {
65
return
I_
.
get
(
"My issues notifier"
);
66
}
67
68
@Override
69
public
String
getDataLabel
() {
70
return
null
;
71
}
72
73
private
List<String> getParticipants() {
74
Date now =
new
Date();
75
WhereClause
wc =
new
WhereClause
();
76
wc.
addClause
(
"select distinct ip.idContact from IssueParticipant as ip"
);
77
wc.
addClause
(
"where ip.issue.status <> :status"
);
78
wc.
addNamedValue
(
"status"
,
IssueStatus
.
STATUS_CLOSED
);
79
wc.
addClause
(
"and (ip.issue.startDate is null or ip.issue.startDate <= :date)"
);
80
wc.
addNamedValue
(
"date"
, now);
81
return
new
DossierPU
().getResultList(wc);
82
}
83
84
}
org.turro.action.Contacts
Definition:
Contacts.java:42
org.turro.action.Contacts.getContactById
static IContact getContactById(String id)
Definition:
Contacts.java:72
org.turro.dossier.db.DossierPU
Definition:
DossierPU.java:42
org.turro.dossier.issue.MyIssuesNotification
Definition:
MyIssuesNotification.java:51
org.turro.dossier.issue.MyIssuesNotification.addToQueue
void addToQueue(IConstructor constructor)
Definition:
MyIssuesNotification.java:86
org.turro.dossier.issue.MyIssuesNotifierTask
Definition:
MyIssuesNotifierTask.java:38
org.turro.dossier.issue.MyIssuesNotifierTask.getName
String getName()
Definition:
MyIssuesNotifierTask.java:64
org.turro.dossier.issue.MyIssuesNotifierTask.execute
void execute()
Definition:
MyIssuesNotifierTask.java:41
org.turro.dossier.issue.MyIssuesNotifierTask.getDataLabel
String getDataLabel()
Definition:
MyIssuesNotifierTask.java:69
org.turro.dossier.issue.MyIssuesNotifierTask.isSystem
boolean isSystem()
Definition:
MyIssuesNotifierTask.java:59
org.turro.elephant.db.WhereClause
Definition:
WhereClause.java:32
org.turro.elephant.db.WhereClause.addClause
void addClause(String clause)
Definition:
WhereClause.java:56
org.turro.elephant.db.WhereClause.addNamedValue
void addNamedValue(String name, Object value)
Definition:
WhereClause.java:78
org.turro.i18n.I_
Definition:
I_.java:39
org.turro.i18n.I_.get
static String get(String msg)
Definition:
I_.java:41
org.turro.log.WebLoggers
Definition:
WebLoggers.java:27
org.turro.log.WebLoggers.severe
static WebLoggers severe(Object entity)
Definition:
WebLoggers.java:51
org.turro.log.WebLoggers.log
void log()
Definition:
WebLoggers.java:39
org.turro.log.WebLoggers.exception
WebLoggers exception(Throwable throwable)
Definition:
WebLoggers.java:29
org.turro.plugin.contacts.ContactList
Definition:
Elephant/elephant/src/main/java/org/turro/plugin/contacts/ContactList.java:32
org.turro.plugin.contacts.ContactList.add
boolean add(IContact e)
Definition:
Elephant/elephant/src/main/java/org/turro/plugin/contacts/ContactList.java:35
org.turro.scheduler.task.AbstractTask
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:36
org.turro.scheduler.task.AbstractTask.getConstructor
IConstructor getConstructor()
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:53
org.turro.dossier.entity.IssueStatus
Definition:
IssueStatus.java:29
org.turro.dossier.entity.IssueStatus.STATUS_CLOSED
STATUS_CLOSED
Definition:
IssueStatus.java:39
org.turro.plugin.contacts.IContact
Definition:
elephant/src/main/java/org/turro/plugin/contacts/IContact.java:33
org.turro.plugin.contacts.IContact.isWebUser
boolean isWebUser()
org.turro.plugin.contacts.IContact.isValid
boolean isValid()
TurroProjects
Public
BrightSide
elephant-dossier
src
main
java
org
turro
dossier
issue
MyIssuesNotifierTask.java
Generated on Tue Mar 12 2024 07:01:20 for BrightSide by
1.9.1