4 package com.edf.gde.entities;
6 import com.edf.gde.transferables.AttributeTO;
7 import java.io.Serializable;
8 import java.util.Objects;
9 import javax.persistence.Basic;
10 import javax.persistence.Column;
11 import javax.persistence.Entity;
12 import javax.persistence.GeneratedValue;
13 import javax.persistence.GenerationType;
14 import javax.persistence.Id;
15 import javax.persistence.NamedQueries;
16 import javax.persistence.NamedQuery;
17 import javax.persistence.SequenceGenerator;
18 import javax.persistence.Table;
19 import javax.validation.constraints.NotNull;
20 import javax.validation.constraints.Size;
21 import javax.xml.bind.annotation.XmlRootElement;
28 @Table(name = "attribute")
31 @NamedQuery(name = "Attribute.findAll", query = "SELECT a FROM Attribute a"),
32 @NamedQuery(name = "Attribute.findById", query = "SELECT a FROM Attribute a WHERE a.id = :id"),
33 @NamedQuery(name = "Attribute.findByName", query = "SELECT a FROM Attribute a WHERE a.name = :name"),
34 @NamedQuery(name = "Attribute.findByType", query = "SELECT a FROM Attribute a WHERE a.type = :type"),
35 @NamedQuery(name = "Attribute.findByValue", query = "SELECT a FROM Attribute a WHERE a.value = :value")
37 public class Attribute implements Serializable {
38 private static final long serialVersionUID = 1L;
40 @Basic(optional = false)
42 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
43 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
47 @Column(name = "name")
50 @Column(name = "type")
53 @Column(name = "value")
55 @Column(name = "mandatory")
56 private Boolean mandatory;
57 @Column(name = "attribute_group_id")
58 private long attributeGroupId;
63 public Attribute(long id) {
71 public void setId(long id) {
75 public String getName() {
79 public void setName(String name) {
83 public String getType() {
87 public void setType(String type) {
91 public String getValue() {
95 public void setValue(String value) {
99 public Boolean getMandatory() {
103 public void setMandatory(Boolean mandatory) {
104 this.mandatory = mandatory;
107 public long getAttributeGroupId() {
108 return attributeGroupId;
111 public void setAttributeGroupId(long groupId) {
112 this.attributeGroupId = groupId;
115 public static Attribute fromAttributeTO(AttributeTO ato) {
116 Attribute attribute = new Attribute();
117 attribute.id = ato.getId();
118 attribute.name = ato.getName();
119 attribute.type = ato.getType();
120 attribute.value = ato.getValue();
121 attribute.mandatory = ato.getMandatory();
122 attribute.attributeGroupId = ato.getGroupId();
126 public AttributeTO toAttributeTO() {
127 AttributeTO ato = new AttributeTO();
129 ato.setName(this.name);
130 ato.setType(this.type);
131 ato.setValue(this.value);
132 ato.setMandatory(this.mandatory);
133 ato.setGroupId(this.attributeGroupId);
138 public String toString() {
139 return "com.edf.gde.entities.Attribute[ id=" + id + " ]";
143 public int hashCode() {
145 hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
146 hash = 67 * hash + Objects.hashCode(this.name);
147 hash = 67 * hash + Objects.hashCode(this.type);
148 hash = 67 * hash + Objects.hashCode(this.value);
149 hash = 67 * hash + Objects.hashCode(this.mandatory);
150 hash = 67 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
155 public boolean equals(Object obj) {
159 if (getClass() != obj.getClass()) {
162 final Attribute other = (Attribute) obj;
163 if (this.id != other.id) {