Examples of TableBuilder


Examples of org.kiji.schema.util.InstanceBuilder.TableBuilder

      for (Entry<Long, ?> cellEntry : columnEntry.getValue().entrySet()) {
        cells.put(cellEntry.getKey(), cellEntry.getValue());
      }
    }

    final TableBuilder tableBuilder =
        new InstanceBuilder(getKiji())
            .withTable(KijiTableLayouts
                    .getLayout("org/kiji/schema/layout/all-types-no-counters-schema.json"));

    final RowBuilder rowBuilder = tableBuilder.withRow(ROW);

    for (Entry<String, NavigableMap<String, NavigableMap<Long, Object>>> familyEntry
        : families.entrySet()) {
      final FamilyBuilder familyBuilder = rowBuilder.withFamily(familyEntry.getKey());

      for (Entry<String, NavigableMap<Long, Object>> columnEntry
          : familyEntry.getValue().entrySet()) {
        final QualifierBuilder qualifierBuilder =
            familyBuilder.withQualifier(columnEntry.getKey());

        for (Entry<Long, Object> cellEntry : columnEntry.getValue().entrySet()) {
          qualifierBuilder.withValue(cellEntry.getKey(), cellEntry.getValue());
        }
      }
    }
    tableBuilder.build();


    mTable = getKiji().openTable("all_types_table");
    mReader = mTable.openTableReader();
  }
View Full Code Here

