HotelmanagementSystem :
There are Four Modul
1. Model Module
2. DAO module
3.Controller Module
4. Services
1. Model module
Customer Class:
package com.hotel.management.indrajeet.model;
import java.util.Date;
public class Customer {
String fname;
String lname;
String address;
String country;
String nationality;
String proofid;
String idno;
Date bookingdate;
Date from_date;
Date to_date;
int roomno;
String roomtype;
String bedtype;
double roomrent;
String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRoomtype() {
return roomtype;
}
public void setRoomtype(String roomtype) {
this.roomtype = roomtype;
}
public String getBedtype() {
return bedtype;
}
public void setBedtype(String bedtype) {
this.bedtype = bedtype;
}
public double getRoomrent() {
return roomrent;
}
public void setRoomrent(double roomrent) {
this.roomrent = roomrent;
}
public Date getBookingdate() {
return bookingdate;
}
public void setBookingdate(Date bookingdate) {
this.bookingdate = bookingdate;
}
public String getIdno() {
return idno;
}
public void setIdno(String idno) {
this.idno = idno;
}
public int getRoomno() {
return roomno;
}
public void setRoomno(int roomno) {
this.roomno = roomno;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getProofid() {
return proofid;
}
public void setProofid(String proofid) {
this.proofid = proofid;
}
public Date getFrom_date() {
return from_date;
}
public void setFrom_date(Date from_date) {
this.from_date = from_date;
}
public Date getTo_date() {
return to_date;
}
public void setTo_date(Date to_date) {
this.to_date = to_date;
}
@Override
public String toString() {
return "Customer [fname=" + fname + ", lname=" + lname + ", address="
+ address + ", country=" + country + ", nationality="
+ nationality + ", proofid=" + proofid + ", idno=" + idno
+ ", bookingdate=" + bookingdate + ", from_date=" + from_date
+ ", to_date=" + to_date + ", roomno=" + roomno + ", roomtype="
+ roomtype + ", bedtype=" + bedtype + ", roomrent=" + roomrent
+ ", status=" + status + "]";
}
}
Login Class:
package com.hotel.management.indrajeet.model;
public class Login {
private String username;
private String password;
private String role;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
@Override
public String toString() {
return "Login [username=" + username + ", password=" + password
+ ", role=" + role + "]";
}
}
/admin.jsp
/receptionist.jsp
/error.jsp
/logoutsuccess.jsp
/UpdateRoom.jsp
AvailableUpdatedRoom
/GetAllRoom.jsp
/UpdatedRooms.jsp
/roomsForDelete.jsp
RoomListForDelete
/deleteRoomError.jsp
/ReceptionistAllRooms.jsp
/ReceptionistAllCustomers.jsp
/ManagerAllCustomer.jsp
/chekoutpage.jsp
/chekoutAction.jsp
/Checkout.jsp
/BookAvailableRooms.jsp
/BookRoom.jsp
/addRoom.jsp
/AdminAllRooms.jsp
bookRoomSuccess.jsp
/bookRoomError.jsp
/bookRoomupdated.jsp
There are Four Modul
1. Model Module
2. DAO module
3.Controller Module
4. Services
1. Model module
Customer Class:
package com.hotel.management.indrajeet.model;
import java.util.Date;
public class Customer {
String fname;
String lname;
String address;
String country;
String nationality;
String proofid;
String idno;
Date bookingdate;
Date from_date;
Date to_date;
int roomno;
String roomtype;
String bedtype;
double roomrent;
String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getRoomtype() {
return roomtype;
}
public void setRoomtype(String roomtype) {
this.roomtype = roomtype;
}
public String getBedtype() {
return bedtype;
}
public void setBedtype(String bedtype) {
this.bedtype = bedtype;
}
public double getRoomrent() {
return roomrent;
}
public void setRoomrent(double roomrent) {
this.roomrent = roomrent;
}
public Date getBookingdate() {
return bookingdate;
}
public void setBookingdate(Date bookingdate) {
this.bookingdate = bookingdate;
}
public String getIdno() {
return idno;
}
public void setIdno(String idno) {
this.idno = idno;
}
public int getRoomno() {
return roomno;
}
public void setRoomno(int roomno) {
this.roomno = roomno;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getProofid() {
return proofid;
}
public void setProofid(String proofid) {
this.proofid = proofid;
}
public Date getFrom_date() {
return from_date;
}
public void setFrom_date(Date from_date) {
this.from_date = from_date;
}
public Date getTo_date() {
return to_date;
}
public void setTo_date(Date to_date) {
this.to_date = to_date;
}
@Override
public String toString() {
return "Customer [fname=" + fname + ", lname=" + lname + ", address="
+ address + ", country=" + country + ", nationality="
+ nationality + ", proofid=" + proofid + ", idno=" + idno
+ ", bookingdate=" + bookingdate + ", from_date=" + from_date
+ ", to_date=" + to_date + ", roomno=" + roomno + ", roomtype="
+ roomtype + ", bedtype=" + bedtype + ", roomrent=" + roomrent
+ ", status=" + status + "]";
}
}
Login Class:
package com.hotel.management.indrajeet.model;
public class Login {
private String username;
private String password;
private String role;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
@Override
public String toString() {
return "Login [username=" + username + ", password=" + password
+ ", role=" + role + "]";
}
}
Room Class:
package com.hotel.management.indrajeet.model;
public class Room {
private int roomno;
private String roomtype;
private String bedtype;
private double roomrent;
public Room() {
}
public int getRoomno() {
return roomno;
}
public void setRoomno(int roomno) {
this.roomno = roomno;
}
public String getRoomtype() {
return roomtype;
}
public void setRoomtype(String roomtype) {
this.roomtype = roomtype;
}
public String getBedtype() {
return bedtype;
}
public void setBedtype(String bedtype) {
this.bedtype = bedtype;
}
public double getRoomrent() {
return roomrent;
}
public void setRoomrent(double roomrent) {
this.roomrent = roomrent;
}
@Override
public String toString() {
return "Room [roomno=" + roomno + ", roomtype=" + roomtype
+ ", bedtype=" + bedtype + ", roomrent=" + roomrent + "]";
}
}
2. DAO module
Customer DAO class:
package com.hotel.management.indrajeet.Dao;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import com.hotel.management.indrajeet.model.Customer;
import com.hotel.management.indrajeet.model.Login;
import com.hotel.management.indrajeet.model.Room;
public class CustomerDao {
private SessionFactory sessionFactory;
static final Logger LOGGER = Logger.getLogger(CustomerDao.class);
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public String BookRoomCustomerDao(Customer customer) {
LOGGER.info(" bookroomcostoemr dao" + customer);
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Object obj = session.save(customer);
session.getTransaction().commit();
if (obj != null) {
return "bookComplete";
} else {
return null;
}
}
public String validateRoomnodao(int roomno) {
boolean roomid;
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
System.out.println("validate in dao ");
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Customer where roomno=:myid");
query.setParameter("myid", roomno);
/*query.setParameter("mystatus", status);*/
String status1;
List list = query.list();
Iterator plist = list.iterator();
if (plist.hasNext()) {
Object obj = plist.next();
Customer cus = (Customer) obj;
status1 = cus.getStatus();
} else {
status1 = "checkout";
}
return status1;
}
public List getAllCustomersDao() {
List customerslist=new ArrayList();
System.out.println("This is a logging to customerDao list of customers");
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
customerslist = session.createQuery(
"from com.hotel.management.indrajeet.model.Customer").list();
return customerslist;
}
public List GetcustomerInfoService(int roomid) {
List Customers = new ArrayList();
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Customer where roomno=:myroomno ");
query.setParameter("myroomno", roomid);
Customers = query.list();
return Customers;
}
public String checkCusIDDao(String proofid) {
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
System.out.println("validate in dao ");
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Customer where idno=:myid");
query.setParameter("myid", proofid);
String status1="";
List list = query.list();
Iterator plist = list.iterator();
if (plist.hasNext()) {
Object obj = plist.next();
Customer cus = (Customer) obj;
status1 = cus.getIdno();
return status1;
}
else {
return status1;
}
}
public String UpdateRoomCustomerdao(Customer customer) {
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
session.update(customer);
session.getTransaction().commit();
return "Update";
}
}
LoginDAO Class
package com.hotel.management.indrajeet.Dao;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import com.hotel.management.indrajeet.model.Login;
public class LoginDao {
private static SessionFactory sessionFactory;
private static org.apache.log4j.Logger log = Logger
.getLogger(LoginDao.class);
public LoginDao() {
System.out.println("dao constructor");
}
public LoginDao(SessionFactory sessionFactory) {
super();
this.sessionFactory = sessionFactory;
}
public static SessionFactory getSessionFactory() {
log.info("Info Message!");
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public static String validate(String username, String userpass) {
String role;
System.out.println("dao 1");
log.info("Info Message!");
boolean status = false;
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
log.info("Info Message!");
System.out.println("dao 2");
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Login where username=:myusername and password=:mypassword");
query.setParameter("myusername", username);
query.setParameter("mypassword", userpass);
System.out.println("dao 3");
List list = query.list();
Iterator plist = list.iterator();
if (plist.hasNext()) {
Object obj = plist.next();
Login pat = (Login) obj;
role = pat.getRole();
System.out.println(role);
} else {
role = "raja";
}
/*
* List list=query.list(); if(list==null) { role="raja"; } else {
* System.out.println("dao 4"); Login login=(Login)list.get(1);
* System.out.println("dao 5"); role=login.getRole(); }
*/
System.out.println("dao " + role);
/*
* if(query.iterate() != null) { log.info("Info Message!"); status=true;
* } System.out.println("dao "+status);
*/
return role;
}
}
RoomDAO Class
package com.hotel.management.indrajeet.Dao;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import com.hotel.management.indrajeet.model.Customer;
import com.hotel.management.indrajeet.model.Room;
public class RoomDao {
private SessionFactory sessionFactory;
private static org.apache.log4j.Logger log = Logger
.getLogger(RoomDao.class);
public RoomDao() {
System.out.println("dao constructor");
}
public RoomDao(SessionFactory sessionFactory) {
super();
this.sessionFactory = sessionFactory;
}
public SessionFactory getSessionFactory() {
log.info("Info Message!");
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public List getAllRoom() {
List rooms = new ArrayList();
log.info("This is a logging statement from log4j doctor dao list patients");
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
rooms = session.createQuery(
"from com.hotel.management.indrajeet.model.Room").list();
return rooms;
}
public String addRoomDao(Room room) {
log.info(" Addroomcostoemr dao" + room);
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Object obj = session.save(room);
session.getTransaction().commit();
if (obj != null) {
return "roomComplete";
} else {
return null;
}
}
public List GetRoomInfodao(int roomid) {
List rooms = new ArrayList();
log.info("This is a logging ");
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Room where roomno=:myroomno");
query.setParameter("myroomno", roomid);
rooms = query.list();
return rooms;
}
public String updateMethodDao(Room room) {
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
session.merge(room);
session.getTransaction().commit();
return "afterUpdate";
}
public String DeleteRoomMethodDao(int roomid) {
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Room room = (Room) session.load(Room.class, roomid);
if (null != room) {
session.delete(room);
}
session.getTransaction().commit();
return "afterDelete";
}
public int validateRoomnodao(int roomno) {
int roomid;
Session session = getSessionFactory().getCurrentSession();
session.beginTransaction();
Query query = session
.createQuery("from com.hotel.management.indrajeet.model.Customer where roomno=:myid");
query.setParameter("myid", roomno);
List list = query.list();
Iterator plist = list.iterator();
if (plist.hasNext()) {
Object obj = plist.next();
Customer pat = (Customer) obj;
roomid = pat.getRoomno();
} else {
roomid = 0;
}
return roomid;
}
}
3.Controller Module
CustomerController Class
package com.hotel.management.indrajeet.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import com.hotel.management.indrajeet.Dao.CustomerDao;
import com.hotel.management.indrajeet.Services.CustomerService;
import com.hotel.management.indrajeet.model.Customer;
public class CustomerController {
String fname;
String lname;
String address;
String country;
String nationality;
String proofid;
String idno;
Date from_date;
Date to_date;
Date bookingdate;
int roomno;
String roomtype;
String bedtype;
double roomrent;
double fine;
double total;
String status;
int noofdays;
List customerslist=new ArrayList();
List customerslist1=new ArrayList();
static final Logger LOGGER = Logger.getLogger(CustomerController.class);
CustomerService customerservice;
Customer customer = new Customer();
public int getNoofdays() {
return noofdays;
}
public void setNoofdays(int noofdays) {
this.noofdays = noofdays;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public double getFine() {
return fine;
}
public void setFine(double fine) {
this.fine = fine;
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public double getRoomrent() {
return roomrent;
}
public void setRoomrent(double roomrent) {
this.roomrent = roomrent;
}
public List getCustomerslist1() {
return customerslist1;
}
public void setCustomerslist1(List customerslist1) {
this.customerslist1 = customerslist1;
}
public List getCustomerslist() {
return customerslist;
}
public void setCustomerslist(List customerslist) {
this.customerslist = customerslist;
}
public String getRoomtype() {
return roomtype;
}
public void setRoomtype(String roomtype) {
this.roomtype = roomtype;
}
public String getBedtype() {
return bedtype;
}
public void setBedtype(String bedtype) {
this.bedtype = bedtype;
}
public Date getBookingdate() {
return bookingdate;
}
public void setBookingdate(Date bookingdate) {
this.bookingdate = bookingdate;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public CustomerService getCustomerservice() {
return customerservice;
}
public void setCustomerservice(CustomerService customerservice) {
this.customerservice = customerservice;
}
public int getRoomno() {
return roomno;
}
public void setRoomno(int roomno) {
this.roomno = roomno;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getProofid() {
return proofid;
}
public void setProofid(String proofid) {
this.proofid = proofid;
}
public Date getFrom_date() {
return from_date;
}
public void setFrom_date(Date from_date) {
this.from_date = from_date;
}
public Date getTo_date() {
return to_date;
}
public void setTo_date(Date to_date) {
this.to_date = to_date;
}
public String getIdno() {
return idno;
}
public void setIdno(String idno) {
this.idno = idno;
}
public String execute() {
LOGGER.info("This is roomrent info"+roomrent);
int roomid1=getRoomno();
/*Date todate=getTo_date();
Date fromdate=getFrom_date();*/
/*String status1=getStatus();*/
String idnocheck=getIdno();
String checkstatus=customerservice.validateRoomnoService(roomid1);
String checkid=customerservice.checkCusID(idnocheck);
if((checkid.equalsIgnoreCase(idnocheck)) && (checkstatus.equalsIgnoreCase("checkout")))
{
customer.setProofid(proofid);
customer.setIdno(idno);
customer.setFrom_date(from_date);
customer.setTo_date(to_date);
customer.setBookingdate(bookingdate);
customer.setRoomno(roomno);
customer.setBedtype(bedtype);
customer.setRoomrent(roomrent);
customer.setRoomtype(roomtype);
customer.setStatus(status);
String chekupdate=customerservice.UpdateRoomCustomerService(customer);
return chekupdate;
}
else if (checkstatus.equalsIgnoreCase("checkout")) {
customer.setAddress(address);
customer.setCountry(country);
customer.setNationality(nationality);
customer.setFname(fname);
customer.setLname(lname);
customer.setProofid(proofid);
customer.setIdno(idno);
customer.setFrom_date(from_date);
customer.setTo_date(to_date);
customer.setBookingdate(bookingdate);
customer.setRoomno(roomno);
customer.setBedtype(bedtype);
customer.setRoomrent(roomrent);
customer.setRoomtype(roomtype);
customer.setStatus(status);
LOGGER.info("This is roomrent info"+customer);
String bookstring = customerservice
.BookRoomCustomerService(customer);
return bookstring;
} else {
return "error";
}
}
public String listCustomers() {
customerslist = customerservice.getAllCustomersService();
return "success";
}
public String checkoutMethod() {
int roomid = getRoomno();
customerslist1 = customerservice.GetcustomerInfoService(roomid);
return "BeforeCheckout";
}
public String checkoutActionMethod()
{
total=getFine()+getRoomrent()*getNoofdays();
return "Checkoutaction";
}
}
LoginController Class
package com.hotel.management.indrajeet.controller;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import com.hotel.management.indrajeet.Dao.LoginDao;
import com.hotel.management.indrajeet.Services.LoginService;
public class LoginController implements SessionAware {
private String username;
private String password;
private String role;
LoginService loginservice;
SessionMap sessionmap;
private static org.apache.log4j.Logger log = Logger
.getLogger(LoginController.class);
public LoginController(String username, String password, String role,
LoginService loginservice) {
super();
this.username = username;
this.password = password;
this.role = role;
this.loginservice = loginservice;
}
static {
System.out.println("1");
}
public LoginController() {
System.out.println("2");
}
public LoginService getLoginservice() {
return loginservice;
}
public void setLoginservice(LoginService loginservice) {
System.out.println("setLoginservice called");
this.loginservice = loginservice;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String execute() {
System.out.println("10");
System.out.println(username);
System.out.println(loginservice);
log.info("logger in execute login");
System.out.println("" + role);
role = loginservice.validateService(username, password);
if (role.equals("manager")) {
return "manager";
} else if (role.equals("receptionist")) {
return "RECEPTIONIST";
} else if (role.equals("raja")) {
return "error";
} else {
return "error";
}
}
public void setSession(Map map) {
sessionmap = (SessionMap) map;
sessionmap.put("login", "true");
}
public String logout() {
sessionmap.invalidate();
return "success";
}
}
RoomController Class:
package com.hotel.management.indrajeet.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import com.hotel.management.indrajeet.Dao.RoomDao;
import com.hotel.management.indrajeet.Services.CustomerService;
import com.hotel.management.indrajeet.Services.RoomService;
import com.hotel.management.indrajeet.model.Room;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class RoomController extends ActionSupport implements ModelDriven {
private int roomno;
private String roomtype;
private String bedtype;
private double roomrent;
private RoomService roomservice;
Room room = new Room();
List roomslist = new ArrayList();
List list1 = new ArrayList();
List list2 = new ArrayList();
private static org.apache.log4j.Logger log = Logger
.getLogger(RoomController.class);
public List getList2() {
return list2;
}
public void setList2(List list2) {
this.list2 = list2;
}
public List getList1() {
return list1;
}
public void setList1(List list1) {
this.list1 = list1;
}
public RoomController() {
}
public int getRoomno() {
return roomno;
}
public void setRoomno(int roomno) {
this.roomno = roomno;
}
public String getRoomtype() {
return roomtype;
}
public void setRoomtype(String roomtype) {
this.roomtype = roomtype;
}
public String getBedtype() {
return bedtype;
}
public void setBedtype(String bedtype) {
this.bedtype = bedtype;
}
public double getRoomrent() {
return roomrent;
}
public void setRoomrent(double roomrent) {
this.roomrent = roomrent;
}
public RoomService getRoomservice() {
return roomservice;
}
public void setRoomservice(RoomService roomservice) {
this.roomservice = roomservice;
}
public Room getRoom() {
return room;
}
public void setRoom(Room room) {
this.room = room;
}
public List getRoomslist() {
return roomslist;
}
public void setRoomslist(List roomslist) {
this.roomslist = roomslist;
}
public Room getModel() {
// TODO Auto-generated method stub
return room;
}
public String listRooms() {
log.info("This is a logging statement from log4j doctor controller show doctors ");
roomslist = roomservice.getAllRoomService();
return "success";
}
public String addroomController()
{
room.setRoomno(roomno);
room.setBedtype(bedtype);
room.setRoomtype(roomtype);
room.setRoomrent(roomrent);
String addroomstring = roomservice.addRoomService(room);
return addroomstring;
}
public String ShowRooms() {
int roomid = getRoomno();
list1 = roomservice.GetRoomInfoService(roomid);
return "BeforeUpdate";
}
public String BookShowRooms() {
int roomid = getRoomno();
list2 = roomservice.GetRoomInfoService(roomid);
return "BeforeBook";
}
public String UpdateMethod() {
room.setRoomno(roomno);
room.setBedtype(bedtype);
room.setRoomtype(roomtype);
room.setRoomrent(roomrent);
String update = roomservice.updateMethodService(room);
return update;
}
public String DeleteRoomMethod() {
int deleteid = getRoomno();
int id = roomservice.validateRoomnoService(deleteid);
if (id == deleteid) {
return "error";
} else {
String deleteString = roomservice.DeleteRoomMethodService(deleteid);
return deleteString;
}
}
}
4. Services Module
CustomerServices Class
package com.hotel.management.indrajeet.Services;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import com.hotel.management.indrajeet.Dao.CustomerDao;
import com.hotel.management.indrajeet.controller.CustomerController;
import com.hotel.management.indrajeet.model.Customer;
public class CustomerService {
CustomerDao customerdao;
List customerslist=new ArrayList();
List customerslist1=new ArrayList();
static final Logger LOGGER = Logger.getLogger(CustomerService.class);
public List getCustomerslist1() {
return customerslist1;
}
public void setCustomerslist1(List customerslist1) {
this.customerslist1 = customerslist1;
}
public List getCustomerslist() {
return customerslist;
}
public void setCustomerslist(List customerslist) {
this.customerslist = customerslist;
}
public CustomerDao getCustomerdao() {
return customerdao;
}
public void setCustomerdao(CustomerDao customerdao) {
this.customerdao = customerdao;
}
public String BookRoomCustomerService(Customer customer) {
LOGGER.info("bookroomservice costomer service" + customer);
String bookroom = customerdao.BookRoomCustomerDao(customer);
return bookroom;
}
public String validateRoomnoService( int roomno) {
LOGGER.info("validate rooms service method ");
String status1 = customerdao.validateRoomnodao(roomno);
return status1;
}
public List getAllCustomersService() {
customerslist=customerdao.getAllCustomersDao();
return customerslist;
}
public List GetcustomerInfoService(int roomid) {
customerslist1=customerdao.GetcustomerInfoService(roomid);
return customerslist1;
}
public String checkCusID(String proofid) {
String checkid=customerdao.checkCusIDDao(proofid);
return checkid;
}
public String UpdateRoomCustomerService(Customer customer) {
String update=customerdao.UpdateRoomCustomerdao(customer);
return update;
}
}
LoginSercvice Class:
package com.hotel.management.indrajeet.Services;
import com.hotel.management.indrajeet.Dao.LoginDao;
public class LoginService {
private static LoginDao loginDao;
public LoginService(LoginDao loginDao) {
super();
this.loginDao = loginDao;
}
public LoginService() {
System.out.println("login service constructor called");
}
public LoginDao getLoginDao() {
return loginDao;
}
public void setLoginDao(LoginDao loginDao) {
this.loginDao = loginDao;
}
public static String validateService(String username, String password) {
String status;
System.out.println("service 1");
status = loginDao.validate(username, password);
System.out.println("service 2");
System.out.println(status);
return status;
}
}
RoomService Class
package com.hotel.management.indrajeet.Services;
import com.hotel.management.indrajeet.Dao.LoginDao;
public class LoginService {
private static LoginDao loginDao;
public LoginService(LoginDao loginDao) {
super();
this.loginDao = loginDao;
}
public LoginService() {
System.out.println("login service constructor called");
}
public LoginDao getLoginDao() {
return loginDao;
}
public void setLoginDao(LoginDao loginDao) {
this.loginDao = loginDao;
}
public static String validateService(String username, String password) {
String status;
System.out.println("service 1");
status = loginDao.validate(username, password);
System.out.println("service 2");
System.out.println(status);
return status;
}
}
Customer.hbm.xml
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
table="Customer">
Login.hbm.xml
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
Room.hbm.xml
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
ContextListener Class
package net.codejava.servlet;
import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.xml.DOMConfigurator;
public class ContextListener implements ServletContextListener {
/**
* Initialize log4j when the application is being started
*/
public void contextInitialized(ServletContextEvent event) {
// initialize log4j here
ServletContext context = event.getServletContext();
String log4jConfigFile = context.getInitParameter("log4j-config-location");
String fullPath = context.getRealPath("") + File.separator + log4jConfigFile;
//PropertyConfigurator.configure(fullPath);
DOMConfigurator.configure("log4j.xml");
}
public void contextDestroyed(ServletContextEvent event) {
// do nothing
}
}
Log4j.xml
Struts.xml
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
class="com.hotel.management.indrajeet.controller.LoginController">
class="com.hotel.management.indrajeet.controller.LoginController"
method="logout">
class="com.hotel.management.indrajeet.controller.RoomController"
method="ShowRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="UpdateMethod">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="DeleteRoomMethod">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.CustomerController"
method="listCustomers">
class="com.hotel.management.indrajeet.controller.CustomerController"
method="listCustomers">
class="com.hotel.management.indrajeet.controller.CustomerController"
method="checkoutMethod">
class="com.hotel.management.indrajeet.controller.CustomerController"
method="checkoutActionMethod">
class="com.hotel.management.indrajeet.controller.CustomerController"
method="listCustomers">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="BookShowRooms">
class="com.hotel.management.indrajeet.controller.RoomController"
method="addroomController">
class="com.hotel.management.indrajeet.controller.RoomController"
method="listRooms">
class="com.hotel.management.indrajeet.controller.CustomerController">