com.evasion.entity.content.Comment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of API Show documentation
Show all versions of API Show documentation
API de l'application modulaire evasion-en-ligne
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.evasion.entity.content;
import com.evasion.EntityJPA;
import com.evasion.entity.security.User;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.annotation.PostConstruct;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Business Object representant un commentaire.
* @author sebastien
*/
@Entity(name=Comment.ENTITY_NAME)
@Table(name = Comment.ENTITY_NAME)
public class Comment extends EntityJPA {
/***
* serialVersionUID.
*/
private static final long serialVersionUID = 1L;
public static final String ENTITY_NAME = "CMS_COMMENT";
/**
* Id technique.
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String userName;
/**
* Texte de la contribution.
*/
@Lob
@Column(nullable = false)
private String text;
/**
* Date d'enregistrement de la contribution.
*/
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Calendar dateEnregistrementInternal;
/**
* Initialise la date de création du commentaire.
*/
@SuppressWarnings("PMD.UnusedPrivateMethod")
@edu.umd.cs.findbugs.annotations.SuppressWarnings("UPM_UNCALLED_PRIVATE_METHOD")
@PostConstruct
private void initDateEnregistrement() {
if (dateEnregistrementInternal == null) {
dateEnregistrementInternal = new GregorianCalendar();
}
}
/**
* Getter de l'ID technique.
* @return ID technique.
*/
public Long getId() {
return id;
}
/**
* Setter de l'ID technique.
* @param id ID technique.
*/
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
protected Calendar getDateEnregistrementInternal() {
return dateEnregistrementInternal;
}
protected void setDateEnregistrementInternal(Calendar calendar) {
dateEnregistrementInternal = calendar;
}
/**
* Getter de la date d'enregistrement de la contribution.
* @return renvoi la date.
*/
public Date getDateEnregistrement() {
return this.getDateEnregistrementInternal().getTime();
}
/**
* Setter de la date d'enregistrement.
* Cette propriete n'est pas directement modifiable par l'utilisateur.
* La valeur est initialise dans le constructeur de l'objet.
* @param dateEnregistrement
*/
protected void setDateEnregistrement(Date dateEnregistrement) {
Calendar cal= new GregorianCalendar();
cal.setTime(dateEnregistrement);
this.setDateEnregistrementInternal(cal);
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
/**
* {@inheritDoc }.
*/
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (!( obj instanceof Comment )) {
return false;
}
final Comment other = (Comment) obj;
return new EqualsBuilder().append(this.id, other.id).isEquals();
}
/**
* {@inheritDoc }.
*/
@Override
public int hashCode() {
return new HashCodeBuilder().append(id).toHashCode();
}
}