Java Code Examples for org.apache.karaf.shell.support.table.ShellTable#column()

The following examples show how to use org.apache.karaf.shell.support.table.ShellTable#column() . 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: RepositoryList.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Object execute() throws Exception {

    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("Title");
    table.emptyTableText("No Repositories");

    if (repositoryManager != null) {
        repositoryManager.getAllRepositories().forEach((repoID, repo) -> {
            RepositoryConfig config = repo.getConfig();
            table.addRow().addContent(config.id(), config.title());
        });
    }

    table.print(System.out);
    return null;
}
 
Example 2
Source File: ApplicationList.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute() throws Exception {
    System.out.println();
    ShellTable table = new ShellTable();
    table.column("id");
    table.column("name");
    table.column("up");
    table.column("state");
    table.column("expected state");

    managementContext.getApplications().forEach((application -> table.addRow().addContent(
            application.getApplicationId(),
            application.getDisplayName(),
            application.sensors().get(Attributes.SERVICE_UP).toString(),
            application.sensors().get(Attributes.SERVICE_STATE_ACTUAL).toString(),
            application.sensors().get(Attributes.SERVICE_STATE_EXPECTED).toString()
    )));
    table.print(System.out, true);
    System.out.println();
    return null;
}
 
Example 3
Source File: ListBussesCommand.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute() throws Exception {
    List<Bus> busses = getBusses();

    ShellTable table = new ShellTable();
    if (terminal != null && terminal.getWidth() > 0) {
        table.size(terminal.getWidth());
    }
    table.column("Name");
    table.column("State");

    for (Bus bus : busses) {
        String name = bus.getId();
        String state = bus.getState().toString();
        table.addRow().addContent(name, state);
    }
    table.print(System.out, !noFormat);
    return null;
}
 
Example 4
Source File: EntityInfo.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
public Object execute() throws Exception {
    Optional<Entity> entity = Optional.ofNullable(managementContext.getEntityManager().getEntity(id));
    if(!entity.isPresent()){
        System.err.println(String.format("Entity [%s] not found", id));
        return null;
    }
    printHeader("Basic Information");
    final ShellTable infoTable = new ShellTable();
    infoTable.column("").bold();
    infoTable.column("");
    infoTable.noHeaders();
    infoTable.addRow().addContent("Application Id", entity.get().getApplicationId());
    infoTable.addRow().addContent("Application Name", entity.get().getApplication().getDisplayName());
    infoTable.addRow().addContent("Name", entity.get().getDisplayName());
    infoTable.addRow().addContent("Id", id);
    infoTable.addRow().addContent("UP", entity.get().sensors().get(Attributes.SERVICE_UP));
    infoTable.addRow().addContent("State", entity.get().sensors().get(Attributes.SERVICE_STATE_ACTUAL));
    infoTable.addRow().addContent("Expected State", entity.get().sensors().get(Attributes.SERVICE_STATE_EXPECTED));
    infoTable.print(System.out, true);
    if (displayChildren || displayAll) {
        printHeader("Child Information");
        final ShellTable childrenTable = new ShellTable();
        childrenTable.column("id");
        childrenTable.column("name");

        entity.get().getChildren().forEach(child -> childrenTable.addRow().addContent(child.getId(), child.getDisplayName()));

        childrenTable.print(System.out, true);
    }
    if (displaySensors || displayAll) {
        printHeader("Sensor Information");
        final ShellTable sensorTable = new ShellTable();
        sensorTable.column("name");
        sensorTable.column("value");
        sensorTable.column("description");

        entity.get().getEntityType().getSensors().stream()
                .filter(AttributeSensor.class::isInstance).map(AttributeSensor.class::cast)
                .forEach(sensor -> sensorTable.addRow().addContent(sensor.getName(), entity.get().getAttribute(sensor), sensor.getDescription()));

        sensorTable.print(System.out, true);
    }

    if (displayConfig || displayAll) {
        printHeader("Config Information");
        final ShellTable configTable = new ShellTable();
        configTable.column("name");
        configTable.column("value");
        configTable.column("description");

        entity.get().getEntityType().getConfigKeys().stream()
                .forEach(configKey -> configTable.addRow().addContent(configKey.getName(), entity.get().getConfig(configKey), configKey.getDescription()));
        configTable.print(System.out, true);
    }

    if (displayBlueprint || displayAll) {
        final Optional<String> bluePrint = Optional.ofNullable(BrooklynTags.findFirst(BrooklynTags.YAML_SPEC_KIND, entity.get().tags().getTags()))
                .map(BrooklynTags.NamedStringTag::getContents);
        if (bluePrint.isPresent()) {
            printHeader("Blueprint Information");
            System.out.println("---");
            System.out.print(bluePrint.get());
            System.out.println("...");
        }
    }

    System.out.println();
    return null;
}