View Javadoc

1   package ecar.dao;
2   
3   import java.util.ArrayList;
4   import java.util.Iterator;
5   import java.util.List;
6   import java.util.Set;
7   
8   import javax.servlet.http.HttpServletRequest;
9   
10  import org.hibernate.HibernateException;
11  
12  import comum.database.Dao;
13  import comum.util.Pagina;
14  import ecar.exception.ECARException;
15  import ecar.pojo.SisAtributoSatb;
16  import ecar.pojo.TipoAcompTipofuncacompSisatributoTaTpfaSatb;
17  import ecar.pojo.TipoAcompTipofuncacompSisatributoTaTpfaSatbId;
18  import ecar.pojo.TipoAcompanhamentoTa;
19  import ecar.util.Dominios;
20  
21  public class TipoAcompTipofuncacompSisatributoTaTpfaSatbDao extends Dao {
22  
23    public TipoAcompTipofuncacompSisatributoTaTpfaSatbDao() {
24      // TODO Auto-generated constructor stub
25    }
26  
27    public TipoAcompTipofuncacompSisatributoTaTpfaSatb buscar(Long codTa, Long codTpfa, Long codSatb) throws ECARException {
28      try {
29        return (TipoAcompTipofuncacompSisatributoTaTpfaSatb) this.getSession().get(TipoAcompTipofuncacompSisatributoTaTpfaSatb.class, new TipoAcompTipofuncacompSisatributoTaTpfaSatbId(codTa, codTpfa, codSatb));
30      } catch (HibernateException e) {
31        // TODO Auto-generated catch block
32        this.logger.error(e);
33        throw new ECARException("erro.hibernateException");
34      }
35    }
36  
37    public void setTipoAcompTipofuncacompSisatributoTaTpfaSatb(TipoAcompTipofuncacompSisatributoTaTpfaSatb tatpfasatb, HttpServletRequest request) {
38      tatpfasatb.setIndLeituraParecer(Pagina.getParamOrDefault(request, "Tpfa" + tatpfasatb.getId().getCodTa() + "-" + tatpfasatb.getId().getCodTpfa() + "-" + tatpfasatb.getId().getCodSatb(), Dominios.SEM_ACESSO_LEITURA));
39    }
40  
41    /**
42     * @param tipoAcompanhamentoTa
43     * @param grupoPermissaoAcessoSatb
44     * @return List
45     */
46  
47    public List pesquisarPermissaoVisualizarParecerTipoFuncaoAcompTpfa(TipoAcompanhamentoTa tipoAcompanhamentoTa, Set gruposAcessoSatb) throws ECARException {
48  
49      List listaTipoFuncaoAcompanhamentoTpfa = new ArrayList();
50  
51      try {
52        Iterator gruposAcessoSatbIt = gruposAcessoSatb.iterator();
53        while (gruposAcessoSatbIt.hasNext()) {
54          TipoAcompTipofuncacompSisatributoTaTpfaSatb tipoAcompTipofuncacompSisatributoTaTpfaSatb = new TipoAcompTipofuncacompSisatributoTaTpfaSatb();
55          SisAtributoSatb grupoPermissaoAcessoSatb = (SisAtributoSatb) gruposAcessoSatbIt.next();
56          tipoAcompTipofuncacompSisatributoTaTpfaSatb.setSisAtributoSatb(grupoPermissaoAcessoSatb);
57          tipoAcompTipofuncacompSisatributoTaTpfaSatb.setTipoAcompanhamentoTa(tipoAcompanhamentoTa);
58          tipoAcompTipofuncacompSisatributoTaTpfaSatb.setIndLeituraParecer("S");
59  
60          List listaTipoAcompTipofuncacompSisatributoTaTpfaSatb = super.pesquisar(tipoAcompTipofuncacompSisatributoTaTpfaSatb, new String[] { "", "" });
61  
62          Iterator listaTipoAcompTipofuncacompSisatributoTaTpfaSatbIt = listaTipoAcompTipofuncacompSisatributoTaTpfaSatb.iterator();
63          while (listaTipoAcompTipofuncacompSisatributoTaTpfaSatbIt.hasNext()) {
64            tipoAcompTipofuncacompSisatributoTaTpfaSatb = (TipoAcompTipofuncacompSisatributoTaTpfaSatb) listaTipoAcompTipofuncacompSisatributoTaTpfaSatbIt.next();
65            listaTipoFuncaoAcompanhamentoTpfa.add(tipoAcompTipofuncacompSisatributoTaTpfaSatb.getTipoFuncAcompTpfa());
66          }
67        }
68      } catch (ECARException e) {
69        this.logger.error(e);
70        throw new ECARException(e);
71      }
72  
73      return listaTipoFuncaoAcompanhamentoTpfa;
74    }
75  
76  }