2021-10-03 17:17:00 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
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;
|
2021-10-07 14:00:40 +02:00
|
|
|
import javax.persistence.EnumType;
|
|
|
|
import javax.persistence.Enumerated;
|
2021-10-03 17:17:00 +02:00
|
|
|
import javax.persistence.GeneratedValue;
|
|
|
|
import javax.persistence.GenerationType;
|
|
|
|
import javax.persistence.Id;
|
|
|
|
import javax.persistence.Lob;
|
|
|
|
import javax.persistence.Table;
|
|
|
|
import javax.persistence.Transient;
|
|
|
|
|
2021-12-03 23:47:17 +01:00
|
|
|
import org.hibernate.search.engine.backend.types.Projectable;
|
2021-12-04 10:57:16 +01:00
|
|
|
import org.hibernate.search.engine.backend.types.Searchable;
|
2021-12-03 23:47:17 +01:00
|
|
|
import org.hibernate.search.engine.backend.types.Sortable;
|
|
|
|
import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBridgeRef;
|
|
|
|
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
|
|
|
|
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;
|
|
|
|
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField;
|
2021-10-03 17:17:00 +02:00
|
|
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2021-12-03 23:47:17 +01:00
|
|
|
import de.bstly.board.model.support.FlaggedStatus;
|
|
|
|
import de.bstly.board.model.support.InstantValueBridge;
|
|
|
|
import de.bstly.board.model.support.Types;
|
|
|
|
|
2021-10-03 17:17:00 +02:00
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* The Class Comment.
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
@Entity
|
|
|
|
@Table(name = "comments")
|
|
|
|
@EntityListeners({ AuditingEntityListener.class })
|
2021-12-04 15:33:51 +01:00
|
|
|
@Indexed(index = "lucene/comment")
|
2021-10-03 17:17:00 +02:00
|
|
|
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)
|
2021-12-03 23:47:17 +01:00
|
|
|
@KeywordField(name = "created", valueBridge = @ValueBridgeRef(type = InstantValueBridge.class), projectable = Projectable.YES, sortable = Sortable.YES)
|
2021-10-03 17:17:00 +02:00
|
|
|
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)
|
2021-12-04 15:33:51 +01:00
|
|
|
@FullTextField(name = "text", searchable = Searchable.YES, analyzer = "english", searchAnalyzer = "english_search")
|
|
|
|
@FullTextField(name = "text_de", searchable = Searchable.YES, analyzer = "german", searchAnalyzer = "german_search")
|
2021-10-03 17:17:00 +02:00
|
|
|
private String text;
|
2021-10-07 14:00:40 +02:00
|
|
|
@Enumerated(EnumType.STRING)
|
|
|
|
@Column(name = "flagged_status", nullable = false, columnDefinition = "varchar(255) default 'NORMAL'")
|
|
|
|
private FlaggedStatus flaggedStatus;
|
2021-10-03 17:17:00 +02:00
|
|
|
@Transient
|
|
|
|
private Map<String, Object> metadata;
|
2021-12-03 23:47:17 +01:00
|
|
|
@Transient
|
|
|
|
private final Types type = Types.comment;
|
2021-10-03 17:17:00 +02:00
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the id.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the id
|
|
|
|
*/
|
|
|
|
public Long getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the id.
|
|
|
|
*
|
|
|
|
* @param id the new id
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setId(Long id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the author.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the author
|
|
|
|
*/
|
|
|
|
public String getAuthor() {
|
|
|
|
return author;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the author.
|
|
|
|
*
|
|
|
|
* @param author the new author
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setAuthor(String author) {
|
|
|
|
this.author = author;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the created.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the created
|
|
|
|
*/
|
|
|
|
public Instant getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the created.
|
|
|
|
*
|
|
|
|
* @param created the new created
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setCreated(Instant created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the target.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the target
|
|
|
|
*/
|
|
|
|
public Long getTarget() {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the target.
|
|
|
|
*
|
|
|
|
* @param target the new target
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setTarget(Long target) {
|
|
|
|
this.target = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the parent.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the parent
|
|
|
|
*/
|
|
|
|
public Long getParent() {
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the parent.
|
|
|
|
*
|
|
|
|
* @param parent the new parent
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setParent(Long parent) {
|
|
|
|
this.parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the text.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the text
|
|
|
|
*/
|
|
|
|
public String getText() {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the text.
|
|
|
|
*
|
|
|
|
* @param text the new text
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setText(String text) {
|
|
|
|
this.text = text;
|
|
|
|
}
|
|
|
|
|
2021-10-07 14:00:40 +02:00
|
|
|
/**
|
|
|
|
* Gets the flagged status.
|
|
|
|
*
|
|
|
|
* @return the flagged status
|
|
|
|
*/
|
|
|
|
public FlaggedStatus getFlaggedStatus() {
|
|
|
|
return flaggedStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the flagged status.
|
|
|
|
*
|
|
|
|
* @param flaggedStatus the new flagged status
|
|
|
|
*/
|
|
|
|
public void setFlaggedStatus(FlaggedStatus flaggedStatus) {
|
|
|
|
this.flaggedStatus = flaggedStatus;
|
|
|
|
}
|
|
|
|
|
2021-10-03 17:17:00 +02:00
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Gets the metadata.
|
|
|
|
*
|
2021-10-03 17:17:00 +02:00
|
|
|
* @return the metadata
|
|
|
|
*/
|
|
|
|
public Map<String, Object> getMetadata() {
|
|
|
|
if (metadata == null) {
|
|
|
|
metadata = Maps.newHashMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:02:40 +02:00
|
|
|
* Sets the metadata.
|
|
|
|
*
|
|
|
|
* @param metadata the metadata
|
2021-10-03 17:17:00 +02:00
|
|
|
*/
|
|
|
|
public void setMetadata(Map<String, Object> metadata) {
|
|
|
|
this.metadata = metadata;
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:47:17 +01:00
|
|
|
/**
|
|
|
|
* @return the type
|
|
|
|
*/
|
|
|
|
public Types getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2021-10-03 17:17:00 +02:00
|
|
|
}
|