Adicionadas entidades para representar nodo, perguntas e respostas
[simdecs_seam.git] / SimDeCS / src / main / org / ufcspa / simdecs / entities / RespostaNodo.java
1 package org.ufcspa.simdecs.entities;
2
3 import java.io.Serializable;
4
5 import javax.persistence.Column;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratedValue;
8 import javax.persistence.GenerationType;
9 import javax.persistence.Id;
10 import javax.persistence.JoinColumn;
11 import javax.persistence.ManyToOne;
12 import javax.persistence.SequenceGenerator;
13 import javax.persistence.Table;
14
15 import org.hibernate.annotations.Index;
16
17
18 @Entity
19 @Table(name="RespostaNodo")
20 @SequenceGenerator(name = "sequenceRespostaNodo", sequenceName = "sqRespostaNodo", initialValue = 1, allocationSize=1)
21 public class RespostaNodo implements Serializable {
22
23         private static final long serialVersionUID = 6879782331178330999L;
24
25         @Id
26         @GeneratedValue(generator="sequenceRespostaNodo", strategy=GenerationType.AUTO)
27         private Long id;
28
29         @Column(length=100, nullable=false)
30         private String resposta;
31         
32         @Column(length=10, nullable=true)
33         private Float percentual;
34         
35     @ManyToOne
36     @JoinColumn(name = "nodo_id", referencedColumnName = "id", nullable = true)
37     @Index(name="resposta_nodo_fk_i")
38         private Nodo nodo;
39         
40         public Long getId() {
41                 return id;
42         }
43         public void setId(Long id) {
44                 this.id = id;
45         }
46         public String getResposta() {
47                 return resposta;
48         }
49         public void setResposta(String resposta) {
50                 this.resposta = resposta;
51         }
52         public Float getPercentual() {
53                 return percentual;
54         }
55         public void setPercentual(Float percentual) {
56                 this.percentual = percentual;
57         }
58         
59         public Nodo getNodo() {
60                 return nodo;
61         }
62
63         public void getNodo(Nodo nodo) {
64                 this.nodo = nodo;
65         }
66
67         public String toString() {
68                 return id + " - " + resposta + " - " + percentual ;
69         }
70
71         @Override
72         public int hashCode() {
73                 final int prime = 31;
74                 int result = 1;
75                 result = prime * result + ((id == null) ? 0 : id.hashCode());
76                 return result;
77         }
78
79         @Override
80         public boolean equals(Object obj) {
81                 if (this == obj)
82                         return true;
83                 if (obj == null)
84                         return false;
85                 if (getClass() != obj.getClass())
86                         return false;
87                 RespostaNodo other = (RespostaNodo) obj;
88                 if (id == null) {
89                         if (other.id != null)
90                                 return false;
91                 } else if (!id.equals(other.id))
92                         return false;
93                 return true;
94         }
95         
96         public RespostaNodo() {
97                 
98         }
99 }