Adicionadas entidades para representar nodo, perguntas e respostas
authorMichele Silva <michele.silva@gmail.com>
Fri, 21 Oct 2011 21:38:36 +0000 (19:38 -0200)
committerMichele Silva <michele.silva@gmail.com>
Fri, 21 Oct 2011 21:38:36 +0000 (19:38 -0200)
associadas.

SimDeCS/src/main/org/ufcspa/simdecs/entities/Nodo.java [new file with mode: 0644]
SimDeCS/src/main/org/ufcspa/simdecs/entities/PerguntaNodo.java [new file with mode: 0644]
SimDeCS/src/main/org/ufcspa/simdecs/entities/RespostaNodo.java [new file with mode: 0644]

diff --git a/SimDeCS/src/main/org/ufcspa/simdecs/entities/Nodo.java b/SimDeCS/src/main/org/ufcspa/simdecs/entities/Nodo.java
new file mode 100644 (file)
index 0000000..20f1003
--- /dev/null
@@ -0,0 +1,108 @@
+package org.ufcspa.simdecs.entities;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Index;
+
+
+@Entity
+@Table(name="Nodo")
+@SequenceGenerator(name = "sequenceNodo", sequenceName = "sqNodo", initialValue = 1, allocationSize=1)
+public class Nodo implements Serializable {
+
+       private static final long serialVersionUID = 6879782331178330999L;
+
+       @Id
+       @GeneratedValue(generator="sequenceNodo", strategy=GenerationType.AUTO)
+       private Long id;
+
+       @Column(length=100, nullable=false)
+       private String nome;
+       
+       @Column(length=10, nullable=true)
+       private Float custo;
+       
+       @Column(length=10, nullable=true)
+       private Long tempo;
+       
+    @ManyToOne
+    @JoinColumn(name = "rede_id", referencedColumnName = "id", nullable = true)
+    @Index(name="nodo_rede_fk_i")
+       private Rede rede;
+       
+       public Long getId() {
+               return id;
+       }
+       public void setId(Long id) {
+               this.id = id;
+       }
+       public String getNome() {
+               return nome;
+       }
+       public void setNome(String nome) {
+               this.nome = nome;
+       }
+       public Float getCusto() {
+               return custo;
+       }
+       public void setCusto(Float custo) {
+               this.custo = custo;
+       }
+       public Long getTempo() {
+               return tempo;
+       }
+       public void setTempo(Long tempo) {
+               this.tempo = tempo;
+       }
+       
+       public Rede getRede() {
+               return rede;
+       }
+
+       public void setRede(Rede rede) {
+               this.rede = rede;
+       }
+
+       public String toString() {
+               return id + " - " + nome;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((id == null) ? 0 : id.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               Nodo other = (Nodo) obj;
+               if (id == null) {
+                       if (other.id != null)
+                               return false;
+               } else if (!id.equals(other.id))
+                       return false;
+               return true;
+       }
+       
+       public Nodo() {
+               
+       }
+}
diff --git a/SimDeCS/src/main/org/ufcspa/simdecs/entities/PerguntaNodo.java b/SimDeCS/src/main/org/ufcspa/simdecs/entities/PerguntaNodo.java
new file mode 100644 (file)
index 0000000..d89e0ea
--- /dev/null
@@ -0,0 +1,90 @@
+package org.ufcspa.simdecs.entities;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Index;
+
+
+@Entity
+@Table(name="PerguntaNodo")
+@SequenceGenerator(name = "sequencePerguntaNodo", sequenceName = "sqPerguntaNodo", initialValue = 1, allocationSize=1)
+public class PerguntaNodo implements Serializable {
+
+       private static final long serialVersionUID = 6879782331178330999L;
+
+       @Id
+       @GeneratedValue(generator="sequencePerguntaNodo", strategy=GenerationType.AUTO)
+       private Long id;
+
+       @Column(length=100, nullable=false)
+       private String pergunta;
+       
+    @ManyToOne
+    @JoinColumn(name = "nodo_id", referencedColumnName = "id", nullable = true)
+    @Index(name="pergunta_nodo_fk_i")
+       private Nodo nodo;
+    
+       public Long getId() {
+               return id;
+       }
+       public void setId(Long id) {
+               this.id = id;
+       }
+       public String getPergunta() {
+               return pergunta;
+       }
+       public void setPergunta(String pergunta) {
+               this.pergunta = pergunta;
+       }
+
+       public Nodo getNodo() {
+               return nodo;
+       }
+
+       public void getNodo(Nodo nodo) {
+               this.nodo = nodo;
+       }
+       
+       public String toString() {
+               return id + " - " + pergunta;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((id == null) ? 0 : id.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               PerguntaNodo other = (PerguntaNodo) obj;
+               if (id == null) {
+                       if (other.id != null)
+                               return false;
+               } else if (!id.equals(other.id))
+                       return false;
+               return true;
+       }
+       
+       public PerguntaNodo() {
+               
+       }
+}
diff --git a/SimDeCS/src/main/org/ufcspa/simdecs/entities/RespostaNodo.java b/SimDeCS/src/main/org/ufcspa/simdecs/entities/RespostaNodo.java
new file mode 100644 (file)
index 0000000..2e8bfbc
--- /dev/null
@@ -0,0 +1,99 @@
+package org.ufcspa.simdecs.entities;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Index;
+
+
+@Entity
+@Table(name="RespostaNodo")
+@SequenceGenerator(name = "sequenceRespostaNodo", sequenceName = "sqRespostaNodo", initialValue = 1, allocationSize=1)
+public class RespostaNodo implements Serializable {
+
+       private static final long serialVersionUID = 6879782331178330999L;
+
+       @Id
+       @GeneratedValue(generator="sequenceRespostaNodo", strategy=GenerationType.AUTO)
+       private Long id;
+
+       @Column(length=100, nullable=false)
+       private String resposta;
+       
+       @Column(length=10, nullable=true)
+       private Float percentual;
+       
+    @ManyToOne
+    @JoinColumn(name = "nodo_id", referencedColumnName = "id", nullable = true)
+    @Index(name="resposta_nodo_fk_i")
+       private Nodo nodo;
+       
+       public Long getId() {
+               return id;
+       }
+       public void setId(Long id) {
+               this.id = id;
+       }
+       public String getResposta() {
+               return resposta;
+       }
+       public void setResposta(String resposta) {
+               this.resposta = resposta;
+       }
+       public Float getPercentual() {
+               return percentual;
+       }
+       public void setPercentual(Float percentual) {
+               this.percentual = percentual;
+       }
+       
+       public Nodo getNodo() {
+               return nodo;
+       }
+
+       public void getNodo(Nodo nodo) {
+               this.nodo = nodo;
+       }
+
+       public String toString() {
+               return id + " - " + resposta + " - " + percentual ;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((id == null) ? 0 : id.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               RespostaNodo other = (RespostaNodo) obj;
+               if (id == null) {
+                       if (other.id != null)
+                               return false;
+               } else if (!id.equals(other.id))
+                       return false;
+               return true;
+       }
+       
+       public RespostaNodo() {
+               
+       }
+}