/*
*
* Copyright (C) 2007-2015 Licensed to the Comunes Association (CA) under
* one or more contributor license agreements (see COPYRIGHT for details).
* The CA licenses this file to you under the GNU Affero General Public
* License version 3, (the "License"); you may not use this file except in
* compliance with the License. This file is part of kune.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package cc.kune.domain;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import cc.kune.domain.utils.HasId;
// TODO: Auto-generated Javadoc
/**
* The Class Tag.
*
* @author vjrj@ourproject.org (Vicente J. Ruiz Jurado)
*/
@Entity
@Indexed
@Table(name = "tags")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Tag implements HasId {
/** The created on. */
@org.hibernate.annotations.Index(name = "createdOn")
@Basic(optional = false)
private final Long createdOn;
/** The id. */
@Id
@GeneratedValue
@DocumentId
private Long id;
/** The name. */
@Field(index = Index.YES, store = Store.NO)
@Column(unique = true)
private String name;
/**
* Instantiates a new tag.
*/
public Tag() {
this(null);
}
/**
* Instantiates a new tag.
*
* @param name
* the name
*/
public Tag(final String name) {
this.name = name;
this.createdOn = System.currentTimeMillis();
}
/**
* Gets the created on.
*
* @return the created on
*/
public Long getCreatedOn() {
return createdOn;
}
/*
* (non-Javadoc)
*
* @see cc.kune.domain.utils.HasId#getId()
*/
@Override
public Long getId() {
return id;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/*
* (non-Javadoc)
*
* @see cc.kune.domain.utils.HasId#setId(java.lang.Long)
*/
@Override
public void setId(final Long id) {
this.id = id;
}
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(final String name) {
this.name = name;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Tag[" + getName() + "]";
}
}