Search in sources :

Example 1 with Booking

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

the class BookingServiceImpl method list.

@Override
public List<Booking> list() {
    List<Booking> bookings = new ArrayList<>();
    for (int i = 0; i < jedis.llen(bookingListName); i++) {
        Booking booking = new GsonBuilder().create().fromJson(jedis.lindex(bookingListName, i), Booking.class);
        bookings.add(booking);
    }
    return bookings;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Booking(org.apache.karaf.examples.redis.api.Booking)

Example 2 with Booking

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

the class AddBookingCommand method execute.

@Override
public Object execute() throws Exception {
    Booking booking = new Booking(customer, flight);
    bookingService.add(booking);
    return null;
}
Also used : Booking(org.apache.karaf.examples.redis.api.Booking)

Example 3 with Booking

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

the class ListBookingCommand method execute.

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

Aggregations

Booking (org.apache.karaf.examples.redis.api.Booking)3 GsonBuilder (com.google.gson.GsonBuilder)1 ArrayList (java.util.ArrayList)1 ShellTable (org.apache.karaf.shell.support.table.ShellTable)1