2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
6 package com.edf.gde.entities;
8 import com.edf.gde.transferables.AttributeTO;
9 import java.io.Serializable;
10 import java.util.Objects;
11 import javax.persistence.Basic;
12 import javax.persistence.Column;
13 import javax.persistence.Entity;
14 import javax.persistence.GeneratedValue;
15 import javax.persistence.GenerationType;
16 import javax.persistence.Id;
17 import javax.persistence.NamedQueries;
18 import javax.persistence.NamedQuery;
19 import javax.persistence.SequenceGenerator;
20 import javax.persistence.Table;
21 import javax.validation.constraints.NotNull;
22 import javax.validation.constraints.Size;
23 import javax.xml.bind.annotation.XmlRootElement;
30 @Table(name = "attribute")
33 @NamedQuery(name = "Attribute.findAll", query = "SELECT a FROM Attribute a"),
34 @NamedQuery(name = "Attribute.findById", query = "SELECT a FROM Attribute a WHERE a.id = :id"),
35 @NamedQuery(name = "Attribute.findByName", query = "SELECT a FROM Attribute a WHERE a.name = :name"),
36 @NamedQuery(name = "Attribute.findByType", query = "SELECT a FROM Attribute a WHERE a.type = :type"),
37 @NamedQuery(name = "Attribute.findByValue", query = "SELECT a FROM Attribute a WHERE a.value = :value"),
38 //@NamedQuery(name = "Attribute.findByMandatory", query = "SELECT a FROM Attribute a WHERE a.mandatory = :mandatory")
40 public class Attribute implements Serializable {
41 private static final long serialVersionUID = 1L;
43 @Basic(optional = false)
45 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
46 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
50 @Column(name = "name")
53 @Column(name = "type")
56 @Column(name = "value")
58 @Column(name = "mandatory")
59 private Boolean mandatory;
60 @Column(name = "attribute_group_id")
61 private long attributeGroupId;
66 public Attribute(long id) {
74 public void setId(long id) {
78 public String getName() {
82 public void setName(String name) {
86 public String getType() {
90 public void setType(String type) {
94 public String getValue() {
98 public void setValue(String value) {
102 public Boolean getMandatory() {
106 public void setMandatory(Boolean mandatory) {
107 this.mandatory = mandatory;
110 public long getAttributeGroupId() {
111 return attributeGroupId;
114 public void setAttributeGroupId(long groupId) {
115 this.attributeGroupId = groupId;
118 public static Attribute fromAttributeTO(AttributeTO ato) {
119 Attribute attribute = new Attribute();
120 attribute.id = ato.getId();
121 attribute.name = ato.getName();
122 attribute.type = ato.getType();
123 attribute.value = ato.getValue();
124 attribute.mandatory = ato.getMandatory();
125 attribute.attributeGroupId = ato.getGroupId();
129 public AttributeTO toAttributeTO() {
130 AttributeTO ato = new AttributeTO();
132 ato.setName(this.name);
133 ato.setType(this.type);
134 ato.setValue(this.value);
135 ato.setMandatory(this.mandatory);
136 ato.setGroupId(this.attributeGroupId);
141 public String toString() {
142 return "com.edf.gde.entities.Attribute[ id=" + id + " ]";
146 public int hashCode() {
148 hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
149 hash = 29 * hash + Objects.hashCode(this.name);
150 hash = 29 * hash + Objects.hashCode(this.type);
151 hash = 29 * hash + Objects.hashCode(this.value);
152 hash = 29 * hash + Objects.hashCode(this.mandatory);
153 hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
158 public boolean equals(Object obj) {
162 if (getClass() != obj.getClass()) {
165 final Attribute other = (Attribute) obj;
166 if (this.id != other.id) {