KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > web > controller > analysis > ProjectContextAjaxServlet


1 package org.openi.web.controller.analysis;
2
3 import java.util.Iterator JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7
8 import org.ajaxtags.helpers.AjaxXmlBuilder;
9 import org.ajaxtags.servlets.BaseAjaxServlet;
10 import org.apache.log4j.Logger;
11 import org.openi.analysis.Datasource;
12 import org.openi.project.ProjectContext;
13 import org.openi.xmla.XmlaConnector;
14
15
16 public class ProjectContextAjaxServlet extends BaseAjaxServlet {
17     private static Logger logger = Logger.getLogger(ProjectContextAjaxServlet.class);
18
19     public ProjectContextAjaxServlet() {
20         super();
21         
22     }
23
24     public String JavaDoc getXmlContent(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
25         ProjectContext projectContext = (ProjectContext)request.getSession().getAttribute("projectContext");
26         
27         String JavaDoc targetDatasource = request.getParameter("targetDatasource");
28         
29         String JavaDoc xmlContent = null;
30         if(targetDatasource != null & targetDatasource.length()>0){
31             logger.debug("discovering cubes for: " + targetDatasource);
32             Datasource datasource = projectContext.getDatasource(targetDatasource);
33             Iterator JavaDoc cubes = new XmlaConnector().getCubeList(datasource.getServer(), datasource.getCatalog(), datasource.getUsername(), datasource.getPassword()).iterator();
34             
35             AjaxXmlBuilder builder = new AjaxXmlBuilder();
36             while(cubes.hasNext()){
37                 String JavaDoc cubeName = (String JavaDoc)cubes.next();
38                 builder.addItem(cubeName, cubeName);
39             }
40             xmlContent = builder.toString();
41         }
42         
43         String JavaDoc action = request.getParameter("action");
44         if(action !=null && action.length()>0){
45             if("getOverviewKeys".equalsIgnoreCase(action)){
46                 AjaxXmlBuilder builder = new AjaxXmlBuilder();
47                 Iterator JavaDoc overviewKeys = projectContext.getProject().getOverviews().keySet().iterator();
48                 while(overviewKeys.hasNext()){
49                     String JavaDoc key = (String JavaDoc)overviewKeys.next();
50                     builder.addItem(key, key);
51                 }
52                 xmlContent = builder.toString();
53             }
54         }
55         
56         return xmlContent;
57     }
58
59 }
60
Popular Tags