예제 #1
0
  public List<MemberDTO> getMember(String fname, String lname, String birthday) {
    DBFacade db = DBFacade.getInstance();
    db.beginTransaction();
    Set<Member> memberSet = db.getPersonByName(fname, lname, birthday);
    db.commitTransaction();
    List<MemberDTO> memberList = new LinkedList<>();

    for (Member member : memberSet) {
      memberList.add(DTOMapper.getMapper().map(member, MemberDTO.class));
    }
    return memberList;
  }
예제 #2
0
 public MemberDTO getMember(String Id) {
   Member m = new Member();
   DBFacadeInterface db = DBFacade.getInstance();
   db.beginTransaction();
   m = db.get(Member.class, Id);
   db.commitTransaction();
   return DTOMapper.getMapper().map(m, MemberDTO.class);
 }
예제 #3
0
  public Member fillMember(
      Member member,
      String gender,
      String country,
      String fname,
      String lname,
      String street,
      String streetnumber,
      String postalCode,
      String city,
      String telephone,
      String mail,
      String birthday,
      Collection<String> roles,
      Collection<String> departments,
      String status)
      throws CouldNotSaveObjectException, MemberAlreadyExistsException, SomeFieldsNotSetException {
    DBFacadeInterface db = DBFacade.getInstance();
    Set<Role> rolesSet = new HashSet<>();
    Set<Department> departmentSet = new HashSet<>();

    // checks if all fields are set
    areAllFieldsSet(
        gender, country, fname, lname, street, streetnumber, postalCode, city, birthday);

    for (String roleID : roles) {
      Role role = db.get(Role.class, roleID);
      if (role != null) {
        rolesSet.add(role);
      }
    }

    for (String departmentID : departments) {
      Department department = db.get(Department.class, departmentID);
      if (department != null) {
        departmentSet.add(department);
        department.getMembers().add(member);
      }
    }

    member.setDepartments(departmentSet);
    member.setRoles(rolesSet);

    member.setGender(gender);
    member.setCountry(country);
    member.setFirstName(fname);
    member.setLastName(lname);
    member.setStreet(street);
    member.setStreetNumber(streetnumber);
    member.setZIP(postalCode);
    member.setCity(city);
    member.setPhone(telephone);
    member.setMail(mail);
    member.setBirthday(birthday);
    member.setStatus(status);

    return member;
  }
예제 #4
0
  public boolean doesMemberExist(String fname, String lname, String birthday) {
    DBFacadeInterface db = DBFacade.getInstance();

    if (db.getPersonByName(fname, lname, birthday).size() > 0) {
      System.out.println("Person existiert bereits");
      // TODO return Statement muss noch mit GUI abgesprochen werden
      return true;
    }
    return false;
  }
예제 #5
0
 public boolean checkForExistingMember(String fname, String lname, String birthday) {
   DBFacadeInterface db = DBFacade.getInstance();
   List<Member> allMembers = db.getAll(Member.class);
   for (Member checkMember : allMembers) {
     if (fname.equals(checkMember.getFirstName())
         && lname.equals(checkMember.getLastName())
         && birthday.equals(checkMember.getBirthday())) {
       return true;
     }
   }
   return false;
 }