Java Code Examples for org.springframework.shell.table.TableBuilder#build()
The following examples show how to use
org.springframework.shell.table.TableBuilder#build() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReleaseCommands.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@ShellMethod(key = "release list", value = "List the latest version of releases with status of deployed or failed.") public Table list( @ShellOption(help = "wildcard expression to search by release name", defaultValue = ShellOption.NULL) String releaseName) { List<Release> releases = this.skipperClient.list(releaseName); LinkedHashMap<String, Object> headers = new LinkedHashMap<>(); headers.put("name", "Name"); headers.put("version", "Version"); headers.put("info.lastDeployed", "Last updated"); headers.put("info.status.statusCode", "Status"); headers.put("pkg.metadata.name", "Package Name"); headers.put("pkg.metadata.version", "Package Version"); headers.put("platformName", "Platform Name"); headers.put("info.status.platformStatusPrettyPrint", "Platform Status"); TableModel model = new BeanListTableModel<>(releases, headers); TableBuilder tableBuilder = new TableBuilder(model); TableUtils.applyStyle(tableBuilder); return tableBuilder.build(); }
Example 2
Source File: ReleaseCommands.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@ShellMethod(key = "release history", value = "List the history of versions for a given release.") public Table history( @ShellOption(help = "wildcard expression to search by release name") @NotNull String releaseName) { Collection<Release> releases; releases = this.skipperClient.history(releaseName); LinkedHashMap<String, Object> headers = new LinkedHashMap<>(); headers.put("version", "Version"); headers.put("info.lastDeployed", "Last updated"); headers.put("info.status.statusCode", "Status"); headers.put("pkg.metadata.name", "Package Name"); headers.put("pkg.metadata.version", "Package Version"); headers.put("info.description", "Description"); TableModel model = new BeanListTableModel<>(releases, headers); TableBuilder tableBuilder = new TableBuilder(model); TableUtils.applyStyle(tableBuilder); return tableBuilder.build(); }
Example 3
Source File: StreamCommands.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@CliCommand(value = STREAM_HISTORY, help = "Get history for the stream deployed using Skipper") public Table history( @CliOption(key = { "", "name" }, help = "the name of the stream", mandatory = true, optionContext = "existing-stream " + "disable-string-converter") String name) { Collection<Release> releases = streamOperations().history(name); LinkedHashMap<String, Object> headers = new LinkedHashMap<>(); headers.put("version", "Version"); headers.put("info.lastDeployed", "Last updated"); headers.put("info.status.statusCode", "Status"); headers.put("pkg.metadata.name", "Package Name"); headers.put("pkg.metadata.version", "Package Version"); headers.put("info.description", "Description"); TableModel model = new BeanListTableModel<>(releases, headers); TableBuilder tableBuilder = new TableBuilder(model); DataFlowTables.applyStyle(tableBuilder); return tableBuilder.build(); }
Example 4
Source File: JobCommands.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@CliCommand(value = INSTANCE_DISPLAY, help = "Display the job executions for a specific job instance.") public Table instanceDisplay(@CliOption(key = { "id" }, help = "the job instance id", mandatory = true) long id) { JobInstanceResource jobInstanceResource = jobOperations().jobInstance(id); TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("Name ").addValue("Execution ID ").addValue("Step Execution Count ") .addValue("Status ").addValue("Job Parameters "); for (JobExecutionResource job : jobInstanceResource.getJobExecutions()) { modelBuilder.addRow().addValue(jobInstanceResource.getJobName()).addValue(job.getExecutionId()) .addValue(job.getStepExecutionCount()).addValue(job.getJobExecution().getStatus().name()) .addValue(job.getJobParametersString()); } TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 5
Source File: JobCommands.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@CliCommand(value = STEP_EXECUTION_LIST, help = "List step executions filtered by jobExecutionId") public Table stepExecutionList(@CliOption(key = { "id" }, help = "the job execution id to be used as a filter", mandatory = true) long id) { final PagedModel<StepExecutionResource> steps = jobOperations().stepExecutionList(id); TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("ID ").addValue("Step Name ").addValue("Job Exec Id ").addValue("Start Time ") .addValue("End Time ").addValue("Status "); for (StepExecutionResource step : steps) { modelBuilder.addRow().addValue(step.getStepExecution().getId()) .addValue(step.getStepExecution().getStepName()).addValue(id) .addValue(step.getStepExecution().getStartTime()).addValue(step.getStepExecution().getEndTime()) .addValue(step.getStepExecution().getStatus().name()); } TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 6
Source File: JobCommands.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@CliCommand(value = STEP_EXECUTION_PROGRESS, help = "Display the details of a specific step progress") public Table stepProgressDisplay( @CliOption(key = { "id" }, help = "the step execution id", mandatory = true) long id, @CliOption(key = { "jobExecutionId" }, help = "the job execution id", mandatory = true) long jobExecutionId) { StepExecutionProgressInfoResource progressInfoResource = jobOperations().stepExecutionProgress(jobExecutionId, id); TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("ID ").addValue("Step Name ").addValue("Complete ").addValue("Duration "); modelBuilder.addRow().addValue(progressInfoResource.getStepExecution().getId()) .addValue(progressInfoResource.getStepExecution().getStepName()) .addValue(progressInfoResource.getPercentageComplete() * 100 + "%") .addValue(progressInfoResource.getDuration() + " ms"); TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 7
Source File: ReleaseCommands.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
@ShellMethod(key = "release status", value = "Status for a last known release version.") public Object status( @ShellOption(help = "release name") @NotNull String releaseName, @ShellOption(help = "the specific release version.", defaultValue = ShellOption.NULL) Integer releaseVersion) { Info info; try { if (releaseVersion == null) { info = this.skipperClient.status(releaseName); } else { info = this.skipperClient.status(releaseName, releaseVersion); } } catch (ReleaseNotFoundException e) { return "Release with name '" + e.getReleaseName() + "' not found"; } Object[][] data = new Object[3][]; data[0] = new Object[] { "Last Deployed", info.getFirstDeployed() }; data[1] = new Object[] { "Status", info.getStatus().getStatusCode().toString() }; DeploymentState aggregateState = aggregateState(info.getStatus().getDeploymentStateList()); StringBuilder sb = new StringBuilder(); sb.append(DeploymentStateDisplay.fromKey(aggregateState.name()).getDescription() + "\n"); sb.append(info.getStatus().getPlatformStatusPrettyPrint()); data[2] = new Object[] { "Platform Status", sb.toString() }; TableModel model = new ArrayTableModel(data); TableBuilder tableBuilder = new TableBuilder(model); TableUtils.applyStyleNoHeader(tableBuilder); return tableBuilder.build(); }
Example 8
Source File: TaskCommands.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@CliCommand(value = TASK_EXECUTION_STATUS, help = "Display the details of a specific task execution") public Table display(@CliOption(key = { "", "id" }, help = "the task execution id", mandatory = true) long id) { TaskExecutionResource taskExecutionResource = taskOperations().taskExecutionStatus(id); TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("Key ").addValue("Value "); modelBuilder.addRow().addValue("Id ").addValue(taskExecutionResource.getExecutionId()); modelBuilder.addRow().addValue("Resource URL ").addValue(taskExecutionResource.getResourceUrl()); modelBuilder.addRow().addValue("Name ").addValue(taskExecutionResource.getTaskName()); modelBuilder.addRow().addValue("CLI Arguments ").addValue(taskExecutionResource.getArguments()); modelBuilder.addRow().addValue("App Arguments ").addValue(taskExecutionResource.getAppProperties()); modelBuilder.addRow().addValue("Deployment Properties ") .addValue(taskExecutionResource.getDeploymentProperties()); modelBuilder.addRow().addValue("Job Execution Ids ").addValue(taskExecutionResource.getJobExecutionIds()); modelBuilder.addRow().addValue("Start Time ").addValue(taskExecutionResource.getStartTime()); modelBuilder.addRow().addValue("End Time ").addValue(taskExecutionResource.getEndTime()); modelBuilder.addRow().addValue("Exit Code ").addValue(taskExecutionResource.getExitCode()); modelBuilder.addRow().addValue("Exit Message ").addValue(taskExecutionResource.getExitMessage()); modelBuilder.addRow().addValue("Error Message ").addValue(taskExecutionResource.getErrorMessage()); modelBuilder.addRow().addValue("External Execution Id ") .addValue(taskExecutionResource.getExternalExecutionId()); TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 9
Source File: TaskCommands.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@CliCommand(value = TASK_EXECUTION_CURRENT, help = "Display count of currently executin tasks and related information") public Table currentExecutions() { Collection<CurrentTaskExecutionsResource> taskExecutionsResources = taskOperations().currentTaskExecutions(); LinkedHashMap<String, Object> headers = new LinkedHashMap<>(); headers.put("name", "Platform Name"); headers.put("type", "Platform Type"); headers.put("runningExecutionCount", "Execution Count"); headers.put("maximumTaskExecutions", "Maximum Executions"); TableBuilder builder = new TableBuilder(new BeanListTableModel<>(taskExecutionsResources, headers)); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 10
Source File: JobCommands.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@CliCommand(value = EXECUTION_LIST, help = "List created job executions filtered by jobName") public Table executionList( @CliOption(key = { "name" }, help = "the job name to be used as a filter", mandatory = false) String name) { final PagedModel<JobExecutionThinResource> jobs; if (name == null) { jobs = jobOperations().executionThinList(); } else { jobs = jobOperations().executionThinListByJobName(name); } TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("ID ").addValue("Task ID").addValue("Job Name ").addValue("Start Time ") .addValue("Step Execution Count ").addValue("Definition Status "); for (JobExecutionThinResource job : jobs) { modelBuilder.addRow().addValue(job.getExecutionId()).addValue(job.getTaskExecutionId()) .addValue(job.getName()) .addValue(job.getStartDateTime()) .addValue(job.getStepExecutionCount()) .addValue(job.isDefined() ? "Created" : "Destroyed"); } TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }
Example 11
Source File: RuntimeCommands.java From spring-cloud-dashboard with Apache License 2.0 | 4 votes |
@CliCommand(value = LIST_APPS, help = "List runtime apps") public Table list( @CliOption(key = "summary", help = "whether to hide app instance details", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean summary, @CliOption(key = {"appId", "appIds"}, help = "app id(s) to display, also supports '<group>.*' pattern") String[] appIds) { Set<String> filter = null; if (appIds != null) { filter = new HashSet<>(Arrays.asList(appIds)); } TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); if (!summary) { modelBuilder.addRow() .addValue("App Id / Instance Id") .addValue("Unit Status") .addValue("No. of Instances / Attributes"); } else { modelBuilder.addRow() .addValue("App Id") .addValue("Unit Status") .addValue("No. of Instances"); } // In detailed mode, keep track of app vs instance lines, to use // a different border style later. List<Integer> splits = new ArrayList<>(); int line = 1; // Optimise for the single app case, which is likely less resource intensive on the server // than client side filtering Iterable<AppStatusResource> statuses; if (filter != null && filter.size() == 1 && !filter.iterator().next().endsWith(".*")) { statuses = Collections.singleton(runtimeOperations().status(filter.iterator().next())); } else { statuses = runtimeOperations().status(); } for (AppStatusResource appStatusResource : statuses) { if (filter != null && !shouldRetain(filter, appStatusResource)) { continue; } modelBuilder.addRow() .addValue(appStatusResource.getDeploymentId()) .addValue(appStatusResource.getState()) .addValue(appStatusResource.getInstances().getContent().size()); splits.add(line); line++; if (!summary) { for (AppInstanceStatusResource appInstanceStatusResource : appStatusResource.getInstances()) { modelBuilder.addRow() .addValue(appInstanceStatusResource.getInstanceId()) .addValue(appInstanceStatusResource.getState()) .addValue(appInstanceStatusResource.getAttributes()); line++; } } } TableModel model = modelBuilder.build(); final TableBuilder builder = new TableBuilder(model); DataFlowTables.applyStyle(builder); builder.on(column(0)).addAligner(middle) .on(column(1)).addAligner(middle) .on(column(1)).addAligner(center) // This will match the "number of instances" cells only .on(ofType(Integer.class)).addAligner(center); Tables.configureKeyValueRendering(builder, " = "); for (int i = 2; i < model.getRowCount(); i++) { if (splits.contains(i)) { builder.paintBorder(fancy_light, TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount()); } else { builder.paintBorder(fancy_light_quadruple_dash, TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount()); } } return builder.build(); }
Example 12
Source File: RuntimeCommands.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@CliCommand(value = LIST_APPS, help = "List runtime apps") public Table list( @CliOption(key = "summary", help = "whether to hide app instance details", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean summary, @CliOption(key = { "appId", "appIds" }, help = "app id(s) to display, also supports '<group>.*' pattern") String[] appIds) { Set<String> filter = null; if (appIds != null) { filter = new HashSet<>(Arrays.asList(appIds)); } TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); if (!summary) { modelBuilder.addRow().addValue("App Id / Instance Id").addValue("Unit Status") .addValue("No. of Instances / Attributes"); } else { modelBuilder.addRow().addValue("App Id").addValue("Unit Status").addValue("No. of Instances"); } // In detailed mode, keep track of app vs instance lines, to use // a different border style later. List<Integer> splits = new ArrayList<>(); int line = 1; // Optimise for the single app case, which is likely less resource intensive on // the server // than client side filtering Iterable<AppStatusResource> statuses; if (filter != null && filter.size() == 1 && !filter.iterator().next().endsWith(".*")) { statuses = Collections.singleton(runtimeOperations().status(filter.iterator().next())); } else { statuses = runtimeOperations().status(); } for (AppStatusResource appStatusResource : statuses) { if (filter != null && !shouldRetain(filter, appStatusResource)) { continue; } modelBuilder.addRow().addValue(appStatusResource.getDeploymentId()).addValue(appStatusResource.getState()) .addValue(appStatusResource.getInstances().getContent().size()); splits.add(line); line++; if (!summary) { for (AppInstanceStatusResource appInstanceStatusResource : appStatusResource.getInstances()) { modelBuilder.addRow().addValue(appInstanceStatusResource.getInstanceId()) .addValue(appInstanceStatusResource.getState()) .addValue(appInstanceStatusResource.getAttributes()); line++; } } } TableModel model = modelBuilder.build(); final TableBuilder builder = new TableBuilder(model); DataFlowTables.applyStyle(builder); builder.on(CellMatchers.column(0)).addAligner(SimpleVerticalAligner.middle).on(CellMatchers.column(1)).addAligner(SimpleVerticalAligner.middle).on(CellMatchers.column(1)).addAligner(SimpleHorizontalAligner.center) // This will match the "number of instances" cells only .on(CellMatchers.ofType(Integer.class)).addAligner(SimpleHorizontalAligner.center); Tables.configureKeyValueRendering(builder, " = "); for (int i = 2; i < model.getRowCount(); i++) { if (splits.contains(i)) { builder.paintBorder(BorderStyle.fancy_light, BorderSpecification.TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount()); } else { builder.paintBorder(BorderStyle.fancy_light_quadruple_dash, BorderSpecification.TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount()); } } return builder.build(); }
Example 13
Source File: JobCommands.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
@CliCommand(value = STEP_EXECUTION_DISPLAY, help = "Display the details of a specific step execution") public Table stepExecutionDisplay( @CliOption(key = { "id" }, help = "the step execution id", mandatory = true) long id, @CliOption(key = { "jobExecutionId" }, help = "the job execution id", mandatory = true) long jobExecutionId) { StepExecutionProgressInfoResource progressInfoResource = jobOperations().stepExecutionProgress(jobExecutionId, id); TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>(); modelBuilder.addRow().addValue("Key ").addValue("Value "); modelBuilder.addRow().addValue("Step Execution Id ").addValue(id); modelBuilder.addRow().addValue("Job Execution Id ").addValue(jobExecutionId); modelBuilder.addRow().addValue("Step Name ").addValue(progressInfoResource.getStepExecution().getStepName()); modelBuilder.addRow().addValue("Start Time ").addValue(progressInfoResource.getStepExecution().getStartTime()); modelBuilder.addRow().addValue("End Time ").addValue(progressInfoResource.getStepExecution().getEndTime()); modelBuilder.addRow().addValue("Duration ").addValue(progressInfoResource.getDuration() + " ms"); modelBuilder.addRow().addValue("Status ").addValue(progressInfoResource.getStepExecution().getStatus().name()); modelBuilder.addRow().addValue("Last Updated ") .addValue(progressInfoResource.getStepExecution().getLastUpdated()); modelBuilder.addRow().addValue("Read Count ") .addValue(progressInfoResource.getStepExecutionHistory().getReadCount().getCount()); modelBuilder.addRow().addValue("Write Count ") .addValue(progressInfoResource.getStepExecutionHistory().getWriteCount().getCount()); modelBuilder.addRow().addValue("Filter Count ") .addValue(progressInfoResource.getStepExecutionHistory().getFilterCount().getCount()); modelBuilder.addRow().addValue("Read Skip Count ") .addValue(progressInfoResource.getStepExecutionHistory().getReadSkipCount().getCount()); modelBuilder.addRow().addValue("Write Skip Count ") .addValue(progressInfoResource.getStepExecutionHistory().getWriteSkipCount().getCount()); modelBuilder.addRow().addValue("Process Skip Count ") .addValue(progressInfoResource.getStepExecutionHistory().getProcessSkipCount().getCount()); modelBuilder.addRow().addValue("Read Skip Count ") .addValue(progressInfoResource.getStepExecutionHistory().getReadSkipCount().getCount()); modelBuilder.addRow().addValue("Commit Count ") .addValue(progressInfoResource.getStepExecutionHistory().getCommitCount().getCount()); modelBuilder.addRow().addValue("Rollback Count ") .addValue(progressInfoResource.getStepExecutionHistory().getRollbackCount().getCount()); modelBuilder.addRow().addValue("Exit Status ") .addValue(progressInfoResource.getStepExecution().getExitStatus().getExitCode()); modelBuilder.addRow().addValue("Exit Description ") .addValue(progressInfoResource.getStepExecution().getExitStatus().getExitDescription()); TableBuilder builder = new TableBuilder(modelBuilder.build()); DataFlowTables.applyStyle(builder); return builder.build(); }