BrightSide Workbench Full Report + Source Code
org.turro.log.SystemLogModel Class Reference

Public Member Functions

long getCountOf (String comment, String entityPath, Date since)
 
void cleanup (String entityPath)
 
SystemLog firstEntry (String entityPath, String comment)
 
SystemLog lastEntry (String entityPath, String comment)
 

Static Public Member Functions

static Set< String > getAllPaths (String root)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 38 of file SystemLogModel.java.

Member Function Documentation

◆ cleanup()

void org.turro.log.SystemLogModel.cleanup ( String  entityPath)

Definition at line 58 of file SystemLogModel.java.

58  {
59  SqlClause.delete("SystemLog")
60  .where().group()
61  .equal("entityPath", entityPath)
62  .or().startsWith("entityPath", entityPath + "/")
63  .endGroup()
64  .and().notIn("comment", List.of("cleanup", "deleted")) // keep cleanups
65  .dao(getDao())
66  .execute();
67  }
Here is the caller graph for this function:

◆ firstEntry()

SystemLog org.turro.log.SystemLogModel.firstEntry ( String  entityPath,
String  comment 
)

Definition at line 83 of file SystemLogModel.java.

83  {
84  return SqlClause.select("l").from("SystemLog l")
85  .where().equal("l.comment", comment)
86  .and().equal("l.entityPath", entityPath)
87  .and("l.dateLog =").sub(
88  SqlClause.select("min(l2.dateLog)").from("SystemLog l2")
89  .where("l2.comment = l.comment")
90  .and("l2.entityPath = l.entityPath")
91  .groupBy("l2.comment, l2.entityPath"))
92  .dao(getDao())
93  .singleResult(SystemLog.class);
94  }

◆ getAllPaths()

static Set<String> org.turro.log.SystemLogModel.getAllPaths ( String  root)
static

Definition at line 71 of file SystemLogModel.java.

71  {
72  try(Stream<String> stream = SqlClause.select("distinct entityPath").from("SystemLog")
73  .where().startsWith("entityPath", "/" + root + "/")
74  .and().notIn("comment", List.of("cleanup", "deleted")) // keep cleanups
75  .dao(new ElephantPU())
76  .stream(String.class)) {
77  return new HashSet<>(stream.map(path -> Path.pathFrom(path).getTill(2)).toList());
78  }
79  }
Here is the caller graph for this function:

◆ getCountOf()

long org.turro.log.SystemLogModel.getCountOf ( String  comment,
String  entityPath,
Date  since 
)

Definition at line 40 of file SystemLogModel.java.

40  {
41  return Optional.ofNullable(
42  SqlClause.select("sum(counts)").from("SystemLog")
43  .where().any()
44  .startIf(!Strings.isBlank(comment))
45  .and().equal("comment", comment)
46  .endIf()
47  .startIf(!Strings.isBlank(entityPath))
48  .and().equal("entityPath", entityPath)
49  .endIf()
50  .startIf(since != null)
51  .and().greaterOrEqual("dateLog", since)
52  .endIf()
53  .dao(getDao())
54  .singleResult(Long.class))
55  .orElse(0L);
56  }
Here is the caller graph for this function:

◆ lastEntry()

SystemLog org.turro.log.SystemLogModel.lastEntry ( String  entityPath,
String  comment 
)

Definition at line 96 of file SystemLogModel.java.

96  {
97  return SqlClause.select("l").from("SystemLog l")
98  .where().equal("l.comment", comment)
99  .and().equal("l.entityPath", entityPath)
100  .and("l.dateLog =").sub(
101  SqlClause.select("max(l2.dateLog)").from("SystemLog l2")
102  .where("l2.comment = l.comment")
103  .and("l2.entityPath = l.entityPath")
104  .groupBy("l2.comment, l2.entityPath"))
105  .dao(getDao())
106  .singleResult(SystemLog.class);
107  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: