From 989a41ed1ec822cdae3c2107e2266cac26ea63ac Mon Sep 17 00:00:00 2001 From: mp-96409975520 Date: Tue, 23 Aug 2016 16:01:31 -0300 Subject: [PATCH] Entidades. --- src/br/com/model/entity/Formulario.java | 1 - src/br/com/model/entity/OpcaoResposta.java | 25 +++++++++++++++++++++++++ src/br/com/model/entity/Pergunta.java | 66 ++++++++++++++++++++++++++++++++++++++++++++++-------------------- src/br/com/model/entity/Questionario.java | 28 ++++++++++++++++++++++++++++ src/br/com/model/entity/RespostaQuestionario.java | 38 +++++++++++++++++++++++++++++++++++++- 5 files changed, 136 insertions(+), 22 deletions(-) diff --git a/src/br/com/model/entity/Formulario.java b/src/br/com/model/entity/Formulario.java index 5391aaa..c0ed51d 100644 --- a/src/br/com/model/entity/Formulario.java +++ b/src/br/com/model/entity/Formulario.java @@ -1,6 +1,5 @@ package br.com.model.entity; -import br.com.caelum.vraptor.Validator; public class Formulario{ diff --git a/src/br/com/model/entity/OpcaoResposta.java b/src/br/com/model/entity/OpcaoResposta.java index 077a839..9b1b15f 100644 --- a/src/br/com/model/entity/OpcaoResposta.java +++ b/src/br/com/model/entity/OpcaoResposta.java @@ -1,9 +1,34 @@ package br.com.model.entity; +import java.sql.ResultSet; + +import br.com.dao.OpcaoRespostaDao; + public class OpcaoResposta { private int idOpcaoResposta; private String descOpcaoResposta; + + public OpcaoResposta (){ + + } + + public OpcaoResposta (int idOpcaoResposta){ + ResultSet rset = null; + OpcaoRespostaDao opcaoRespostaDao = new OpcaoRespostaDao(); + + rset = opcaoRespostaDao.retornarOpcaoResposta(idOpcaoResposta); + + try { + while (rset.next()) { + this.idOpcaoResposta = idOpcaoResposta; + this.descOpcaoResposta = rset.getString("desc_opcao_resposta"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public int getIdOpcaoResposta() { return idOpcaoResposta; } diff --git a/src/br/com/model/entity/Pergunta.java b/src/br/com/model/entity/Pergunta.java index 76f04cb..9d3d206 100644 --- a/src/br/com/model/entity/Pergunta.java +++ b/src/br/com/model/entity/Pergunta.java @@ -1,25 +1,51 @@ package br.com.model.entity; +import java.sql.ResultSet; + +import br.com.dao.PerguntaDao; + public class Pergunta { - private int idPergunta; - private String descPergunta; - - public int getIdPergunta() { - return idPergunta; - } - - public void setIdPergunta(int idPergunta) { - this.idPergunta = idPergunta; - } - - public String getDescPergunta() { - return descPergunta; - } - - public void setDescPergunta(String descPergunta) { - this.descPergunta = descPergunta; - } - - + private int idPergunta; + private String descPergunta; + + + public Pergunta() { + + } + + public Pergunta(int idPergunta) { + ResultSet rset = null; + PerguntaDao perguntaDao = new PerguntaDao(); + + rset = perguntaDao.retornarPergunta(idPergunta); + try { + while (rset.next()) { + this.idPergunta = idPergunta; + this.descPergunta = rset.getString("desc_pergunta"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + public int getIdPergunta() { + return idPergunta; + } + + public void setIdPergunta(int idPergunta) { + this.idPergunta = idPergunta; + } + + public String getDescPergunta() { + return descPergunta; + } + + public void setDescPergunta(String descPergunta) { + this.descPergunta = descPergunta; + } + + } diff --git a/src/br/com/model/entity/Questionario.java b/src/br/com/model/entity/Questionario.java index 702594c..2538943 100644 --- a/src/br/com/model/entity/Questionario.java +++ b/src/br/com/model/entity/Questionario.java @@ -1,6 +1,10 @@ package br.com.model.entity; import java.sql.Date; +import java.sql.ResultSet; + +import br.com.dao.PerguntaDao; +import br.com.dao.QuestionarioDao; public class Questionario { @@ -10,6 +14,30 @@ public class Questionario { private String noOrgao; private String hashAutenticacao; + public Questionario() + { + + } + + public Questionario(int idQuestionario) + { + ResultSet rset = null; + QuestionarioDao questionarioDao = new QuestionarioDao(); + + rset = questionarioDao.retornarQuestionario(idQuestionario); + try { + while (rset.next()) { + this.idQuestionario = idQuestionario; + this.dtInicioQuestionario = rset.getString("dt_inicio_questionario"); + this.dtFimQuestionario = rset.getString("dt_fim_questionario"); + this.noOrgao = rset.getString("no_orgao"); + this.hashAutenticacao = rset.getString("hash_autenticacao"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public int getIdQuestionario() { return idQuestionario; } diff --git a/src/br/com/model/entity/RespostaQuestionario.java b/src/br/com/model/entity/RespostaQuestionario.java index 718cfae..6833bd5 100644 --- a/src/br/com/model/entity/RespostaQuestionario.java +++ b/src/br/com/model/entity/RespostaQuestionario.java @@ -1,6 +1,8 @@ package br.com.model.entity; -import java.util.Date; +import java.sql.ResultSet; + +import br.com.dao.RespostaQuestionarioDao; public class RespostaQuestionario { @@ -9,6 +11,32 @@ public class RespostaQuestionario { private Pergunta pergunta; private OpcaoResposta opcaoResposta; private String dtRespostaQuestionario; + private String textoResposta; + + public RespostaQuestionario() + { + + } + + public RespostaQuestionario(int idRespostaQuestionario) + { + ResultSet rset = null; + RespostaQuestionarioDao respostaQuestionarioDao = new RespostaQuestionarioDao(); + + rset = respostaQuestionarioDao.retornarRespostaQuestionario(idRespostaQuestionario); + try { + while (rset.next()) { + this.idRespostaQuestionario = idRespostaQuestionario; + this.questionario = new Questionario(Integer.parseInt(rset.getString("id_questionario"))); + this.pergunta = new Pergunta(Integer.parseInt(rset.getString("id_pergunta"))); + this.opcaoResposta = new OpcaoResposta(Integer.parseInt(rset.getString("id_opcao_resposta"))); + this.dtRespostaQuestionario = rset.getDate("dt_resposta_questionario").toString(); + this.textoResposta = rset.getString("texto_resposta"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } public int getIdRespostaQuestionario() { return idRespostaQuestionario; @@ -49,6 +77,14 @@ public class RespostaQuestionario { public void setDtRespostaQuestionario(String dtRespostaQuestionario) { this.dtRespostaQuestionario = dtRespostaQuestionario; } + + public String getTextoResposta() { + return textoResposta; + } + + public void setTextoResposta(String textoResposta) { + this.textoResposta = textoResposta; + } -- libgit2 0.21.2