public static String checkLogin(String userMobileNo, Context _context) throws Exception {
    String errorCode = "";
    try {
      JSONObject reqParameters = new JSONObject();
      reqParameters.put("UMOBILENO", userMobileNo);

      JsonHandler jsonHandler = JsonHandler.getInstance();
      String url = jsonHandler.getFullUrl("UserLogin.php");
      JSONObject result = jsonHandler.postJsonDataToServer(url, reqParameters, _context);
      if (result != null) {
        String resultCode = result.getString("RESULT");

        if (resultCode.contentEquals(AppConstant.PHPRESPONSE_KO)) {
          errorCode = result.getString("ERRORCODE");

        } else {
          JSONObject jsonData = result.getJSONObject("USERDATA");
          UserDTO userDto = new UserDTO();
          LaunchActivity.loginUserId = jsonData.getInt("USERID");
          userDto.setUserId(LaunchActivity.loginUserId);
          userDto.setFirstName(jsonData.getString("UFNAME"));
          userDto.setLastName(jsonData.getString("ULNAME"));
          userDto.setCityId(jsonData.getInt("CITYID"));
          userDto.setGender(jsonData.getInt("GENDER"));
          userDto.setAge(jsonData.getInt("AGE"));
          userDto.setContactNo(jsonData.getString("UCONTACTNO"));
          userDto.setUserCity(jsonData.getString("USERCITY"));
          userDto.setAppLoginUser(true);
          LaunchActivity.repository.addUserDTO(userDto);
        }
      } else {
        errorCode = PHP_ERROR_CODE.TECHNICAL;
      }
    } catch (JSONException e) {
      // e.printStackTrace();
      throw e;
    } catch (ClientProtocolException e) {
      // e.printStackTrace();
      throw e;
    } catch (IOException e) {
      // e.printStackTrace();
      throw e;
    } catch (Exception e) {
      // e.printStackTrace();
      throw e;
    }
    return errorCode;
  }
Esempio n. 2
0
  public static List<ProjectDTO> getAllProject() {
    // Get project list
    List<Project> projectList;
    // retrieve project list from JPA controller
    projectList = ProxyManager.getProjectProxy().getProjectsList();

    ArrayList<ProjectDTO> resList = new ArrayList<ProjectDTO>();
    ProjectDTO projectDTO;
    for (Project p : projectList) {
      projectDTO = new ProjectDTO();
      projectDTO.setName(p.getName());
      projectDTO.setDescription(p.getDescription());
      projectDTO.setStatus(p.getStatus());
      Team team = p.getTeamTeamId();
      if (team != null) {
        TeamDTO teamDTO = new TeamDTO();
        teamDTO.setTeamId(team.getTeamId());
        teamDTO.setProductOwnerId(team.getProductOwnerId());
        teamDTO.setScrumMasterId(team.getScrumMasterId());
        ArrayList<UserDTO> userDTOList = new ArrayList<UserDTO>();
        for (User user : team.getUserList()) {
          UserDTO userDTO = new UserDTO();
          userDTO.setUserId(user.getUserId());
          userDTO.setUsername(user.getUsername());
          userDTO.setPassword(user.getPassword());
          userDTO.setFirstName(user.getFirstName());
          userDTO.setLastName(user.getLastName());
          userDTO.setEmail(user.getEmail());
          userDTO.setAdmin(user.getIsAdmin());
          userDTO.setSalt(user.getSalt());
          userDTO.setActive(user.getIsActive());
          userDTO.setTimeCreated(user.getTimeCreated());
          userDTOList.add(userDTO);
        }
        teamDTO.setUserList(userDTOList);
        projectDTO.setTeamTeamId(teamDTO);
      } else projectDTO.setTeamTeamId(null); // TODO: possible break
      resList.add(projectDTO);
    }
    return resList;
  }
  @Override
  public StudentDTO updateStudentForAPP(StudentDTO studentDTO) {
    // 更新联系方式
    UserDTO userDTO = new UserDTO();
    boolean isAllNot = true;
    // 学生姓名
    String name = studentDTO.getRealName();
    if (!StringUtils.isEmpty(name)) {
      userDTO.setRealName(name);
      isAllNot = false;
    }

    String school = studentDTO.getSchoolId();
    if (school != null) {
      userDTO.setSchoolId(school);
      isAllNot = false;
    } else {
      logger.warn("schoolId不能为空");
      return null;
    }

    String userId = studentDTO.getUserId();
    if (!StringUtils.isEmpty(userId)) {
      userDTO.setUserId(userId);
    } else {
      logger.warn("userId不能为空");
      return null;
    }

    String mobile = studentDTO.getMobile();
    if (!StringUtils.isEmpty(mobile)) {
      userDTO.setMobile(mobile);
      isAllNot = false;
    }

    String email = studentDTO.getEmail();
    if (!StringUtils.isEmpty(email)) {
      userDTO.setEmail(email);
      isAllNot = false;
    }

    if (!isAllNot) {
      userService.updateByUserId(userDTO);
    }

    // 更新班级
    String schoolId = userService.getSchoolId(userId);
    if (StringUtils.isEmpty(schoolId)) {
      throw new MemberException("该学生没有学校");
    }

    MSchool mSchool = mSchoolMapper.selectByPrimaryKey(schoolId);

    String classId = studentDTO.getClassId();
    if (!StringUtils.isEmpty(classId)) {
      MClass mClass = classMapper.selectByPrimaryKey(classId, schoolId);
      if (mClass == null) {
        logger.warn("找不到班级号为" + classId + "的班级");
        return null;
      }
      MStudent mStudent = new MStudent();
      mStudent.setUserId(studentDTO.getUserId());
      mStudent.setClassName(mClass.getName());
      mStudent.setClassId(classId);
      mStudent.setSchoolId(schoolId);

      studentMapper.updateByPrimaryKey(mStudent);
    }

    studentDTO.setClassId(classId);
    studentDTO.setSchoolId(schoolId);
    studentDTO.setSchoolName(mSchool.getName());
    return studentDTO;
  }
