View Javadoc

1   /*
2    * Criado em 19/05/2006
3    */
4   package ecar.dao;
5   
6   import java.util.List;
7   
8   import javax.servlet.http.HttpServletRequest;
9   
10  import org.hibernate.HibernateException;
11  import org.hibernate.criterion.Restrictions;
12  
13  import comum.database.Dao;
14  import comum.util.Pagina;
15  
16  import ecar.exception.ECARException;
17  import ecar.pojo.TipoAcompFuncAcompPK;
18  import ecar.pojo.TipoAcompFuncAcompTafc;
19  import ecar.pojo.TipoAcompanhamentoTa;
20  import ecar.util.Dominios;
21  
22  /**
23   * @author evandro
24   */
25  public class TipoAcompFuncAcompDao extends Dao {
26  
27    /**
28     * Construtor. Chama o Session factory do Hibernate
29     */
30    public TipoAcompFuncAcompDao(HttpServletRequest request) {
31      super();
32      this.request = request;
33    }
34  
35    public TipoAcompFuncAcompDao() {
36      super();
37    }
38  
39    /**
40     * Busca
41     * @param codTa
42     * @param codTpfa
43     * @return TipoAcompFuncAcompTafc
44     * @throws ECARException
45     */
46    public TipoAcompFuncAcompTafc buscar(Long codTa, Long codTpfa) throws ECARException {
47      try {
48        // return (TipoAcompFuncAcompTafc) this.getSession()
49        // .createCriteria(TipoAcompFuncAcompTafc.class)
50        // .add(Restrictions.eq("comp_id",new
51        // TipoAcompFuncAcompPK(codTa,codTpfa)))
52        // .uniqueResult();
53        return (TipoAcompFuncAcompTafc) this.getSession().get(TipoAcompFuncAcompTafc.class, new TipoAcompFuncAcompPK(codTa, codTpfa));
54      } catch (HibernateException e) {
55        this.logger.error(e);
56        throw new ECARException(e);
57      }
58    }
59  
60    /**
61     * @author Robson
62     * @return List<TipoAcompFuncAcompTafc>
63     * @since 26/11/2007
64     */
65    public List getListaAcessotpfa(TipoAcompanhamentoTa ta) {
66      return this.getSession().createCriteria(TipoAcompFuncAcompTafc.class).add(Restrictions.eq("tipoAcompanhamentoTa", ta)).add(Restrictions.eq("indLeituraTipoAcomp", Dominios.COM_ACESSO_LEITURA)).list();
67    }
68  
69    /**
70     * @author Robson
71     * @param TipoAcompFuncAcompTafc
72     * @param HttpServletRequest
73     * @since 26/11/2007
74     */
75    public void setTipoAcompFuncAcompTafc(TipoAcompFuncAcompTafc tafc, HttpServletRequest request) {
76  
77      tafc.setIndLeituraTipoAcomp(Pagina.getParamOrDefault(request, "Tpfa" + tafc.getComp_id().getCodTa() + "-" + tafc.getComp_id().getCodTpfa(), Dominios.SEM_ACESSO_LEITURA));
78    }
79  }