Examples of org.kiji.schema.util.InstanceBuilder.TableBuilder

      for (Entry<Long, ?> cellEntry : columnEntry.getValue().entrySet()) {
        cells.put(cellEntry.getKey(), cellEntry.getValue());
      }
    }

    final TableBuilder tableBuilder =
        new InstanceBuilder(getKiji())
            .withTable(KijiTableLayouts.getLayout("org/kiji/schema/layout/all-types-schema.json"));

    final RowBuilder rowBuilder = tableBuilder.withRow(ROW);

    for (Entry<String, NavigableMap<String, NavigableMap<Long, Object>>> familyEntry
        : families.entrySet()) {
      final FamilyBuilder familyBuilder = rowBuilder.withFamily(familyEntry.getKey());

      for (Entry<String, NavigableMap<Long, Object>> columnEntry
          : familyEntry.getValue().entrySet()) {
        final QualifierBuilder qualifierBuilder =
            familyBuilder.withQualifier(columnEntry.getKey());

        for (Entry<Long, Object> cellEntry : columnEntry.getValue().entrySet()) {
          qualifierBuilder.withValue(cellEntry.getKey(), cellEntry.getValue());
        }
      }
    }
    tableBuilder.build();


    mTable = HBaseKijiTable.downcast(getKiji().openTable("all_types_table"));
    mReader = (HBaseKijiTableReader) mTable.openTableReader();
  }
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

        taskEntry = app.getTaskClient().getTaskEntry(taskId);
        List<Message> logs = taskEntry.getLogMessages();
        app.getOutputStream().println();

        // Create a table for the last log entry
        TableBuilder table = new TableBuilder();
        table.appendHeading(INFO_TASKINFO_FIELD_LOG.get());
        if (logs != null && logs.size() > 0) {
          for (Message log : logs) {
            table.startRow();
            table.appendCell(log);
          }
        } else {
          table.startRow();
          table.appendCell(INFO_TASKINFO_NONE.get());
        }
        StringWriter sw = new StringWriter();
        TextTablePrinter tablePrinter = new TextTablePrinter(sw);
        tablePrinter.setTotalWidth(80);
        tablePrinter.setIndentWidth(INDENT);
        tablePrinter.setColumnWidth(0, 0);
        table.print(tablePrinter);
        app.getOutputStream().println(Message.raw(sw.getBuffer().toString()));
        app.getOutputStream().println();
      } catch (Exception e) {
        app.println(ERR_TASKINFO_ACCESSING_LOGS.get(taskId, e.getMessage()));
      }
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

        Message message = ERR_LISTBACKENDS_NO_VALID_BACKENDS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }

      TableBuilder table = new TableBuilder();
      Message[] headers = {backendIDLabel, baseDNLabel};
      for (int i=0; i< headers.length; i++)
      {
        table.appendHeading(headers[i]);
      }
      for (String id : backendIDs)
      {
        table.startRow();
        table.appendCell(id);
        StringBuffer buf = new StringBuffer();

        TreeSet<DN> baseDNs = backends.get(id);
        boolean isFirst = true;
        for (DN dn : baseDNs)
        {
          if (!isFirst)
          {
            buf.append(",");
          }
          else
          {
            isFirst = false;
          }
          if (dn.getNumComponents() > 1)
          {
            buf.append("\""+dn.toString()+"\"");
          }
          else
          {
            buf.append(dn.toString());
          }
        }
        table.appendCell(buf.toString());
      }
      TextTablePrinter printer = new TextTablePrinter(out);
      printer.setColumnSeparator(ToolConstants.LIST_TABLE_SEPARATOR);
      table.print(printer);
    }


    // If we've gotten here, then everything completed successfully.
    return invalidDn ? 1 : 0 ;
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

   * Creates a menu from this menu builder.
   *
   * @return Returns the new menu.
   */
  public Menu<T> toMenu() {
    TableBuilder nbuilder = new TableBuilder();
    Map<String, MenuCallback<T>> callbacks =
      new HashMap<String, MenuCallback<T>>();

    // Determine whether multiple columns should be used for numeric
    // options.
    boolean useMultipleColumns = false;
    if (threshold >= 0 && numericCallbacks.size() >= threshold) {
      useMultipleColumns = true;
    }

    // Create optional column headers.
    if (!columnHeadings.isEmpty()) {
      nbuilder.appendHeading();
      for (Message heading : columnHeadings) {
        if (heading != null) {
          nbuilder.appendHeading(heading);
        } else {
          nbuilder.appendHeading();
        }
      }

      if (useMultipleColumns) {
        nbuilder.appendHeading();
        for (Message heading : columnHeadings) {
          if (heading != null) {
            nbuilder.appendHeading(heading);
          } else {
            nbuilder.appendHeading();
          }
        }
      }
    }

    // Add the numeric options first.
    int sz = numericCallbacks.size();
    int rows = sz;

    if (useMultipleColumns) {
      // Display in two columns the first column should contain half
      // the options. If there are an odd number of columns then the
      // first column should contain an additional option (e.g. if
      // there are 23 options, the first column should contain 12
      // options and the second column 11 options).
      rows /= 2;
      rows += sz % 2;
    }

    for (int i = 0, j = rows; i < rows; i++, j++) {
      nbuilder.startRow();
      nbuilder.appendCell(INFO_MENU_NUMERIC_OPTION.get(i + 1));

      for (Message field : numericFields.get(i)) {
        if (field != null) {
          nbuilder.appendCell(field);
        } else {
          nbuilder.appendCell();
        }
      }

      callbacks.put(String.valueOf(i + 1), numericCallbacks.get(i));

      // Second column.
      if (useMultipleColumns && (j < sz)) {
        nbuilder.appendCell(INFO_MENU_NUMERIC_OPTION.get(j + 1));

        for (Message field : numericFields.get(j)) {
          if (field != null) {
            nbuilder.appendCell(field);
          } else {
            nbuilder.appendCell();
          }
        }

        callbacks.put(String.valueOf(j + 1), numericCallbacks.get(j));
      }
    }

    // Add the char options last.
    TableBuilder cbuilder = new TableBuilder();
    for (int i = 0; i < charCallbacks.size(); i++) {
      char c = charKeys.get(i).charAt(0);
      Message option = INFO_MENU_CHAR_OPTION.get(c);

      cbuilder.startRow();
      cbuilder.appendCell(option);
      cbuilder.appendCell(charSynopsis.get(i));

      callbacks.put(String.valueOf(c), charCallbacks.get(i));
    }

    // Configure the table printer.
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

   */
  private void printSummaryTable()
          throws LDAPException, IOException, ASN1Exception {
    List<TaskEntry> entries = taskClient.getTaskEntries();
    if (entries.size() > 0) {
      TableBuilder table = new TableBuilder();
      Map<String, TaskEntry> mapIdToEntry =
              new TreeMap<String, TaskEntry>();
      for (TaskEntry entry : entries) {
        String taskId = entry.getId();
        if (taskId != null) {
          mapIdToEntry.put(taskId, entry);
        }
      }

      table.appendHeading(INFO_TASKINFO_FIELD_ID.get());
      table.appendHeading(INFO_TASKINFO_FIELD_TYPE.get());
      table.appendHeading(INFO_TASKINFO_FIELD_STATUS.get());
      for (String taskId : mapIdToEntry.keySet()) {
        TaskEntry entryWrapper = mapIdToEntry.get(taskId);
        table.startRow();
        table.appendCell(taskId);
        table.appendCell(entryWrapper.getType());
        table.appendCell(entryWrapper.getState());
      }
      StringWriter sw = new StringWriter();
      TextTablePrinter tablePrinter = new TextTablePrinter(sw);
      tablePrinter.setIndentWidth(INDENT);
      tablePrinter.setTotalWidth(80);
      table.print(tablePrinter);
      getOutputStream().println(Message.raw(sw.getBuffer()));
    } else {
      getOutputStream().println(INFO_TASKINFO_NO_TASKS.get());
      getOutputStream().println();
    }
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

      Message m = null;
      TaskEntry taskEntry = null;
      try {
        taskEntry = app.getTaskClient().getTaskEntry(taskId);

        TableBuilder table = new TableBuilder();
        table.appendHeading(INFO_TASKINFO_DETAILS.get());

        table.startRow();
        table.appendCell(INFO_TASKINFO_FIELD_ID.get());
        table.appendCell(taskEntry.getId());

        table.startRow();
        table.appendCell(INFO_TASKINFO_FIELD_TYPE.get());
        table.appendCell(taskEntry.getType());

        table.startRow();
        table.appendCell(INFO_TASKINFO_FIELD_STATUS.get());
        table.appendCell(taskEntry.getState());

        if (TaskState.isRecurring(taskEntry.getTaskState())) {
          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get());
          m = taskEntry.getScheduleTab();
          table.appendCell(m);
        } else {
          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get());
          m = taskEntry.getScheduledStartTime();
          if (m == null || m.equals(Message.EMPTY)) {
            table.appendCell(INFO_TASKINFO_IMMEDIATE_EXECUTION.get());
          } else {
            table.appendCell(m);
          }

          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_ACTUAL_START.get());
          table.appendCell(taskEntry.getActualStartTime());

          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_COMPLETION_TIME.get());
          table.appendCell(taskEntry.getCompletionTime());
        }

        writeMultiValueCells(
                table,
                INFO_TASKINFO_FIELD_DEPENDENCY.get(),
                taskEntry.getDependencyIds());

        table.startRow();
        table.appendCell(INFO_TASKINFO_FIELD_FAILED_DEPENDENCY_ACTION.get());
        m = taskEntry.getFailedDependencyAction();
        table.appendCell(m != null ? m : INFO_TASKINFO_NONE.get());

        writeMultiValueCells(
                table,
                INFO_TASKINFO_FIELD_NOTIFY_ON_COMPLETION.get(),
                taskEntry.getCompletionNotificationEmailAddresses(),
                INFO_TASKINFO_NONE_SPECIFIED.get());

        writeMultiValueCells(
                table,
                INFO_TASKINFO_FIELD_NOTIFY_ON_ERROR.get(),
                taskEntry.getErrorNotificationEmailAddresses(),
                INFO_TASKINFO_NONE_SPECIFIED.get());

        StringWriter sw = new StringWriter();
        TextTablePrinter tablePrinter = new TextTablePrinter(sw);
        tablePrinter.setTotalWidth(80);
        tablePrinter.setIndentWidth(INDENT);
        tablePrinter.setColumnWidth(1, 0);
        table.print(tablePrinter);
        app.getOutputStream().println();
        app.getOutputStream().println(Message.raw(sw.getBuffer().toString()));

        // Create a table for the task options
        table = new TableBuilder();
        table.appendHeading(INFO_TASKINFO_OPTIONS.get(taskEntry.getType()));
        Map<Message,List<String>> taskSpecificAttrs =
                taskEntry.getTaskSpecificAttributeValuePairs();
        for (Message attrName : taskSpecificAttrs.keySet()) {
          table.startRow();
          table.appendCell(attrName);
          List<String> values = taskSpecificAttrs.get(attrName);
          if (values.size() > 0) {
            table.appendCell(values.get(0));
          }
          if (values.size() > 1) {
            for (int i = 1; i < values.size(); i++) {
              table.startRow();
              table.appendCell();
              table.appendCell(values.get(i));
            }
          }
        }
        sw = new StringWriter();
        tablePrinter = new TextTablePrinter(sw);
        tablePrinter.setTotalWidth(80);
        tablePrinter.setIndentWidth(INDENT);
        tablePrinter.setColumnWidth(1, 0);
        table.print(tablePrinter);
        app.getOutputStream().println(Message.raw(sw.getBuffer().toString()));

        // Print the last log message if any
        List<Message> logs = taskEntry.getLogMessages();
        if (logs != null && logs.size() > 0) {

          // Create a table for the last log entry
          table = new TableBuilder();
          table.appendHeading(INFO_TASKINFO_FIELD_LAST_LOG.get());
          table.startRow();
          table.appendCell(logs.get(logs.size() - 1));

          sw = new StringWriter();
          tablePrinter = new TextTablePrinter(sw);
          tablePrinter.setTotalWidth(80);
          tablePrinter.setIndentWidth(INDENT);
          tablePrinter.setColumnWidth(0, 0);
          table.print(tablePrinter);
          app.getOutputStream().println(Message.raw(sw.getBuffer().toString()));
        }

        app.getOutputStream().println();
      } catch (Exception e) {
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

  // Display a property's syntax.
  private static <T> void displayPropertySyntax(ConsoleApplication app,
      PropertyDefinition<T> d) throws IllegalArgumentException {
    PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder(true);

    TableBuilder builder = new TableBuilder();
    builder.startRow();
    builder.appendCell(INFO_EDITOR_HEADING_SYNTAX.get());
    builder.appendCell(b.getUsage(d));

    TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
    printer.setDisplayHeadings(false);
    printer.setIndentWidth(4);
    printer.setColumnWidth(1, 0);
    builder.print(printer);
  }
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

        }
      }
    }

    // Now output its properties.
    TableBuilder builder = new TableBuilder();
    builder.appendHeading(INFO_DSCFG_HEADING_PROPERTY_NAME.get());
    builder.appendHeading(INFO_DSCFG_HEADING_PROPERTY_VALUE.get());
    builder.addSortKey(0);
    for (PropertyDefinition<?> pd : pdList) {
      if (pd.hasOption(PropertyOption.HIDDEN)) {
        continue;
      }

      if (!app.isAdvancedMode() && pd.hasOption(PropertyOption.ADVANCED)) {
        continue;
      }

      if (propertyNames.isEmpty() || propertyNames.contains(pd.getName())) {
        displayProperty(app, builder, child, pd, valuePrinter);
        setCommandBuilderUseful(true);
      }
    }

    PrintStream out = app.getOutputStream();
    if (app.isScriptFriendly()) {
      TablePrinter printer = createScriptFriendlyTablePrinter(out);
      builder.print(printer);
    } else {
      TextTablePrinter printer = new TextTablePrinter(out);
      printer.setColumnSeparator(ToolConstants.LIST_TABLE_SEPARATOR);
      printer.setColumnWidth(1, 0);
      builder.print(printer);
    }

    return MenuResult.success(0);
  }
View Full Code Here

Examples of org.nasutekds.server.util.table.TableBuilder

      if (app.isInteractive()) {
        // If interactive, let the user go back to the main menu.
        app.println();
        app.println(msg);
        app.println();
        TableBuilder builder = new TableBuilder();
        for (Message reason : e.getMessages()) {
          builder.startRow();
          builder.appendCell("*");
          builder.appendCell(reason);
        }
        TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
        printer.setDisplayHeadings(false);
        printer.setColumnWidth(1, 0);
        printer.setIndentWidth(4);
        builder.print(printer);
        return MenuResult.cancel();
      } else {
        throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION,
            msg, e);
      }
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.