Пример #1
0
 private String getXtableString(List<XTablereference> tableReferences) {
   StringBuilder builder = new StringBuilder();
   for (XTablereference ref : tableReferences) {
     builder.append(ref.getDestTable()).append(".").append(ref.getDestColumn()).append(",");
   }
   return builder.toString();
 }
Пример #2
0
  @CliCommand(value = "describe cube", help = "describe cube")
  public String describeCube(
      @CliOption(
              key = {"", "cube"},
              mandatory = true,
              help = "<cube-name>")
          String cubeName) {

    XCube cube = client.getCube(cubeName);
    StringBuilder builder = new StringBuilder();
    builder.append("Cube Name : ").append(cube.getName()).append("\n");
    builder
        .append("Description : ")
        .append(cube.getDescription() != null ? cube.getDescription() : "");
    if (cube.getMeasures() != null) {
      builder.append("Measures :").append("\n");
      builder
          .append("\t")
          .append("name")
          .append("\t")
          .append("type")
          .append("\t")
          .append("cost")
          .append("\t")
          .append("format string")
          .append("\t")
          .append("unit")
          .append("\t")
          .append("starttime(in miliseconds)")
          .append("\t")
          .append("endtime(in miliseconds)")
          .append("\n");
      for (XMeasure measure : cube.getMeasures().getMeasures()) {
        builder
            .append("\t")
            .append(measure.getName() != null ? measure.getName() : "")
            .append("\t")
            .append(measure.getType() != null ? measure.getType() : "")
            .append("\t")
            .append(measure.getCost())
            .append("\t")
            .append(measure.getFormatString() != null ? measure.getFormatString() : "")
            .append("\t")
            .append(measure.getUnit() != null ? measure.getUnit() : "")
            .append("\t")
            .append(
                measure.getStartTime() != null
                    ? measure.getStartTime().toGregorianCalendar().getTimeInMillis()
                    : "")
            .append("\t")
            .append(
                measure.getEndTime() != null
                    ? measure.getEndTime().toGregorianCalendar().getTimeInMillis()
                    : "")
            .append("\t")
            .append("\n");
      }
    }
    if (cube.getDimensions() != null) {
      builder.append("Dimensions  :").append("\n");
      builder
          .append("\t")
          .append("name")
          .append("\t")
          .append("type")
          .append("\t")
          .append("cost")
          .append("\t")
          .append("Expression")
          .append("\t")
          .append("table references")
          .append("\t")
          .append("starttime(in miliseconds)")
          .append("\t")
          .append("endtime(in miliseconds)")
          .append("\n");
      for (XDimension dim : cube.getDimensions().getDimensions()) {
        builder
            .append("\t")
            .append(dim.getName() != null ? dim.getName() : "")
            .append("\t")
            .append(dim.getType() != null ? dim.getType() : "")
            .append("\t")
            .append(dim.getCost() != null ? dim.getCost() : "")
            .append("\t")
            .append(dim.getExpr() != null ? dim.getExpr() : "")
            .append("\t")
            .append(
                dim.getReferences() != null
                    ? getXtableString(dim.getReferences().getTableReferences())
                    : "")
            .append(
                dim.getStartTime() != null
                    ? dim.getStartTime().toGregorianCalendar().getTimeInMillis()
                    : "")
            .append("\t")
            .append(
                dim.getEndTime() != null
                    ? dim.getEndTime().toGregorianCalendar().getTimeInMillis()
                    : "")
            .append("\t")
            .append("\n");
      }
    }
    builder.append(FormatUtils.formatProperties(cube.getProperties().getProperties()));
    return builder.toString();
  }