Initial import for Diagrama.
[simdecs_seam.git] / SimDeCS / src / main / org / ufcspa / simdecs / entities / RedeBayesiana.java
1 package org.ufcspa.simdecs.entities;
2
3 import java.io.Serializable;
4 import java.util.Collection;
5
6 import javax.persistence.CascadeType;
7 import javax.persistence.Column;
8 import javax.persistence.Entity;
9 import javax.persistence.GenerationType;
10 import javax.persistence.Id;
11 import javax.persistence.GeneratedValue;
12 import javax.persistence.JoinColumn;
13 import javax.persistence.JoinTable;
14 import javax.persistence.ManyToMany;
15 import javax.persistence.OneToOne;
16 import javax.persistence.SequenceGenerator;
17 import javax.persistence.Table;
18 import javax.persistence.UniqueConstraint;
19
20 import org.hibernate.annotations.Index;
21
22
23 @Entity
24 //Short name: "redeBayesiana"
25 @Table(name="RedeBayesiana")
26 @SequenceGenerator(name = "sequenceRedeBayesiana", sequenceName = "sqRedeBayesiana", initialValue = 1, allocationSize=1)
27 public class RedeBayesiana implements Serializable
28 {
29         private static final long serialVersionUID = -8764281348427990153L;
30
31         @GeneratedValue(generator = "sequenceRedeBayesiana", strategy = GenerationType.AUTO)
32         @Id
33         private Long id;
34
35         @Column(nullable=false, length=50)
36         private String nome;
37
38         @Column(length=1, nullable=false)
39         private boolean aplicavelSexoMasculino;
40
41         @Column(length=1, nullable=false)
42         private boolean aplicavelSexoFeminino;
43
44     @ManyToMany
45     @JoinTable( name = "FaixaEtariaRede",
46                         joinColumns = {@JoinColumn(name = "rede_id")},
47                         inverseJoinColumns = {@JoinColumn(name = "faiet_id")},
48                         uniqueConstraints={@UniqueConstraint(columnNames={"rede_id", "faiet_id"})})
49     private Collection<FaixaEtaria> faixasEtarias;
50     
51     @OneToOne(cascade=CascadeType.ALL)
52     @JoinColumn(name = "arquivoRedeBayesiana_id", referencedColumnName = "id", nullable = true)
53     @Index(name="rede_arquivo_fk_i")    
54         private ArquivoRedeBayesiana arquivo;
55         public ArquivoRedeBayesiana getArquivo() { return arquivo;      }
56         public void setArquivo(ArquivoRedeBayesiana arquivo) { this.arquivo = arquivo; }
57
58     
59     public Long getId() {
60                 return id;
61         }
62
63         public void setId(Long id) {
64                 this.id = id;
65         }
66
67         public String getNome() {
68                 return nome;
69         }
70
71         public void setNome(String nome) {
72                 this.nome = nome;
73         }
74
75         public boolean isAplicavelSexoMasculino() {
76                 return aplicavelSexoMasculino;
77         }
78
79         public void setAplicavelSexoMasculino(boolean aplicavelSexoMasculino) {
80                 this.aplicavelSexoMasculino = aplicavelSexoMasculino;
81         }
82
83         public boolean isAplicavelSexoFeminino() {
84                 return aplicavelSexoFeminino;
85         }
86
87         public void setAplicavelSexoFeminino(boolean aplicavelSexoFeminino) {
88                 this.aplicavelSexoFeminino = aplicavelSexoFeminino;
89         }
90
91         public Collection<FaixaEtaria> getFaixasEtarias() {
92                 return faixasEtarias;
93         }
94
95         public void setFaixasEtarias(Collection<FaixaEtaria> faixasEtarias) {
96                 this.faixasEtarias = faixasEtarias;
97         }
98
99         @Override
100         public int hashCode() {
101                 final int prime = 31;
102                 int result = 1;
103                 result = prime * result + ((id == null) ? 0 : id.hashCode());
104                 return result;
105         }
106
107         @Override
108         public boolean equals(Object obj) {
109                 if (this == obj)
110                         return true;
111                 if (obj == null)
112                         return false;
113                 if (getClass() != obj.getClass())
114                         return false;
115                 RedeBayesiana other = (RedeBayesiana) obj;
116                 if (id == null) {
117                         if (other.id != null)
118                                 return false;
119                 } else if (!id.equals(other.id))
120                         return false;
121                 return true;
122         }
123
124 }