working on loading journal entries
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.model.ObjectWithId;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
|
||||
public class JournalEntry extends ObjectWithId {
|
||||
|
||||
long timestamp, userId, entityId;
|
||||
String action, description, module;
|
||||
|
||||
public JournalEntry(long id, long timestamp, long userId, String module, long entityId, String action, String description){
|
||||
super(id);
|
||||
this.timestamp = timestamp;
|
||||
this.userId = userId;
|
||||
this.module = module;
|
||||
this.entityId = entityId;
|
||||
this.action = action;
|
||||
this.description = description;
|
||||
}
|
||||
public static JournalEntry of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(ID);
|
||||
var timestamp = rs.getLong(TIMESTAMP);
|
||||
var userId = rs.getLong(USER_ID);
|
||||
var module = rs.getString(MODULE);
|
||||
var entityId = rs.getLong(ENTITY_ID);
|
||||
var action = rs.getString(ACTION);
|
||||
var description = rs.getString(DESCRIPTION);
|
||||
|
||||
return new JournalEntry(id, timestamp, userId, module, entityId, action, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return map(
|
||||
TIMESTAMP, timestamp,
|
||||
USER_ID, userId,
|
||||
MODULE, module,
|
||||
ENTITY_ID, entityId,
|
||||
ACTION, action,
|
||||
DESCRIPTION, description
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user