@Override public void initialize(URL location, ResourceBundle resources) { TestData td = new TestData(); td.bookData(); td.libraryMemberData(); td.userData(); DataAccess da = new DataAccessFacade(); System.out.println(da.readBooksMap()); System.out.println(da.readUserMap()); System.out.println(da.readMemberMap()); }
public void login(String name, String paswd) throws LoginException, IOException { System.out.println(name); System.out.println(paswd); DataAccess da = new DataAccessFacade(); HashMap<String, User> map = da.readUserMap(); if (!map.containsKey(name)) { errorMessage.setText("*Name not found!"); throw new LoginException("Name " + name + " not found"); } String passwordFound = map.get(name).getPassword(); if (!passwordFound.equals(paswd)) { errorMessage.setText("*Password not match!"); throw new LoginException("Passord does not match password on record"); } currentAuth = map.get(name).getAuthorization(); System.out.println("Successfully login by " + currentAuth.toString()); if (currentAuth.toString().equals("LIBRARIAN")) { Stage libStage = new Stage(); Parent root; try { root = FXMLLoader.load(getClass().getResource("../view/LiberianMain.fxml")); libStage.setTitle("Librarian - Checkin/Checkout"); Scene scene = new Scene(root, 1000, 800); libStage.setScene(scene); libStage.show(); userName.getScene().getWindow().hide(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (currentAuth.toString().equals("ADMIN")) { Stage libStage = new Stage(); Parent root; try { root = FXMLLoader.load(getClass().getResource("../view/AdministratorMain.fxml")); libStage.setTitle("Administrator"); Scene scene = new Scene(root, 1000, 800); libStage.setScene(scene); libStage.show(); userName.getScene().getWindow().hide(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }