Fix broken usage of LogEntry#getActed

This commit is contained in:
Luck
2017-11-09 21:05:06 +00:00
Unverified
parent 14005563a3
commit 22fba0c172
13 changed files with 37 additions and 29 deletions
@@ -72,10 +72,7 @@ public class ExtendedLogEntry implements LogEntry {
.thenComparing(LogEntry::getActor)
.thenComparing(LogEntry::getActorName, String.CASE_INSENSITIVE_ORDER)
.thenComparing(LogEntry::getType)
.thenComparing(e -> {
UUID u = e.getActed().orElse(null);
return u == null ? "" : u.toString();
})
.thenComparing(e -> e.getActed().map(UUID::toString).orElse(""))
.thenComparing(LogEntry::getActedName, String.CASE_INSENSITIVE_ORDER)
.thenComparing(LogEntry::getAction);
@@ -187,7 +184,7 @@ public class ExtendedLogEntry implements LogEntry {
this.getActor().equals(other.getActor()) &&
this.getActorName().equals(other.getActorName()) &&
this.getType() == other.getType() &&
(this.getActed() == null ? other.getActed() == null : this.getActed().equals(other.getActed())) &&
this.getActed().equals(other.getActed()) &&
this.getActedName().equals(other.getActedName()) &&
this.getAction().equals(other.getAction());
}
@@ -200,7 +197,7 @@ public class ExtendedLogEntry implements LogEntry {
result = result * PRIME + this.getActor().hashCode();
result = result * PRIME + this.getActorName().hashCode();
result = result * PRIME + this.getType().hashCode();
result = result * PRIME + (this.getActed() == null ? 43 : this.getActed().hashCode());
result = result * PRIME + this.getActed().hashCode();
result = result * PRIME + this.getActedName().hashCode();
result = result * PRIME + this.getAction().hashCode();
return result;
@@ -365,8 +362,8 @@ public class ExtendedLogEntry implements LogEntry {
data.add("actor", new JsonPrimitive(entry.getActor().toString()));
data.add("actorName", new JsonPrimitive(entry.getActorName()));
data.add("type", new JsonPrimitive(entry.getType().name()));
if (entry.getActed() != null) {
data.add("acted", new JsonPrimitive(entry.getActed().toString()));
if (entry.getActed().isPresent()) {
data.add("acted", new JsonPrimitive(entry.getActed().get().toString()));
}
data.add("actedName", new JsonPrimitive(entry.getActedName()));
data.add("action", new JsonPrimitive(entry.getAction()));
@@ -120,8 +120,8 @@ public class Log {
public SortedSet<ExtendedLogEntry> getUserHistory(UUID uuid) {
return content.stream()
.filter(e -> e.getType() == LogEntry.Type.USER)
.filter(e -> e.getActed() != null)
.filter(e -> e.getActed().equals(uuid))
.filter(e -> e.getActed().isPresent())
.filter(e -> e.getActed().get().equals(uuid))
.collect(Collectors.toCollection(TreeSet::new));
}
@@ -132,8 +132,8 @@ public class Log {
public int getUserHistoryMaxPages(UUID uuid) {
return getMaxPages(content.stream()
.filter(e -> e.getType() == LogEntry.Type.USER)
.filter(e -> e.getActed() != null)
.filter(e -> e.getActed().equals(uuid))
.filter(e -> e.getActed().isPresent())
.filter(e -> e.getActed().get().equals(uuid))
.count(), PAGE_ENTRIES);
}
@@ -291,7 +291,7 @@ public abstract class ConfigurateDao extends AbstractDao {
(entry.getActor().equals(Constants.CONSOLE_UUID) ? "" : entry.getActor() + " "),
entry.getActorName(),
Character.toString(entry.getType().getCode()),
(entry.getActed() == null ? "" : entry.getActed().toString() + " "),
entry.getActed().map(e -> e.toString() + " ").orElse(""),
entry.getActedName(),
entry.getAction())
);
@@ -170,8 +170,8 @@ public class MongoDao extends AbstractDao {
.append("actedName", entry.getActedName())
.append("action", entry.getAction());
if (entry.getActed() != null) {
doc.append("acted", entry.getActed());
if (entry.getActed().isPresent()) {
doc.append("acted", entry.getActed().get());
}
c.insertOne(doc, new InsertOneOptions());
@@ -234,7 +234,7 @@ public class SqlDao extends AbstractDao {
ps.setString(2, entry.getActor().toString());
ps.setString(3, entry.getActorName());
ps.setString(4, Character.toString(entry.getType().getCode()));
ps.setString(5, String.valueOf(entry.getActed()));
ps.setString(5, entry.getActed().map(UUID::toString).orElse("null"));
ps.setString(6, entry.getActedName());
ps.setString(7, entry.getAction());
ps.execute();
+1 -1
View File
@@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
`id` INT AUTO_INCREMENT NOT NULL,
`time` BIGINT NOT NULL,
`actor_uuid` VARCHAR(36) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`type` CHAR(1) NOT NULL,
`acted_uuid` VARCHAR(36) NOT NULL,
`acted_name` VARCHAR(36) NOT NULL,
+1 -1
View File
@@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
`id` INT AUTO_INCREMENT NOT NULL,
`time` BIGINT NOT NULL,
`actor_uuid` VARCHAR(36) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`type` CHAR(1) NOT NULL,
`acted_uuid` VARCHAR(36) NOT NULL,
`acted_name` VARCHAR(36) NOT NULL,
+1 -1
View File
@@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
`id` INT AUTO_INCREMENT NOT NULL,
`time` BIGINT NOT NULL,
`actor_uuid` VARCHAR(36) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`type` CHAR(1) NOT NULL,
`acted_uuid` VARCHAR(36) NOT NULL,
`acted_name` VARCHAR(36) NOT NULL,
@@ -41,7 +41,7 @@ CREATE TABLE "{prefix}actions" (
"id" SERIAL PRIMARY KEY NOT NULL,
"time" BIGINT NOT NULL,
"actor_uuid" VARCHAR(36) NOT NULL,
"actor_name" VARCHAR(100) NOT NULL,
"actor_name" VARCHAR(100) NOT NULL,
"type" CHAR(1) NOT NULL,
"acted_uuid" VARCHAR(36) NOT NULL,
"acted_name" VARCHAR(36) NOT NULL,
+1 -1
View File
@@ -43,7 +43,7 @@ CREATE TABLE `{prefix}actions` (
`id` INTEGER PRIMARY KEY NOT NULL,
`time` BIGINT NOT NULL,
`actor_uuid` VARCHAR(36) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`actor_name` VARCHAR(100) NOT NULL,
`type` CHAR(1) NOT NULL,
`acted_uuid` VARCHAR(36) NOT NULL,
`acted_name` VARCHAR(36) NOT NULL,