1 package de.dlr.shepard.mongoDB;
2
3 import com.fasterxml.jackson.annotation.JsonFormat;
4 import com.fasterxml.jackson.annotation.JsonIgnore;
5 import de.dlr.shepard.util.HasId;
6 import java.util.Date;
7 import lombok.Data;
8 import lombok.NoArgsConstructor;
9 import org.bson.codecs.pojo.annotations.BsonIgnore;
10 import org.eclipse.microprofile.openapi.annotations.media.Schema;
11 import org.neo4j.ogm.annotation.GeneratedValue;
12 import org.neo4j.ogm.annotation.Id;
13 import org.neo4j.ogm.annotation.Index;
14 import org.neo4j.ogm.annotation.typeconversion.DateLong;
15
16 @Data
17 @NoArgsConstructor
18 public abstract class AbstractMongoObject implements HasId {
19
20 @Id
21 @GeneratedValue
22 @JsonIgnore
23 private Long id;
24
25 @Index
26 @BsonIgnore
27 @Schema(readOnly = true)
28 private String oid;
29
30 @Schema(readOnly = true, nullable = true, format = "date-time", example = "2024-08-15T11:18:44.632+00:00")
31 @JsonFormat(shape = JsonFormat.Shape.STRING)
32 @DateLong
33 private Date createdAt;
34
35
36
37
38
39
40 protected AbstractMongoObject(String oid) {
41 this.oid = oid;
42 }
43
44 protected AbstractMongoObject(String oid, Date createdAt) {
45 this.oid = oid;
46 this.createdAt = createdAt;
47 }
48
49 @BsonIgnore
50 @Override
51 public String getUniqueId() {
52 return oid;
53 }
54 }