yet more polishing
This commit is contained in:
@@ -10,4 +10,5 @@ public interface BookingService {
|
||||
|
||||
public Hotel findHotelById(Long id);
|
||||
|
||||
public void cancelBooking(Long id);
|
||||
}
|
||||
|
||||
@@ -41,4 +41,12 @@ public class JpaBookingService implements BookingService {
|
||||
public Hotel findHotelById(Long id) {
|
||||
return em.find(Hotel.class, id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelBooking(Long id) {
|
||||
Booking booking = em.find(Booking.class, id);
|
||||
if (booking != null) {
|
||||
em.remove(booking);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class BookingActions extends MultiAction {
|
||||
|
||||
public Event createBooking(RequestContext context) {
|
||||
Hotel hotel = (Hotel) context.getFlowScope().get("hotel");
|
||||
User user = (User) context.getFlowScope().get("user");
|
||||
User user = (User) context.getConversationScope().get("user");
|
||||
Booking booking = new Booking(hotel, user);
|
||||
EntityManager em = (EntityManager) context.getFlowScope().get("entityManager");
|
||||
em.persist(booking);
|
||||
|
||||
@@ -39,9 +39,4 @@ public class MainActions extends MultiAction {
|
||||
context.getFlowScope().put("hotels", new SerializableListDataModel(hotels));
|
||||
return success();
|
||||
}
|
||||
|
||||
public Event removeBooking(RequestContext context) {
|
||||
return success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,8 +34,12 @@
|
||||
<transition on="cancel" to="displayMain" />
|
||||
</subflow-state>
|
||||
|
||||
<action-state id="removeBooking">
|
||||
<action method="removeBooking" bean="mainActions" />
|
||||
<action-state id="cancelBooking">
|
||||
<bean-action method="cancelBooking" bean="bookingService">
|
||||
<method-arguments>
|
||||
<argument expression="param.bookingId" parameter-type="long"/>
|
||||
</method-arguments>
|
||||
</bean-action>
|
||||
<transition on="success" to="reloadCurrentUserBookings" />
|
||||
</action-state>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user