1    package com.instantbank.collections.collectionsActivities.web;
2    
3    import java.io.ByteArrayInputStream;
4    import java.io.Serializable;
5    import oracle.xml.parser.v2.DOMParser;
6    import oracle.xml.parser.v2.XMLDocument;
7    import org.w3c.dom.Node;
8    import org.w3c.dom.NodeList;
9    import com.instantbank.collections.collectionsActivities.ejb.ActionResultServices;
10   import com.instantbank.collections.collectionsActivities.ejb.ActionResultServicesHome;
11   import com.instantbank.collections.util.InstantbankException;
12   import com.instantbank.collections.util.ServiceLocator;
13   import com.instantbank.collections.util.StringFormat;
14   
15   
16   public class ActionsResultsBean
17       implements Serializable {
18   
19     private String controller;
20     private XMLDocument xmlDoc;
21   
22   
23     public ActionsResultsBean() { }
24   
25   
26     public String getActionOptionsList() throws InstantbankException {
27       NodeList FirstTag;
28       NodeList FirstChild;
29       String Description = new String("");
30       String Code = new String("");
31       String Id = new String("");
32       String s = new String("");
33   
34       try {
35         s = "";
36         FirstTag = xmlDoc.getElementsByTagName("ActionList");
37         FirstTag = FirstTag.item(0).getChildNodes();
38         for(int i = 0; i < FirstTag.getLength(); i++) {
39           FirstChild = FirstTag.item(i).getChildNodes();
40           for(int j = 0; j < FirstChild.getLength(); j++) {
41             Node n;
42             n = FirstChild.item(j);
43             if(n.getNodeName().equals("description")) {
44               Description = n.getChildNodes().item(0).getNodeValue();
45             }
46             else if(n.getNodeName().equals("id")) {
47               Id = n.getChildNodes().item(0).getNodeValue();
48             }
49             else if(n.getNodeName().equals("code")) {
50               Code = n.getChildNodes().item(0).getNodeValue();
51             }
52           }
53           s += "<option value=\"" + Id + "\">" + Description + "</option>";
54         }
55       }
56       catch(Exception e) {}
57       return s;
58     }
59   
60   
61     public String getActionCodeOptionsList() throws InstantbankException {
62       NodeList FirstTag;
63       NodeList FirstChild;
64       String Description = new String("");
65       String Code = new String("");
66       String Id = new String("");
67       String s = new String("");
68   
69       try {
70         s = "";
71         FirstTag = xmlDoc.getElementsByTagName("ActionList");
72         FirstTag = FirstTag.item(0).getChildNodes();
73         for(int i = 0; i < FirstTag.getLength(); i++) {
74           FirstChild = FirstTag.item(i).getChildNodes();
75           for(int j = 0; j < FirstChild.getLength(); j++) {
76             Node n;
77             n = FirstChild.item(j);
78             if(n.getNodeName().equals("description")) {
79               Description = n.getChildNodes().item(0).getNodeValue();
80             }
81             else if(n.getNodeName().equals("id")) {
82               Id = n.getChildNodes().item(0).getNodeValue();
83             }
84             else if(n.getNodeName().equals("code")) {
85               Code = n.getChildNodes().item(0).getNodeValue();
86             }
87           }
88           s += "<option value=\"" + Id + "\">" + Code + "</option>";
89         }
90       }
91       catch(Exception e) {}
92       return s;
93     }
94   
95   
96     public String getResultsOptionsList() throws InstantbankException {
97       NodeList FirstTag;
98       NodeList FirstChild;
99       String Description = new String("");
100      String Code = new String("");
101      String Id = new String("");
102      String s = new String("");
103  
104      try {
105        s = "";
106        FirstTag = xmlDoc.getElementsByTagName("ResultList");
107        FirstTag = FirstTag.item(0).getChildNodes();
108        for(int i = 0; i < FirstTag.getLength(); i++) {
109          FirstChild = FirstTag.item(i).getChildNodes();
110          for(int j = 0; j < FirstChild.getLength(); j++) {
111            Node n;
112            n = FirstChild.item(j);
113            if(n.getNodeName().equals("description")) {
114              Description = n.getChildNodes().item(0).getNodeValue();
115            }
116            else if(n.getNodeName().equals("id")) {
117              Id = n.getChildNodes().item(0).getNodeValue();
118            }
119            else if(n.getNodeName().equals("code")) {
120              Code = n.getChildNodes().item(0).getNodeValue();
121            }
122          }
123          s += "<option value=\"" + Id + "\">" + StringFormat.toSafeHTMLString(Description) + " " + StringFormat.toSafeHTMLString(Code) + "</option>";
124        }
125      }
126      catch(Exception e) {}
127      return s;
128    }
129  
130  
131    public void Initialize(Long companyId) throws InstantbankException {
132      ActionResultServicesHome home;
133      ActionResultServices services;
134      ByteArrayInputStream stream;
135      DOMParser docParser = new DOMParser();
136      String name;
137      String xml;
138  
139      try {
140        home = (ActionResultServicesHome)ServiceLocator.instance().createEJB("ActionResultServicesHome", ActionResultServicesHome.class, false);
141        services = home.create();
142        xml = services.getLists(companyId);
143        xmlDoc = null;
144        stream = new ByteArrayInputStream(xml.getBytes());
145        docParser.setValidationMode(false);
146        docParser.parse(stream);
147        xmlDoc = docParser.getDocument();
148      }
149      catch(Exception e) {}
150    }
151  }
152  
153