Search in sources :

Example 51 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ListCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("Name");
    table.column("Service Id");
    table.column("Product");
    table.column("Version");
    table.column("URL");
    table.column("Status");
    boolean duplication = false;
    Map<String, Long> nameToId = new HashMap<>();
    List<Long> datasources = this.getJdbcService().datasourceServiceIds();
    Collections.sort(datasources);
    for (Long id : datasources) {
        try {
            Map<String, String> info = this.getJdbcService().info(Long.toString(id));
            table.addRow().addContent(info.get("name"), info.get("service.id"), info.get("db.product"), info.get("db.version"), info.get("url"), "OK");
            if (nameToId.put(info.get("name"), id) != null) {
                duplication = true;
            }
        } catch (Exception e) {
            table.addRow().addContent(id, "", "", "", "", "Error " + e.getMessage());
        }
    }
    table.print(System.out);
    if (duplication) {
        System.out.println("\nThere are multiple data source services registered with the same name. Please review your configuration.");
    }
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) HashMap(java.util.HashMap)

Example 52 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ConnectionFactoriesCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("JMS Connection Factory");
    List<String> connectionFactories = getJmsService().connectionFactories();
    for (String connectionFactory : connectionFactories) {
        table.addRow().addContent(connectionFactory);
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 53 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class QueryCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    Map<String, List<String>> map = this.getJdbcService().query(datasource, query);
    int rowCount = 0;
    for (String column : map.keySet()) {
        table.column(column);
        rowCount = map.get(column).size();
    }
    for (int i = 0; i < rowCount; i++) {
        Row row = table.addRow();
        for (String column : map.keySet()) {
            row.addContent(map.get(column).get(i));
        }
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) List(java.util.List) Row(org.apache.karaf.shell.support.table.Row)

Example 54 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class CountCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("Messages Count");
    table.addRow().addContent(getJmsService().count(connectionFactory, queue, username, password));
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 55 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class InfoCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("Property");
    table.column("Value");
    Map<String, String> info = getJmsService().info(connectionFactory, username, password);
    for (String key : info.keySet()) {
        table.addRow().addContent(key, info.get(key));
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Aggregations

ShellTable (org.apache.karaf.shell.support.table.ShellTable)59 Row (org.apache.karaf.shell.support.table.Row)10 Col (org.apache.karaf.shell.support.table.Col)7 ArrayList (java.util.ArrayList)4 Bundle (org.osgi.framework.Bundle)4 Map (java.util.Map)3 Feature (org.apache.karaf.features.Feature)3 Repository (org.apache.karaf.features.Repository)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Bus (org.apache.cxf.Bus)2 Booking (org.apache.karaf.examples.jdbc.api.Booking)2 Booking (org.apache.karaf.examples.jpa.Booking)2 MavenRepositoryURL (org.apache.karaf.maven.core.MavenRepositoryURL)2 Attribute (ddf.catalog.data.Attribute)1 Result (ddf.catalog.data.Result)1 SortByImpl (ddf.catalog.filter.impl.SortByImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1