fi.evolver.basics.spring.log.entity.MessageLogLite Maven / Gradle / Ivy
package fi.evolver.basics.spring.log.entity;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import fi.evolver.basics.spring.log.entity.MessageLog.Direction;
import jakarta.persistence.*;
@Entity
@Table(name="message_log")
public class MessageLogLite {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
@Column(name="address")
private String address;
@Column(name="app_server")
private String appServer;
@Column(name="app_version")
private String appVersion;
@Column(name="duration_ms")
private Integer durationMs;
@Column(name="message_chain_id")
private long messageChainId;
@Enumerated(EnumType.STRING)
@Column(name="data_direction")
private Direction dataDirection;
@Column(name="message_type")
private String messageType;
@Column(name="protocol")
private String protocol;
@Column(name="request_headers")
private String requestHeaders;
@Column(name="request_size")
private Integer requestSize;
@Column(name="response_headers")
private String responseHeaders;
@Column(name="response_size")
private Integer responseSize;
@Column(name="requesting_system")
private String requestingSystem;
@Column(name="start_time")
private LocalDateTime startTime;
@Column(name="status_code")
private String statusCode;
@Column(name="status_message")
private String statusMessage;
@Column(name="responding_system")
private String respondingSystem;
@OrderBy("key, id")
@BatchSize(size=100)
@Fetch(value = FetchMode.JOIN)
@OneToMany(mappedBy="messageLog", fetch=FetchType.EAGER)
private List metadata;
public long getId() {
return this.id;
}
public String getAddress() {
return this.address;
}
public String getAppServer() {
return appServer;
}
public String getAppVersion() {
return this.appVersion;
}
public Integer getDurationMs() {
return this.durationMs;
}
public long getMessageChainId() {
return this.messageChainId;
}
public String getMessageType() {
return this.messageType;
}
public Map getMetadata() {
return metadata.stream().collect(Collectors.toMap(
MessageLogMetadataLite::getKey,
MessageLogMetadataLite::getValue,
(u, v) -> u,
LinkedHashMap::new));
}
public String getProtocol() {
return this.protocol;
}
public String getRequestHeaders() {
return this.requestHeaders;
}
public Integer getRequestSize() {
return this.requestSize;
}
public String getResponseHeaders() {
return this.responseHeaders;
}
public Integer getResponseSize() {
return this.responseSize;
}
public String getRequestingSystem() {
return this.requestingSystem;
}
public LocalDateTime getStartTime() {
return this.startTime;
}
public String getStatusCode() {
return this.statusCode;
}
public String getStatusMessage() {
return this.statusMessage;
}
public String getRespondingSystem() {
return this.respondingSystem;
}
public Direction getDataDirection() {
return dataDirection;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getMessageType()).append(": ");
builder.append(getRequestingSystem()).append(' ');
if (getDataDirection() == Direction.INBOUND)
builder.append('<');
builder.append('=');
if (getDataDirection() == Direction.OUTBOUND)
builder.append('>');
builder.append(' ');
builder.append(getRespondingSystem());
return builder.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy