Search in sources :

Example 6 with TableWriter

use of org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter 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);
}
Also used : VariableDTO(org.apache.nifi.web.api.dto.VariableDTO) PrintStream(java.io.PrintStream) DynamicTableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter) TableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter) VariableRegistryEntity(org.apache.nifi.web.api.entity.VariableRegistryEntity) Collectors(java.util.stream.Collectors) List(java.util.List) Validate(org.apache.commons.lang3.Validate) ResultType(org.apache.nifi.toolkit.cli.api.ResultType) Table(org.apache.nifi.toolkit.cli.impl.result.writer.Table) VariableRegistryDTO(org.apache.nifi.web.api.dto.VariableRegistryDTO) Comparator(java.util.Comparator) Collections(java.util.Collections) Table(org.apache.nifi.toolkit.cli.impl.result.writer.Table) DynamicTableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter) TableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter) VariableRegistryDTO(org.apache.nifi.web.api.dto.VariableRegistryDTO) VariableDTO(org.apache.nifi.web.api.dto.VariableDTO) DynamicTableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter)

Example 7 with TableWriter

use of org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter 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);
}
Also used : Table(org.apache.nifi.toolkit.cli.impl.result.writer.Table) DynamicTableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter) TableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter) Date(java.util.Date) DynamicTableWriter(org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter)

Aggregations

DynamicTableWriter (org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter)7 Table (org.apache.nifi.toolkit.cli.impl.result.writer.Table)7 TableWriter (org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter)7 PrintStream (java.io.PrintStream)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Validate (org.apache.commons.lang3.Validate)1 Bucket (org.apache.nifi.registry.bucket.Bucket)1 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)1 ResultType (org.apache.nifi.toolkit.cli.api.ResultType)1 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)1 RegistryDTO (org.apache.nifi.web.api.dto.RegistryDTO)1 VariableDTO (org.apache.nifi.web.api.dto.VariableDTO)1 VariableRegistryDTO (org.apache.nifi.web.api.dto.VariableRegistryDTO)1 VersionControlInformationDTO (org.apache.nifi.web.api.dto.VersionControlInformationDTO)1 RegistryClientEntity (org.apache.nifi.web.api.entity.RegistryClientEntity)1 VariableRegistryEntity (org.apache.nifi.web.api.entity.VariableRegistryEntity)1