justify"> ()
.1 -
()
.1 -
()
.1 - rmi-service-dao
()
.1 -
.2 -
()
.1 -
()
-
.1 - -
.2 - -
()
, -
1. RMI -
public interface IRmiForAdmin extends Remote {Admin getAdminByLogin (String login) throws RemoteException; ArrayList lt; DishDO gt; getDishesByDishType (String dishType) throws RemoteException; List lt; DishDO gt; findDishesByName (String dishName) throws RemoteException; List lt; DishDO gt; selectAllDishes () throws RemoteException; boolean deleteDishById (int dishId) throws RemoteException; boolean editDish (Dish dish) throws RemoteException; boolean addDish (Dish dish) throws RemoteException; boolean addClient (Client client) throws RemoteException; boolean addOrder (Order order) throws RemoteException ; int countTotalCostTakingIntoDiscount (int totalCost) throws RemoteException; int getClientMaxId () throws RemoteException; List lt; Order gt; selectOrders () throws RemoteException; boolean deleteOrder (Order order) throws RemoteException; Client getClientById (int clientId) throws RemoteException; List lt; DishType gt; selectDishType () throws RemoteException; Order getOrderById (int orderId) throws RemoteException; String selectDiscount () throws RemoteException;
}
2. class RmiForAdminImpl extends UnicastRemoteObject implements IRmiForAdmin {AdminService adminService; DishService dishService; DishTypeService dishTypeService; ClientService clientService; OrderService orderService; RmiForAdminImpl () throws RemoteException {= new AdminService ();=new DishService ();=new ClientService ();=new OrderService ();=new DishTypeService ();
}
//Admin
public Admin getAdminByLogin (String login) throws RemoteException {adminService.getAdminByLogin (login);
}
//
public ArrayList lt; DishDO gt; getDishesByDishType (String dishType) throws RemoteException {dishService.getDishByDishType (dishType);
} List lt; DishDO gt; findDishesByName (String dishName) throws RemoteException {dishService.findDishesByName (dishName);
} List lt; DishDO gt; selectAllDishes () throws RemoteException {dishService.selectAllDishes ();
} boolean deleteDishById (int dishId) throws RemoteException {dishService.deleteDishById (dishId);
} boolean editDish (Dish dish) throws RemoteException {dishService.editDish (dish);
} boolean addDish (Dish dish) throws RemoteException {dishService.addDish (dish);
} boolean addClient (Client client) throws RemoteException {clientService.addClient (client);
} boolean addOrder (Order order) throws RemoteException {orderService.createOrder (order);
} int countTotalCostTakingIntoDiscount (int totalCost) throws RemoteException {orderService.countTotalCostTakingIntoDiscount (totalCost);
} boolean deleteOrder (Order order) {orderService.deleteOrder (order);
} List lt; DishType gt; selectDishType () {dishTypeService.selectDishTypes ();
} Order getOrderById (int orderId) {orderService.getOrderById (orderId);
} String selectDiscount () {discountDao=new DiscountDaoImpl (); xstream=new XStream () ;. alias ( discount , Discount.class); xml=xstream.toXML (discountDao.selectAll ()); xml ;
}}
3. DishService.javaclass DishService {dishDao; DishService () {= new DishDaoImpl ();
} ArrayList lt; DishDO gt; getDishByDishType (String dishType) { lt; DishDO gt; dishDoList=new ArrayList lt; DishDO gt; (); lt; Dish gt; dishList=dishDao.selectDishesByDishType (dishType); (Dish dish: dishList) { lt; DishComposition gt; productsList=dishDao.selectDishCompositionByDishId (dish.getId ()) ;. add (new DishDO (dish, productsList));
} dishDoList;
} List lt; DishDO gt; findDishesByName (String dishName) { lt; DishDO gt; dishList=new ArrayList lt; DishDO gt; (); (Dish dish: dishDao.selectDishes()){(dish.getName().toLowerCase().contains(dishName.toLowerCase())){lt;DishCompositiongt; productsList=dishDao.selectDishCompositionByDishId (dish.getId ()) ;. add (new DishDO (dish, productsList));
}} dishList; } List lt; DishDO gt; selectAllDishes () { lt; DishDO gt; dishDoList=new ArrayList lt; DishDO gt; (); lt; Dish gt; dishList=dishDao.selectDishes (); (Dish dish: dishList) { lt; DishComposition gt; productsList=dishDao.selectDishCompositionByDishId (dish.getId ()) ;. add (new DishDO (dish, productsList));
} return dishDo...