KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > xmla > XMLA_OlapModelTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.xmla;
14
15 import java.io.IOException JavaDoc;
16 import java.net.URL JavaDoc;
17
18 import org.apache.log4j.Logger;
19 import org.xml.sax.SAXException JavaDoc;
20
21 import com.tonbeller.jpivot.core.Model;
22 import com.tonbeller.jpivot.core.ModelFactory;
23 import com.tonbeller.jpivot.olap.model.OlapException;
24 import com.tonbeller.jpivot.olap.model.OlapModel;
25 import com.tonbeller.jpivot.tags.OlapModelTag;
26 import com.tonbeller.wcf.controller.RequestContext;
27
28 /**
29  * JSP tag for XMLA Olap Model
30  */

31 public class XMLA_OlapModelTag extends OlapModelTag {
32   private static Logger logger = Logger.getLogger(XMLA_OlapModelTag.class);
33  
34   private String JavaDoc config = null;
35   private String JavaDoc uri = null; //"http://TBNTSRV3/XML4A/msxisapi.dll";
36
private String JavaDoc catalog = null; //"Foodmart 2000";
37
private String JavaDoc dataSource = null; //"Provider=MSOLAP;Data Source=local";
38

39   protected OlapModel getOlapModel(RequestContext context) throws SAXException JavaDoc, IOException JavaDoc, OlapException {
40
41     URL JavaDoc url;
42     if (config == null)
43       url = getClass().getResource("config.xml");
44     else
45       url = pageContext.getServletContext().getResource(config);
46
47     // let Digester create a model from config input
48
// the config input stream MUST refer to the XMLA_Model class
49
// <model class="com.tonbeller.bii.xmla.XMLA_Model"> is required
50
Model model = ModelFactory.instance(url);
51
52     if (!(model instanceof XMLA_Model))
53       throw new OlapException("invalid class attribute for model tag, resource=" + config);
54
55     XMLA_Model xm = (XMLA_Model) model;
56     xm.setUri(uri);
57     xm.setDataSource(dataSource);
58     xm.setCatalog(catalog);
59     xm.setMdxQuery(getBodyContent().getString());
60
61     return xm;
62   }
63
64   /**
65    * Returns the config.
66    * @return String
67    */

68   public String JavaDoc getConfig() {
69     return config;
70   }
71
72   /**
73    * Sets the config.
74    * @param config The config to set
75    */

76   public void setConfig(String JavaDoc config) {
77     this.config = config;
78   }
79
80   /**
81    * Returns the catalog.
82    * @return String
83    */

84   public String JavaDoc getCatalog() {
85     return catalog;
86   }
87
88   /**
89    * Returns the dataSource.
90    * @return String
91    */

92   public String JavaDoc getDataSource() {
93     return dataSource;
94   }
95
96   /**
97    * Returns the uri.
98    * @return String
99    */

100   public String JavaDoc getUri() {
101     return uri;
102   }
103
104   /**
105    * Sets the catalog.
106    * @param catalog The catalog to set
107    */

108   public void setCatalog(String JavaDoc catalog) {
109     this.catalog = catalog;
110   }
111
112   /**
113    * Sets the dataSource.
114    * @param dataSource The dataSource to set
115    */

116   public void setDataSource(String JavaDoc dataSource) {
117     this.dataSource = dataSource;
118   }
119
120   /**
121    * Sets the uri.
122    * @param uri The uri to set
123    */

124   public void setUri(String JavaDoc uri) {
125     this.uri = uri;
126   }
127
128 } // End XMLA_OlapModelTag
129
Popular Tags