BrightSide Workbench Full Report + Source Code
TaskSet.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.scheduler.task;
20
21
import
java.io.IOException;
22
import
java.util.Collections;
23
import
java.util.Set;
24
import
java.util.TreeSet;
25
import
java.util.stream.Collectors;
26
import
org.turro.elephant.context.IConstructor;
27
import
org.turro.log.WebLoggers;
28
import
org.turro.scheduler.task.settings.TaskSettings;
29
import
org.turro.scheduler.task.settings.TaskSettingsSet;
30
35
public
class
TaskSet
extends
TreeSet<AbstractTask> {
36
37
/* Factory */
38
39
private
static
final
Set<AbstractTask> tasks = Collections.synchronizedSet(
new
TaskSet
());
40
41
public
static
Set<AbstractTask>
load
(
IConstructor
constructor) {
42
try
{
43
tasks.clear();
44
TaskSettingsSet
set
=
TaskSettingsSet
.
load
();
45
for
(
TaskSettings
settings :
set
) {
46
AbstractTask
task = settings.
build
(constructor);
47
if
(task !=
null
) {
48
tasks.add(task);
49
}
50
}
51
return
tasks;
52
}
catch
(IOException ex) {
53
WebLoggers
.
severe
(
TaskSet
.class).
exception
(ex).
log
();
54
}
55
return
Collections.EMPTY_SET;
56
}
57
58
public
static
void
save
(Set<AbstractTask> tasks) {
59
try
{
60
TaskSettingsSet
settings = tasks.stream()
61
.filter(t -> !t.isSystem())
62
.map(t -> t.getSettings())
63
.collect(Collectors.toCollection(TaskSettingsSet::new));
64
settings.
save
();
65
}
catch
(IOException ex) {
66
WebLoggers
.
severe
(
TaskSet
.class).
exception
(ex).
log
();
67
}
68
}
69
70
}
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.scheduler.task.AbstractTask
Definition:
elephant-scheduler/src/main/java/org/turro/scheduler/task/AbstractTask.java:36
org.turro.scheduler.task.TaskSet
Definition:
TaskSet.java:35
org.turro.scheduler.task.TaskSet.load
static Set< AbstractTask > load(IConstructor constructor)
Definition:
TaskSet.java:41
org.turro.scheduler.task.TaskSet.save
static void save(Set< AbstractTask > tasks)
Definition:
TaskSet.java:58
org.turro.scheduler.task.settings.TaskSettingsSet
Definition:
TaskSettingsSet.java:34
org.turro.scheduler.task.settings.TaskSettingsSet.save
void save()
Definition:
TaskSettingsSet.java:54
org.turro.scheduler.task.settings.TaskSettingsSet.load
static TaskSettingsSet load()
Definition:
TaskSettingsSet.java:45
org.turro.scheduler.task.settings.TaskSettings
Definition:
TaskSettings.java:33
org.turro.scheduler.task.settings.TaskSettings.build
AbstractTask build(IConstructor constructor)
Definition:
TaskSettings.java:110
org.turro.elephant.context.IConstructor
Definition:
IConstructor.java:42
TurroProjects
Public
Elephant
elephant-scheduler
src
main
java
org
turro
scheduler
task
TaskSet.java
Generated on Tue Mar 12 2024 07:01:21 for BrightSide by
1.9.1