Search in sources :

Example 1 with Booking

use of org.apache.karaf.examples.command.api.Booking in project karaf by apache.

the class ListCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("Flight");
    table.column("Customer");
    for (Booking booking : bookingService.list()) {
        table.addRow().addContent(booking.getId(), booking.getFlight(), booking.getCustomer());
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Booking(org.apache.karaf.examples.command.api.Booking)

Example 2 with Booking

use of org.apache.karaf.examples.command.api.Booking in project karaf by apache.

the class AddCommand method execute.

@Override
public Object execute() throws Exception {
    Booking booking = new Booking();
    if (id == 0) {
        Random random = new Random();
        id = Long.valueOf(random.nextInt(9000000) + 1000000);
    }
    booking.setId(id);
    booking.setCustomer(customer);
    booking.setFlight(flight);
    bookingService.add(booking);
    return null;
}
Also used : Random(java.util.Random) Booking(org.apache.karaf.examples.command.api.Booking)

Aggregations

Booking (org.apache.karaf.examples.command.api.Booking)2 Random (java.util.Random)1 ShellTable (org.apache.karaf.shell.support.table.ShellTable)1