1
2
3
4
5
6
7 package org.tailormap.api.persistence;
8
9 import jakarta.persistence.Basic;
10 import jakarta.persistence.Entity;
11 import jakarta.persistence.EntityListeners;
12 import jakarta.persistence.FetchType;
13 import jakarta.persistence.GeneratedValue;
14 import jakarta.persistence.GenerationType;
15 import jakarta.persistence.Id;
16 import jakarta.validation.constraints.NotNull;
17 import java.time.OffsetDateTime;
18 import java.time.ZoneId;
19 import java.util.UUID;
20 import org.tailormap.api.persistence.listener.EntityEventPublisher;
21
22 @Entity
23 @EntityListeners(EntityEventPublisher.class)
24 public class Upload {
25 public static final String CATEGORY_APP_LOGO = "app-logo";
26 public static final String CATEGORY_LEGEND = "legend";
27 public static final String CATEGORY_PORTAL_IMAGE = "portal-image";
28
29 @Id
30 @GeneratedValue(strategy = GenerationType.UUID)
31 private UUID id;
32
33 private String category;
34
35 private String filename;
36
37 private String mimeType;
38
39 private Integer imageWidth;
40
41 private Integer imageHeight;
42
43 private Boolean hiDpiImage;
44
45 @NotNull private OffsetDateTime lastModified = OffsetDateTime.now(ZoneId.systemDefault());
46
47 @Basic(fetch = FetchType.LAZY)
48 private byte[] content;
49
50 public int getContentLength() {
51 return getContent() == null ? 0 : content.length;
52 }
53
54 public UUID getId() {
55 return id;
56 }
57
58 public Upload setId(UUID id) {
59 this.id = id;
60 return this;
61 }
62
63 public String getCategory() {
64 return category;
65 }
66
67 public Upload setCategory(String category) {
68 this.category = category;
69 return this;
70 }
71
72 public String getFilename() {
73 return filename;
74 }
75
76 public Upload setFilename(String filename) {
77 this.filename = filename;
78 return this;
79 }
80
81 public String getMimeType() {
82 return mimeType;
83 }
84
85 public Upload setMimeType(String mimeType) {
86 this.mimeType = mimeType;
87 return this;
88 }
89
90 public Integer getImageWidth() {
91 return imageWidth;
92 }
93
94 public Upload setImageWidth(Integer imageWidth) {
95 this.imageWidth = imageWidth;
96 return this;
97 }
98
99 public Integer getImageHeight() {
100 return imageHeight;
101 }
102
103 public Upload setImageHeight(Integer imageHeight) {
104 this.imageHeight = imageHeight;
105 return this;
106 }
107
108 public Boolean getHiDpiImage() {
109 return hiDpiImage;
110 }
111
112 public Upload setHiDpiImage(Boolean hiDpiImage) {
113 this.hiDpiImage = hiDpiImage;
114 return this;
115 }
116
117 public OffsetDateTime getLastModified() {
118 return lastModified;
119 }
120
121 public Upload setLastModified(OffsetDateTime lastModified) {
122 this.lastModified = lastModified;
123 return this;
124 }
125
126 public byte[] getContent() {
127 return content;
128 }
129
130 public Upload setContent(byte[] content) {
131 this.content = content;
132 return this;
133 }
134 }