1 package ecar.dao;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.hibernate.HibernateException;
9 import org.hibernate.Transaction;
10
11 import comum.database.Dao;
12 import comum.util.Data;
13 import comum.util.Pagina;
14
15 import ecar.exception.ECARException;
16 import ecar.pojo.Aba;
17 import ecar.pojo.FuncaoFun;
18 import ecar.pojo.Link;
19
20
21
22
23
24 public class LinkDao extends Dao {
25
26 public LinkDao(HttpServletRequest request) {
27 super();
28 this.request = request;
29 }
30
31 @SuppressWarnings("unchecked")
32 public void alterar(HttpServletRequest request) throws ECARException {
33 Transaction tx = null;
34 try {
35 ArrayList<Link> objetos = new ArrayList<Link>();
36 super.inicializarLogBean();
37 tx = session.beginTransaction();
38
39
40 ArrayList<Link> lista = (ArrayList<Link>) this.listar(Link.class, new String[] { "codLink", "asc" });
41
42 for (Link link : lista) {
43
44 if ("S".equals(Pagina.getParamStr(request, "exibeMonitoramentoLink" + link.getCodLink().toString()))) {
45 link.setExibeMonitoramentoLink("S");
46 }
47 else {
48 link.setExibeMonitoramentoLink("N");
49 }
50
51 link.setOrdemLink(Integer.valueOf(Pagina.getParamInt(request, "ordemLink" + link.getCodLink().toString())));
52 link.setLabelLink(Pagina.getParamStr(request, "labelLink" + link.getCodLink().toString()));
53 link.setIconeLink(Pagina.getParamStr(request, "iconeLink" + link.getCodLink().toString()));
54
55
56
57 session.update(link);
58 objetos.add(link);
59 }
60
61 tx.commit();
62
63
64 if (super.logBean != null) {
65 super.logBean.setCodigoTransacao(Data.getHoraAtual(false));
66 super.logBean.setOperacao("ALT");
67
68 for (Iterator itObj = objetos.iterator(); itObj.hasNext();) {
69 super.logBean.setObj(itObj.next());
70 super.loggerAuditoria.info(logBean.toString());
71 }
72 }
73 } catch (HibernateException e) {
74 if (tx != null)
75 try {
76 tx.rollback();
77 } catch (HibernateException r) {
78 this.logger.error(r);
79 throw new ECARException("erro.hibernateException");
80 }
81 this.logger.error(e);
82 throw new ECARException("erro.hibernateException");
83 } catch (ECARException e) {
84 if (tx != null)
85 try {
86 tx.rollback();
87 } catch (HibernateException r) {
88 this.logger.error(r);
89 throw new ECARException("erro.hibernateException");
90 }
91 this.logger.error(e);
92 throw e;
93 }
94 }
95
96 }