improvements + bookmarks

This commit is contained in:
2021-10-04 13:02:40 +02:00
parent 1fc18fdeb2
commit d3f6c86db6
48 changed files with 1542 additions and 432 deletions
@@ -0,0 +1,90 @@
/**
*
*/
package de.bstly.board.model;
import java.util.List;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.google.common.collect.Lists;
/**
* The Class Bookmarks.
*/
@Entity
@Table(name = "bookmarks")
@EntityListeners({ AuditingEntityListener.class })
public class Bookmarks {
@Id
@Column(name = "username", nullable = false)
private String username;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "bookmark_entries")
private List<Long> entries;
/**
* @param username
*/
public Bookmarks() {
super();
}
/**
* @param username
*/
public Bookmarks(String username) {
super();
this.username = username;
this.entries = Lists.newArrayList();
}
/**
* Gets the username.
*
* @return the username
*/
public String getUsername() {
return username;
}
/**
* Sets the username.
*
* @param username the new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Gets the entries.
*
* @return the entries
*/
public List<Long> getEntries() {
return entries;
}
/**
* Sets the entries.
*
* @param entries the new entries
*/
public void setEntries(List<Long> entries) {
this.entries = entries;
}
}
@@ -20,34 +20,49 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.google.common.collect.Maps;
/**
* @author Lurkars
*
* The Class Comment.
*/
@Entity
@Table(name = "comments")
@EntityListeners({ AuditingEntityListener.class })
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "author", nullable = false)
private String author;
@Column(name = "created", nullable = false)
private Instant created;
@Column(name = "target", nullable = false)
private Long target;
@Column(name = "parent", nullable = true)
private Long parent;
@Lob
@Column(name = "text", nullable = false)
private String text;
@Transient
private Map<String, Object> metadata;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
@@ -55,13 +70,17 @@ public class Comment {
}
/**
* @param id the id to set
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the author.
*
* @return the author
*/
public String getAuthor() {
@@ -69,13 +88,17 @@ public class Comment {
}
/**
* @param author the author to set
* Sets the author.
*
* @param author the new author
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Gets the created.
*
* @return the created
*/
public Instant getCreated() {
@@ -83,13 +106,17 @@ public class Comment {
}
/**
* @param created the created to set
* Sets the created.
*
* @param created the new created
*/
public void setCreated(Instant created) {
this.created = created;
}
/**
* Gets the target.
*
* @return the target
*/
public Long getTarget() {
@@ -97,13 +124,17 @@ public class Comment {
}
/**
* @param target the target to set
* Sets the target.
*
* @param target the new target
*/
public void setTarget(Long target) {
this.target = target;
}
/**
* Gets the parent.
*
* @return the parent
*/
public Long getParent() {
@@ -111,13 +142,17 @@ public class Comment {
}
/**
* @param parent the parent to set
* Sets the parent.
*
* @param parent the new parent
*/
public void setParent(Long parent) {
this.parent = parent;
}
/**
* Gets the text.
*
* @return the text
*/
public String getText() {
@@ -125,13 +160,17 @@ public class Comment {
}
/**
* @param text the text to set
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}
/**
* Gets the metadata.
*
* @return the metadata
*/
public Map<String, Object> getMetadata() {
@@ -143,7 +182,9 @@ public class Comment {
}
/**
* @param metadata the metadata to set
* Sets the metadata.
*
* @param metadata the metadata
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
+77 -17
View File
@@ -22,42 +22,63 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.google.common.collect.Maps;
/**
* @author Lurkars
*
* The Class Entry.
*/
@Entity
@Table(name = "entries")
@EntityListeners({ AuditingEntityListener.class })
public class Entry {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "author", nullable = false)
private String author;
@Column(name = "created", nullable = false)
private Instant created;
@Enumerated(EnumType.STRING)
@Column(name = "entry_type", nullable = false)
private EntryType entryType;
@Enumerated(EnumType.STRING)
@Column(name = "entry_status", nullable = false, columnDefinition = "varchar(255) default 'NORMAL'")
private EntryStatus entryStatus;
@Column(name = "url")
private String url;
@Column(name = "title", nullable = false)
private String title;
@Lob
@Column(name = "text")
private String text;
@Transient
private Double ranking;
@Transient
private Map<String, Object> metadata;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
@@ -65,13 +86,17 @@ public class Entry {
}
/**
* @param id the id to set
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the author.
*
* @return the author
*/
public String getAuthor() {
@@ -79,13 +104,17 @@ public class Entry {
}
/**
* @param author the author to set
* Sets the author.
*
* @param author the new author
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Gets the created.
*
* @return the created
*/
public Instant getCreated() {
@@ -93,41 +122,53 @@ public class Entry {
}
/**
* @param created the created to set
* Sets the created.
*
* @param created the new created
*/
public void setCreated(Instant created) {
this.created = created;
}
/**
* @return the entryType
* Gets the entry type.
*
* @return the entry type
*/
public EntryType getEntryType() {
return entryType;
}
/**
* @param entryType the entryType to set
* Sets the entry type.
*
* @param entryType the new entry type
*/
public void setEntryType(EntryType entryType) {
this.entryType = entryType;
}
/**
* @return the entryStatus
* Gets the entry status.
*
* @return the entry status
*/
public EntryStatus getEntryStatus() {
return entryStatus;
}
/**
* @param entryStatus the entryStatus to set
* Sets the entry status.
*
* @param entryStatus the new entry status
*/
public void setEntryStatus(EntryStatus entryStatus) {
this.entryStatus = entryStatus;
}
/**
* Gets the url.
*
* @return the url
*/
public String getUrl() {
@@ -135,13 +176,17 @@ public class Entry {
}
/**
* @param url the url to set
* Sets the url.
*
* @param url the new url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Gets the title.
*
* @return the title
*/
public String getTitle() {
@@ -149,13 +194,17 @@ public class Entry {
}
/**
* @param title the title to set
* Sets the title.
*
* @param title the new title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Gets the text.
*
* @return the text
*/
public String getText() {
@@ -163,13 +212,17 @@ public class Entry {
}
/**
* @param text the text to set
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}
/**
* Gets the ranking.
*
* @return the ranking
*/
public Double getRanking() {
@@ -177,13 +230,17 @@ public class Entry {
}
/**
* @param ranking the ranking to set
* Sets the ranking.
*
* @param ranking the new ranking
*/
public void setRanking(Double ranking) {
this.ranking = ranking;
}
/**
* Gets the metadata.
*
* @return the metadata
*/
public Map<String, Object> getMetadata() {
@@ -194,16 +251,19 @@ public class Entry {
}
/**
* @param metadata the metadata to set
* Sets the metadata.
*
* @param metadata the metadata
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}
/**
*
* @param rankedEntry
* @return
* From ranked entry.
*
* @param rankedEntry the ranked entry
* @return the entry
*/
public static Entry fromRankedEntry(RankedEntry rankedEntry) {
Entry entry = new Entry();
@@ -3,12 +3,17 @@
*/
package de.bstly.board.model;
/**
* @author Lurkars
*
* The Enum EntryStatus.
*/
public enum EntryStatus {
NORMAL, ARCHIVED, PINNED
NORMAL,
ARCHIVED,
PINNED
}
@@ -3,12 +3,19 @@
*/
package de.bstly.board.model;
/**
* @author Lurkars
*
* The Enum EntryType.
*/
public enum EntryType {
DISCUSSION, INTERN, LINK, QUESTION
DISCUSSION,
INTERN,
LINK,
QUESTION
}
@@ -23,44 +23,65 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.google.common.collect.Maps;
/**
* @author monitoring@bstly.de
*
* The Class LocalUser.
*/
@Entity
@Table(name = "users")
@JsonInclude(Include.NON_EMPTY)
public class LocalUser {
@Id
@Column(name = "username", nullable = false)
private String username;
@Column(name = "external_id", nullable = true)
private String externalId;
@JsonIgnore
@Column(name = "password_hash", nullable = true)
private String passwordHash;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "users_roles")
private List<String> roles;
@Lob
@Column(name = "about", nullable = true)
private String about;
@Column(name = "email", nullable = true)
private String email;
@Column(name = "locale", nullable = false, columnDefinition = "varchar(255) default 'en'")
private String locale;
@Column(name = "dark_theme", columnDefinition = "boolean default false")
private boolean darkTheme;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionTable(name = "users_settings")
private Map<String, String> settings;
@Transient
private Map<String, Object> metadata;
/**
* Gets the username.
*
* @return the username
*/
public String getUsername() {
@@ -68,41 +89,53 @@ public class LocalUser {
}
/**
* @param username the username to set
* Sets the username.
*
* @param username the new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the externalId
* Gets the external id.
*
* @return the external id
*/
public String getExternalId() {
return externalId;
}
/**
* @param externalId the externalId to set
* Sets the external id.
*
* @param externalId the new external id
*/
public void setExternalId(String externalId) {
this.externalId = externalId;
}
/**
* @return the passwordHash
* Gets the password hash.
*
* @return the password hash
*/
public String getPasswordHash() {
return passwordHash;
}
/**
* @param passwordHash the passwordHash to set
* Sets the password hash.
*
* @param passwordHash the new password hash
*/
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
/**
* Gets the roles.
*
* @return the roles
*/
public List<String> getRoles() {
@@ -110,13 +143,17 @@ public class LocalUser {
}
/**
* @param roles the roles to set
* Sets the roles.
*
* @param roles the new roles
*/
public void setRoles(List<String> roles) {
this.roles = roles;
}
/**
* Gets the about.
*
* @return the about
*/
public String getAbout() {
@@ -124,13 +161,17 @@ public class LocalUser {
}
/**
* @param about the about to set
* Sets the about.
*
* @param about the new about
*/
public void setAbout(String about) {
this.about = about;
}
/**
* Gets the email.
*
* @return the email
*/
public String getEmail() {
@@ -138,13 +179,17 @@ public class LocalUser {
}
/**
* @param email the email to set
* Sets the email.
*
* @param email the new email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the locale.
*
* @return the locale
*/
public String getLocale() {
@@ -152,27 +197,35 @@ public class LocalUser {
}
/**
* @param locale the locale to set
* Sets the locale.
*
* @param locale the new locale
*/
public void setLocale(String locale) {
this.locale = locale;
}
/**
* @return the darkTheme
* Checks if is dark theme.
*
* @return true, if is dark theme
*/
public boolean isDarkTheme() {
return darkTheme;
}
/**
* @param darkTheme the darkTheme to set
* Sets the dark theme.
*
* @param darkTheme the new dark theme
*/
public void setDarkTheme(boolean darkTheme) {
this.darkTheme = darkTheme;
}
/**
* Gets the settings.
*
* @return the settings
*/
public Map<String, String> getSettings() {
@@ -180,13 +233,17 @@ public class LocalUser {
}
/**
* @param settings the settings to set
* Sets the settings.
*
* @param settings the settings
*/
public void setSettings(Map<String, String> settings) {
this.settings = settings;
}
/**
* Gets the metadata.
*
* @return the metadata
*/
public Map<String, Object> getMetadata() {
@@ -197,7 +254,9 @@ public class LocalUser {
}
/**
* @param metadata the metadata to set
* Sets the metadata.
*
* @param metadata the metadata
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
@@ -10,25 +10,34 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author monitoring@bstly.de
*
* The Class PersistentLogin.
*/
@Entity
@Table(name = "persistent_logins")
public class PersistentLogin {
@Column(name = "username", length = 64, nullable = false)
private String username;
@Id
@Column(name = "series", length = 64)
private String series;
@Column(name = "token", length = 64, nullable = false)
private String token;
@Column(name = "last_used", nullable = false)
private Instant last_used;
/**
* Gets the username.
*
* @return the username
*/
public String getUsername() {
@@ -36,13 +45,17 @@ public class PersistentLogin {
}
/**
* @param username the username to set
* Sets the username.
*
* @param username the new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Gets the series.
*
* @return the series
*/
public String getSeries() {
@@ -50,13 +63,17 @@ public class PersistentLogin {
}
/**
* @param series the series to set
* Sets the series.
*
* @param series the new series
*/
public void setSeries(String series) {
this.series = series;
}
/**
* Gets the token.
*
* @return the token
*/
public String getToken() {
@@ -64,21 +81,27 @@ public class PersistentLogin {
}
/**
* @param token the token to set
* Sets the token.
*
* @param token the new token
*/
public void setToken(String token) {
this.token = token;
}
/**
* @return the last_used
* Gets the last used.
*
* @return the last used
*/
public Instant getLast_used() {
return last_used;
}
/**
* @param last_used the last_used to set
* Sets the last used.
*
* @param last_used the new last used
*/
public void setLast_used(Instant last_used) {
this.last_used = last_used;
@@ -5,27 +5,72 @@ package de.bstly.board.model;
import java.time.Instant;
/**
* @author Lurkars
*
* The Interface RankedEntry.
*/
public interface RankedEntry {
/**
* Gets the id.
*
* @return the id
*/
Long getId();
/**
* Gets the author.
*
* @return the author
*/
String getAuthor();
/**
* Gets the created.
*
* @return the created
*/
Instant getCreated();
/**
* Gets the entry type.
*
* @return the entry type
*/
EntryType getEntry_Type();
/**
* Gets the url.
*
* @return the url
*/
String getUrl();
/**
* Gets the title.
*
* @return the title
*/
String getTitle();
/**
* Gets the text.
*
* @return the text
*/
String getText();
/**
* Gets the ranking.
*
* @return the ranking
*/
Double getRanking();
/**
* Gets the points.
*
* @return the points
*/
Long getPoints();
}
@@ -3,11 +3,16 @@
*/
package de.bstly.board.model;
/**
* @author Lurkars
*
* The Enum Types.
*/
public enum Types {
comment, entry, user
comment,
entry,
user
}
+37 -8
View File
@@ -13,29 +13,40 @@ import javax.persistence.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
/**
* @author Lurkars
*
* The Class Vote.
*/
@Entity
@Table(name = "votes")
@EntityListeners({ AuditingEntityListener.class })
public class Vote {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "target", nullable = false)
private Long target;
@Column(name = "target_type", nullable = false)
private Types targetType;
@Column(name = "author", nullable = false)
private String author;
@Column(name = "type", nullable = false)
private VoteType type;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
@@ -43,13 +54,17 @@ public class Vote {
}
/**
* @param id the id to set
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the target.
*
* @return the target
*/
public Long getTarget() {
@@ -57,27 +72,35 @@ public class Vote {
}
/**
* @param target the target to set
* Sets the target.
*
* @param target the new target
*/
public void setTarget(Long target) {
this.target = target;
}
/**
* @return the targetType
* Gets the target type.
*
* @return the target type
*/
public Types getTargetType() {
return targetType;
}
/**
* @param targetType the targetType to set
* Sets the target type.
*
* @param targetType the new target type
*/
public void setTargetType(Types targetType) {
this.targetType = targetType;
}
/**
* Gets the author.
*
* @return the author
*/
public String getAuthor() {
@@ -85,13 +108,17 @@ public class Vote {
}
/**
* @param author the author to set
* Sets the author.
*
* @param author the new author
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* Gets the type.
*
* @return the type
*/
public VoteType getType() {
@@ -99,7 +126,9 @@ public class Vote {
}
/**
* @param type the type to set
* Sets the type.
*
* @param type the new type
*/
public void setType(VoteType type) {
this.type = type;
@@ -3,10 +3,15 @@
*/
package de.bstly.board.model;
/**
* @author Lurkars
*
* The Enum VoteType.
*/
public enum VoteType {
up, down
up,
down
}