1 package com.instantbank.lettertemplate.control.ejb.handlers;
2
3 import java.util.Hashtable;
4
5 import java.rmi.RemoteException;
6 import javax.naming.InitialContext;
7 import javax.naming.NamingException;
8 import javax.ejb.CreateException;
9 import javax.ejb.DuplicateKeyException;
10 import javax.ejb.FinderException;
11
12 import com.instantbank.lettertemplate.control.event.CategoryEvent;
13 import com.instantbank.lettertemplate.control.event.LetterTemplateEvent;
14 import com.instantbank.lettertemplate.control.LetterTemplateEventException;
15
16 import com.instantbank.component.lettertemplate.ejb.LetterTemplate;
17 import com.instantbank.component.job.ejb.Job;
18
19 import com.instantbank.common.utilcomponents.Debug;
20 import com.instantbank.common.utilcomponents.LetterTemplateGlobals;
21
22
28 public class CategoryHandler extends StateHandlerSupport {
29
30 private Debug debug = null;
31
32
33
40 public Object perform(LetterTemplateEvent event)
41 throws LetterTemplateEventException {
42 debug = new Debug();
43 debug.setDebugginOn(true);
44 debug.setPreMessage("** CategoryHandler-services tier: ");
45
46 Object answer = "";
47 CategoryEvent ce = (CategoryEvent)event;
48
49 switch (ce.getActionType()) {
50
51 case CategoryEvent.LIST_CATEGORIES:
52 {
53 debug.println("LIST_CATEGORIES event");
54 try {
55 LetterTemplate letterTemplate
56 = machine.getLetterTemplateControllerEJB()
57 .getLetterTemplate
58 (ce.getCompanyId(), ce.getUserId());
59
60
61 answer = letterTemplate.loadCategories();
62
63 }
64 catch(Exception e) {
65
66
67 throw new LetterTemplateEventException(e.getMessage());
68 }
69
70 }
71 break;
72 case CategoryEvent.UPDATE_CATEGORIES:
73 {
74 debug.println("UPDATE_CATEGORIES event");
75 try {
76 LetterTemplate letterTemplate
77 = machine.getLetterTemplateControllerEJB()
78 .getLetterTemplate
79 (ce.getCompanyId(), ce.getUserId());
80
81
82 answer = letterTemplate.applyItemsCategory(ce.getItems());
83 }
84 catch(Exception e) {
85 throw new LetterTemplateEventException(e.getMessage());
86 }
87
88 }
89 break;
90 default:
91 debug.println("Error: not implemented yet");
92 break;
93 }
94 return answer;
95 }
96 }
97
98