use of com.tap5.hotelbooking.entities.User in project tapestry5-hotel-booking by ccordenier.
the class UserWorkspace method startBooking.
public void startBooking(Hotel hotel, User user) {
Booking booking = new Booking(hotel, user, 1, 1);
this.current = booking;
notConfirmed.add(booking);
}
use of com.tap5.hotelbooking.entities.User in project tapestry5-hotel-booking by ccordenier.
the class Settings method onSuccess.
public Object onSuccess() {
if (!verifyPassword.equals(password)) {
settingsForm.recordError(messages.get("error.verifypassword"));
return null;
}
User user = authenticator.getLoggedUser();
authenticator.logout();
user.setPassword(password);
crudServiceDAO.update(user);
signin.setFlashMessage(messages.get("settings.password-changed"));
return signin;
}
use of com.tap5.hotelbooking.entities.User in project tapestry5-hotel-booking by ccordenier.
the class View method startBooking.
/**
* Start booking process.
*
* @param hotel
* @return link to the current hotel booking
*/
@OnEvent(value = EventConstants.SUCCESS, component = "startBookingForm")
Object startBooking(Hotel hotel) {
User user = (User) dao.find(User.class, authenticator.getLoggedUser().getId());
userWorkspace.startBooking(hotel, user);
return Book.class;
}
use of com.tap5.hotelbooking.entities.User in project tapestry5-hotel-booking by ccordenier.
the class DataModule method initialize.
@Startup
public void initialize() {
List<Hotel> hotels = new ArrayList<Hotel>();
List<User> users = new ArrayList<User>();
users.add(new User("Christophe Cordenier", "cordenier", "ccordenier@example.com", "cordenier"));
users.add(new User("Katia Aresti", "karesti", "karesti@example.com", "karesti"));
hotels.add(new Hotel(129, 3, "Marriott Courtyard", "Tower Place, Buckhead", "Atlanta", "GA", "30305", "USA"));
hotels.add(new Hotel(84, 4, "Doubletree Atlanta-Buckhead", "3342 Peachtree Road NE", "Atlanta", "GA", "30326", "USA"));
hotels.add(new Hotel(289, 4, "W New York - Union Square", "201 Park Avenue South", "New York", "NY", "10003", "USA"));
hotels.add(new Hotel(219, 3, "W New York", "541 Lexington Avenue", "New York", "NY", "10022", "USA"));
hotels.add(new Hotel(250, 3, "Hotel Rouge", "1315 16th Street NW", "Washington", "DC", "20036", "USA"));
hotels.add(new Hotel(159, 4, "70 Park Avenue Hotel", "70 Park Avenue, 38th St", "New York", "NY", "10016", "USA"));
hotels.add(new Hotel(198, 4, "Parc 55", "55 Cyril Magnin Street", "San Francisco", "CA", "94102", "USA"));
hotels.add(new Hotel(189, 4, "Conrad Miami", "1395 Brickell Ave", "Miami", "FL", "33131", "USA"));
hotels.add(new Hotel(111, 4, "Grand Hyatt", "345 Stockton Street", "San Francisco", "CA", "94108", "USA"));
hotels.add(new Hotel(54, 1, "Super 8 Eau Claire Campus Area", "1151 W MacArthur Ave", "Eau Claire", "WI", "54701", "USA"));
hotels.add(new Hotel(199, 4, "San Francisco Marriott", "55 Fourth Street", "San Francisco", "CA", "94103", "USA"));
hotels.add(new Hotel(543, 4, "Hilton Diagonal Mar", "Passeig del Taulat 262-264", "Barcelona", "Catalunya", "08019", "ES"));
hotels.add(new Hotel(335, 5, "Hilton Tel Aviv", "Independence Park", "Tel Aviv", null, "63405", "IL"));
hotels.add(new Hotel(242, 5, "InterContinental Hotel Tokyo Bay", "1-15-2 Kaigan", "Tokyo", "Minato", "105", "JP"));
hotels.add(new Hotel(130, 4, "Hotel Beaulac", " Esplanade Léopold-Robert 2", "Neuchatel", null, "2000", "CH"));
hotels.add(new Hotel(266, 5, "Conrad Treasury Place", "130 William Street", "Brisbane", "QL", "4001", "AU"));
hotels.add(new Hotel(170, 4, "Ritz-Carlton Montreal", "1228 Sherbrooke St West", "Montreal", "Quebec", "H3G1H6", "CA"));
hotels.add(new Hotel(179, 4, "Ritz-Carlton Atlanta", "181 Peachtree St NE", "Atlanta", "GA", "30303", "USA"));
hotels.add(new Hotel(145, 4, "Swissotel Sydney", "68 Market Street", "Sydney", "NSW", "2000", "AU"));
hotels.add(new Hotel(178, 4, "Melié White House", "Albany Street Regents Park", "London", null, "NW13UP", "GB"));
hotels.add(new Hotel(159, 3, "Hotel Allegro", "171 W Randolph Street", "Chicago", "IL", "60601", "USA"));
hotels.add(new Hotel(296, 5, "Caesars Palace", "3570 Las Vegas Blvd S", "Las Vegas", "NV", "89109", "USA"));
hotels.add(new Hotel(300, 4, "Mandalay Bay Resort & Casino", "3950 Las Vegas Blvd S", "Las Vegas", "NV", "89119", "USA"));
hotels.add(new Hotel(100, 2, "Hotel Cammerpoorte", "Nationalestraat 38-40", "Antwerp", null, "2000", "BE"));
LOGGER.info("-- Loading initial demo data");
create(users);
create(hotels);
List<User> userList = dao.findWithNamedQuery(User.ALL);
LOGGER.info("Users " + userList);
LOGGER.info("-- Data Loaded. Exit");
}
use of com.tap5.hotelbooking.entities.User in project tapestry5-hotel-booking by ccordenier.
the class Signup method proceedSignup.
@OnEvent(value = EventConstants.SUCCESS, component = "RegisterForm")
public Object proceedSignup() {
User userVerif = crudServiceDAO.findUniqueWithNamedQuery(User.BY_USERNAME_OR_EMAIL, QueryParameters.with("username", username).and("email", email).parameters());
if (userVerif != null) {
registerForm.recordError(messages.get("error.userexists"));
return null;
}
User user = new User(fullName, username, email, password);
crudServiceDAO.create(user);
try {
authenticator.login(username, password);
} catch (AuthenticationException ex) {
registerForm.recordError("Authentication process has failed");
return this;
}
return Search.class;
}
Aggregations