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"),
36 @NamedQuery(name = "Attribute.findByGroupId", query = "SELECT a FROM Attribute a WHERE a.attributeGroupId = :attributeGroupId")
38 public class Attribute implements Serializable {
39 private static final long serialVersionUID = 1L;
41 @Basic(optional = false)
43 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
44 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
48 @Column(name = "name")
51 @Column(name = "type")
54 @Column(name = "value")
56 @Column(name = "mandatory")
57 private Boolean mandatory;
58 @Column(name = "attribute_group_id")
59 private long attributeGroupId;
64 public Attribute(long id) {
72 public void setId(long id) {
76 public String getName() {
80 public void setName(String name) {
84 public String getType() {
88 public void setType(String type) {
92 public String getValue() {
96 public void setValue(String value) {
100 public Boolean getMandatory() {
104 public void setMandatory(Boolean mandatory) {
105 this.mandatory = mandatory;
108 public long getAttributeGroupId() {
109 return attributeGroupId;
112 public void setAttributeGroupId(long groupId) {
113 this.attributeGroupId = groupId;
116 public static Attribute fromAttributeTO(AttributeTO ato) {
117 Attribute attribute = new Attribute();
118 attribute.id = ato.getId();
119 attribute.name = ato.getName();
120 attribute.type = ato.getType();
121 attribute.value = ato.getValue();
122 attribute.mandatory = ato.getMandatory();
123 attribute.attributeGroupId = ato.getGroupId();
127 public AttributeTO toAttributeTO() {
128 AttributeTO ato = new AttributeTO();
130 ato.setName(this.name);
131 ato.setType(this.type);
132 ato.setValue(this.value);
133 ato.setMandatory(this.mandatory);
134 ato.setGroupId(this.attributeGroupId);
139 public String toString() {
140 return "com.edf.gde.entities.Attribute[ id=" + id + " ]";
144 public int hashCode() {
146 hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
147 hash = 67 * hash + Objects.hashCode(this.name);
148 hash = 67 * hash + Objects.hashCode(this.type);
149 hash = 67 * hash + Objects.hashCode(this.value);
150 hash = 67 * hash + Objects.hashCode(this.mandatory);
151 hash = 67 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
156 public boolean equals(Object obj) {
160 if (getClass() != obj.getClass()) {
163 final Attribute other = (Attribute) obj;
164 if (this.id != other.id) {