From cb7eaf54fc3dcd66511885e1a3ab4140977a5d4a Mon Sep 17 00:00:00 2001 From: maroni Date: Wed, 14 Mar 2012 13:53:23 -0300 Subject: [PATCH] --- src/conf/persistence.xml | 2 + .../simdecs/entities/IntervaloTabelaRespota.java | 102 +++++++++++++++++ .../org/ufcspa/simdecs/entities/PerguntaNodo.java | 71 +++++------- .../org/ufcspa/simdecs/entities/RespostaNodo.java | 116 ++++++++------------ .../ufcspa/simdecs/entities/TabelaResposta.java | 70 ++++++++++++ .../org/ufcspa/simdecs/mb/bn/RedeEditBean.java | 12 +- 6 files changed, 256 insertions(+), 117 deletions(-) create mode 100644 src/java/org/ufcspa/simdecs/entities/IntervaloTabelaRespota.java create mode 100644 src/java/org/ufcspa/simdecs/entities/TabelaResposta.java diff --git a/src/conf/persistence.xml b/src/conf/persistence.xml index 0f4e6b5..9ccec6b 100644 --- a/src/conf/persistence.xml +++ b/src/conf/persistence.xml @@ -5,6 +5,7 @@ jdbc/SimDeCS org.ufcspa.simdecs.entities.Caso org.ufcspa.simdecs.entities.DependenciaNodo + org.ufcspa.simdecs.entities.IntervaloTabelaRespota org.ufcspa.simdecs.entities.Log org.ufcspa.simdecs.entities.Nodo org.ufcspa.simdecs.entities.NodoPaciente @@ -15,6 +16,7 @@ org.ufcspa.simdecs.entities.RespostaNodo org.ufcspa.simdecs.entities.SessaoUsuario org.ufcspa.simdecs.entities.SinonimoResposta + org.ufcspa.simdecs.entities.TabelaResposta org.ufcspa.simdecs.entities.TipoEventoLog org.ufcspa.simdecs.entities.Usuario true diff --git a/src/java/org/ufcspa/simdecs/entities/IntervaloTabelaRespota.java b/src/java/org/ufcspa/simdecs/entities/IntervaloTabelaRespota.java new file mode 100644 index 0000000..ffc634a --- /dev/null +++ b/src/java/org/ufcspa/simdecs/entities/IntervaloTabelaRespota.java @@ -0,0 +1,102 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.entities; + +import java.io.Serializable; +import javax.persistence.*; + +/** + * + * @author maroni + */ +@Entity +@Table(name="INTERVALO_TABELA_REPOSTA") +public class IntervaloTabelaRespota implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @SequenceGenerator(name="seqIntervaloTabelaResposta", sequenceName="SQ_INTERVALO_TABELA_RESPOSTA") + @GeneratedValue(strategy = GenerationType.AUTO, generator="seqIntervaloTabelaResposta") + private Long id; + + @ManyToOne + @JoinColumn(name="tabres_id", nullable=false) + private TabelaResposta tabelaResposta; + + @Column(nullable=false, length=3) + private Integer pesoMinimo; + + @Column(nullable=false, length=3) + private Integer pesoMaximo; + + @Column(nullable=false, length=2000) + private String texto; + + public TabelaResposta getTabelaResposta() { + return tabelaResposta; + } + + public void setTabelaResposta(TabelaResposta tabelaResposta) { + this.tabelaResposta = tabelaResposta; + } + + public Integer getPesoMaximo() { + return pesoMaximo; + } + + public void setPesoMaximo(Integer pesoMaximo) { + this.pesoMaximo = pesoMaximo; + } + + public Integer getPesoMinimo() { + return pesoMinimo; + } + + public void setPesoMinimo(Integer pesoMinimo) { + this.pesoMinimo = pesoMinimo; + } + + public String getTexto() { + return texto; + } + + public void setTexto(String texto) { + this.texto = texto; + } + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof IntervaloTabelaRespota)) { + return false; + } + IntervaloTabelaRespota other = (IntervaloTabelaRespota) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "org.ufcspa.simdecs.entities.IntervaloTabelaRespota[ id=" + id + " ]"; + } + +} diff --git a/src/java/org/ufcspa/simdecs/entities/PerguntaNodo.java b/src/java/org/ufcspa/simdecs/entities/PerguntaNodo.java index fc3f74b..607a6d7 100644 --- a/src/java/org/ufcspa/simdecs/entities/PerguntaNodo.java +++ b/src/java/org/ufcspa/simdecs/entities/PerguntaNodo.java @@ -5,7 +5,6 @@ package org.ufcspa.simdecs.entities; import java.io.Serializable; -import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -13,7 +12,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; @@ -23,7 +21,7 @@ import javax.persistence.Table; */ @Entity @Table(name="PERGUNTA_NODO") -public class PerguntaNodo implements Serializable, IdHolder, Comparable { +public class PerguntaNodo implements Serializable { private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name="SeqPerguntaNodo", sequenceName="SQ_PERGUNTA_NODO") @@ -37,9 +35,9 @@ public class PerguntaNodo implements Serializable, IdHolder, Comparable respostas; - + public PerguntaNodo() { + } + public Long getId() { return id; } @@ -48,29 +46,12 @@ public class PerguntaNodo implements Serializable, IdHolder, Comparable getRespostas() { - return respostas; + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PerguntaNodo other = (PerguntaNodo) obj; + if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) { + return false; + } + return true; } - public void setRespostas(List respostas) { - this.respostas = respostas; + @Override + public int hashCode() { + int hash = 5; + hash = 89 * hash + (this.id != null ? this.id.hashCode() : 0); + return hash; } @Override - public int compareTo(PerguntaNodo t) { - return t.getId().intValue()- this.getId().intValue(); + public String toString() { + return "PerguntaNodo{" + "id=" + id + ", texto=" + texto + ", nodo=" + nodo + '}'; } - + } diff --git a/src/java/org/ufcspa/simdecs/entities/RespostaNodo.java b/src/java/org/ufcspa/simdecs/entities/RespostaNodo.java index d167bbb..a5f0588 100644 --- a/src/java/org/ufcspa/simdecs/entities/RespostaNodo.java +++ b/src/java/org/ufcspa/simdecs/entities/RespostaNodo.java @@ -5,8 +5,6 @@ package org.ufcspa.simdecs.entities; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -14,7 +12,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; // @@ -24,28 +21,25 @@ import javax.persistence.Table; */ @Entity @Table(name="RESPOSTA_NODO") -public class RespostaNodo implements Serializable, IdHolder, Comparable { +public class RespostaNodo implements Serializable { + private static final long serialVersionUID = 1L; + @Id - @SequenceGenerator(name="SeqRespotaNOdo", sequenceName="SQ_RESPOTA_NODO") - @GeneratedValue(strategy = GenerationType.AUTO) + @SequenceGenerator(name="SeqRespotaNodo", sequenceName="SQ_RESPOTA_NODO") + @GeneratedValue(strategy = GenerationType.AUTO, generator="SeqRespotaNodo") private Long id; - @Column(nullable=false, length=3) - private Integer pesoMinimo; - - @Column(nullable=false, length=3) - private Integer pesoMaximo; - - @ManyToOne - @JoinColumn(name="pergunta_id", nullable=false) - private PerguntaNodo pergunta; + @Column(nullable=false, length=2000) + private String texto; - @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy="resposta") - private List sinonimos; + @ManyToOne + @JoinColumn(name="nodo_id", nullable=false) + private Nodo nodo; - @Column(nullable=true, length=2000) - private String texto; + @ManyToOne + @JoinColumn(name="tabres_id", nullable=false) + private TabelaResposta tabelaResposta; public Long getId() { return id; @@ -55,74 +49,58 @@ public class RespostaNodo implements Serializable, IdHolder, Comparable getSinonimos() { - return sinonimos; + @Override + public String toString() { + return "RespostaNodo{" + "id=" + id + ", texto=" + texto + ", nodo=" + nodo + '}'; } - public void setSinonimos(List sinonimos) { - this.sinonimos = sinonimos; - } - - public void setTexto(String texto) { - this.texto = texto; - } - - public String getTexto(){ - return this.texto; - } - - @Override - public int compareTo(RespostaNodo t) { - return t.getId().intValue() - this.getId().intValue(); - } } diff --git a/src/java/org/ufcspa/simdecs/entities/TabelaResposta.java b/src/java/org/ufcspa/simdecs/entities/TabelaResposta.java new file mode 100644 index 0000000..8daa599 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/entities/TabelaResposta.java @@ -0,0 +1,70 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.entities; + +import java.io.Serializable; +import javax.persistence.*; + +/** + * + * @author maroni + */ +@Entity +@Table(name="TABELA_RESPOSTA") +public class TabelaResposta implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @SequenceGenerator(name="seqTabelaResposta", sequenceName="SQ_TABELA_RESPOSTA") + @GeneratedValue(strategy = GenerationType.AUTO, generator="seqTabelaResposta") + private Long id; + + @Column(nullable=false, length=100) + private String nome; + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof TabelaResposta)) { + return false; + } + TabelaResposta other = (TabelaResposta) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "org.ufcspa.simdecs.entities.TabelaResposta[ id=" + id + " ]"; + } + +} diff --git a/src/java/org/ufcspa/simdecs/mb/bn/RedeEditBean.java b/src/java/org/ufcspa/simdecs/mb/bn/RedeEditBean.java index 15b4be3..2cca545 100644 --- a/src/java/org/ufcspa/simdecs/mb/bn/RedeEditBean.java +++ b/src/java/org/ufcspa/simdecs/mb/bn/RedeEditBean.java @@ -54,7 +54,7 @@ public class RedeEditBean extends DefaultManagedBean { public PerguntaNodo getSelectedPergunta() { return selectedPergunta; } - +/* public SimdecsDataModel getSelectablePerguntas() { if (selectedNodo != null && selectedNodo.getPerguntas() != null) { Collections.sort(selectedNodo.getPerguntas()); @@ -78,7 +78,7 @@ public class RedeEditBean extends DefaultManagedBean { return new SimdecsDataModel(new ArrayList()); } } - +*/ public RespostaNodo getSelectedResposta() { return selectedResposta; } @@ -86,7 +86,7 @@ public class RedeEditBean extends DefaultManagedBean { public void setSelectedResposta(RespostaNodo selectedResposta) { this.selectedResposta = selectedResposta; } - +/* public void addPergunta() { if (selectedNodo != null) { try { @@ -106,7 +106,7 @@ public class RedeEditBean extends DefaultManagedBean { } } - +*/ public void removePergunta(PerguntaNodo pergunta) { try { em.getTransaction().begin(); @@ -117,7 +117,7 @@ public class RedeEditBean extends DefaultManagedBean { } addInfoMessage("Pergunta Removida", "Pergunta removida com sucesso."); } - +/* public void addResposta() { if (selectedPergunta != null) { try { @@ -148,7 +148,7 @@ public class RedeEditBean extends DefaultManagedBean { } addInfoMessage("Resposta removida", "Resposta removida com sucesso."); } - +*/ public void addNodo() { if (rede != null) { try { -- 1.7.6.4