Exemplo n.º 1
0
 @Test
 public void testUserCreate() throws Exception {
   System.out.println("testUserCreate: START");
   // =================================================================================
   int id = 0;
   String username = "******";
   String password = "******";
   boolean active = true;
   boolean admin = true;
   String dob = "11/03/1966";
   String email = "*****@*****.**";
   String securityQuestion1 = "XXX";
   String securityAnswer1 = "XXX";
   String securityQuestion2 = "YYY";
   String securityAnswer2 = "YYY";
   Date birthDate = sdf.parse(dob);
   // =================================================================================
   System.out.println("testUserCreate: START: CREATE");
   UserDTO user = new UserDTO();
   assertNotNull(user);
   // ***************************************************************
   user.setId(id);
   user.setUsername(username);
   user.setPassword(password);
   user.setActive(active);
   user.setEmail(email);
   user.setSecurityQuestion1(securityQuestion1);
   user.setSecurityAnswer1(securityAnswer1);
   user.setSecurityQuestion2(securityQuestion2);
   user.setSecurityAnswer2(securityAnswer2);
   System.out.println("testUserCreate: user="******"testUserCreate: FINISH: CREATE");
 }
Exemplo n.º 2
0
  public static Pair<Boolean, String> updateProject(
      ProjectDTO projectDTO, boolean changedProjectName, String originalProjectName) {
    try {
      // Additional duplication control
      Project existingProject;
      if (changedProjectName) {
        existingProject = ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName());
      } else existingProject = null;

      if (existingProject != null && changedProjectName) {
        System.out.println("Existing project exists!");
        return Pair.of(false, "Project with this name already exists!");
      }

      Project p = ProxyManager.getProjectProxy().findProjectByName(originalProjectName);
      p.setProjectId(projectDTO.getProjectId());
      p.setName(projectDTO.getName());
      p.setDescription(projectDTO.getDescription());
      p.setStatus(projectDTO.getStatus());
      Team team = new Team();
      team.setTeamId(projectDTO.getTeamTeamId().getTeamId());
      team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId());
      team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId());

      List<User> userList = new ArrayList<User>();
      if (projectDTO.getTeamTeamId().getUserList() != null) {
        for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) {
          User user = new User();
          user.setUserId(userDTO.getUserId());
          user.setUsername(userDTO.getUsername());
          user.setPassword(userDTO.getPassword());
          user.setFirstName(userDTO.getFirstName());
          user.setLastName(userDTO.getLastName());
          user.setEmail(userDTO.getEmail());
          user.setIsAdmin(userDTO.isAdmin());
          user.setSalt(userDTO.getSalt());
          user.setIsActive(userDTO.isActive());
          user.setTimeCreated(userDTO.getTimeCreated());
          userList.add(user);
        }
        team.setUserList(userList);
      } else return Pair.of(false, "No project list when saving team.");
      p.setTeamTeamId(team);
      try {
        if (p == null) return Pair.of(false, "Data error!");
        ProxyManager.getProjectProxy().edit(p);

      } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        return Pair.of(false, e.getMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
      return Pair.of(false, e.getMessage());
    }
    return Pair.of(true, "Project updated successfully.");
  }
Exemplo n.º 3
0
  public static Pair<Boolean, String> saveNewProject(ProjectDTO projectDTO) {

    // check for project in database
    System.out.println("Project to check in base: " + projectDTO.getName());
    Project existingProject =
        ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName());
    try {
      if (existingProject != null) {
        System.out.println("Existing project exists!");
        return Pair.of(false, "Project with this name already exists!");
      } else System.out.println("Project check passed, no existing project.");

      Project p = new Project();
      p.setName(projectDTO.getName());
      p.setDescription(projectDTO.getDescription());
      p.setStatus(projectDTO.getStatus());
      Team team = new Team();
      team.setTeamId(projectDTO.getTeamTeamId().getTeamId());
      team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId());
      team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId());

      List<User> userList = new ArrayList<User>();
      if (projectDTO.getTeamTeamId().getUserList() != null) {
        for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) {
          User user = new User();
          user.setUserId(userDTO.getUserId());
          user.setUsername(userDTO.getUsername());
          user.setPassword(userDTO.getPassword());
          user.setFirstName(userDTO.getFirstName());
          user.setLastName(userDTO.getLastName());
          user.setEmail(userDTO.getEmail());
          user.setIsAdmin(userDTO.isAdmin());
          user.setSalt(userDTO.getSalt());
          user.setIsActive(userDTO.isActive());
          user.setTimeCreated(userDTO.getTimeCreated());
          userList.add(user);
        }
        team.setUserList(userList);
      } else return Pair.of(false, "No user list when saving team.");
      p.setTeamTeamId(team);
      try {
        if (p == null) return Pair.of(false, "Data error!");

        ProxyManager.getProjectProxy().create(p);

      } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        return Pair.of(false, e.getMessage());
      }
    } catch (Exception e) {
      e.printStackTrace();
      return Pair.of(false, e.getMessage());
    }
    return Pair.of(true, "Project saved successfully.");
  }