public void run()

in odps-console-resource/src/main/java/com/aliyun/openservices/odps/console/resource/ListResourcesCommand.java [72:132]


  public void run() throws OdpsException, ODPSConsoleException {
    coordinate.interpretByCtx(getContext());
    String project = coordinate.getProjectName();
    String schema = coordinate.getSchemaName();
    Odps odps = getCurrentOdps();

    int[] columnPercent = new int[]{15, 15, 15, 15, 5, 5, 10, 10, 10};
    String[] headers = new String[]{
        "Resource Name",
        "Owner",
        "Creation Time",
        "Last Modified Time",
        "Type",
        "Last Updator",
        "Resource Size",
        "Source",
        "Comment"};

    Iterator<Resource> iterator;

    iterator = odps.resources().iterator(project, schema, prefix);

    //check permission
    iterator.hasNext();

    ODPSConsoleUtils
        .formaterTableRow(headers, columnPercent, getContext().getConsoleWidth());

    int totalCount = 0;
    int columnCounter = 0;
    while (iterator.hasNext()) {
      ODPSConsoleUtils.checkThreadInterrupted();

      Resource p = iterator.next();
      String[] resourceAttr = new String[columnPercent.length];
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetString(p, "getName");
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetString(p, "getOwner");
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetDateString(p, "getCreatedTime");
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetDateString(p, "getLastModifiedTime");
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetString(p, "getType").toLowerCase();
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetString(p, "getLastUpdator");
      resourceAttr[columnCounter++] = ODPSConsoleUtils.safeGetString(p, "getSize");
      if (p.getType() == Resource.Type.TABLE) {
        Table sourceTable = (Table) ODPSConsoleUtils.safeGetObject(p, "getSourceTable");
        String tableSource = sourceTable == null ?
                             " " : sourceTable.getProject() + "." + sourceTable.getName();
        resourceAttr[columnCounter++] = tableSource;
      } else {
        resourceAttr[columnCounter++] = "";
      }

      resourceAttr[columnCounter] = ODPSConsoleUtils.safeGetString(p, "getComment");

      ODPSConsoleUtils.formaterTableRow(resourceAttr, columnPercent, getContext()
          .getConsoleWidth());
      totalCount++;
      columnCounter = 0;
    }

    getWriter().writeError(totalCount + " resources");
  }