Esempio n. 4
0
  public static ProjectDTO getProjectByName(String name) {
    Project p;
    p = ProxyManager.getProjectProxy().findProjectByName(name);
    if (p != null) {
      ProjectDTO projectDTO = new ProjectDTO();
      projectDTO.setProjectId(p.getProjectId());
      projectDTO.setName(p.getName());
      projectDTO.setDescription(p.getDescription());
      projectDTO.setStatus(p.getStatus());
      Team team = p.getTeamTeamId();
      if (team != null) {
        TeamDTO teamDTO = new TeamDTO();
        teamDTO.setTeamId(team.getTeamId());
        teamDTO.setProductOwnerId(team.getProductOwnerId());
        teamDTO.setScrumMasterId(team.getScrumMasterId());
        ArrayList<UserDTO> userDTOList = new ArrayList<UserDTO>();
        for (User user : team.getUserList()) {
          UserDTO userDTO = new UserDTO();
          userDTO.setUserId(user.getUserId());
          userDTO.setUsername(user.getUsername());
          userDTO.setPassword(user.getPassword());
          userDTO.setFirstName(user.getFirstName());
          userDTO.setLastName(user.getLastName());
          userDTO.setEmail(user.getEmail());
          userDTO.setAdmin(user.getIsAdmin());
          userDTO.setSalt(user.getSalt());
          userDTO.setActive(user.getIsActive());
          userDTO.setTimeCreated(user.getTimeCreated());
          userDTOList.add(userDTO);
        }
        teamDTO.setUserList(userDTOList);
        projectDTO.setTeamTeamId(teamDTO);
      } else projectDTO.setTeamTeamId(null);

      List<SprintDTO> sprintDTOList = new ArrayList<SprintDTO>();
      if (p.getSprintList() != null) {
        for (Sprint s : p.getSprintList()) {
          s = ProxyManager.getSprintProxy().findSprint(s.getSprintPK());
          SprintDTO sprintDTO = new SprintDTO();
          SprintPKDTO sprintPKDTO = new SprintPKDTO();
          sprintPKDTO.setSprintId(s.getSprintPK().getSprintId());
          sprintPKDTO.setProjectProjectId(s.getSprintPK().getProjectProjectId());
          sprintDTO.setSprintPK(sprintPKDTO);
          sprintDTO.setSeqNumber(s.getSeqNumber());
          sprintDTO.setStatus(s.getStatus());
          sprintDTO.setStartDate(s.getStartDate());
          sprintDTO.setEndDate(s.getEndDate());
          sprintDTO.setVelocity(s.getVelocity());
          if (s.getUserStoryList() != null) {
            List<UserStoryDTO> userStoryDTOList = new ArrayList<UserStoryDTO>();
            for (UserStory userStory : s.getUserStoryList()) {
              userStory = ProxyManager.getUserStoryProxy().findUserStory(userStory.getStoryId());
              UserStoryDTO userStoryDTO = new UserStoryDTO();
              userStoryDTO.setStoryId(userStory.getStoryId());
              userStoryDTO.setName(userStory.getName());
              userStoryDTO.setContent(userStory.getContent());
              userStoryDTO.setBusinessValue(userStory.getBusinessValue());
              userStoryDTO.setStatus(userStory.getStatus());
              if (userStory.getEstimateTime() != null) {
                userStoryDTO.setEstimateTime(userStory.getEstimateTime().doubleValue());
              } else userStoryDTO.setEstimateTime(null);
              userStoryDTO.setStoryId(userStory.getStoryId());
              userStoryDTO.setProjectProjectId(projectDTO);
              userStoryDTO.setComment(userStory.getComment());
              userStoryDTO.setSprint(sprintDTO);

              PriorityDTO priorityDTO = new PriorityDTO();
              priorityDTO.setPriorityId(userStory.getPriorityPriorityId().getPriorityId());
              priorityDTO.setName(userStory.getPriorityPriorityId().getName());
              userStoryDTO.setPriorityPriorityId(priorityDTO);

              List<AcceptanceTestDTO> acceptanceTestDTOList = new ArrayList<AcceptanceTestDTO>();
              for (AcceptanceTest at : userStory.getAcceptanceTestList()) {
                AcceptanceTestDTO acceptanceTestDTO = new AcceptanceTestDTO();
                acceptanceTestDTO.setAcceptanceTestId(at.getAcceptanceTestId());
                acceptanceTestDTO.setContent(at.getContent());
                acceptanceTestDTOList.add(acceptanceTestDTO);
              }
              userStoryDTO.setAcceptanceTestList(acceptanceTestDTOList);

              if (userStory.getTaskList() != null) {
                List<TaskDTO> taskDTOList = new ArrayList<TaskDTO>();
                for (Task task : userStory.getTaskList()) {
                  task = ProxyManager.getTaskProxy().findTask(task.getTaskPK());
                  TaskDTO taskDTO = new TaskDTO();
                  taskDTO.setDescription(task.getDescription());
                  taskDTO.setTimeRemaining(task.getTimeRemaining());
                  taskDTO.setEstimatedTime(task.getEstimatedTime());
                  taskDTO.setStatus(task.getStatus());
                  taskDTO.setPreassignedUserName(task.getPreassignedUserName());
                  taskDTO.setAssignedDate(task.getAssignedDate());

                  taskDTO.setUserStory(userStoryDTO);

                  TaskPKDTO taskPKDTO = new TaskPKDTO();
                  taskPKDTO.setTaskId(task.getTaskPK().getTaskId());
                  taskPKDTO.setUserStoryStoryId(task.getTaskPK().getUserStoryStoryId());
                  taskDTO.setTaskPK(taskPKDTO);

                  if (task.getUserUserId() != null) {
                    User user =
                        ProxyManager.getUserProxy().findUser(task.getUserUserId().getUserId());
                    UserDTO userDTO = new UserDTO();
                    userDTO.setUserId(user.getUserId());
                    userDTO.setUsername(user.getUsername());
                    userDTO.setPassword(user.getPassword());
                    userDTO.setFirstName(user.getFirstName());
                    userDTO.setLastName(user.getLastName());
                    userDTO.setEmail(user.getEmail());
                    userDTO.setAdmin(user.getIsAdmin());
                    userDTO.setSalt(user.getSalt());
                    userDTO.setActive(user.getIsActive());
                    userDTO.setTimeCreated(user.getTimeCreated());
                    taskDTO.setUserUserId(userDTO);
                  }

                  List<WorkloadDTO> workloadDTOList = new ArrayList<WorkloadDTO>();
                  for (Workload workload : task.getWorkloadList()) {
                    workload =
                        ProxyManager.getWorkloadProxy().findWorkload(workload.getWorkloadPK());
                    WorkloadDTO workloadDTO = new WorkloadDTO();
                    workloadDTO.setDay(workload.getDay());
                    workloadDTO.setTimeRemaining(workload.getTimeRemaining());
                    workloadDTO.setTimeSpent(workload.getTimeSpent());
                    workloadDTO.setStarted(workload.getStarted());
                    workloadDTO.setStartTime(workload.getStartTime());
                    workloadDTO.setStopTime(workload.getStopTime());

                    User user =
                        ProxyManager.getUserProxy().findUser(workload.getUser().getUserId());
                    UserDTO userDTO = new UserDTO();
                    userDTO.setUserId(user.getUserId());
                    userDTO.setUsername(user.getUsername());
                    userDTO.setPassword(user.getPassword());
                    userDTO.setFirstName(user.getFirstName());
                    userDTO.setLastName(user.getLastName());
                    userDTO.setEmail(user.getEmail());
                    userDTO.setAdmin(user.getIsAdmin());
                    userDTO.setSalt(user.getSalt());
                    userDTO.setActive(user.getIsActive());
                    userDTO.setTimeCreated(user.getTimeCreated());
                    workloadDTO.setUser(userDTO);

                    workloadDTO.setTask(taskDTO);

                    WorkloadPKDTO workloadPKDTO = new WorkloadPKDTO();
                    WorkloadPK workloadPK = workload.getWorkloadPK();
                    workloadPKDTO.setTaskTaskId(workloadPK.getTaskTaskId());
                    workloadPKDTO.setTaskUserStoryStoryId(workloadPK.getTaskUserStoryStoryId());
                    workloadPKDTO.setUserUserId(workloadPK.getUserUserId());
                    workloadPKDTO.setWorkloadId(workloadPK.getWorkloadId());
                    workloadDTO.setWorkloadPK(workloadPKDTO);

                    List<WorkblockDTO> workblockDTOList = new ArrayList<WorkblockDTO>();
                    for (Workblock workblock : workload.getWorkblockList()) {
                      workblock =
                          ProxyManager.getWorkblockProxy()
                              .findWorkblock(workblock.getWorkblockPK());
                      WorkblockDTO workblockDTO = new WorkblockDTO();
                      workblockDTO.setTimeStart(workblock.getTimeStart());
                      workblockDTO.setTimeStop(workblock.getTimeStop());

                      workblockDTO.setWorkload(workloadDTO);

                      WorkblockPKDTO workblockPKDTO = new WorkblockPKDTO();
                      WorkblockPK workblockPK = workblock.getWorkblockPK();
                      workloadPKDTO.setWorkloadId(workblockPK.getWorkloadWorkloadId());
                      workblockPKDTO.setWorkloadTaskTaskId(workloadPK.getTaskTaskId());
                      workblockPKDTO.setWorkloadTaskUserStoryStoryId(
                          workblockPK.getWorkloadTaskUserStoryStoryId());
                      workblockPKDTO.setWorkloadUserUserId(workblockPK.getWorkloadUserUserId());
                      workblockPKDTO.setWorkloadWorkloadId(workblockPK.getWorkloadWorkloadId());
                      workblockDTO.setWorkblockPK(workblockPKDTO);

                      workblockDTOList.add(workblockDTO);
                    }
                    workloadDTO.setWorkblockList(workblockDTOList);

                    workloadDTOList.add(workloadDTO);
                  }
                  taskDTO.setWorkloadList(workloadDTOList);

                  taskDTOList.add(taskDTO);
                }
                userStoryDTO.setTaskList(taskDTOList);
              }
              userStoryDTOList.add(userStoryDTO);
            }
            sprintDTO.setUserStoryList(userStoryDTOList);
          }
          sprintDTOList.add(sprintDTO);
        }
        projectDTO.setSprintList(sprintDTOList);

      } else projectDTO.setSprintList(null);

      List<UserStoryDTO> userStoryDTOList = new ArrayList<UserStoryDTO>();
      if (p.getUserStoryList() != null) {
        for (UserStory us : p.getUserStoryList()) {
          UserStoryDTO userStoryDTO = new UserStoryDTO();
          userStoryDTO.setStoryId(us.getStoryId());
          userStoryDTO.setName(us.getName());
          userStoryDTO.setContent(us.getContent());
          userStoryDTO.setBusinessValue(us.getBusinessValue());
          userStoryDTO.setStatus(us.getStatus());
          if (us.getEstimateTime() != null) {
            userStoryDTO.setEstimateTime(us.getEstimateTime().doubleValue());
          } else userStoryDTO.setEstimateTime(null);
          userStoryDTO.setStoryId(us.getStoryId());
          userStoryDTO.setProjectProjectId(projectDTO);

          PriorityDTO priorityDTO = new PriorityDTO();
          priorityDTO.setPriorityId(us.getPriorityPriorityId().getPriorityId());
          priorityDTO.setName(us.getPriorityPriorityId().getName());
          userStoryDTO.setPriorityPriorityId(priorityDTO);

          List<AcceptanceTestDTO> acceptanceTestDTOList = new ArrayList<AcceptanceTestDTO>();
          for (AcceptanceTest at : us.getAcceptanceTestList()) {
            AcceptanceTestDTO acceptanceTestDTO = new AcceptanceTestDTO();
            acceptanceTestDTO.setAcceptanceTestId(at.getAcceptanceTestId());
            acceptanceTestDTO.setContent(at.getContent());
            acceptanceTestDTOList.add(acceptanceTestDTO);
          }
          userStoryDTO.setAcceptanceTestList(acceptanceTestDTOList);

          // TODO: Set taskList to userStoryDTO
          if (us.getTaskList() != null) {
            List<TaskDTO> taskDTOList = new ArrayList<TaskDTO>();
            for (Task task : us.getTaskList()) {
              task = ProxyManager.getTaskProxy().findTask(task.getTaskPK());
              TaskDTO taskDTO = new TaskDTO();
              taskDTO.setDescription(task.getDescription());
              taskDTO.setTimeRemaining(task.getTimeRemaining());
              taskDTO.setEstimatedTime(task.getEstimatedTime());
              taskDTO.setStatus(task.getStatus());
              taskDTO.setPreassignedUserName(task.getPreassignedUserName());
              taskDTO.setAssignedDate(task.getAssignedDate());

              taskDTO.setUserStory(userStoryDTO);

              TaskPKDTO taskPKDTO = new TaskPKDTO();
              taskPKDTO.setTaskId(task.getTaskPK().getTaskId());
              taskPKDTO.setUserStoryStoryId(task.getTaskPK().getUserStoryStoryId());
              taskDTO.setTaskPK(taskPKDTO);

              if (task.getUserUserId() != null) {
                User user = ProxyManager.getUserProxy().findUser(task.getUserUserId().getUserId());
                UserDTO userDTO = new UserDTO();
                userDTO.setUserId(user.getUserId());
                userDTO.setUsername(user.getUsername());
                userDTO.setPassword(user.getPassword());
                userDTO.setFirstName(user.getFirstName());
                userDTO.setLastName(user.getLastName());
                userDTO.setEmail(user.getEmail());
                userDTO.setAdmin(user.getIsAdmin());
                userDTO.setSalt(user.getSalt());
                userDTO.setActive(user.getIsActive());
                userDTO.setTimeCreated(user.getTimeCreated());
                taskDTO.setUserUserId(userDTO);
              }

              List<WorkloadDTO> workloadDTOList = new ArrayList<WorkloadDTO>();
              for (Workload workload : task.getWorkloadList()) {
                workload = ProxyManager.getWorkloadProxy().findWorkload(workload.getWorkloadPK());
                WorkloadDTO workloadDTO = new WorkloadDTO();
                workloadDTO.setDay(workload.getDay());
                workloadDTO.setTimeRemaining(workload.getTimeRemaining());
                workloadDTO.setTimeSpent(workload.getTimeSpent());

                User user = ProxyManager.getUserProxy().findUser(workload.getUser().getUserId());
                UserDTO userDTO = new UserDTO();
                userDTO.setUserId(user.getUserId());
                userDTO.setUsername(user.getUsername());
                userDTO.setPassword(user.getPassword());
                userDTO.setFirstName(user.getFirstName());
                userDTO.setLastName(user.getLastName());
                userDTO.setEmail(user.getEmail());
                userDTO.setAdmin(user.getIsAdmin());
                userDTO.setSalt(user.getSalt());
                userDTO.setActive(user.getIsActive());
                userDTO.setTimeCreated(user.getTimeCreated());
                workloadDTO.setUser(userDTO);

                workloadDTO.setTask(taskDTO);

                WorkloadPKDTO workloadPKDTO = new WorkloadPKDTO();
                WorkloadPK workloadPK = workload.getWorkloadPK();
                workloadPKDTO.setTaskTaskId(workloadPK.getTaskTaskId());
                workloadPKDTO.setTaskUserStoryStoryId(workloadPK.getTaskUserStoryStoryId());
                workloadPKDTO.setUserUserId(workloadPK.getUserUserId());
                workloadPKDTO.setWorkloadId(workloadPK.getWorkloadId());
                workloadDTO.setWorkloadPK(workloadPKDTO);

                List<WorkblockDTO> workblockDTOList = new ArrayList<WorkblockDTO>();
                for (Workblock workblock : workload.getWorkblockList()) {
                  workblock =
                      ProxyManager.getWorkblockProxy().findWorkblock(workblock.getWorkblockPK());
                  WorkblockDTO workblockDTO = new WorkblockDTO();
                  workblockDTO.setTimeStart(workblock.getTimeStart());
                  workblockDTO.setTimeStop(workblock.getTimeStop());

                  workblockDTO.setWorkload(workloadDTO);

                  WorkblockPKDTO workblockPKDTO = new WorkblockPKDTO();
                  WorkblockPK workblockPK = workblock.getWorkblockPK();
                  workloadPKDTO.setWorkloadId(workblockPK.getWorkloadWorkloadId());
                  workblockPKDTO.setWorkloadTaskTaskId(workloadPK.getTaskTaskId());
                  workblockPKDTO.setWorkloadTaskUserStoryStoryId(
                      workblockPK.getWorkloadTaskUserStoryStoryId());
                  workblockPKDTO.setWorkloadUserUserId(workblockPK.getWorkloadUserUserId());
                  workblockPKDTO.setWorkloadWorkloadId(workblockPK.getWorkloadWorkloadId());
                  workblockDTO.setWorkblockPK(workblockPKDTO);

                  workblockDTOList.add(workblockDTO);
                }
                workloadDTO.setWorkblockList(workblockDTOList);

                workloadDTOList.add(workloadDTO);
              }
              taskDTO.setWorkloadList(workloadDTOList);

              taskDTOList.add(taskDTO);
            }
            userStoryDTO.setTaskList(taskDTOList);
          } else userStoryDTO.setTaskList(null);

          SprintDTO sprintDTO = new SprintDTO();
          if (us.getSprint() != null) {
            SprintPKDTO sprintPKDTO = new SprintPKDTO();
            sprintPKDTO.setSprintId(us.getSprint().getSprintPK().getSprintId());
            sprintPKDTO.setProjectProjectId(us.getSprint().getSprintPK().getProjectProjectId());
            sprintDTO.setSprintPK(sprintPKDTO);
            sprintDTO.setSeqNumber(us.getSprint().getSeqNumber());
            sprintDTO.setStatus(us.getSprint().getStatus());
            sprintDTO.setStartDate(us.getSprint().getStartDate());
            sprintDTO.setEndDate(us.getSprint().getEndDate());
            sprintDTO.setVelocity(us.getSprint().getVelocity());
          } else sprintDTO = null;
          userStoryDTO.setSprint(sprintDTO);
          userStoryDTOList.add(userStoryDTO);
        }
        projectDTO.setUserStoryList(userStoryDTOList);
      }
      return projectDTO;
    } else return null;
  }