KickJava   Java API By Example, From Geeks To Geeks.

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


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.Reader JavaDoc;
16 import java.io.StringReader JavaDoc;
17 import java.util.ArrayList JavaDoc;
18 import java.util.Collection JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Locale JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import java_cup.runtime.Symbol;
26
27 import javax.servlet.ServletContext JavaDoc;
28 import javax.servlet.http.HttpSessionBindingEvent JavaDoc;
29
30 import org.apache.log4j.Logger;
31
32 import com.tonbeller.jpivot.core.Extension;
33 import com.tonbeller.jpivot.core.ModelChangeEvent;
34 import com.tonbeller.jpivot.core.ModelChangeListener;
35 import com.tonbeller.jpivot.olap.mdxparse.Exp;
36 import com.tonbeller.jpivot.olap.mdxparse.Formula;
37 import com.tonbeller.jpivot.olap.mdxparse.FunCall;
38 import com.tonbeller.jpivot.olap.mdxparse.Lexer;
39 import com.tonbeller.jpivot.olap.mdxparse.Literal;
40 import com.tonbeller.jpivot.olap.mdxparse.ParsedQuery;
41 import com.tonbeller.jpivot.olap.mdxparse.parser;
42 import com.tonbeller.jpivot.olap.model.Dimension;
43 import com.tonbeller.jpivot.olap.model.Hierarchy;
44 import com.tonbeller.jpivot.olap.model.Level;
45 import com.tonbeller.jpivot.olap.model.Member;
46 import com.tonbeller.jpivot.olap.model.OlapDiscoverer;
47 import com.tonbeller.jpivot.olap.model.OlapException;
48 import com.tonbeller.jpivot.olap.model.OlapItem;
49 import com.tonbeller.jpivot.olap.model.OlapModel;
50 import com.tonbeller.jpivot.olap.model.Result;
51 import com.tonbeller.jpivot.olap.navi.SortRank;
52 import com.tonbeller.jpivot.olap.query.ExpBean;
53 import com.tonbeller.jpivot.olap.query.MdxOlapModel;
54 import com.tonbeller.jpivot.olap.query.PositionNodeBean;
55 import com.tonbeller.jpivot.olap.query.Quax;
56 import com.tonbeller.jpivot.olap.query.QuaxBean;
57 import com.tonbeller.jpivot.olap.query.QueryAdapter;
58 import com.tonbeller.jpivot.util.TreeNode;
59 /**
60  * Model for XMLA
61  */

