KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > analysis > AnalysisGenerator


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 - 2006 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.analysis;
21
22 import java.util.Collection JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.LinkedList JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import org.openi.xmla.XmlaConnector;
30
31 import com.tonbeller.jpivot.olap.model.OlapException;
32 import com.tonbeller.jpivot.olap.model.OlapItem;
33
34 /**
35  *Intended to generate analyses for a high level EDA process
36  */

37 public class AnalysisGenerator {
38
39     /**
40      *
41      */

42     public AnalysisGenerator() {
43         super();
44     }
45     public Map JavaDoc generateMdxForDimensions(String JavaDoc uri, String JavaDoc catalog, String JavaDoc cube) throws OlapException{
46         return this.generateMdxForDimensions(uri, catalog, cube, null, null);
47     }
48     
49     /**
50      * key - title "measures by dimensionName"
51      * value - mdx String
52      *
53      * @throws OlapException
54      */

55     public Map JavaDoc generateMdxForDimensions(String JavaDoc uri, String JavaDoc catalog, String JavaDoc cube, String JavaDoc user, String JavaDoc pwd) throws OlapException {
56         Map JavaDoc mdx = new HashMap JavaDoc();
57         Iterator JavaDoc dimensions = discoverDimensions(uri, catalog, cube, user, pwd).iterator();
58         while(dimensions.hasNext()){
59             String JavaDoc dimensionName = (String JavaDoc)dimensions.next();
60             if(!"measures".equalsIgnoreCase(dimensionName) ){
61                 mdx.put("by " + dimensionName, generateMdx(uri, catalog, user, pwd, cube, dimensionName) );
62             }
63         }
64         return mdx;
65     }
66     
67   
68     
69     private String JavaDoc generateMdx(String JavaDoc uri, String JavaDoc catalog, String JavaDoc user, String JavaDoc pwd, String JavaDoc cube, String JavaDoc dimensionName) throws OlapException{
70         return new XmlaConnector().createDefaultMdx(uri, catalog, user, pwd, cube, dimensionName);
71     }
72     
73     private List JavaDoc discoverCubes(String JavaDoc uri, String JavaDoc catalog, String JavaDoc user, String JavaDoc pwd) throws OlapException{
74         return new XmlaConnector().getCubeList(uri, catalog, user, pwd);
75     }
76     
77     private List JavaDoc discoverDimensions(String JavaDoc uri, String JavaDoc catalog, String JavaDoc cube, String JavaDoc user, String JavaDoc pwd) throws OlapException{
78         return new XmlaConnector().getDimensionList(uri, catalog, cube, user, pwd);
79     }
80     
81
82
83     /**
84      * @param uri
85      * @param catalog
86      * @param cube
87      * @return
88      */

89     public Collection JavaDoc generate(String JavaDoc uri, String JavaDoc catalog, String JavaDoc cube) {
90         Collection JavaDoc analyses = new LinkedList JavaDoc();
91         return analyses;
92     }
93
94 }
95
Popular Tags