本文整理汇总了Java中org.springframework.shell.table.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于org.springframework.shell.table包,在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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 = 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();
}
示例2: history
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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).getContent();
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();
}
示例3: history
import org.springframework.shell.table.Table; //导入依赖的package包/类
@CliCommand(value = STREAM_SKIPPER_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();
}
示例4: executionListByName
import org.springframework.shell.table.Table; //导入依赖的package包/类
@CliCommand(value = EXECUTION_LIST, help = "List created task executions filtered by taskName")
public Table executionListByName(@CliOption(key = "name", help = "the task name to be used as a filter",
optionContext = "existing-task disable-string-converter") String name) {
final PagedResources<TaskExecutionResource> tasks;
if (name == null) {
tasks = taskOperations().executionList();
}
else {
tasks = taskOperations().executionListByTaskName(name);
}
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
headers.put("taskName", "Task Name");
headers.put("executionId", "ID");
headers.put("startTime", "Start Time");
headers.put("endTime", "End Time");
headers.put("exitCode", "Exit Code");
final TableBuilder builder = new TableBuilder(new BeanListTableModel<>(tasks, headers));
return DataFlowTables.applyStyle(builder).build();
}
示例5: display
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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("Name ").addValue(taskExecutionResource.getTaskName());
modelBuilder.addRow().addValue("Arguments ").addValue(taskExecutionResource.getArguments());
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();
}
示例6: instanceDisplay
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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();
}
示例7: stepExecutionList
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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 PagedResources<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();
}
示例8: stepProgressDisplay
import org.springframework.shell.table.Table; //导入依赖的package包/类
@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();
}
示例9: testViewInstance
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testViewInstance() throws InterruptedException {
logger.info("Retrieve Job Instance Detail by Id");
Table table = getTable(job().instanceDisplay(jobInstances.get(0).getInstanceId()));
verifyColumnNumber(table, 5);
checkCell(table, 0, 0, "Name ");
checkCell(table, 0, 1, "Execution ID ");
checkCell(table, 0, 2, "Step Execution Count ");
checkCell(table, 0, 3, "Status ");
checkCell(table, 0, 4, "Job Parameters ");
boolean isValidCell = false;
if (table.getModel().getValue(1, 4).equals("foo=FOO,-bar=BAR")
|| table.getModel().getValue(1, 4).equals("-bar=BAR,foo=FOO")) {
isValidCell = true;
}
assertTrue("Job Parameters does match expected.", isValidCell);
}
示例10: testCounterInteractions
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testCounterInteractions() {
Table table = metrics().listCounters();
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getRowCount(), is(1));
repository.set(new Metric<>("counter.foo", 12.0d));
repository.set(new Metric<>("counter.bar", 42.0d));
table = metrics().listCounters();
// Test alphabetical order
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getValue(1, 0), is("bar"));
assertThat(table.getModel().getValue(2, 0), is("foo"));
String value = metrics().displayCounter("foo");
assertThat(value, is("12"));
String message = metrics().resetCounter("foo");
assertThat(message, is("Deleted counter 'foo'"));
table = metrics().listCounters();
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getRowCount(), is(2));
}
示例11: testFVCInteractions
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testFVCInteractions() {
Table table = metrics().listFieldValueCounters();
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getRowCount(), is(1));
repository.increment("foo", "fieldA", 12.0d);
repository.increment("foo", "fieldB", 42.0d);
repository.increment("bar", "fieldA", 12.0d);
table = metrics().listFieldValueCounters();
// Test alphabetical order
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getValue(1, 0), is("bar"));
assertThat(table.getModel().getValue(2, 0), is("foo"));
Table values = metrics().displayFieldValueCounter("foo");
assertThat(values, hasRowThat(is("fieldA"), is(12d)));
assertThat(values, hasRowThat(is("fieldB"), is(42d)));
String message = metrics().resetFieldValueCounter("foo");
assertThat(message, is("Deleted field value counter 'foo'"));
table = metrics().listFieldValueCounters();
assertThat(table.getModel().getColumnCount(), is(1));
assertThat(table.getModel().getRowCount(), is(2));
}
示例12: testInfo
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testInfo() throws IOException {
DataFlowOperations dataFlowOperations = mock(DataFlowOperations.class);
AboutOperations aboutOperations = mock(AboutOperations.class);
when(dataFlowOperations.aboutOperation()).thenReturn(aboutOperations);
AboutResource aboutResource = new AboutResource();
when(aboutOperations.get()).thenReturn(aboutResource);
dataFlowShell.setDataFlowOperations(dataFlowOperations);
aboutResource.getFeatureInfo().setTasksEnabled(false);
aboutResource.getVersionInfo().getCore().setName("Foo Core");
aboutResource.getVersionInfo().getCore().setVersion("1.2.3.BUILD-SNAPSHOT");
aboutResource.getSecurityInfo().setAuthenticationEnabled(true);
aboutResource.getRuntimeEnvironment().getAppDeployer().setJavaVersion("1.8");
aboutResource.getRuntimeEnvironment().getAppDeployer().getPlatformSpecificInfo().put("Some", "Stuff");
aboutResource.getRuntimeEnvironment().getTaskLauncher().setDeployerSpiVersion("6.4");
final Table infoResult = (Table) configCommands.info().get(0);
String expectedOutput = FileCopyUtils.copyToString(new InputStreamReader(
getClass().getResourceAsStream(ConfigCommandTests.class.getSimpleName() + "-testInfo.txt"), "UTF-8"));
assertThat(infoResult.render(80), is(expectedOutput));
}
示例13: testList
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testList() {
String[][] apps = new String[][] { { "http", "source" }, { "filter", "processor" },
{ "transform", "processor" }, { "file", "source" }, { "log", "sink" },
{ "moving-average", "processor" } };
Collection<AppRegistrationResource> data = new ArrayList<>();
for (String[] app : apps) {
data.add(new AppRegistrationResource(app[0], app[1], null));
}
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppRegistrationResource> result = new PagedResources<>(data, metadata);
when(appRegistryOperations.list()).thenReturn(result);
Object[][] expected = new String[][] { { "source", "processor", "sink", "task" },
{ "http", "filter", "log", null }, { "file", "transform", null, null },
{ null, "moving-average", null, null }, };
TableModel model = ((Table) appRegistryCommands.list(null)).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(model.getValue(row, col), Matchers.is(expected[row][col]));
}
}
}
示例14: testTaskExecutionList
import org.springframework.shell.table.Table; //导入依赖的package包/类
@Test
public void testTaskExecutionList() throws InterruptedException {
logger.info("Retrieve Task Execution List Test");
CommandResult cr = task().taskExecutionList();
assertTrue("task execution list command must be successful", cr.isSuccess());
Table table = (Table) cr.getResult();
assertEquals("Number of columns returned was not expected", 5, table.getModel().getColumnCount());
assertEquals("First column should be Task Name", "Task Name", table.getModel().getValue(0, 0));
assertEquals("Second column should be ID", "ID", table.getModel().getValue(0, 1));
assertEquals("Third column should be Start Time", "Start Time", table.getModel().getValue(0, 2));
assertEquals("Fourth column should be End Time", "End Time", table.getModel().getValue(0, 3));
assertEquals("Fifth column should be Exit Code", "Exit Code", table.getModel().getValue(0, 4));
assertEquals("First column, second row should be " + TASK_NAME, TASK_NAME, table.getModel().getValue(1, 0));
assertEquals("Second column, second row should be " + TASK_EXECUTION_ID, TASK_EXECUTION_ID,
table.getModel().getValue(1, 1));
assertEquals("Third column, second row should be " + startTime, startTime, table.getModel().getValue(1, 2));
assertEquals("Fourth column, second row should be End Time" + endTime, endTime,
table.getModel().getValue(1, 3));
assertEquals("Fifth column, second row should be Exit Code" + EXIT_CODE, EXIT_CODE,
table.getModel().getValue(1, 4));
}
示例15: verifyExists
import org.springframework.shell.table.Table; //导入依赖的package包/类
/**
* Verify the stream is listed in stream list.
*
* @param streamName the name of the stream
* @param definition definition of the stream
*/
public void verifyExists(String streamName, String definition, boolean deployed) {
CommandResult cr = shell.executeCommand("stream list");
assertTrue("Failure. CommandResult = " + cr.toString(), cr.isSuccess());
Table table = (org.springframework.shell.table.Table) cr.getResult();
TableModel model = table.getModel();
Collection<String> statuses = deployed
? Arrays.asList(DeploymentStateResource.DEPLOYED.getDescription(),
DeploymentStateResource.DEPLOYING.getDescription())
: Arrays.asList(DeploymentStateResource.UNDEPLOYED.getDescription());
for (int row = 0; row < model.getRowCount(); row++) {
if (streamName.equals(model.getValue(row, 0))
&& definition.replace("\\\\", "\\").equals(model.getValue(row, 1))
&& statuses.contains(model.getValue(row, 2))) {
return;
}
}
fail("Stream named " + streamName + " does not exist");
}