Examples of MyOlapContext


Examples of com.narirelays.ems.olap.context.MyOlapContext

import static com.narirelays.ems.resources.EMSi18n.*;

public class OlapService {
 
  public static List getTimeDimensionTree() throws Exception{
    MyOlapContext context = MyOlapContext.getMyOlapContext();
    MdmPrimaryDimension mdmTimeDim = context.getMdmPrimaryDimension("MYTIME");
      MdmLevelHierarchy mdmTimeHier = (MdmLevelHierarchy)mdmTimeDim.getDefaultHierarchy();
//      StringSource prodHier =  (StringSource) mdmProdHier.getSource();

      MdmLevel mdmLevel = context.getLevelByName(mdmTimeHier, "YEAR");
      Source levelSrc = mdmLevel.getSource();
      StringSource timeHier = (StringSource) mdmTimeHier.getSource();
      // Get the Source for the short label attribute of the dimension.
      Source prodShortLabel = mdmTimeDim.getShortValueDescriptionAttribute()
                                        .getSource();
      Source levelSrcWithShortDescr = prodShortLabel.join(levelSrc);
      MdmAttribute mdmTimeHierParentAttr = mdmTimeHier.getParentAttribute();
      Source prodHierParentAttr = mdmTimeHierParentAttr.getSource();
      Source timeHierChildren = timeHier.join(prodHierParentAttr,
          timeHier.value());
      Cursor queryCursor = getCursor(context,levelSrcWithShortDescr);
      List<LazyDynaBean> result = convertDimensionShortDescCursor2List(queryCursor);
     
     
      for(int yeari=0;result!=null&&yeari<result.size();yeari++){
        LazyDynaBean yearbean = result.get(yeari);
        Object objectID = yearbean.get("id");
        if(objectID!=null){
          String id = objectID.toString();
            Source levelElement = timeHier.selectValue(id);
            Source levelElementChildren = timeHierChildren.join(timeHier, levelElement);
            Source levelElementChildrenWithShortDescr =
                                             prodShortLabel.join(levelElementChildren);
            queryCursor = getCursor(context,levelElementChildrenWithShortDescr);
            List<LazyDynaBean> quarterList = convertDimensionShortDescCursor2List(queryCursor);
            yearbean.set("children", quarterList);
          for(int quarteri=0;quarterList!=null&&quarteri<quarterList.size();quarteri++){
            LazyDynaBean quarterbean = quarterList.get(quarteri);
            objectID = quarterbean.get("id");
            if(objectID!=null){
              id = objectID.toString();
                  levelElement = timeHier.selectValue(id);
                  levelElementChildren = timeHierChildren.join(timeHier, levelElement);
                  levelElementChildrenWithShortDescr =
                                                   prodShortLabel.join(levelElementChildren);
                  queryCursor = getCursor(context,levelElementChildrenWithShortDescr);
                  List<LazyDynaBean> monthList = convertDimensionShortDescCursor2List(queryCursor);
                  quarterbean.set("children", monthList);
                for(int monthi=0;monthList!=null&&monthi<monthList.size();monthi++){
                  LazyDynaBean monthbean = monthList.get(monthi);
                  objectID = monthbean.get("id");
                  if(objectID!=null){
                    id = objectID.toString();
                        levelElement = timeHier.selectValue(id);
                        levelElementChildren = timeHierChildren.join(timeHier, levelElement);
                        levelElementChildrenWithShortDescr =
                                                         prodShortLabel.join(levelElementChildren);
                        queryCursor = getCursor(context,levelElementChildrenWithShortDescr);
                        List<LazyDynaBean> dayList = convertDimensionShortDescCursor2List(queryCursor);
                        monthbean.set("children", dayList);
                  }
                }
            }
          }
        }
      }
//     
//      System.out.println(JSONArray.fromObject(result).toString());
      context.closeContext();
    return result;
  }
View Full Code Here

Examples of com.narirelays.ems.olap.context.MyOlapContext

      context.closeContext();
    return result;
  }
 
  public static List getRootMeasureInfo() throws Exception{
    MyOlapContext context = MyOlapContext.getMyOlapContext();
    ExpressDataProvider dp = context.getExpressDataProvider();
    MdmMetadataProvider mp = null;
      mp = (MdmMetadataProvider) dp.getDefaultMetadataProvider();
      MdmSchema rootSchema = mp.getRootSchema();
//      MdmMeasureDimension mdmMeasureDim = (MdmMeasureDimension)rootSchema.getMeasureDimension();
//      List mdmMeasures = mdmMeasureDim.getMeasures();
View Full Code Here

Examples of com.narirelays.ems.olap.context.MyOlapContext

     * 首先查询并得到各个维度,如果某个维度不存在,那么退出
     */
    if(dimensionNames==null||dimensionList==null||measure==null||dimensionNames.size()!=dimensionList.size()){
      return null;
    }
    MyOlapContext context = MyOlapContext.getMyOlapContext();
    MdmMeasure mdmMeasure = context.getMdmMeasure(measure);
    if(mdmMeasure==null){
      context.closeContext();
      return null;
    }
    Source measureSource = mdmMeasure.getSource();
   
    ArrayList<Source> HierarchySelectedList = new ArrayList<Source>();
    for(String dimensionName:dimensionNames){
      MdmPrimaryDimension mdmDim = context.getMdmPrimaryDimension(dimensionName);
      MdmHierarchy mdmHier = mdmDim.getDefaultHierarchy();
      StringSource hier = (StringSource)mdmHier.getSource();
      Source selected = hier.selectValues(dimensionList.get(dimensionName));
      Source depShortLabel = mdmDim.getShortValueDescriptionAttribute().getSource();
      Source deptShortDescr = depShortLabel.join(selected);
      HierarchySelectedList.add(deptShortDescr);
    }
    for(int i=HierarchySelectedList.size()-1;i>=0;i--){
      measureSource = measureSource.join(HierarchySelectedList.get(i));
    }
//    for(Source source:HierarchySelectedList){
//      measureSource = measureSource.join(source);
//    }
   
//    context.prepareAndCommit();
//    ExpressDataProvider dp = context.getExpressDataProvider();
//      CursorManagerSpecification cursorMngrSpec = dp.createCursorManagerSpecification(measureSource);
//      SpecifiedCursorManager cursorMngr =
//        dp.createCursorManager(cursorMngrSpec);
      Cursor queryCursor = getCursor(context,measureSource);
      List<LazyDynaBean> result = convertCursor2List(queryCursor,dimensionNames,measure);
      context.closeContext();
      return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.