/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* This file is part of CATS.
*
* CATS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CATS 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CATS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comcast.cats.keymanager.entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* KeyCodeFormat initially generated by hbm2java. Added Named queries,
* additional constructors, getters and setters.
*
* @author thusai000
*/
@Entity
@Table(name = "key_code_format", catalog = "keymanager")
@NamedQueries( { @NamedQuery(name = "KeyCodeFormat.FindByName", query = "SELECT kcf FROM KeyCodeFormat kcf "
+ "WHERE kcf.keyCodeFormatName =:keyCodeFormat") })
public class KeyCodeFormat implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -8496954064836322669L;
private Integer keyCodeFormatId;
private String keyCodeFormatName;
private String keyCodeFormatDescription;
private Set<KeyCodes> keyCodes = new HashSet<KeyCodes>(0);
private Set<KeyLayout> keyLayouts = new HashSet<KeyLayout>(0);
/**
* Default Constructor
*/
public KeyCodeFormat() {
}
/**
* ID would be auto-generated. Required name field only set at construction
* time.
*
* @param keyCodeFormatName
*/
public KeyCodeFormat(String keyCodeFormatName) {
this.keyCodeFormatName = keyCodeFormatName;
this.keyCodeFormatDescription = keyCodeFormatDescription;
}
/**
* ID auto-generated, name and description set during construction.
*
* @param keyCodeFormatName
* @param keyCodeFormatDescription
*/
public KeyCodeFormat(String keyCodeFormatName,
String keyCodeFormatDescription) {
this.keyCodeFormatName = keyCodeFormatName;
this.keyCodeFormatDescription = keyCodeFormatDescription;
}
/**
* Constructor requiring all parameters for the Entity.
*
* @param keyCodeFormatId
* @param keyCodeFormatName
* @param keyCodeFormatDescription
*/
public KeyCodeFormat(int keyCodeFormatId, String keyCodeFormatName,
String keyCodeFormatDescription) {
this.keyCodeFormatId = keyCodeFormatId;
this.keyCodeFormatName = keyCodeFormatName;
this.keyCodeFormatDescription = keyCodeFormatDescription;
}
/**
* This constructor can be used to add a whole library of key set with
* keycodes, format, and layouts defined.
*
* @param keyCodeFormatId
* @param keyCodeFormatName
* @param keyCodeFormatDescription
* @param keyCodes
* @param keyLayouts
*/
public KeyCodeFormat(int keyCodeFormatId, String keyCodeFormatName,
String keyCodeFormatDescription, Set<KeyCodes> keyCodes,
Set<KeyLayout> keyLayouts) {
this.keyCodeFormatId = keyCodeFormatId;
this.keyCodeFormatName = keyCodeFormatName;
this.keyCodeFormatDescription = keyCodeFormatDescription;
this.keyCodes = keyCodes;
this.keyLayouts = keyLayouts;
}
@Id
@GeneratedValue
@Column(name = "key_code_format_id", unique = true, nullable = false)
public Integer getKeyCodeFormatId() {
return this.keyCodeFormatId;
}
public void setKeyCodeFormatId(Integer keyCodeFormatId) {
this.keyCodeFormatId = keyCodeFormatId;
}
@Column(name = "key_code_format_name", length = 45)
public String getKeyCodeFormatName() {
return this.keyCodeFormatName;
}
public void setKeyCodeFormatName(String keyCodeFormatName) {
this.keyCodeFormatName = keyCodeFormatName;
}
@Column(name = "key_code_format_description")
public String getKeyCodeFormatDescription() {
return this.keyCodeFormatDescription;
}
public void setKeyCodeFormatDescription(String keyCodeFormatDescription) {
this.keyCodeFormatDescription = keyCodeFormatDescription;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "keyCodeFormat")
public Set<KeyCodes> getKeyCodes() {
return this.keyCodes;
}
public void setKeyCodes(Set<KeyCodes> keyCodes) {
this.keyCodes = keyCodes;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "keyCodeFormat")
public Set<KeyLayout> getKeyLayouts() {
return this.keyLayouts;
}
public void setKeyLayouts(Set<KeyLayout> keyLayouts) {
this.keyLayouts = keyLayouts;
}
@Override
public String toString() {
return ("\n" + this.keyCodeFormatId + ": " + this.keyCodeFormatName);
}
}