use of org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter in project nifi by apache.
the class VariableRegistryResult method writeSimpleResult.
@Override
protected void writeSimpleResult(final PrintStream output) {
final VariableRegistryDTO variableRegistryDTO = variableRegistryEntity.getVariableRegistry();
if (variableRegistryDTO == null || variableRegistryDTO.getVariables() == null) {
return;
}
final List<VariableDTO> variables = variableRegistryDTO.getVariables().stream().map(v -> v.getVariable()).collect(Collectors.toList());
Collections.sort(variables, Comparator.comparing(VariableDTO::getName));
final Table table = new Table.Builder().column("#", 3, 3, false).column("Name", 5, 40, false).column("Value", 5, 40, false).build();
for (int i = 0; i < variables.size(); i++) {
final VariableDTO var = variables.get(i);
table.addRow(String.valueOf(i + 1), var.getName(), var.getValue());
}
final TableWriter tableWriter = new DynamicTableWriter();
tableWriter.write(table, output);
}
use of org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter in project nifi by apache.
the class VersionedFlowSnapshotMetadataResult method writeSimpleResult.
@Override
protected void writeSimpleResult(final PrintStream output) {
if (versions == null || versions.isEmpty()) {
return;
}
// date length, with locale specifics
final String datePattern = "%1$ta, %<tb %<td %<tY %<tR %<tZ";
final int dateLength = String.format(datePattern, new Date()).length();
final Table table = new Table.Builder().column("Ver", 3, 3, false).column("Date", dateLength, dateLength, false).column("Author", 20, 200, true).column("Message", 8, 40, true).build();
versions.forEach(vfs -> {
table.addRow(String.valueOf(vfs.getVersion()), String.format(datePattern, new Date(vfs.getTimestamp())), vfs.getAuthor(), vfs.getComments());
});
final TableWriter tableWriter = new DynamicTableWriter();
tableWriter.write(table, output);
}
Aggregations