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 | ||
7f3a0a9f MS |
26 | private NodeType nodeRole; |
27 | ||
5d05ee58 MS |
28 | private Integer time = 0; |
29 | ||
30 | private Float cost = 0.0f; | |
31 | ||
32 | @ManyToOne | |
33 | private BayesianNetwork bayesianNetwork; | |
34 | ||
35 | @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy = "node") | |
36 | private List<Question> questions; | |
37 | ||
38 | public Long getId() { | |
39 | return id; | |
40 | } | |
41 | ||
42 | public void setId(Long id) { | |
43 | this.id = id; | |
44 | } | |
45 | ||
46 | public String getName() { | |
47 | return name; | |
48 | } | |
49 | ||
50 | public void setName(String name) { | |
51 | this.name = name; | |
52 | } | |
53 | ||
54 | public NodeType getNodeType() { | |
55 | return nodeType; | |
56 | } | |
57 | ||
58 | public void setNodeType(NodeType nodeType) { | |
59 | this.nodeType = nodeType; | |
60 | } | |
61 | ||
7f3a0a9f MS |
62 | public NodeType getNodeRole() { |
63 | return nodeRole; | |
64 | } | |
65 | ||
66 | public void setNodeRole(NodeType nodeRole) { | |
67 | this.nodeRole = nodeRole; | |
68 | } | |
69 | ||
5d05ee58 MS |
70 | public Integer getTime() { |
71 | return time; | |
72 | } | |
73 | ||
74 | public void setTime(Integer time) { | |
75 | this.time = time; | |
76 | } | |
77 | ||
78 | public float getCost() { | |
79 | return cost; | |
80 | } | |
81 | ||
82 | public void setCost(float cost) { | |
83 | this.cost = cost; | |
84 | } | |
85 | ||
86 | public BayesianNetwork getBayesianNetwork() { | |
87 | return bayesianNetwork; | |
88 | } | |
89 | ||
90 | public void setBayesianNetwork(BayesianNetwork bayesianNetwork) { | |
91 | this.bayesianNetwork = bayesianNetwork; | |
92 | } | |
93 | ||
94 | public List<Question> getQuestions() { | |
95 | return questions; | |
96 | } | |
97 | ||
98 | public void setQuestions(List<Question> questions) { | |
99 | this.questions = questions; | |
100 | } | |
101 | ||
102 | @Override | |
103 | public int hashCode() { | |
104 | int hash = 0; | |
105 | hash += (getId() != null ? getId().hashCode() : 0); | |
106 | return hash; | |
107 | } | |
108 | ||
109 | @Override | |
110 | public boolean equals(Object object) { | |
111 | // TODO: Warning - this method won't work in the case the id fields are not set | |
112 | if (!(object instanceof Node)) { | |
113 | return false; | |
114 | } | |
115 | Node other = (Node) object; | |
116 | if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) { | |
117 | return false; | |
118 | } | |
119 | return true; | |
120 | } | |
121 | ||
122 | @Override | |
123 | public String toString() { | |
124 | return "org.ufcspa.simdecs.entity.Node[ id=" + getId() + " ]"; | |
125 | } | |
126 | } |