本文整理汇总了Java中com.brownfield.pss.book.entity.Passenger类的典型用法代码示例。如果您正苦于以下问题:Java Passenger类的具体用法?Java Passenger怎么用?Java Passenger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Passenger类属于com.brownfield.pss.book.entity包,在下文中一共展示了Passenger类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.brownfield.pss.book.entity.Passenger; //导入依赖的package包/类
@Override
public void run(String... strings) throws Exception {
Inventory[] invs = {
new Inventory("BF100", "22-JAN-16", 100),
new Inventory("BF101", "22-JAN-16", 100),
new Inventory("BF102", "22-JAN-16", 100),
new Inventory("BF103", "22-JAN-16", 100),
new Inventory("BF104", "22-JAN-16", 100),
new Inventory("BF105", "22-JAN-16", 100),
new Inventory("BF106", "22-JAN-16", 100)};
Arrays.asList(invs).forEach(inventory -> inventoryRepository.save(inventory));
BookingRecord booking = new BookingRecord("BF101", "NYC","SFO","22-JAN-16",new Date(),"101");
Set<Passenger> passengers = new HashSet<Passenger>();
passengers.add(new Passenger("Gean","Franc","Male", booking));
// passengers.add(new Passenger("Redi","Ivan","Female",booking));
booking.setPassengers(passengers);
long record = bookingComponent.book(booking);
logger.info("Booking successfully saved..." + record);
logger.info("Looking to load booking record...");
logger.info("Result: " + bookingComponent.getBooking(record));
}
示例2: book
import com.brownfield.pss.book.entity.Passenger; //导入依赖的package包/类
public long book(BookingRecord record) {
logger.info("calling fares to get fare");
//call fares to get fare
Fare fare = restTemplate.getForObject(FareURL +"/get?flightNumber="+record.getFlightNumber()+"&flightDate="+record.getFlightDate(),Fare.class);
logger.info("calling fares to get fare "+ fare);
//check fare
if (!record.getFare().equals(fare.getFare()))
throw new BookingException("fare is tampered");
logger.info("calling inventory to get inventory");
//check inventory
Inventory inventory = inventoryRepository.findByFlightNumberAndFlightDate(record.getFlightNumber(),record.getFlightDate());
if(!inventory.isAvailable(record.getPassengers().size())){
throw new BookingException("No more seats avaialble");
}
logger.info("successfully checked inventory" + inventory);
logger.info("calling inventory to update inventory");
//update inventory
inventory.setAvailable(inventory.getAvailable() - record.getPassengers().size());
inventoryRepository.saveAndFlush(inventory);
logger.info("sucessfully updated inventory");
//save booking
record.setStatus(BookingStatus.BOOKING_CONFIRMED);
Set<Passenger> passengers = record.getPassengers();
passengers.forEach(passenger -> passenger.setBookingRecord(record));
record.setBookingDate(new Date());
long id= bookingRepository.save(record).getId();
logger.info("Successfully saved booking");
//send a message to search to update inventory
logger.info("sending a booking event");
Map<String, Object> bookingDetails = new HashMap<String, Object>();
bookingDetails.put("FLIGHT_NUMBER", record.getFlightNumber());
bookingDetails.put("FLIGHT_DATE", record.getFlightDate());
bookingDetails.put("NEW_INVENTORY", inventory.getBookableInventory());
sender.send(bookingDetails);
logger.info("booking event successfully delivered "+ bookingDetails);
return id;
}
示例3: run
import com.brownfield.pss.book.entity.Passenger; //导入依赖的package包/类
@Override
public void run(String... strings) throws Exception {
Inventory[] invs = {
new Inventory("BF100", "22-JAN-16", 100),
new Inventory("BF101", "22-JAN-16", 100),
new Inventory("BF102", "22-JAN-16", 100),
new Inventory("BF103", "22-JAN-16", 100),
new Inventory("BF104", "22-JAN-16", 100),
new Inventory("BF105", "22-JAN-16", 100),
new Inventory("BF106", "22-JAN-16", 100)};
Arrays.asList(invs).forEach(inventory -> inventoryRepository.save(inventory));
BookingRecord booking = new BookingRecord("BF101", "NYC","SFO","22-JAN-16",new Date(),"101");
Set<Passenger> passengers = new HashSet<Passenger>();
passengers.add(new Passenger("Gean","Franc","Male", booking));
booking.setPassengers(passengers);
long record = bookingComponent.book(booking);
logger.info("Booking successfully saved..." + record);
logger.info("Looking to load booking record...");
logger.info("Result: " + bookingComponent.getBooking(record));
}
示例4: book
import com.brownfield.pss.book.entity.Passenger; //导入依赖的package包/类
public long book(BookingRecord record) {
logger.info("calling fares to get fare");
//call fares to get fare
// Fare fare = restTemplate.getForObject(fareServiceUrl+FareURL +"/get?flightNumber="+record.getFlightNumber()+"&flightDate="+record.getFlightDate(),Fare.class);
Fare fare = fareServiceProxy.getFare(record.getFlightNumber(), record.getFlightDate());
logger.info("calling fares to get fare "+ fare);
//check fare
if (!record.getFare().equals(fare.getFare()))
throw new BookingException("fare is tampered");
logger.info("calling inventory to get inventory");
//check inventory
Inventory inventory = inventoryRepository.findByFlightNumberAndFlightDate(record.getFlightNumber(),record.getFlightDate());
if(!inventory.isAvailable(record.getPassengers().size())){
throw new BookingException("No more seats avaialble");
}
logger.info("successfully checked inventory" + inventory);
logger.info("calling inventory to update inventory");
//update inventory
inventory.setAvailable(inventory.getAvailable() - record.getPassengers().size());
inventoryRepository.saveAndFlush(inventory);
logger.info("sucessfully updated inventory");
//save booking
record.setStatus(BookingStatus.BOOKING_CONFIRMED);
Set<Passenger> passengers = record.getPassengers();
passengers.forEach(passenger -> passenger.setBookingRecord(record));
record.setBookingDate(new Date());
long id= bookingRepository.save(record).getId();
logger.info("Successfully saved booking");
//send a message to search to update inventory
logger.info("sending a booking event");
Map<String, Object> bookingDetails = new HashMap<String, Object>();
bookingDetails.put("FLIGHT_NUMBER", record.getFlightNumber());
bookingDetails.put("FLIGHT_DATE", record.getFlightDate());
bookingDetails.put("NEW_INVENTORY", inventory.getBookableInventory());
sender.send(bookingDetails);
logger.info("booking event successfully delivered "+ bookingDetails);
return id;
}