initial commit
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the author
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author to set
|
||||
*/
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the created
|
||||
*/
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created the created to set
|
||||
*/
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the target
|
||||
*/
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target the target to set
|
||||
*/
|
||||
public void setTarget(Long target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parent
|
||||
*/
|
||||
public Long getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent the parent to set
|
||||
*/
|
||||
public void setParent(Long parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text the text to set
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the metadata
|
||||
*/
|
||||
public Map<String, Object> getMetadata() {
|
||||
if (metadata == null) {
|
||||
metadata = Maps.newHashMap();
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param metadata the metadata to set
|
||||
*/
|
||||
public void setMetadata(Map<String, Object> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the author
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author to set
|
||||
*/
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the created
|
||||
*/
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created the created to set
|
||||
*/
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryType
|
||||
*/
|
||||
public EntryType getEntryType() {
|
||||
return entryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryType the entryType to set
|
||||
*/
|
||||
public void setEntryType(EntryType entryType) {
|
||||
this.entryType = entryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryStatus
|
||||
*/
|
||||
public EntryStatus getEntryStatus() {
|
||||
return entryStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryStatus the entryStatus to set
|
||||
*/
|
||||
public void setEntryStatus(EntryStatus entryStatus) {
|
||||
this.entryStatus = entryStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url the url to set
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title the title to set
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text the text to set
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ranking
|
||||
*/
|
||||
public Double getRanking() {
|
||||
return ranking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ranking the ranking to set
|
||||
*/
|
||||
public void setRanking(Double ranking) {
|
||||
this.ranking = ranking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the metadata
|
||||
*/
|
||||
public Map<String, Object> getMetadata() {
|
||||
if (metadata == null) {
|
||||
metadata = Maps.newHashMap();
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param metadata the metadata to set
|
||||
*/
|
||||
public void setMetadata(Map<String, Object> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rankedEntry
|
||||
* @return
|
||||
*/
|
||||
public static Entry fromRankedEntry(RankedEntry rankedEntry) {
|
||||
Entry entry = new Entry();
|
||||
entry.setId(rankedEntry.getId());
|
||||
entry.setAuthor(rankedEntry.getAuthor());
|
||||
entry.setCreated(rankedEntry.getCreated());
|
||||
entry.setEntryType(rankedEntry.getEntry_Type());
|
||||
entry.setUrl(rankedEntry.getUrl());
|
||||
entry.setTitle(rankedEntry.getTitle());
|
||||
entry.setText(rankedEntry.getText());
|
||||
entry.setRanking(rankedEntry.getRanking());
|
||||
entry.getMetadata().put("points", rankedEntry.getPoints());
|
||||
return entry;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
public enum EntryStatus {
|
||||
|
||||
NORMAL, ARCHIVED, PINNED
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
public enum EntryType {
|
||||
|
||||
DISCUSSION, INTERN, LINK, QUESTION
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @author monitoring@bstly.de
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the externalId
|
||||
*/
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param externalId the externalId to set
|
||||
*/
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the passwordHash
|
||||
*/
|
||||
public String getPasswordHash() {
|
||||
return passwordHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passwordHash the passwordHash to set
|
||||
*/
|
||||
public void setPasswordHash(String passwordHash) {
|
||||
this.passwordHash = passwordHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roles
|
||||
*/
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roles the roles to set
|
||||
*/
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the about
|
||||
*/
|
||||
public String getAbout() {
|
||||
return about;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param about the about to set
|
||||
*/
|
||||
public void setAbout(String about) {
|
||||
this.about = about;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param email the email to set
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the locale
|
||||
*/
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locale the locale to set
|
||||
*/
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the darkTheme
|
||||
*/
|
||||
public boolean isDarkTheme() {
|
||||
return darkTheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param darkTheme the darkTheme to set
|
||||
*/
|
||||
public void setDarkTheme(boolean darkTheme) {
|
||||
this.darkTheme = darkTheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the settings
|
||||
*/
|
||||
public Map<String, String> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param settings the settings to set
|
||||
*/
|
||||
public void setSettings(Map<String, String> settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the metadata
|
||||
*/
|
||||
public Map<String, Object> getMetadata() {
|
||||
if (metadata == null) {
|
||||
metadata = Maps.newHashMap();
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param metadata the metadata to set
|
||||
*/
|
||||
public void setMetadata(Map<String, Object> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author monitoring@bstly.de
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the series
|
||||
*/
|
||||
public String getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param series the series to set
|
||||
*/
|
||||
public void setSeries(String series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the token
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token the token to set
|
||||
*/
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the last_used
|
||||
*/
|
||||
public Instant getLast_used() {
|
||||
return last_used;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param last_used the last_used to set
|
||||
*/
|
||||
public void setLast_used(Instant last_used) {
|
||||
this.last_used = last_used;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
public interface RankedEntry {
|
||||
|
||||
Long getId();
|
||||
|
||||
String getAuthor();
|
||||
|
||||
Instant getCreated();
|
||||
|
||||
EntryType getEntry_Type();
|
||||
|
||||
String getUrl();
|
||||
|
||||
String getTitle();
|
||||
|
||||
String getText();
|
||||
|
||||
Double getRanking();
|
||||
|
||||
Long getPoints();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
public enum Types {
|
||||
|
||||
comment, entry, user
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the target
|
||||
*/
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target the target to set
|
||||
*/
|
||||
public void setTarget(Long target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetType
|
||||
*/
|
||||
public Types getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetType the targetType to set
|
||||
*/
|
||||
public void setTargetType(Types targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the author
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param author the author to set
|
||||
*/
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public VoteType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(VoteType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.bstly.board.model;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
*/
|
||||
public enum VoteType {
|
||||
up, down
|
||||
}
|
||||
Reference in New Issue
Block a user