working implementation of journal display
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -21,7 +21,6 @@ import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Token;
|
||||
import de.srsoftware.umbrella.messagebus.EventListener;
|
||||
import de.srsoftware.umbrella.messagebus.events.Event;
|
||||
import de.srsoftware.umbrella.messagebus.events.JournalEntry;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -59,7 +58,7 @@ public class JournalModule extends BaseHandler implements EventListener {
|
||||
for (var entry : entries) userMap.put(entry.userId(),loader.get(entry.userId()).toMap());
|
||||
return sendContent(ex,Map.of(
|
||||
Field.USER_LIST,userMap,
|
||||
Field.JOURNAL,entries.stream().map(JournalEntry::toMap).toList()
|
||||
Field.JOURNAL,entries.stream().map(entry -> entry.toMap(user.get().language())).toList()
|
||||
));
|
||||
} catch (NumberFormatException e) {
|
||||
throw invalidField(Field.ENTITY_ID, Text.NUMBER);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class SqliteDb extends BaseDb implements JournalDb{
|
||||
public SqliteDb(Connection connection) {
|
||||
@@ -74,8 +75,9 @@ public class SqliteDb extends BaseDb implements JournalDb{
|
||||
public void logEvent(Event<?> event) {
|
||||
try {
|
||||
var timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
|
||||
var description = new JSONObject(event.describe(false).toMap()).toString(2);
|
||||
insertInto(TABLE_JOURNAL,TIMESTAMP,USER_ID,MODULE,ENTITY_ID,ACTION,DESCRIPTION)
|
||||
.values(timestamp,event.initiator().id(), event.module(), event.objectId(), event.eventType(), event.describe())
|
||||
.values(timestamp,event.initiator().id(), event.module(), event.objectId(), event.eventType(), description)
|
||||
.execute(db).close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(ERROR_WRITE_EVENT,event.eventType(),event.initiator().name());
|
||||
|
||||
Reference in New Issue
Block a user