コード例 #1
0
 /**
  * This method checks if memberId already exists -- if so, it cannot be added as a new member, and
  * an exception is thrown. If new, creates a new LibraryMember based on input data and uses
  * DataAccess to store it.
  *
  * @throws Exception
  */
 public void addNewMember(
     String memberId, String firstName, String lastName, String telNumber, Address addr)
     throws Exception {
   DataAccess dataAccess = new DataAccessFacade();
   HashMap<String, LibraryMember> memberMap = dataAccess.readMemberMap();
   if (!memberMap.containsKey(memberId)) {
     memberIdError.setText("");
     service.saveMember(new LibraryMember(memberId, firstName, lastName, telNumber, addr));
   } else {
     memberIdError.setText("Member with Id# " + memberID.getText() + " already exists!");
   }
 }
コード例 #2
0
  @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());
  }
コード例 #3
0
  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();
      }
    }
  }
コード例 #4
0
 @Override
 public Book searchBook(String isbn) {
   DataAccess da = new DataAccessFacade();
   return da.searchBook(isbn);
 }