1 package com.instantbank.component.parameter.ejb;
2
3 import java.util.ArrayList;
4 import java.util.Hashtable;
5 import java.rmi.RemoteException;
6 import javax.ejb.SessionBean;
7 import javax.ejb.SessionContext;
8 import javax.ejb.EJBException;
9 import javax.ejb.ObjectNotFoundException;
10 import com.instantbank.common.utilcomponents.CodeDescription;
11 import com.instantbank.component.parameter.util.*;
12 import com.instantbank.common.utilcomponents.Debug;
13 import com.instantbank.common.utilcomponents.DAOException;
14
15
21 public class ParameterEJB
22 implements SessionBean {
23
24
25
28 String companyId;
29
32 Long userId;
33
34
35
38 private SessionContext context;
39
42 private ParameterDAO parameterDao;
43 private Debug debug = null;
44
45
46
47
50 public ParameterEJB() { }
51
52
53
54
59 public void setSessionContext(SessionContext sc) {
60 debug = new Debug();
61 debug.setDebugginOn(true);
62 debug.setPreMessage("** ParameterEJB");
63 this.context = sc;
64 }
65
66
67
70 public void ejbActivate() {
71 try {
72 getDao();
73 }
74 catch(DAOException se) {
75 throw new RuntimeException(se.getMessage());
76 }
77 debug = new Debug();
78 debug.setDebugginOn(true);
79 debug.setPreMessage("** ParameterEJB");
80 }
81
82
83
86 public void ejbPassivate() {
87 parameterDao = null;
88 debug = null;
89 }
90
91
92
93
94
101 public void ejbCreate(String companyId, Long userId) {
102
103 this.companyId = companyId;
104 this.userId = userId;
105 try {
106 getDao();
107 }
108 catch(DAOException se) {
109 throw new RuntimeException(se.getMessage());
110 }
111 }
112
113
114
117 public void ejbRemove() { }
118
119
120
121
122
130 public ArrayList loadParamLevelsName() throws DAOException {
131 debug.println("load ParamLevelsName service");
132 ArrayList answer = null;
133 try {
134 getDao();
135 answer = parameterDao.loadParamLevelsName();
136 }
137 catch(DAOException se) {
138 debug.println("DAOException " + se);
139 throw new DAOException(se.getMessage());
140 }
141 catch(Exception ex) {
142 throw new EJBException(ex.getMessage());
143 }
144 return answer;
145 }
146
147
148
160 public ArrayList updateParamLevelsName(ArrayList items)
161 throws DAOException {
162 debug.println("updateParamLevelsName service");
163 ArrayList answer = null;
164 try {
165 getDao();
166 answer = parameterDao.updateParamLevelsName(items);
167 }
168 catch(DAOException se) {
169 debug.println("DAOException: " + se);
170 throw new DAOException(se.getMessage());
171 }
172 catch(Exception ex) {
173 throw new EJBException(ex.getMessage());
174 }
175 return answer;
176 }
177
178
179
187 public CodeDescription[] listParamLevel1Points()
188 throws DAOException {
189 debug.println("list ParamLevel1Points service");
190 CodeDescription[] answer = null;
191 try {
192 getDao();
193 answer = parameterDao.listParamLevel1Points();
194 }
195 catch(DAOException se) {
196 debug.println("DAOException " + se);
197 throw new DAOException(se.getMessage());
198 }
199 catch(Exception ex) {
200 throw new EJBException(ex.getMessage());
201 }
202 return answer;
203 }
204
205
206
220 public ArrayList applyItemsParamLevel1Points(ArrayList items)
221 throws DAOException {
222 debug.println("applyItemsParamLevel1Points service");
223 ArrayList answer = null;
224 try {
225 getDao();
226 answer = parameterDao.applyItemsParamLevel1Points(items);
227 }
228 catch(DAOException se) {
229 debug.println("DAOException: " + se);
230 throw new DAOException(se.getMessage());
231 }
232 catch(Exception ex) {
233 throw new EJBException(ex.getMessage());
234 }
235 return answer;
236 }
237
238
239
247 public CodeDescription[] listParamLevel2Points()
248 throws DAOException {
249 debug.println("list ParamLevel2Points service");
250 CodeDescription[] answer = null;
251 try {
252 getDao();
253 answer = parameterDao.listParamLevel2Points();
254 }
255 catch(DAOException se) {
256 debug.println("DAOException " + se);
257 throw new DAOException(se.getMessage());
258 }
259 catch(Exception ex) {
260 throw new EJBException(ex.getMessage());
261 }
262 return answer;
263 }
264
265
266
280 public ArrayList applyItemsParamLevel2Points(ArrayList items)
281 throws DAOException {
282 debug.println("applyItemsParamLevel2Points service");
283 ArrayList answer = null;
284 try {
285 getDao();
286 answer = parameterDao.applyItemsParamLevel2Points(items);
287 }
288 catch(DAOException se) {
289 debug.println("DAOException: " + se);
290 throw new DAOException(se.getMessage());
291 }
292 catch(Exception ex) {
293 throw new EJBException(ex.getMessage());
294 }
295 return answer;
296 }
297
298
299
300
301
309 public ArrayList loadParamSearchValues() throws DAOException {
310 debug.println("load ParamSearchValues service");
311 ArrayList answer = null;
312 try {
313 getDao();
314 answer = parameterDao.loadParamSearchValues();
315 }
316 catch(DAOException se) {
317 debug.println("DAOException " + se);
318 throw new DAOException(se.getMessage());
319 }
320 catch(Exception ex) {
321 throw new EJBException(ex.getMessage());
322 }
323 return answer;
324 }
325
326
327
339 public ArrayList updateParamSearchValues(ArrayList items)
340 throws DAOException {
341 debug.println("update ParamSearchValues service");
342 ArrayList answer = null;
343 try {
344 getDao();
345 answer = parameterDao.updateParamSearchValues(items);
346 }
347 catch(DAOException se) {
348 debug.println("DAOException: " + se);
349 throw new DAOException(se.getMessage());
350 }
351 catch(Exception ex) {
352 throw new EJBException(ex.getMessage());
353 }
354 return answer;
355 }
356
357
358
359
368 public ArrayList listParamRestrictions() throws DAOException {
369
370 debug.println("listParamRestrictions service");
371 ArrayList answer = null;
372 try {
373 getDao();
374 answer = parameterDao.listParamRestrictions();
375 }
376 catch(DAOException se) {
377 debug.println("DAOException: " + se);
378 throw new DAOException(se.getMessage());
379 }
380 catch(Exception ex) {
381 throw new EJBException(ex.getMessage());
382 }
383 return answer;
384 }
385
386
387
399 public ArrayList updateParamRestrictions(Hashtable items)
400 throws DAOException {
401
402 debug.println("updateParamRestrictions service");
403 ArrayList answer = null;
404 try {
405 getDao();
406 answer = parameterDao.updateParamRestrictions(items);
407 }
408 catch(DAOException se) {
409 debug.println("DAOException: " + se);
410 throw new DAOException(se.getMessage());
411 }
412 catch(Exception ex) {
413 throw new EJBException(ex.getMessage());
414 }
415 return answer;
416 }
417
418
419
420
429 public ParameterModel listParamValues(String codeParamater)
430 throws DAOException {
431
432 debug.println("listParamValues service");
433 ParameterModel answer = null;
434 try {
435 getDao();
436 answer = parameterDao.listParamValues(codeParamater);
437 }
438 catch(DAOException se) {
439 debug.println("DAOException: " + se);
440 throw new DAOException(se.getMessage());
441 }
442 catch(Exception ex) {
443 throw new EJBException(ex.getMessage());
444 }
445 return answer;
446 }
447
448
449
456 public Hashtable loadLevel1Code() throws DAOException {
457
458 debug.println("loadLevel1Code service");
459 Hashtable level1Code = null;
460 try {
461 getDao();
462 level1Code = parameterDao.loadLevel1Code();
463 }
464 catch(DAOException se) {
465 debug.println("DAOException: " + se);
466 throw new DAOException(se.getMessage());
467 }
468 catch(Exception ex) {
469 throw new EJBException(ex.getMessage());
470 }
471 return level1Code;
472 }
473
474
475
482 public Hashtable loadLevel2Code() throws DAOException {
483
484 debug.println("loadLevel2Code service");
485 Hashtable level2Code = null;
486 try {
487 getDao();
488 level2Code = parameterDao.loadLevel2Code();
489 }
490 catch(DAOException se) {
491 debug.println("DAOException: " + se);
492 throw new DAOException(se.getMessage());
493 }
494 catch(Exception ex) {
495 throw new EJBException(ex.getMessage());
496 }
497 return level2Code;
498 }
499
500
501
515 public String updateParamValues(ParameterValue items, Hashtable level1Code,
516 Hashtable level2Code) throws DAOException {
517
518 debug.println("updateParamValues service");
519 String answer = null;
520 try {
521 getDao();
522 answer = parameterDao.updateParamValues(items, level1Code, level2Code);
523 }
524 catch(DAOException se) {
525 debug.println("DAOException: " + se);
526 throw new DAOException(se.getMessage());
527 }
528 catch(Exception ex) {
529 throw new EJBException(ex.getMessage());
530 }
531 return answer;
532 }
533
534
535
547 public ParameterModel verifyParamValues(ParameterValue items)
548 throws DAOException {
549
550 debug.println("verifyParamValues service");
551 ParameterModel answer = null;
552 try {
553 getDao();
554 answer = parameterDao.verifyParamValues(items);
555 }
556 catch(DAOException se) {
557 debug.println("DAOException: " + se);
558 throw new DAOException(se.getMessage());
559 }
560 catch(Exception ex) {
561 throw new EJBException(ex.getMessage());
562 }
563 return answer;
564 }
565
566
567
568
574 private ParameterDAO getDao()
575 throws DAOException {
576 if(parameterDao == null) {
577 parameterDao =
578 new ParameterDAO(companyId, userId);
579 }
580 return parameterDao;
581 }
582 }
583