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
32    private Long version;
33  
34    /** Used by the frontend that displays pages to determine how to show the page, a string like 'page'. */
35    private String type;
36  
37    @Column(unique = true)
38    @NotNull private String name;
39  
40    private String title;
41  
42    /** Content of the page, interpreted by the page display frontend, can contain Markdown for example. */
43    @Column(columnDefinition = "text")
44    private String content;
45  
46    /** CSS class name to apply to the page. */
47    private String className;
48  
49    @Type(value = io.hypersistence.utils.hibernate.type.json.JsonBinaryType.class)
50    @Column(columnDefinition = "jsonb")
51    private List<PageTile> tiles = new ArrayList<>();
52  
53    public Long getId() {
54      return id;
55    }
56  
57    public void setId(Long id) {
58      this.id = id;
59    }
60  
61    public Long getVersion() {
62      return version;
63    }
64  
65    public void setVersion(Long version) {
66      this.version = version;
67    }
68  
69    public String getType() {
70      return type;
71    }
72  
73    public void setType(String type) {
74      this.type = type;
75    }
76  
77    public String getName() {
78      return name;
79    }
80  
81    public void setName(String name) {
82      this.name = name;
83    }
84  
85    public String getTitle() {
86      return title;
87    }
88  
89    public void setTitle(String title) {
90      this.title = title;
91    }
92  
93    public String getContent() {
94      return content;
95    }
96  
97    public void setContent(String content) {
98      this.content = content;
99    }
100 
101   public String getClassName() {
102     return className;
103   }
104 
105   public void setClassName(String className) {
106     this.className = className;
107   }
108 
109   public List<PageTile> getTiles() {
110     return tiles;
111   }
112 
113   public void setTiles(List<PageTile> tiles) {
114     this.tiles = tiles;
115   }
116 }