Пример #1
0
 /**
  * 构建列的元定义
  *
  * @param level
  * @return 列的元定义
  */
 private ColumnMetaDefine buildColumn(Level level) {
   ColumnMetaDefine column = new ColumnMetaDefine();
   if (level != null) {
     column.setCaption(level.getCaption());
     // modify by jiangyichao at 2014-10-15
     String source = null;
     if (level instanceof CallbackLevel) {
       source = ((CallbackLevel) level).getFactTableColumn();
     } else {
       source = ((MiniCubeLevel) level).getSource();
     }
     column.setName(source);
     // TODO 如果是时间维度,需要特殊处理
     // column.setType(level.getType());
   }
   return column;
 }
Пример #2
0
 /**
  * 构建事实表
  *
  * @param cube cube定义
  * @return 事实表定义
  */
 private FactTableMetaDefine buildFactTable(MiniCube cube) {
   FactTableMetaDefine factTable = new FactTableMetaDefine();
   factTable.setCubeId(cube.getId());
   factTable.setMutilple(cube.isMutilple());
   if (factTable.isMutilple()) {
     // 分库分表导致多张表组成事实表
     factTable.setRegExp(cube.getSource());
     if (cube.getSource() != null) {
       List<String> regexTables = Lists.newArrayList();
       Collections.addAll(regexTables, cube.getSource().split(","));
       factTable.setRegExpTables(regexTables);
       if (regexTables != null && regexTables.size() > 0) {
         factTable.setName(regexTables.get(0));
       }
     }
     factTable.setDivideTableStrategyVo(cube.getDivideTableStrategyVo());
   } else {
     // 事实表名称
     factTable.setName(cube.getSource());
   }
   if (cube.getMeasures() == null || cube.getMeasures().isEmpty()) {
     logger.debug("measure is empty");
   } else {
     Collection<Measure> measures = cube.getMeasures().values();
     if (measures == null) {
       logger.debug("can't get measuers");
       return factTable;
     }
     measures.forEach(
         m -> {
           ColumnMetaDefine column = new ColumnMetaDefine();
           column.setCaption(m.getCaption());
           column.setName(m.getDefine());
           factTable.addColumn(column);
         });
     // 添加维度引用的列
     cube.getDimensions()
         .values()
         .forEach(
             dim -> {
               ColumnMetaDefine column = new ColumnMetaDefine();
               // modify by jiangyichao at 2014-10-09 修改维度caption
               column.setCaption(dim.getFacttableCaption());
               column.setName(dim.getFacttableColumn());
               factTable.addColumn(column);
             });
   }
   return factTable;
 }