/** * 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!"); } }
/** * Reads data store for a library member with specified id. Ids begin at 1001... Returns a * LibraryMember if found, null otherwise * * @throws Exception */ public LibraryMember search(String memberId) throws Exception { MemberService ms = new MemberServiceImpl(); return ms.searchMember(memberId); }