1
2
3
4 package ecar.dao;
5
6 import java.util.ArrayList;
7 import java.util.Date;
8 import java.util.List;
9
10 import javax.servlet.http.HttpServletRequest;
11
12 import org.apache.log4j.Logger;
13 import org.hibernate.Query;
14
15 import comum.database.Dao;
16 import comum.util.Pagina;
17
18 import ecar.exception.ECARException;
19 import ecar.pojo.EfImportOcorrenciasEfio;
20
21
22
23
24 public class EfImportOcorrenciasDao extends Dao {
25
26
27
28
29 public EfImportOcorrenciasDao(HttpServletRequest request) {
30 super();
31 this.request = request;
32 }
33
34
35
36
37
38
39 public void setOcorrencia(HttpServletRequest request, EfImportOcorrenciasEfio ocorrencia) {
40 ocorrencia.setDescricaoEfio(Pagina.getParamStr(request, "descricaoEfio"));
41 }
42
43
44
45
46
47
48 public List getOcorrenciasAnteriores() throws ECARException {
49 List retorno = new ArrayList();
50 try {
51 String select = "select distinct ocorrencias.importacaoImp.dataHoraImp from EfImportOcorrenciasEfio ocorrencias" + " order by ocorrencias.importacaoImp.dataHoraImp desc";
52 Query q = this.session.createQuery(select);
53 retorno = q.list();
54 } catch (Exception e) {
55 Logger logger = Logger.getLogger(this.getClass());
56 logger.error(e);
57 }
58 return retorno;
59 }
60
61
62
63
64
65
66 public List getOcorrencias(Date data) {
67 List retorno = new ArrayList();
68 try {
69 String select = "from EfImportOcorrenciasEfio ocorrencias";
70
71 if (data != null)
72 select += " where ocorrencias.importacaoImp.dataHoraImp = :data";
73
74 Query q = this.session.createQuery(select);
75
76 if (data != null)
77 q.setDate("data", data);
78
79 retorno = q.list();
80 } catch (Exception e) {
81 Logger logger = Logger.getLogger(this.getClass());
82 logger.error(e);
83 }
84 return retorno;
85 }
86 }