1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.es.log.exentity;
17
18 import java.time.LocalDateTime;
19 import java.time.ZoneId;
20 import java.time.ZonedDateTime;
21 import java.time.format.DateTimeFormatter;
22 import java.util.Map;
23
24 import org.codelibs.fess.es.log.bsentity.BsFavoriteLog;
25
26
27
28
29 public class FavoriteLog extends BsFavoriteLog {
30
31 private static final long serialVersionUID = 1L;
32
33 private Map<String, Object> fields;
34
35 public String getId() {
36 return asDocMeta().id();
37 }
38
39 public void setId(final String id) {
40 asDocMeta().id(id);
41 }
42
43 public Long getVersionNo() {
44 return asDocMeta().version();
45 }
46
47 public void setVersionNo(final Long version) {
48 asDocMeta().version(version);
49 }
50
51 public void addField(final String key, final Object value) {
52 fields.put(key, value);
53 }
54
55 public String getLogMessage() {
56 return getUrl();
57 }
58
59 public LocalDateTime getRequestedAt() {
60 return getCreatedAt();
61 }
62
63 @Override
64 public Map<String, Object> toSource() {
65 final Map<String, Object> sourceMap = super.toSource();
66 if (fields != null) {
67 sourceMap.putAll(fields);
68 }
69 return sourceMap;
70 }
71
72 @Override
73 protected void addFieldToSource(final Map<String, Object> sourceMap, final String field, final Object value) {
74 if (value instanceof LocalDateTime) {
75 final LocalDateTime ldt = (LocalDateTime) value;
76 final ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
77 super.addFieldToSource(sourceMap, field, DateTimeFormatter.ISO_INSTANT.format(zdt));
78 } else {
79 super.addFieldToSource(sourceMap, field, value);
80 }
81 }
82
83 @Override
84 public String toString() {
85 return "FavoriteLog [createdAt=" + createdAt + ", url=" + url + ", docId=" + docId + ", queryId=" + queryId + ", userInfoId="
86 + userInfoId + ", docMeta=" + docMeta + "]";
87 }
88 }