1 package ecar.dao;
2
3 import java.util.Iterator;
4 import java.util.List;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.apache.commons.fileupload.FileItem;
9
10 import comum.database.Dao;
11 import comum.util.FileUpload;
12
13 import ecar.exception.ECARException;
14 import ecar.pojo.Cor;
15 import ecar.pojo.CorTipoFuncAcompCtfa;
16 import ecar.pojo.CorTipoFuncAcompCtfaPK;
17 import ecar.pojo.TipoFuncAcompTpfa;
18
19
20
21
22
23 public class CorTipoFuncAcompDao extends Dao {
24
25
26
27
28
29 public CorTipoFuncAcompDao(HttpServletRequest request) {
30 super();
31 this.request = request;
32 }
33
34
35
36
37
38
39
40
41
42 public void salvar(CorTipoFuncAcompCtfa ctfa) throws ECARException {
43 super.salvar(ctfa);
44 }
45
46
47
48
49
50
51
52
53
54
55
56
57
58 public List criarListaCorTipoFuncAcomp(String posicao, List listFuncao, List listCampo, Cor cor, List currentList) throws ECARException {
59 Iterator itf = listFuncao.iterator();
60 Iterator itc = null;
61
62 while (itf.hasNext()) {
63 TipoFuncAcompTpfa tfa = (TipoFuncAcompTpfa) itf.next();
64
65 CorTipoFuncAcompCtfaPK ctfapk = new CorTipoFuncAcompCtfaPK();
66 ctfapk.setCodCor(cor.getCodCor());
67 ctfapk.setCodTpfa(tfa.getCodTpfa());
68 ctfapk.setPosicaoCtfa(posicao);
69 CorTipoFuncAcompCtfa ctfa = null;
70
71
72
73
74
75 try {
76 ctfa = (CorTipoFuncAcompCtfa) this.buscar(CorTipoFuncAcompCtfa.class, ctfapk);
77 } catch (ECARException e) {
78 ctfa = new CorTipoFuncAcompCtfa();
79 ctfa.setComp_id(ctfapk);
80 ctfa.setCor(cor);
81 ctfa.setTipoFuncAcompTpfa(tfa);
82 ctfa.setPosicaoCtfa(posicao);
83 }
84
85 itc = listCampo.iterator();
86 while (itc.hasNext()) {
87 FileItem file = (FileItem) itc.next();
88 String fieldName = posicao + "-" + tfa.getCodTpfa();
89
90
91 if (fieldName.equals(file.getFieldName()) && (file.getName() != null && !"".equals(file.getName().trim()))) {
92 ctfa.setCaminhoImagemCtfa(FileUpload.getNomeArquivo(file));
93 currentList.add(ctfa);
94 }
95 }
96 }
97
98 return currentList;
99 }
100 }