1 package com.instantbank.lettertemplate.templates.web;
2
3 import java.io.*;
4 import java.net.*;
5 import java.util.*;
6 import javax.naming.*;
7 import javax.rmi.*;
8 import javax.servlet.http.HttpServletRequest;
9
10 import oracle.xml.parser.v2.*;
11 import org.w3c.dom.*;
12 import org.xml.sax.*;
13 import com.instantbank.lettertemplate.control.util.WebKeys;
14 import com.instantbank.common.utilcomponents.CodeDescription;
15 import com.instantbank.common.utilcomponents.Debug;
16
17
23 public class TemplatesTranslator
24 implements Serializable {
25
26 private String[] code;
27 private String[] name;
28 private String[] codetemplate;
29 private String[] category;
30 private String[] printtype;
31 private String[] nametempl;
32 private int nlLengthT;
33 private int nlLengthC;
34
35 private Debug debug = null;
36
37
38
44 public void setData(HttpServletRequest request) {
45
46 debug = new Debug();
47 debug.setDebugginOn(true);
48 debug.setPreMessage("** TemplatesTranslator: ");
49
50 try {
51 ArrayList listTempl = new ArrayList();
52 ArrayList item = new ArrayList();
53
54 listTempl = (ArrayList)request.getAttribute(WebKeys.TemplatesList);
55 debug.println("templates list obtained");
56
57 nlLengthT = listTempl.size();
58 codetemplate = new String[nlLengthT];
59 category = new String[nlLengthT];
60 printtype = new String[nlLengthT];
61 nametempl = new String[nlLengthT];
62
63 for(int i = 0; i < nlLengthT; i++) {
64 item = (ArrayList)(listTempl.get(i));
65 codetemplate[i] = String.valueOf(((Long)item.get(0)).longValue());
66 category[i] = (String)item.get(1);
67 printtype[i] = (String)item.get(2);
68 nametempl[i] = (String)item.get(3);
69 }
70
71 CodeDescription[] cd = (CodeDescription[])
72 request.getAttribute(WebKeys.CategoryList);
73 debug.println("categories list obtained");
74
75 nlLengthC = cd.length;
76 code = new String[nlLengthC];
77 name = new String[nlLengthC];
78
79 for(int i = 0; i < nlLengthC; i++) {
80 code[i] = String.valueOf(cd[i].getCode());
81 name[i] = cd[i].getDescription();
82 }
83 }
84
85 catch(Exception e) {
86 debug.println("Exception unexpected:" + e.getMessage());
87 }
88 }
89
90
91
97 public String getTemplatesArray() {
98 String Head = null;
99 String Body = null;
100 char Ch = '"';
101
102 Head = "numberOfItems = " + nlLengthT + "; \n" +
103 "numberOfDeleted=0;\n";
104 Body = "";
105 for(int i = 0; i < nlLengthT; i++) {
106 Body = Body +
107 "itemsArray[" + i + "] = new Item("
108 + Ch + codetemplate[i] + Ch + ","
109 + Ch + category[i] + Ch + ","
110 + Ch + printtype[i] + Ch + ","
111 + Ch + nametempl[i] + Ch + ","
112 + Ch + "N" + Ch +
113
114 ");\n";
115 }
116 return (Head + Body);
117 }
118
119
120
126 public String getCategoriesArray() {
127 String Head = null;
128 String Body = null;
129 char Ch = '"';
130
131 Head = "numberOfItemsC = " + nlLengthC + "; \n";
132 Body = "";
133 for(int i = 0; i < nlLengthC; i++) {
134 Body = Body +
135 "itemsCategoriesArray[" + i
136 + "] = new ItemCategories("
137 + Ch + code[i] + Ch + ","
138 + Ch + name[i] + Ch +
139 ");\n";
140 }
141 return (Head + Body);
142 }
143 }
144
145