示例#1
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);
 }
示例#2
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;
  }
示例#3
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;
  }
示例#4
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;
 }