BrightSide Workbench Full Report + Source Code
PublicationSenderTask.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.publication.util;
20
21
import
java.util.List;
22
import
org.turro.i18n.I_;
23
import
org.turro.jpa.Dao;
24
import
org.turro.log.WebLoggers;
25
import
org.turro.publication.db.PublicationPU;
26
import
org.turro.publication.entity.Publication;
27
import
org.turro.publication.entity.PublicationCategory;
28
import
org.turro.scheduler.task.AbstractTask;
29
34
public
class
PublicationSenderTask
extends
AbstractTask
{
35
36
private
long
idCat;
37
private
String path;
38
39
@Override
40
public
void
execute
() {
41
try
{
42
parseData();
43
44
Dao
dao =
new
PublicationPU
();
45
46
PublicationCategory
pubcat = dao.find(
PublicationCategory
.class, Long.valueOf(idCat));
47
48
if
(pubcat !=
null
) {
49
List<Publication> pubs =
PublicationCategories
.
getNotSentPublications
(pubcat.
getId
());
50
51
if
(!pubs.isEmpty()) {
52
new
PublicationNotification
(
getConstructor
(), path, pubs, pubcat).
send
();
53
54
PublicationCategories
.
markAsSentPublications
(pubcat.
getId
());
55
}
56
}
57
}
catch
(Exception ex) {
58
WebLoggers
.
severe
(
this
).
exception
(ex).
log
();
59
}
60
}
61
62
@Override
63
public
boolean
isSystem
() {
64
return
false
;
65
}
66
67
@Override
68
public
String
getName
() {
69
return
I_
.
get
(
"Publication sender"
);
70
}
71
72
@Override
73
public
String
getDataLabel
() {
74
return
I_
.
get
(
"Category ID"
);
75
}
76
77
private
void
parseData() {
78
String data =
getSettings
().
getData
();
79
int
p = data.indexOf(
"/"
);
80
if
(p > -1) {
81
idCat = Long.valueOf(data.substring(0, p));
82
path = data.substring(p);
83
}
else
{
84
idCat = Long.valueOf(data);
85
path =
null
;
86
}
87
}
88
89
}
org.turro.i18n.I_
Definition:
I_.java:39
org.turro.i18n.I_.get
static String get(String msg)
Definition:
I_.java:41
org.turro.jpa.Dao
Definition:
Dao.java:52
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.mail.queue.QueuedSender.send
void send()
Definition:
QueuedSender.java:39
org.turro.publication.db.PublicationPU
Definition:
PublicationPU.java:39
org.turro.publication.entity.PublicationCategory
Definition:
PublicationCategory.java:49
org.turro.publication.entity.PublicationCategory.getId
Long getId()
Definition:
PublicationCategory.java:79
org.turro.publication.util.PublicationCategories
Definition:
PublicationCategories.java:42
org.turro.publication.util.PublicationCategories.markAsSentPublications
static void markAsSentPublications(long categoryID)
Definition:
PublicationCategories.java:202
org.turro.publication.util.PublicationCategories.getNotSentPublications
static List< Publication > getNotSentPublications(long categoryID)
Definition:
PublicationCategories.java:186
org.turro.publication.util.PublicationNotification
Definition:
PublicationNotification.java:62
org.turro.publication.util.PublicationSenderTask
Definition:
PublicationSenderTask.java:34
org.turro.publication.util.PublicationSenderTask.execute
void execute()
Definition:
PublicationSenderTask.java:40
org.turro.publication.util.PublicationSenderTask.isSystem
boolean isSystem()
Definition:
PublicationSenderTask.java:63
org.turro.publication.util.PublicationSenderTask.getName
String getName()
Definition:
PublicationSenderTask.java:68
org.turro.publication.util.PublicationSenderTask.getDataLabel
String getDataLabel()
Definition:
PublicationSenderTask.java:73
org.turro.scheduler.task.AbstractTask
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:36
org.turro.scheduler.task.AbstractTask.getSettings
TaskSettings getSettings()
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:57
org.turro.scheduler.task.AbstractTask.getConstructor
IConstructor getConstructor()
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:53
org.turro.scheduler.task.settings.TaskSettings.getData
String getData()
Definition:
TaskSettings.java:64
TurroProjects
Public
BrightSide
elephant-publications
src
main
java
org
turro
publication
util
PublicationSenderTask.java
Generated on Tue Mar 12 2024 07:01:20 for BrightSide by
1.9.1