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;
}
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;
}
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;
}
Aggregations