/* Jug Management is a web application conceived to manage user groups or
* communities focused on a certain domain of knowledge, whose members are
* constantly sharing information and participating in social and educational
* events. Copyright (C) 2011 Ceara Java User Group - CEJUG.
*
* This application is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This application is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* There is a full copy of the GNU Lesser General Public License along with
* this library. Look for the file license.txt at the root level. If you do not
* find it, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA.
* */
package org.cejug.yougi.knowledge.entity;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.cejug.yougi.exception.BusinessLogicException;
/**
* @author Hildeberto Mendonca - http://www.hildeberto.com
*/
@Entity
@Table(name = "topic")
public class Topic implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String name;
private String label;
private String description;
private Boolean valid;
public Topic() {}
public Topic(String name) {
this.name = name;
}
/**
* Name is the id of the entity Topic and it must be fully uppercase,
* independent if the user typed it like that or not. What the user types is
* actually preserved in the field Label.
*/
public String getName() {
return name;
}
public void setName(String name) {
if(name == null) {
throw new BusinessLogicException("Name not informed.");
}
this.name = name.trim().toUpperCase();
}
/**
* Label preserves exactly what the user typed in order to preserve its
* visualization on the user interface. It is used for visualization
* purpose only. All search and indexation is done with the field Name.
*/
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Boolean getValid() {
return valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public int hashCode() {
int hash = 0;
hash += (name != null ? name.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof Topic)) {
return false;
}
Topic other = (Topic) object;
if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) {
return false;
}
return true;
}
@Override
public String toString() {
return this.label;
}
}