View Javadoc
1   /*
2    * Copyright (C) 2024 B3Partners B.V.
3    *
4    * SPDX-License-Identifier: MIT
5    */
6   
7   package org.tailormap.api.persistence;
8   
9   import jakarta.persistence.Column;
10  import jakarta.persistence.Entity;
11  import jakarta.persistence.EntityListeners;
12  import jakarta.persistence.GeneratedValue;
13  import jakarta.persistence.GenerationType;
14  import jakarta.persistence.Id;
15  import jakarta.persistence.Version;
16  import jakarta.validation.constraints.NotNull;
17  import java.util.ArrayList;
18  import java.util.List;
19  import org.hibernate.annotations.Type;
20  import org.tailormap.api.persistence.json.PageTile;
21  import org.tailormap.api.persistence.listener.EntityEventPublisher;
22  
23  @Entity
24  @EntityListeners(EntityEventPublisher.class)
25  public class Page {
26  
27    @Id
28    @GeneratedValue(strategy = GenerationType.IDENTITY)
29    private Long id;
30  
31    @Version private Long version;
32  
33    /**
34     * Used by the frontend that displays pages to determine how to show the page, a string like
35     * 'page'.
36     */
37    private String type;
38  
39    @Column(unique = true)
40    @NotNull
41    private String name;
42  
43    private String title;
44  
45    /**
46     * Content of the page, interpreted by the page display frontend, can contain Markdown for
47     * example.
48     */
49    @Column(columnDefinition = "text")
50    private String content;
51  
52    /** CSS class name to apply to the page. */
53    private String className;
54  
55    @Type(value = io.hypersistence.utils.hibernate.type.json.JsonBinaryType.class)
56    @Column(columnDefinition = "jsonb")
57    private List<PageTile> tiles = new ArrayList<>();
58  
59    public Long getId() {
60      return id;
61    }
62  
63    public void setId(Long id) {
64      this.id = id;
65    }
66  
67    public Long getVersion() {
68      return version;
69    }
70  
71    public void setVersion(Long version) {
72      this.version = version;
73    }
74  
75    public String getType() {
76      return type;
77    }
78  
79    public void setType(String type) {
80      this.type = type;
81    }
82  
83    public String getName() {
84      return name;
85    }
86  
87    public void setName(String name) {
88      this.name = name;
89    }
90  
91    public String getTitle() {
92      return title;
93    }
94  
95    public void setTitle(String title) {
96      this.title = title;
97    }
98  
99    public String getContent() {
100     return content;
101   }
102 
103   public void setContent(String content) {
104     this.content = content;
105   }
106 
107   public String getClassName() {
108     return className;
109   }
110 
111   public void setClassName(String className) {
112     this.className = className;
113   }
114 
115   public List<PageTile> getTiles() {
116     return tiles;
117   }
118 
119   public void setTiles(List<PageTile> tiles) {
120     this.tiles = tiles;
121   }
122 }