BrightSide Workbench Full Report + Source Code
CommonsInitializer.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2021 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.entities;
20
21
import
org.turro.string.Strings;
22
import
org.turro.action.IElephantInitializer;
23
import
org.turro.annotation.ElephantInitializer;
24
import
org.turro.cleanup.Cleanup;
25
import
org.turro.elephant.context.ElephantContext;
26
import
org.turro.elephant.context.IConstructor;
27
import
org.turro.elephant.db.ElephantPU;
28
import
org.turro.elephant.entities.db.SystemLog;
29
import
org.turro.jpa.Dao;
30
import
org.turro.log.SystemLogAccumulator;
31
import
org.turro.log.SystemLogMigration;
32
import
org.turro.log.WebLoggers;
33
import
org.turro.path.Path;
34
import
org.turro.related.RelatedMigration;
35
import
org.turro.sql.SqlClause;
36
import
org.turro.tags.TagMigration;
37
42
@ElephantInitializer
43
public
class
CommonsInitializer
implements
IElephantInitializer
{
44
45
@Override
46
public
void
initialize
(
IConstructor
constructor) {
47
WebLoggers
.
info
(
this
).
message
(
"SystemLogMigration started"
).
log
();
48
SystemLogMigration
.
migrate
();
49
WebLoggers
.
info
(
this
).
message
(
"TagMigration started"
).
log
();
50
TagMigration
.
migrate
();
51
WebLoggers
.
info
(
this
).
message
(
"TagMigration.clean started"
).
log
();
52
TagMigration
.
clean
();
53
WebLoggers
.
info
(
this
).
message
(
"RelatedMigration started"
).
log
();
54
RelatedMigration
.
migrate
();
55
WebLoggers
.
info
(
this
).
message
(
"repairDownloadedFiles started"
).
log
();
56
repairDownloadedFiles();
57
WebLoggers
.
info
(
this
).
message
(
"SystemLogAccumulator started"
).
log
();
58
SystemLogAccumulator
.
accumulate
();
59
WebLoggers
.
info
(
this
).
message
(
"Cleanup.orphans started"
).
log
();
60
Cleanup
.
orphans
();
61
}
62
63
private
void
repairDownloadedFiles() {
64
Dao
dao =
new
ElephantPU
();
65
SqlClause.select(
"l"
).from(
"SystemLog l"
)
66
.where().like(
"l.comment"
,
"% downloaded"
)
67
.dao(dao)
68
.resultList(
SystemLog
.class).forEach(sl -> {
69
dao.
deleteObject
(sl);
70
String fullPath = sl.getComment().substring(0, sl.getComment().length() -
" downloaded"
.length());
71
sl.setEntityPath(
"/file"
+ Strings.isBlank(
ElephantContext
.
getRelativePath
(fullPath), fullPath));
72
sl.setEntityName(Path.pathFrom(fullPath).getLastNode());
73
sl.setComment(
"downloaded"
);
74
dao.saveObject(sl);
75
});
76
}
77
78
}
org.turro.cleanup.Cleanup
Definition:
Cleanup.java:32
org.turro.cleanup.Cleanup.orphans
static void orphans()
Definition:
Cleanup.java:61
org.turro.elephant.context.ElephantContext
Definition:
ElephantContext.java:59
org.turro.elephant.context.ElephantContext.getRelativePath
static String getRelativePath(String path)
Definition:
ElephantContext.java:125
org.turro.elephant.db.ElephantPU
Definition:
ElephantPU.java:39
org.turro.elephant.entities.db.SystemLog
Definition:
SystemLog.java:44
org.turro.entities.CommonsInitializer
Definition:
CommonsInitializer.java:43
org.turro.entities.CommonsInitializer.initialize
void initialize(IConstructor constructor)
Definition:
CommonsInitializer.java:46
org.turro.jpa.Dao
Definition:
Dao.java:52
org.turro.jpa.Dao.deleteObject
void deleteObject(Object obj)
Definition:
Dao.java:162
org.turro.log.SystemLogAccumulator
Definition:
SystemLogAccumulator.java:33
org.turro.log.SystemLogAccumulator.accumulate
static void accumulate()
Definition:
SystemLogAccumulator.java:38
org.turro.log.SystemLogMigration
Definition:
SystemLogMigration.java:35
org.turro.log.SystemLogMigration.migrate
static void migrate()
Definition:
SystemLogMigration.java:39
org.turro.log.WebLoggers
Definition:
WebLoggers.java:27
org.turro.log.WebLoggers.message
WebLoggers message(String text, Object... parameters)
Definition:
WebLoggers.java:34
org.turro.log.WebLoggers.log
void log()
Definition:
WebLoggers.java:39
org.turro.log.WebLoggers.info
static WebLoggers info(Object entity)
Definition:
WebLoggers.java:43
org.turro.related.RelatedMigration
Definition:
RelatedMigration.java:35
org.turro.related.RelatedMigration.migrate
static void migrate()
Definition:
RelatedMigration.java:39
org.turro.tags.TagMigration
Definition:
TagMigration.java:36
org.turro.tags.TagMigration.clean
static void clean()
Definition:
TagMigration.java:40
org.turro.tags.TagMigration.migrate
static void migrate()
Definition:
TagMigration.java:47
org.turro.action.IElephantInitializer
Definition:
IElephantInitializer.java:26
org.turro.elephant.context.IConstructor
Definition:
IConstructor.java:42
TurroProjects
Public
Elephant
elephant-jpa
src
main
java
org
turro
entities
CommonsInitializer.java
Generated on Tue Mar 12 2024 07:01:18 for BrightSide by
1.9.1