62 public class XMLA_Model extends MdxOlapModel implements OlapModel, QueryAdapter.QueryAdapterHolder {
63
64   static Logger logger = Logger.getLogger(XMLA_Model.class);
65
66   private String JavaDoc ID = null;
67
68   private String JavaDoc uri = null; //"http://TBNTSRV3/XML4A/msxisapi.dll";
69
private String JavaDoc user = null;
70   private String JavaDoc password = null;
71   private String JavaDoc catalog = null; //"Foodmart 2000";
72
private String JavaDoc dataSource = null; // "Provider=MSOLAP.2;Data Source=local";
73

74   private String JavaDoc mdxQuery;
75   private String JavaDoc currentMdx;
76
77   private ParsedQuery pQuery = null;
78
79   private XMLA_Result result = null;
80
81   private List JavaDoc aDimensions = new ArrayList JavaDoc();
82   private List JavaDoc aHierarchies = new ArrayList JavaDoc();
83   private List JavaDoc aLevels = new ArrayList JavaDoc();
84   private List JavaDoc aMeasures = new ArrayList JavaDoc();
85   private List JavaDoc aMembers = new ArrayList JavaDoc();
86
87   private XMLA_QueryAdapter queryAdapter = null;
88
89   private String JavaDoc cube = null; // save cube name
90
private boolean isNewCube = false;
91   private XMLA_SOAP soap = null;
92
93   private boolean isInitialized = false;
94   private Locale JavaDoc loc = null;
95
96   // Cell properties are encoded as FONT_SIZE values
97
private Map JavaDoc calcMeasurePropMap;
98
99   /** default constructor
100    */

101   public XMLA_Model() {
102
103     //System.setProperty("http.proxyHost", "localhost"); // "proxy.tonbeller.com"
104
//System.setProperty("http.proxyPort", "80");
105
this.mdxQuery = null;
106     this.currentMdx = null;
107
108     addModelChangeListener(new ModelChangeListener() {
109       public void modelChanged(ModelChangeEvent e) {
110         result = null; // will force re-execution of query
111
}
112
113       public void structureChanged(ModelChangeEvent e) {
114         result = null; // will force re-execution of query
115
}
116     });
117   }
118
119   /**
120    *
121    * @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
122    */

123   public void initialize() throws OlapException {
124     logger.info(this);
125
126     boolean logInfo = logger.isInfoEnabled();
127
128     if (catalog == null)
129       throw new OlapException("XMLA Model requires catalog specification");
130     // do we have a special locale setting?
131
// if yes, promote it to the connection
132
loc = getLocale(); // Locale.GERMANY
133
if (loc != null) {
134       if (logInfo) {
135         String JavaDoc msg = "Locale language=" + loc.getLanguage() + " Country=" + loc.getCountry();
136         logger.info(msg);
137       }
138     }
139
140     if (dataSource != null && dataSource.length() > 0)
141       soap = new XMLA_SOAP(uri, user, password, dataSource);
142     else
143       // discover yourself
144
soap = new XMLA_SOAP(uri, user, password);
145
146     if (logInfo) {
147       List JavaDoc dsprops = soap.discoverDSProps();
148       for (Iterator JavaDoc iter = dsprops.iterator(); iter.hasNext();) {
149         OlapItem oi = (OlapItem) iter.next();
150         Map JavaDoc pmap = oi.getProperties();
151         logger.info("Property: " + oi.getName());
152         for (Iterator JavaDoc iterator = pmap.keySet().iterator(); iterator.hasNext();) {
153           Object JavaDoc keyo = iterator.next();
154           logger.info(keyo + "=" + pmap.get(keyo));
155         }
156       }
157     }
158     parse(mdxQuery);
159     queryAdapter = new XMLA_QueryAdapter(this);
160     XMLA_SortRank sortExt = (XMLA_SortRank) getExtension(SortRank.ID);
161     if (sortExt != null)
162       sortExt.reset();
163
164     isInitialized = true;
165
166     // as initialization is complete, notify extensions
167
Map JavaDoc extMap = getExtensions();
168     Collection JavaDoc extensions = extMap.values();
169     for (Iterator JavaDoc iter = extensions.iterator(); iter.hasNext();) {
170       Extension extension = (Extension) iter.next();
171       extension.modelInitialized();
172     }
173     initCubeMetaData();
174     isNewCube = false;
175     calcMeasurePropMap = new HashMap JavaDoc();
176   }
177
178   /**
179    * Sets the mdxQuery.
180    * @param mdxQuery The mdxQuery to set
181    */

182   public void setMdxQuery(String JavaDoc mdxQuery) {
183     this.mdxQuery = mdxQuery;
184     this.currentMdx = mdxQuery.replace('\r', ' ');
185     if (logger.isInfoEnabled())
186       logger.info("setMdxQuery:" + mdxQuery);
187   }
188
189   /**
190    * Let Mondrian parse and execute the query
191    * @see com.tonbeller.jpivot.olap.model.OlapModel#getResult()
192    * @return Result of Query Execution
193    */

194   public synchronized Result getResult() throws OlapException {
195
196     if (result != null)
197       return result;
198
199     if (!isInitialized) {
200       logger.fatal("Model not initialized");
201       throw new OlapException("Model not initialized");
202     }
203
204     // initialize cube meta data
205
if (isNewCube)
206       initCubeMetaData();
207     isNewCube = false;
208
209     queryAdapter.onExecute();
210
211     long lBefore = System.currentTimeMillis();
212     logger.debug(currentMdx);
213     XMLA_Result res = new XMLA_Result(this, soap, catalog, currentMdx);
214     long lTime = System.currentTimeMillis() - lBefore;
215     logger.debug("Time for executeQuery(ms)=" + lTime);
216     // no exception gotten
217
result = res;
218
219     queryAdapter.afterExecute(result);
220
221     return result;
222   }
223   
224   /**
225    * get the result variable without any action
226    *
227    * @return current XMLA result, or null
228    */

229   XMLA_Result currentResult() {
230     return result;
231   }
232
233   //dsf
234
public synchronized Result getDrillResult() throws OlapException {
235
236     if (result != null)
237       return result;
238
239     if (!isInitialized) {
240       logger.fatal("Model not initialized");
241       throw new OlapException("Model not initialized");
242     }
243
244     // initialize cube meta data
245
if (isNewCube)
246       initCubeMetaData();
247     isNewCube = false;
248
249     // dsf : call onExecuteDrill
250
queryAdapter.onExecuteDrill();
251
252     long lBefore = System.currentTimeMillis();
253     logger.debug(currentMdx);
254     XMLA_Result res = new XMLA_Result(this, soap, catalog, currentMdx, true);
255     long lTime = System.currentTimeMillis() - lBefore;
256     logger.debug("Time for executeQuery(ms)=" + lTime);
257     // no exception gotten
258
result = res;
259     queryAdapter.afterExecute(result);
260     return result;
261   }
262
263   /**
264    * get the MDX for the user to edit
265    * @return current MDX statement
266    * @see com.tonbeller.jpivot.olap.query.MdxOlapModel#getCurrentMdx()
267    */

268   public String JavaDoc getCurrentMdx() {
269     if (queryAdapter != null)
270       return queryAdapter.getCurrentMdx();
271     else
272       return this.mdxQuery;
273   }
274
275   /**
276    * set the mdx entered by the user.
277    * @task error handling: restore mdx in case of error
278    * @throws OlapException if the syntax is invalid
279    * @param mdxQuery
280    */

281   public void setUserMdx(String JavaDoc mdxQuery) throws OlapException {
282     if (this.currentMdx.equals(mdxQuery))
283       return;
284
285     parse(mdxQuery);
286
287     this.mdxQuery = mdxQuery;
288     result = null;
289     queryAdapter = new XMLA_QueryAdapter(this);
290     XMLA_SortRank sortExt = (XMLA_SortRank) getExtension(SortRank.ID);
291     if (sortExt != null)
292       sortExt.reset();
293
294     if (logger.isInfoEnabled())
295       logger.info("setUserMdx =" + mdxQuery);
296     this.currentMdx = mdxQuery.replace('\r', ' ');
297   }
298
299   /**
300    * Returns the mdxQuery.
301    * @return String
302    */

303   String JavaDoc getMdxQuery() {
304     return mdxQuery;
305   }
306
307   /**
308    * Sets the currentMdx.
309    * @param currentMdx The currentMdx to set
310    */

311   void setCurrentMdx(String JavaDoc currentMdx) {
312     this.currentMdx = currentMdx.replaceAll("\r", "");
313   }
314
315   /**
316    *
317    * @see com.tonbeller.jpivot.olap.model.OlapModel#getDimensions()
318    */

319   public Dimension[] getDimensions() {
320     return (Dimension[]) aDimensions.toArray(new Dimension[0]);
321   }
322
323   /**
324    * @see com.tonbeller.jpivot.olap.model.OlapModel#getMeasures()
325    */

326   public Member[] getMeasures() {
327     return (Member[]) aMeasures.toArray(new Member[0]);
328   }
329
330   /**
331    * session terminated, closing connections etc
332    * @task close connection here
333    */

334   public void destroy() {
335     super.destroy();
336   }
337
338   public Object JavaDoc getRootDecoree() {
339     return this;
340   }
341
342   /**
343    * lookup Dimension by unique name
344    * @param name
345    * @return Dimension
346    */

347   XMLA_Dimension lookupDimByUName(String JavaDoc uName) {
348
349     for (Iterator JavaDoc iter = aDimensions.iterator(); iter.hasNext();) {
350       XMLA_Dimension dim = (XMLA_Dimension) iter.next();
351       if (dim.getUniqueName().equals(uName))
352         return dim;
353     }
354
355     return null;
356   }
357
358   /**
359    * lookup hierarchy by unique name
360    * @param name
361    * @return Hierarchy
362    */

363   XMLA_Hierarchy lookupHierByUName(String JavaDoc uName) {
364
365     for (Iterator JavaDoc iter = aHierarchies.iterator(); iter.hasNext();) {
366       XMLA_Hierarchy hier = (XMLA_Hierarchy) iter.next();
367       if (hier.getUniqueName().equals(uName))
368         return hier;
369     }
370
371     return null;
372   }
373
374   /**
375    * lookup level by unique name
376    * @param name
377    * @return level
378    */

379   XMLA_Level lookupLevelByUName(String JavaDoc uName) {
380
381     for (Iterator JavaDoc iter = aLevels.iterator(); iter.hasNext();) {
382       XMLA_Level lev = (XMLA_Level) iter.next();
383       if (lev.getUniqueName().equals(uName))
384         return lev;
385     }
386
387     return null;
388   }
389
390   /**
391    * lookup member by unique name
392    * @param name
393    * @return Member
394    */

395   public Member lookupMemberByUName(String JavaDoc uName) {
396
397     for (Iterator JavaDoc iter = aMembers.iterator(); iter.hasNext();) {
398       XMLA_Member mem = (XMLA_Member) iter.next();
399       if (mem.getUniqueName().equals(uName))
400         return mem;
401     }
402
403     return null;
404   }
405
406   /**
407    * add all members for an hierarchy
408    * @param hier
409    */

410   /*
411    protected void addMembers(XMLA_Hierarchy hier) throws OlapException {
412    if (hier.isMembersGotten())
413    return;
414    try {
415    discoverMembers(hier.getUniqueName());
416    } catch (SOAPException ex) {
417    throw new OlapException("SOAP Error getting members");
418    }
419    
420    }
421    */

422
423   /** add single member
424    */

425   void addMember(XMLA_Member mem) {
426     aMembers.add(mem);
427   }
428
429   /** remove single member
430    */

431   public void removeMember(XMLA_Member mem) {
432     if (aMembers.contains(mem))
433       aMembers.remove(mem);
434   }
435
436   /**
437    * create a Memento bean object holding current state.
438    * @return Memento current state
439    */

440   public Object JavaDoc getBookmarkState(int levelOfDetail) {
441     try {
442       XMLA_Memento memento = new XMLA_Memento();
443       memento.setVersion(XMLA_Memento.CURRENT_VERSION);
444       memento.setUri(uri);
445       memento.setDataSource(dataSource);
446       memento.setCatalog(catalog);
447       memento.setUser(user);
448       memento.setPassword(password);
449       // set the MDX query string
450
// When the state is reset, this mdx will be parsed as the
451
// startup query.
452
memento.setMdxQuery(currentMdx);
453       boolean useQuax = queryAdapter.isUseQuax();
454       memento.setUseQuax(useQuax);
455       if (useQuax) {
456         XMLA_Quax[] quaxes = (XMLA_Quax[]) queryAdapter.getQuaxes();
457
458         QuaxBean[] quaxBeans = new QuaxBean[quaxes.length];
459         for (int i = 0; i < quaxes.length; i++) {
460           quaxBeans[i] = new QuaxBean();
461           beanFromQuax(quaxBeans[i], quaxes[i]);
462         } // for i quaxes
463

464         // set quaxes to memento
465
memento.setQuaxes(quaxBeans);
466       }
467       // axes swapped
468
memento.setAxesSwapped(queryAdapter.isSwapAxes());
469       // sorting
470
XMLA_SortRank sortExt = (XMLA_SortRank) getExtension(SortRank.ID);
471       if (sortExt != null)
472         storeSort(sortExt, memento);
473       // calc measure property assignment
474
if (calcMeasurePropMap != null)
475         memento.setCalcMeasurePropMap(calcMeasurePropMap);
476       return memento;
477     } catch (OlapException e) {
478       logger.error(null, e);
479       throw new RuntimeException JavaDoc(e);
480     }
481   }
482
483   /**
484    * restore state from Memento.
485    * @param Object state bean to be restored
486    */

487   public void setBookmarkState(Object JavaDoc state) {
488
489     XMLA_Memento memento = (XMLA_Memento) state;
490
491     mdxQuery = memento.getMdxQuery();
492     try {
493       if (isInitialized) {
494         // already initialized, only new query adapter needed
495

496         parse(mdxQuery);
497         queryAdapter = new XMLA_QueryAdapter(this);
498         XMLA_SortRank sortExt = (XMLA_SortRank) getExtension(SortRank.ID);
499         if (sortExt != null)
500           sortExt.reset();
501         isNewCube = false;
502       } else {
503
504         uri = memento.getUri();
505         dataSource = memento.getDataSource();
506         catalog = memento.getCatalog();
507         mdxQuery = memento.getMdxQuery();
508
509         // Regardless of any state, we will have to process the start MDX.
510
// It might contain WITH MEMBER declarations, which must not be lost.
511
// The start MDX is processed in the QueryAdapter c'tor.
512

513         initialize();
514       }
515
516       // need to get the result first, so that members are gotten
517
result = (XMLA_Result) getResult();
518     } catch (OlapException e) {
519       // should really not occur
520
String JavaDoc err = e.getMessage();
521       logger.fatal(err);
522       throw new RuntimeException JavaDoc(err);
523     }
524     boolean useQuax = memento.isUseQuax();
525     queryAdapter.setUseQuax(useQuax);
526
527     if (useQuax) {
528       // reset the Quaxes to current state
529
QuaxBean[] quaxBeans = memento.getQuaxes();
530       Quax quaxes[] = queryAdapter.getQuaxes();
531       // update the quaxes
532
try {
533         quaxesFromBeans(quaxes, quaxBeans);
534       } catch (OlapException e) {
535         throw new IllegalArgumentException JavaDoc(e.toString());
536       }
537     }
538     // sorting
539
XMLA_SortRank sortExt = (XMLA_SortRank) getExtension(SortRank.ID);
540     restoreSort(sortExt, memento);
541
542     // swap axes if neccessary
543
queryAdapter.setSwapAxes(memento.isAxesSwapped());
544
545     // calc measure property assignment
546
calcMeasurePropMap = memento.getCalcMeasurePropMap();
547     if (calcMeasurePropMap == null)
548       calcMeasurePropMap = new HashMap JavaDoc();
549     result = null;
550   }
551
552   /**
553    *
554    * @param rootBean
555    * @return
556    */

557   private TreeNode createPosTreeFromBean(PositionNodeBean rootBean) throws OlapException {
558     ExpBean expBean = rootBean.getReference(); // null for root
559
Exp exp;
560     if (expBean == null)
561       exp = null;
562     else
563       exp = (Exp) createExpFromBean(expBean);
564     TreeNode node = new TreeNode(exp);
565     PositionNodeBean[] beanChildren = rootBean.getChildren();
566     for (int i = 0; i < beanChildren.length; i++) {
567       TreeNode childNode = createPosTreeFromBean(beanChildren[i]);
568       node.addChildNode(childNode);
569     }
570     return node;
571   }
572
573   /**
574    *
575    * @param expBean
576    * @return
577    * @throws OlapException
578    */

579   protected Object JavaDoc createExpFromBean(ExpBean expBean) throws OlapException {
580     if (expBean.getType() == ExpBean.TYPE_MEMBER) {
581       XMLA_Member member = (XMLA_Member) lookupMemberByUName(expBean.getName());
582       if (member == null) {
583         retrieveMember(expBean.getName());
584       }
585       member = (XMLA_Member) lookupMemberByUName(expBean.getName());
586       if (member == null) {
587         // probably schema changed, cannot restore state
588
throw new OlapException("could not find member " + expBean.getName());
589       }
590       return member;
591     } else if (expBean.getType() == ExpBean.TYPE_FUNCALL) {
592       // FunCall
593
String JavaDoc name = expBean.getName();
594       ExpBean[] argBeans = expBean.getArgs();
595       Exp[] args = new Exp[argBeans.length];
596       for (int i = 0; i < argBeans.length; i++) {
597         args[i] = (Exp) createExpFromBean(argBeans[i]);
598       }
599
600       int synType = XMLA_Util.funCallSyntax(name);
601       FunCall f = new FunCall(name, args, synType);
602       return f;
603     } else if (expBean.getType() == ExpBean.TYPE_LEVEL) {
604       // Level
605
XMLA_Level lev = lookupLevelByUName(expBean.getName());
606       if (lev == null) {
607         // probably schema changed, cannot restore state
608
throw new OlapException("could not find Level " + expBean.getName());
609       }
610       return lev;
611     } else if (expBean.getType() == ExpBean.TYPE_HIER) {
612       // Hierarchy
613
XMLA_Hierarchy hier = lookupHierByUName(expBean.getName());
614       if (hier == null) {
615         // probably schema changed, cannot restore state
616
throw new OlapException("could not find Hierarchy " + expBean.getName());
617       }
618       return hier;
619     } else if (expBean.getType() == ExpBean.TYPE_DIM) {
620       // Dimension
621
XMLA_Dimension dim = lookupDimByUName(expBean.getName());
622       if (dim == null) {
623         // probably schema changed, cannot restore state
624
throw new OlapException("could not find Dimension " + expBean.getName());
625       }
626       return dim;
627     } else if (expBean.getType() == ExpBean.TYPE_STRING_LITERAL) {
628       // String literal
629
String JavaDoc str = (String JavaDoc) expBean.getLiteralValue();
630       return Literal.createString(str);
631     } else if (expBean.getType() == ExpBean.TYPE_INTEGER_LITERAL) {
632       // Integer literal
633
Integer JavaDoc iii = (Integer JavaDoc) expBean.getLiteralValue();
634       return Literal.create(iii);
635     } else if (expBean.getType() == ExpBean.TYPE_DOUBLE_LITERAL) {
636       // Double literal
637
Double JavaDoc ddd = (Double JavaDoc) expBean.getLiteralValue();
638       return Literal.create(ddd);
639     } else
640       throw new OlapException("Invalid ExpBean Type " + expBean.getType());
641   }
642
643   protected ExpBean createBeanFromExp(Object JavaDoc exp) throws OlapException {
644     ExpBean bean = new ExpBean();
645     if (exp instanceof Member) {
646       XMLA_Member m = (XMLA_Member) exp;
647       bean.setType(ExpBean.TYPE_MEMBER);
648       bean.setName(m.getUniqueName());
649       bean.setArgs(new ExpBean[0]);
650     } else if (exp instanceof FunCall) {
651       FunCall f = (FunCall) exp;
652       bean.setType(ExpBean.TYPE_FUNCALL);
653       bean.setName(f.getFunction());
654       ExpBean[] args = new ExpBean[f.getArgs().length];
655       for (int i = 0; i < args.length; i++) {
656         args[i] = createBeanFromExp(f.getArgs()[i]);
657       }
658       bean.setArgs(args);
659     } else if (exp instanceof Level) {
660       XMLA_Level lev = (XMLA_Level) exp;
661       bean.setType(ExpBean.TYPE_LEVEL);
662       bean.setName(lev.getUniqueName());
663       bean.setArgs(new ExpBean[0]);
664     } else if (exp instanceof Hierarchy) {
665       XMLA_Hierarchy hier = (XMLA_Hierarchy) exp;
666       bean.setType(ExpBean.TYPE_HIER);
667       bean.setName(hier.getUniqueName());
668       bean.setArgs(new ExpBean[0]);
669     } else if (exp instanceof Dimension) {
670       XMLA_Dimension dim = (XMLA_Dimension) exp;
671       bean.setType(ExpBean.TYPE_DIM);
672       bean.setName(dim.getUniqueName());
673       bean.setArgs(new ExpBean[0]);
674     } else if (exp instanceof Literal) {
675       Literal lit = (Literal) exp;
676       Object JavaDoc val = lit.getValueObject();
677       if (lit.type == Literal.TYPE_NUMERIC) {
678         if (val instanceof Integer JavaDoc)
679           bean.setType(ExpBean.TYPE_INTEGER_LITERAL);
680         else
681           bean.setType(ExpBean.TYPE_DOUBLE_LITERAL);
682       } else {
683         bean.setType(ExpBean.TYPE_STRING_LITERAL);
684       }
685       bean.setLiteralValue(val);
686       bean.setArgs(new ExpBean[0]);
687     } else {
688       logger.fatal("cannot create ExpBean type =" + exp.getClass().toString());
689     }
690     return bean;
691   }
692
693   /**
694    *
695    * @param mdxQuery
696    */

697   private void parse(String JavaDoc mdxQuery) throws OlapException {
698
699     // parse the query string
700
parser parser_obj;
701     Reader JavaDoc reader = new StringReader JavaDoc(mdxQuery);
702     parser_obj = new parser(new Lexer(reader));
703
704     Symbol parse_tree = null;
705     pQuery = null;
706     try {
707       parse_tree = parser_obj.parse();
708     } catch (Exception JavaDoc e) {
709       throw new OlapException(e);
710     }
711     pQuery = (ParsedQuery) parse_tree.value;
712     pQuery.afterParse();
713
714     String JavaDoc newCube = pQuery.getCube();
715     if (cube == null || !cube.equals(newCube)) {
716       isNewCube = true;
717       cube = newCube;
718     }
719   }
720
721   /**
722    * get meta data from mdx data source
723    */

724   private void initCubeMetaData() throws OlapException {
725
726     /*
727      // find out, whether this cube contains mandatory SAP variables
728      // SAP bug
729      // SAP variables are not returned fully,
730      // only data type and description.
731      if (this.isSAP()){
732      List sapvars = discoverer.discoverSapVar(catalog, pQuery.getCube());
733      }
734      */

735
736     // read dimensions
737
List JavaDoc dims = soap.discoverDim(catalog, pQuery.getCube());
738     evaluateDimensions(dims);
739
740     // read hierarchies
741
List JavaDoc hiers = soap.discoverHier(catalog, pQuery.getCube(), null);
742     evaluateHiers(hiers);
743
744     // now, as we got all hierarchies, assign them to the dimensions
745
// first, create HashMap of dimensions
746
HashMap JavaDoc hDim = new HashMap JavaDoc();
747     for (Iterator JavaDoc iter = aDimensions.iterator(); iter.hasNext();) {
748       XMLA_Dimension dim = (XMLA_Dimension) iter.next();
749       hDim.put(dim.getUniqueName(), dim);
750     }
751     for (Iterator JavaDoc iter = aHierarchies.iterator(); iter.hasNext();) {
752       XMLA_Hierarchy hier = (XMLA_Hierarchy) iter.next();
753       XMLA_Dimension dim = (XMLA_Dimension) hDim.get(hier.getDimUniqueName());
754       if (dim != null) {
755         dim.addHier(hier);
756         hier.setDimension(dim);
757       }
758     }
759
760     // read levels
761
List JavaDoc levels = soap.discoverLev(catalog, pQuery.getCube(), null, null);
762     evaluateLevels(levels);
763
764     // now, as we got all Levels, assign them to the hierarchies
765
// first, create HashMap of dimensions
766
HashMap JavaDoc hHier = new HashMap JavaDoc();
767     for (Iterator JavaDoc iter = aHierarchies.iterator(); iter.hasNext();) {
768       XMLA_Hierarchy hier = (XMLA_Hierarchy) iter.next();
769       hHier.put(hier.getUniqueName(), hier);
770     }
771     for (Iterator JavaDoc iter = aLevels.iterator(); iter.hasNext();) {
772       XMLA_Level lev = (XMLA_Level) iter.next();
773       XMLA_Hierarchy hier = (XMLA_Hierarchy) hHier.get(lev.getHierUniqueName());
774       if (hier != null) {
775         hier.addLevel(lev);
776         lev.setHierarchy(hier);
777       }
778     }
779
780     // now go through levels of hierarchy and set the child/parent pointers
781
for (Iterator JavaDoc iter = aHierarchies.iterator(); iter.hasNext();) {
782       XMLA_Hierarchy hier = (XMLA_Hierarchy) iter.next();
783       adjustLevels(hier);
784     }
785
786     // get all properties for the cube
787
// assign properties to levels (not SAP)
788
// assign properties to dimensions (SAP)
789
List JavaDoc propList = null;
790     try {
791       propList = soap.discoverProp(getCatalog(), getCube(), null, null, null);
792     } catch (OlapException e) {
793       // not handled
794
logger.error("?", e);
795     }
796
797     if (propList != null && propList.size() > 0) {
798       PropLoop: for (Iterator JavaDoc iterator = propList.iterator(); iterator.hasNext();) {
799         OlapItem poi = (OlapItem) iterator.next();
800         String JavaDoc name = poi.getName();
801         // what is the level for this property
802
// SAP: level information is garbage
803
String JavaDoc propType = poi.getProperty("PROPERTY_TYPE");
804         // 1 == MDPROP_MEMBER
805
// 2 = MDPROP_CELL
806
if (!"1".equals(propType))
807           continue PropLoop; // only member properties
808
String JavaDoc levUName = poi.getProperty("LEVEL_UNIQUE_NAME");
809         String JavaDoc dimUName = poi.getProperty("DIMENSION_UNIQUE_NAME");
810         String JavaDoc caption = poi.getCaption();
811         if (caption == null)
812           caption = name;
813         XMLA_Dimension dim = this.lookupDimByUName(dimUName);
814         if (this.isSAP() || this.isMondrian()) {
815           // dimension contain the properties
816
XMLA_MemberProp prop = new XMLA_MemberProp(name, caption, dim);
817           dim.addProp(prop);
818
819         } else {
820           // Microsoft, use Level
821
if (levUName != null && levUName.length() > 0) {
822             XMLA_Level level = lookupLevelByUName(levUName);
823             XMLA_MemberProp prop = new XMLA_MemberProp(name, caption, level);
824             level.addProp(prop);
825           }
826         }
827
828       }
829     }
830
831   }
832
833   /**
834    * set paren and child level
835    * @param hier
836    */

837   private void adjustLevels(XMLA_Hierarchy hier) {
838     XMLA_Level[] levels = (XMLA_Level[]) hier.getLevels();
839     XMLA_Level[] orderedLevels = new XMLA_Level[levels.length];
840     for (int i = 0; i < levels.length; i++) {
841       int num = levels[i].getDepth();
842       orderedLevels[num] = levels[i];
843     }
844     for (int i = 0; i < levels.length; i++) {
845       int num = levels[i].getDepth();
846       if (num > 0) {
847         levels[i].setParentLevel(orderedLevels[num - 1]);
848       } else {
849         levels[i].setParentLevel(null);
850       }
851
852       if (num < levels.length - 1) {
853         levels[i].setChildLevel(orderedLevels[num + 1]);
854       } else {
855         levels[i].setChildLevel(null);
856       }
857     }
858
859   }
860
861   /**
862    * Evaluate the result of Discovery MDSCHEMA_DIMENSIONS request
863    * @param dims list of dimension items
864    */

865   private void evaluateDimensions(List JavaDoc dims) {
866
867     for (Iterator JavaDoc iter = dims.iterator(); iter.hasNext();) {
868       OlapItem dimit = (OlapItem) iter.next();
869
870       XMLA_Dimension dim = new XMLA_Dimension();
871       dim.setName(dimit.getName());
872       dim.setCaption(dimit.getCaption());
873       dim.setUniqueName(dimit.getUniqueName());
874
875       String JavaDoc str = dimit.getProperty("DIMENSION_ORDINAL");
876       if (str != null)
877         dim.setOrdinal(Integer.parseInt(str));
878
879       str = dimit.getProperty("DIMENSION_TYPE");
880       if (str != null)
881         dim.setType(Integer.parseInt(str));
882
883       str = dimit.getProperty("DIMENSION_CARDINALITY");
884       if (str != null)
885         dim.setCardinality(Integer.parseInt(str));
886
887       str = dimit.getProperty("DEFAULT_HIERARCHY");
888       if (str != null)
889         dim.setDefaultHier(str);
890
891       str = dimit.getProperty("IS_VIRTUAL");
892       if (str != null)
893         dim.setVirtual(str.equals("true"));
894
895       str = dimit.getProperty("IS_READWRITE");
896       if (str != null)
897         dim.setReadWrite(str.equals("true"));
898
899       str = dimit.getProperty("DIMENSION_UNIQUE_SETTINGS");
900       if (str != null)
901         dim.setUniqueSettings(Integer.parseInt(str));
902
903       str = dimit.getProperty("DIMENSION_IS_VISIBLE");
904       if (str != null)
905         dim.setVisible(str.equals("true"));
906
907       aDimensions.add(dim);
908     }
909
910   }
911
912   /**
913    * Evaluate the result of Discovery MDSCHEMA_HIERARCHIES request
914    * @param hiers list of olap items
915    */

916   private void evaluateHiers(List JavaDoc hiers) {
917
918     for (Iterator JavaDoc iter = hiers.iterator(); iter.hasNext();) {
919       OlapItem hierit = (OlapItem) iter.next();
920
921       XMLA_Hierarchy hier = new XMLA_Hierarchy(this);
922       // hier.setName(hierit.getName());
923
hier.setCaption(hierit.getCaption());
924       hier.setUniqueName(hierit.getUniqueName());
925
926       String JavaDoc str = hierit.getProperty("HIERARCHY_CAPTION");
927       if (str != null)
928         hier.setCaption(str);
929
930       str = hierit.getProperty("DIMENSION_UNIQUE_NAME");
931       if (str != null)
932         hier.setDimUniqueName(str);
933
934       str = hierit.getProperty("DIMENSION_TYPE");
935       if (str != null)
936         hier.setDimType(Integer.parseInt(str));
937
938       str = hierit.getProperty("HIERARCHY_CARDINALITY");
939       if (str != null)
940         hier.setCardinality(Integer.parseInt(str));
941
942       str = hierit.getProperty("DEFAULT_MEMBER");
943       if (str != null)
944         hier.setDefaultMember(str);
945
946       str = hierit.getProperty("ALL_MEMBER");
947       if (str != null)
948         hier.setAllMember(str);
949
950       str = hierit.getProperty("STRUCTURE");
951       if (str != null)
952         hier.setStructure(Integer.parseInt(str));
953
954       str = hierit.getProperty("IS_VIRTUAL");
955       if (str != null)
956         hier.setVirtual(str.equals("true"));
957
958       str = hierit.getProperty("IS_READWRITE");
959       if (str != null)
960         hier.setReadWrite(str.equals("true"));
961
962       str = hierit.getProperty("DIMENSION_UNIQUE_SETTINGS");
963       if (str != null)
964         hier.setDimUniqueSettings(Integer.parseInt(str));
965
966       str = hierit.getProperty("DIMENSION_IS_VISIBLE");
967       if (str != null)
968         hier.setDimVisible(str.equals("true"));
969
970       str = hierit.getProperty("HIERARCHY_ORDINAL");
971       if (str != null)
972         hier.setOrdinal(Integer.parseInt(str));
973
974       str = hierit.getProperty("DIMENSION_IS_SHARED");
975       if (str != null)
976         hier.setDimShared(str.equals("true"));
977
978       aHierarchies.add(hier);
979     }
980   }
981
982   /**
983    * Evaluate the result of Discovery MDSCHEMA_LEVELS request
984    * @param levels List of OlapItems
985    */

986   private void evaluateLevels(List JavaDoc levels) {
987
988     for (Iterator JavaDoc iter = levels.iterator(); iter.hasNext();) {
989       OlapItem levit = (OlapItem) iter.next();
990       XMLA_Level lev = new XMLA_Level(this);
991       lev.setName(levit.getName());
992       lev.setCaption(levit.getCaption());
993       lev.setUniqueName(levit.getUniqueName());
994
995       String JavaDoc str = levit.getProperty("DIMENSION_UNIQUE_NAME");
996       if (str != null)
997         lev.setDimUniqueName(str);
998
999       str = levit.getProperty("HIERARCHY_UNIQUE_NAME");
1000      if (str != null)
1001        lev.setHierUniqueName(str);
1002
1003      str = levit.getProperty("LEVEL_NUMBER");
1004      if (str != null)
1005        lev.setNumber(Integer.parseInt(str));
1006
1007      str = levit.getProperty("LEVEL_CARDINALITY");
1008      if (str != null)
1009        lev.setCardinality(Integer.parseInt(str));
1010
1011      str = levit.getProperty("LEVEL_TYPE");
1012      if (str != null)
1013        lev.setType(Integer.parseInt(str));
1014
1015      str = levit.getProperty("CUSTOM_ROLLUP_SETTINGS");
1016      if (str != null)
1017        lev.setCustomRollupSettings(Integer.parseInt(str));
1018
1019      str = levit.getProperty("LEVEL_UNIQUE_SETTINGS");
1020      if (str != null)
1021        lev.setUniqueSettings(Integer.parseInt(str));
1022
1023      str = levit.getProperty("LEVEL_IS_VISIBLE");
1024      if (str != null)
1025        lev.setVisible(str.equals("true"));
1026
1027      str = levit.getProperty("LEVEL_ORDERING_PROPERTY");
1028      if (str != null)
1029        lev.setOrderingProperty(str);
1030
1031      str = levit.getProperty("LEVEL_DBTYPE");
1032      if (str != null)
1033        lev.setDbType(Integer.parseInt(str));
1034
1035      str = levit.getProperty("LEVEL_NAME_SQL_COLUMN_NAME");
1036      if (str != null)
1037        lev.setNameSqlColumnName(str);
1038
1039      str = levit.getProperty("LEVEL_KEY_SQL_COLUMN_NAME");
1040      if (str != null)
1041        lev.setKeySqlColumnName(str);
1042
1043      str = levit.getProperty("LEVEL_UNIQUE_NAME_SQL_COLUMN_NAME");
1044      if (str != null)
1045        lev.setUniqueNameSqlColumnName(str);
1046
1047      aLevels.add(lev);
1048    }
1049
1050  }
1051
1052  /**
1053   * retrieve the cube's members for a given level
1054   *
1055   * @throws OlapException
1056   */

1057  void completeLevel(XMLA_Level level) throws OlapException {
1058
1059    List JavaDoc mems = soap.discoverMem(catalog, cube, null, level.getHierUniqueName(), level
1060        .getUniqueName());
1061    // evaluate
1062
ArrayList JavaDoc aNewMembers = new ArrayList JavaDoc();
1063    ArrayList JavaDoc aAllMembers = new ArrayList JavaDoc();
1064    evaluateMembers(mems, aNewMembers, aAllMembers);
1065    aMembers.addAll(aNewMembers);
1066    level.setMembers(aAllMembers);
1067  }
1068
1069  /**
1070   * retrieve a members children
1071   * @throws OlapException
1072   */

1073  void retrieveMemberChildren(XMLA_Member member) throws OlapException {
1074    // potential killer
1075

1076    // 1=children
1077
List JavaDoc mems = soap.discoverMemTree(catalog, cube, member.getUniqueName(), 1);
1078
1079    // evaluate
1080
ArrayList JavaDoc aNewMembers = new ArrayList JavaDoc();
1081    ArrayList JavaDoc aAllMembers = new ArrayList JavaDoc();
1082    // one level, properties are delivered
1083
evaluateMembers(mems, aNewMembers, aAllMembers);
1084
1085    aMembers.addAll(aNewMembers);
1086    // assign children
1087
setMemberChildren(member, aAllMembers);
1088
1089  }
1090
1091  /**
1092   * retrieve a members parent
1093   * @throws OlapException
1094   */

1095  void retrieveMemberParent(XMLA_Member member) throws OlapException {
1096
1097    member.setParentOk(true);
1098    if (((XMLA_Level) member.getLevel()).getDepth() == 0
1099        || ((XMLA_Level) member.getLevel()).getParentLevel() == null) {
1100      member.setParent(null);
1101      return;
1102    }
1103
1104    if (member.isComplete()) {
1105      // we know, if there is no parent at all
1106
String JavaDoc pUname = member.getParentUniqueName();
1107      if (pUname == null || pUname.length() == 0) {
1108        member.setParent(null);
1109        return;
1110      }
1111    }
1112
1113    // 4=parent
1114
// ###SAP### for a measure, the member itself is returned
1115
List JavaDoc mems = soap.discoverMemTree(catalog, cube, member.getUniqueName(), 4);
1116
1117    // for SAP
1118
for (Iterator JavaDoc iter = mems.iterator(); iter.hasNext();) {
1119      OlapItem oli = (OlapItem) iter.next();
1120      if (oli.getUniqueName().equals(member.getUniqueName())) {
1121        // member itself
1122
member.setParent(null);
1123        return;
1124      }
1125    }
1126
1127    if (mems.size() == 0) {
1128      member.setParent(null);
1129      return;
1130    }
1131
1132    // evaluate
1133
ArrayList JavaDoc aNewMembers = new ArrayList JavaDoc();
1134    ArrayList JavaDoc aAllMembers = new ArrayList JavaDoc();
1135    // one level, properties are delivered
1136
evaluateMembers(mems, aNewMembers, aAllMembers);
1137    aMembers.addAll(aNewMembers);
1138
1139    // assign parent
1140
XMLA_Member pmem = (XMLA_Member) aAllMembers.get(0);
1141    member.setParent(pmem);
1142
1143  }
1144
1145  /**
1146   * retrieve the cube's members for a given hierarchy
1147   * @throws OlapException
1148   */

1149  void completeMember(XMLA_Member member) throws OlapException {
1150    // 8 = self
1151
List JavaDoc mems = soap.discoverMemTree(catalog, cube, member.getUniqueName(), 8);
1152    // evaluate
1153
ArrayList JavaDoc aNewMembers = new ArrayList JavaDoc();
1154    ArrayList JavaDoc aAllMembers = new ArrayList JavaDoc();
1155    evaluateMembers(mems, aNewMembers, aAllMembers);
1156
1157    /*
1158     // if this member is resulting from a "children" function call,
1159     // then it is a good idea, to complete all its siblings in one call
1160     List mems;
1161     Member parent = member.getParent();
1162     boolean parentChildren = false;
1163     if (parent != null && queryAdapter.isChildrenOnAxis(parent)) {
1164     // 1 = children
1165     mems = soap.discoverMemTree(catalog, cube, parent.getUniqueName(), 1);
1166     parentChildren = true;
1167     } else {
1168     // 8 = self
1169     mems = soap.discoverMemTree(catalog, cube, member.getUniqueName(), 8);
1170     }
1171     // evaluate
1172     ArrayList aNewMembers = new ArrayList();
1173     ArrayList aAllMembers = new ArrayList();
1174     evaluateMembers(mems, aNewMembers, aAllMembers, true);
1175     
1176     if (parentChildren) {
1177     for (Iterator iter = aAllMembers.iterator(); iter.hasNext();) {
1178     XMLA_Member m = (XMLA_Member) iter.next();
1179     if (!m.isParentOk())
1180     m.setParent((XMLA_Member) parent);
1181     }
1182     }
1183     aMembers.addAll(aNewMembers);
1184     */

1185  }
1186
1187  /**
1188   * retrieve a member by unique name
1189   * @throws OlapException
1190   */

1191
1192  public void retrieveMember(String JavaDoc uniqueName) throws OlapException {
1193
1194    // 8 = self
1195
List JavaDoc mems = soap.discoverMemTree(catalog, cube, uniqueName, 8);
1196
1197    // evaluate
1198
ArrayList JavaDoc aNewMembers = new ArrayList JavaDoc();
1199    ArrayList JavaDoc aAllMembers = new ArrayList JavaDoc();
1200    evaluateMembers(mems, aNewMembers, aAllMembers);
1201    aMembers.addAll(aNewMembers);
1202    XMLA_Member member = (XMLA_Member) this.lookupMemberByUName(uniqueName);
1203    if (member == null) { throw new OlapException("could not find member " + uniqueName); }
1204  }
1205
1206  /**
1207   * assign children member
1208   * @param member
1209   * @param aAllMembers
1210   */

1211  private void setMemberChildren(XMLA_Member member, ArrayList JavaDoc aAllMembers) {
1212    ArrayList JavaDoc aChildren = new ArrayList JavaDoc();
1213
1214    for (Iterator JavaDoc iter = aAllMembers.iterator(); iter.hasNext();) {
1215      XMLA_Member mem = (XMLA_Member) iter.next();
1216      if (member.getUniqueName().equals(mem.getParentUniqueName()))
1217        aChildren.add(mem); // mem is a child
1218
}
1219
1220    member.setChildren(aChildren);
1221    member.setChildrenOk(true);
1222
1223    for (Iterator JavaDoc iter = aChildren.iterator(); iter.hasNext();) {
1224      XMLA_Member child = (XMLA_Member) iter.next();
1225      child.setParent(member);
1226      child.setParentOk(true);
1227    }
1228  }
1229
1230  /**
1231   * assign children and parent to member
1232   * @param member
1233   * @param aAllMembers
1234   */

1235  /*
1236   private void setParentAndChildren(XMLA_Member member, ArrayList aAllMembers) {
1237   ArrayList aChildren = new ArrayList();
1238   
1239   for (Iterator iter = aAllMembers.iterator(); iter.hasNext();) {
1240   XMLA_Member mem = (XMLA_Member) iter.next();
1241   if (member.getUniqueName().equals(mem.getParentUniqueName()))
1242   aChildren.add(mem); // mem is a child
1243   
1244   if (mem.getUniqueName().equals(member.getParentUniqueName())) {
1245   
1246   member.setParent(mem); // mem is the parent
1247   }
1248   }
1249   
1250   member.setChildren(aChildren);
1251   
1252   for (Iterator iter = aChildren.iterator(); iter.hasNext();) {
1253   XMLA_Member child = (XMLA_Member) iter.next();
1254   child.setParent(member);
1255   }
1256   }
1257   */

1258  /**
1259   * Evaluate the result of Discovery MDSCHEMA_MEMBERS request
1260   * @param evalProps true, if properties should be evaluated
1261   * @param mems List of OlapItems
1262   */

1263  private void evaluateMembers(List JavaDoc mems, List JavaDoc aNewMembers, List JavaDoc aAllMembers) {
1264
1265    MLoop: for (Iterator JavaDoc iter = mems.iterator(); iter.hasNext();) {
1266      OlapItem oi = (OlapItem) iter.next();
1267
1268      String JavaDoc uName = oi.getUniqueName();
1269      XMLA_Member mem = (XMLA_Member) this.lookupMemberByUName(uName);
1270      if (mem != null) {
1271        aAllMembers.add(mem); // already there
1272
} else {
1273        // not there, create new
1274
String JavaDoc caption = oi.getCaption();
1275        String JavaDoc levUName = oi.getProperty("LEVEL_UNIQUE_NAME");
1276        //long levelNumber = Long.parseLong((String) hMemItems.get("LEVEL_NUMBER")); Microsoft
1277
//String hierUName = oi.getProperty("HIERARCHY_UNIQUE_NAME");
1278
XMLA_Level lev = this.lookupLevelByUName(levUName);
1279        boolean isCalc = isMemberInFormulas(uName);
1280        mem = new XMLA_Member(this, uName, caption, lev, isCalc);
1281        aNewMembers.add(mem);
1282        aAllMembers.add(mem);
1283      }
1284      if (!mem.isComplete()) {
1285        // set the secondary values (not gotten from result)
1286
long ordinal = 0;
1287        String JavaDoc sOrdinal = oi.getProperty("MEMBER_ORDINAL");
1288        if (sOrdinal != null)
1289          ordinal = Long.parseLong(sOrdinal);
1290        // not always there for SAP
1291
String JavaDoc name = oi.getName();
1292        int type = 0;
1293        String JavaDoc str = oi.getProperty("MEMBER_TYPE");
1294        if (str != null)
1295          type = Integer.parseInt(str);
1296        long childrenCard = 0;
1297        String JavaDoc sCard = oi.getProperty("CHILDREN_CARDINALITY");
1298        if (sCard != null)
1299          childrenCard = Long.parseLong(sCard);
1300        // not always there for SAP, default 0
1301
long parentLevel = 0;
1302        String JavaDoc sLev = oi.getProperty("PARENT_LEVEL");
1303        if (sLev != null)
1304          parentLevel = Long.parseLong(sLev);
1305        // not always there for SAP, default 0
1306
String JavaDoc parentUniqueName = oi.getProperty("PARENT_UNIQUE_NAME");
1307        String JavaDoc key = oi.getProperty("MEMBER_KEY");
1308        boolean isPlaceHolderMember = ("true".equals(oi.getProperty("IS_PLACEHOLDERMEMBER")));
1309        boolean isDataMember = ("true".equals(oi.getProperty("IS_DATAMEMBER")));
1310        mem.complete(name, type, ordinal, parentUniqueName, childrenCard, parentLevel,
1311            isDataMember, isPlaceHolderMember, key);
1312      }
1313      // properties gotten by result, DIMENSION PROPERTIES
1314
/*
1315       if (!mem.isPropsOk() && evalProps) {
1316       mem.setPropsOk(true);
1317       XMLA_Level lev = (XMLA_Level) mem.getLevel();
1318       Map propMap = lev.getProps();
1319       Map oiProps = oi.getProperties();
1320       for (Iterator iterator = propMap.values().iterator(); iterator.hasNext();) {
1321       XMLA_MemberProp mProp = (XMLA_MemberProp) iterator.next();
1322       String xmlTag = mProp.getXmlTag();
1323       if (oiProps.containsKey(xmlTag)) {
1324       PropertyImpl prop = new PropertyImpl();
1325       prop.setName(mProp.getName());
1326       prop.setValue((String) oiProps.get(xmlTag));
1327       mem.addProp(prop);
1328       }
1329       }
1330       }
1331       */

1332    } // MLoop
1333
}
1334
1335  /**
1336   * find out, whether a member is in the formulas
1337   * @param uName - unique name
1338   * @return
1339   */

1340  public boolean isMemberInFormulas(String JavaDoc uName) {
1341    if (pQuery == null)
1342      return false;
1343    Formula[] formulas = pQuery.getFormulas();
1344    for (int i = 0; i < formulas.length; i++) {
1345      if (formulas[i].isMember() && uName.equals(formulas[i].getUniqeName()))
1346        return true;
1347    }
1348    return false;
1349  }
1350
1351  /**
1352   * Returns the catalog.
1353   * @return String
1354   */

1355  public String JavaDoc getCatalog() {
1356    return catalog;
1357  }
1358
1359  /**
1360   * Returns the uri.
1361   * @return String
1362   */

1363  public String JavaDoc getUri() {
1364    return uri;
1365  }
1366
1367  /**
1368   * Sets the catalog.
1369   * @param catalog The catalog to set
1370   */

1371  public void setCatalog(String JavaDoc catalog) {
1372    this.catalog = catalog;
1373  }
1374
1375  /**
1376   * Returns the dataSource.
1377   * @return String
1378   */

1379  public String JavaDoc getDataSource() {
1380    return dataSource;
1381  }
1382
1383  /**
1384   * Sets the dataSource.
1385   * @param dataSource The dataSource to set
1386   */

1387  public void setDataSource(String JavaDoc dataSource) {
1388    this.dataSource = dataSource;
1389  }
1390
1391  /**
1392   * Sets the uri.
1393   * @param uri The uri to set
1394   */

1395  public void setUri(String JavaDoc uri) {
1396    this.uri = uri;
1397  }
1398
1399  /**
1400   * Returns the pQuery.
1401   * @return ParsedQuery
1402   */

1403  public ParsedQuery getPQuery() {
1404    return pQuery;
1405  }
1406
1407  /**
1408   * Returns the queryAdapter.
1409   * @return XMLA_QueryAdapter
1410   */

1411  public QueryAdapter getQueryAdapter() {
1412    return queryAdapter;
1413  }
1414
1415  /**
1416   * @return ID
1417   */

1418  public String JavaDoc getID() {
1419    return ID;
1420  }
1421
1422  /**
1423   * @param ID
1424   */

1425  public void setID(String JavaDoc string) {
1426    ID = string;
1427  }
1428
1429  /**
1430   * @return user
1431   */

1432  public String JavaDoc getUser() {
1433    return user;
1434  }
1435
1436  /**
1437   * @param user
1438   */

1439  public void setUser(String JavaDoc string) {
1440    user = string;
1441  }
1442
1443  /**
1444   * @return
1445   */

1446  public String JavaDoc getPassword() {
1447    return password;
1448  }
1449
1450  /**
1451   * @param string
1452   */

1453  public void setPassword(String JavaDoc string) {
1454    password = string;
1455  }
1456
1457  public boolean isSAP() {
1458    return (soap.getProvider() == OlapDiscoverer.PROVIDER_SAP);
1459  }
1460
1461  public boolean isMicrosoft() {
1462    return (soap.getProvider() == OlapDiscoverer.PROVIDER_MICROSOFT);
1463  }
1464
1465  public boolean isMondrian() {
1466    return (soap.getProvider() == OlapDiscoverer.PROVIDER_MONDRIAN);
1467  }
1468
1469  /**
1470   * @return cube name
1471   */

1472  public String JavaDoc getCube() {
1473    if (pQuery == null)
1474      return null;
1475    else
1476      return pQuery.getCube();
1477  }
1478
1479  /**
1480   * @return calcMeasurePropMap
1481   */

1482  public Map JavaDoc getCalcMeasurePropMap() {
1483    return calcMeasurePropMap;
1484  }
1485
1486  public void setServletContext(ServletContext JavaDoc servletContext) {
1487    // we don't need it
1488
}
1489
1490} // End XMLA_Model
1491

1492         
1493
Popular Tags