Commit | Line | Data |
---|---|---|
5d05ee58 MS |
1 | /* |
2 | * To change this template, choose Tools | Templates | |
3 | * and open the template in the editor. | |
4 | */ | |
5 | package org.ufcspa.simdecs.bn.entity; | |
6 | ||
7 | import java.io.Serializable; | |
8 | import java.util.List; | |
9 | import javax.persistence.*; | |
10 | ||
11 | /** | |
12 | * | |
13 | * @author mchelem | |
14 | */ | |
15 | @Entity | |
16 | public class Node implements Serializable { | |
17 | private static final long serialVersionUID = 1L; | |
18 | @Id | |
19 | @GeneratedValue(strategy = GenerationType.AUTO) | |
20 | private Long id; | |
21 | ||
22 | private String name; | |
23 | ||
24 | private NodeType nodeType; | |
25 | ||
26 | private Integer time = 0; | |
27 | ||
28 | private Float cost = 0.0f; | |
29 | ||
30 | @ManyToOne | |
31 | private BayesianNetwork bayesianNetwork; | |
32 | ||
33 | @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy = "node") | |
34 | private List<Question> questions; | |
35 | ||
36 | public Long getId() { | |
37 | return id; | |
38 | } | |
39 | ||
40 | public void setId(Long id) { | |
41 | this.id = id; | |
42 | } | |
43 | ||
44 | public String getName() { | |
45 | return name; | |
46 | } | |
47 | ||
48 | public void setName(String name) { | |
49 | this.name = name; | |
50 | } | |
51 | ||
52 | public NodeType getNodeType() { | |
53 | return nodeType; | |
54 | } | |
55 | ||
56 | public void setNodeType(NodeType nodeType) { | |
57 | this.nodeType = nodeType; | |
58 | } | |
59 | ||
60 | public Integer getTime() { | |
61 | return time; | |
62 | } | |
63 | ||
64 | public void setTime(Integer time) { | |
65 | this.time = time; | |
66 | } | |
67 | ||
68 | public float getCost() { | |
69 | return cost; | |
70 | } | |
71 | ||
72 | public void setCost(float cost) { | |
73 | this.cost = cost; | |
74 | } | |
75 | ||
76 | public BayesianNetwork getBayesianNetwork() { | |
77 | return bayesianNetwork; | |
78 | } | |
79 | ||
80 | public void setBayesianNetwork(BayesianNetwork bayesianNetwork) { | |
81 | this.bayesianNetwork = bayesianNetwork; | |
82 | } | |
83 | ||
84 | public List<Question> getQuestions() { | |
85 | return questions; | |
86 | } | |
87 | ||
88 | public void setQuestions(List<Question> questions) { | |
89 | this.questions = questions; | |
90 | } | |
91 | ||
92 | @Override | |
93 | public int hashCode() { | |
94 | int hash = 0; | |
95 | hash += (getId() != null ? getId().hashCode() : 0); | |
96 | return hash; | |
97 | } | |
98 | ||
99 | @Override | |
100 | public boolean equals(Object object) { | |
101 | // TODO: Warning - this method won't work in the case the id fields are not set | |
102 | if (!(object instanceof Node)) { | |
103 | return false; | |
104 | } | |
105 | Node other = (Node) object; | |
106 | if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) { | |
107 | return false; | |
108 | } | |
109 | return true; | |
110 | } | |
111 | ||
112 | @Override | |
113 | public String toString() { | |
114 | return "org.ufcspa.simdecs.entity.Node[ id=" + getId() + " ]"; | |
115 | } | |
116 | } |