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