use of org.apache.karaf.shell.support.table.ShellTable in project ddf by codice.
the class RangeCommand method executeWithSubject.
@Override
protected Object executeWithSubject() throws Exception {
Filter filter;
Date wayInTheFuture = new DateTime().plusYears(5000).toDate();
Date endDate = wayInTheFuture;
SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
if (WILDCARD.equals(rangeBeginning) && WILDCARD.equals(rangeEnd)) {
filter = filterBuilder.attribute(attributeName).before().date(endDate);
} else if (WILDCARD.equals(rangeBeginning) && !WILDCARD.equals(rangeEnd)) {
try {
endDate = formatter.parse(rangeEnd);
} catch (ParseException e) {
throw new InterruptedException("Could not parse second parameter [" + rangeEnd + "]");
}
filter = filterBuilder.attribute(attributeName).before().date(endDate);
} else if (!WILDCARD.equals(rangeBeginning) && WILDCARD.equals(rangeEnd)) {
try {
Date startDate = formatter.parse(rangeBeginning);
filter = filterBuilder.attribute(attributeName).during().dates(startDate, endDate);
} catch (ParseException e) {
throw new InterruptedException("Could not parse first parameter [" + rangeBeginning + "]");
}
} else {
try {
Date startDate = formatter.parse(rangeBeginning);
endDate = formatter.parse(rangeEnd);
filter = filterBuilder.attribute(attributeName).during().dates(startDate, endDate);
} catch (ParseException e) {
throw new InterruptedException("Could not parse date parameters.");
}
}
QueryImpl query = new QueryImpl(filter);
query.setPageSize(MAX_RESULTS);
query.setSortBy(new SortByImpl(attributeName, SortOrder.DESCENDING.name()));
QueryRequest queryRequest = new QueryRequestImpl(query);
SourceResponse response = getCatalog().query(queryRequest);
List<Result> results = response.getResults();
final ShellTable table = new ShellTable();
table.column(NUMBER);
table.column(ID);
table.column(attributeName);
table.column(TITLE).maxSize(MAX_LENGTH);
table.emptyTableText("No results");
int i = 1;
for (Result result : results) {
Attribute attribute = result.getMetacard().getAttribute(attributeName);
if (attribute != null && attribute.getValue() != null) {
String returnedDate = new DateTime(attribute.getValue()).toString(DATETIME_FORMATTER);
String title = result.getMetacard().getTitle();
final Row row = table.addRow();
row.addContent(i, result.getMetacard().getId(), returnedDate, title);
}
i++;
}
table.print(console, true);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project cxf by apache.
the class ListEndpointsCommand method execute.
@Override
public Object execute() throws Exception {
List<Bus> busses;
if (name == null) {
busses = getBusses();
} else {
Bus b = getBus(name);
if (b != null) {
busses = Collections.singletonList(getBus(name));
} else {
busses = Collections.emptyList();
}
}
ShellTable table = new ShellTable();
if (terminal != null && terminal.getWidth() > 0) {
table.size(terminal.getWidth());
}
table.column("Name");
table.column("State");
table.column("Address");
table.column("BusID");
for (Bus b : busses) {
ServerRegistry reg = b.getExtension(ServerRegistry.class);
List<Server> servers = reg.getServers();
for (Server serv : servers) {
String qname = serv.getEndpoint().getEndpointInfo().getName().getLocalPart();
String started = serv.isStarted() ? "Started" : "Stopped";
String address = serv.getEndpoint().getEndpointInfo().getAddress();
if (fullAddress) {
address = toFullAddress(address);
}
String busId = b.getId();
table.addRow().addContent(qname, started, address, busId);
}
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project cxf by apache.
the class ListBussesCommand method execute.
@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;
}
use of org.apache.karaf.shell.support.table.ShellTable in project fuse-karaf by jboss-fuse.
the class ListCredentialStore method execute.
@Override
public Object execute() throws Exception {
final ShellTable table = new ShellTable();
table.column(new Col("Alias"));
table.column(new Col("Reference"));
final CredentialStore credentialStore = CredentialStoreHelper.credentialStoreFromEnvironment();
for (final String alias : credentialStore.getAliases()) {
table.addRow().addContent(alias, CredentialStoreHelper.referenceForAlias(alias));
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class GetCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Flight");
table.column("Customer");
Booking booking = bookingService.get(id);
table.addRow().addContent(booking.getId(), booking.getFlight(), booking.getCustomer());
table.print(System.out);
return null;
}
Aggregations