public QueryInputOutputVO getAllImeisSentAndUnsentBySurvey(String surveyId)
      throws MSMApplicationException {
    QueryInputOutputVO queryIOVO = new QueryInputOutputVO();
    queryIOVO.setQueryResult(new ArrayList<Object>());

    queryIOVO.getQueryResult().add(getImeisSentBySurvey(surveyId, null).getQueryResult());
    queryIOVO.getQueryResult().add(getImeisUnsentBySurvey(surveyId, null).getQueryResult());

    queryIOVO.setRecordCount(queryIOVO.getQueryResult().size());

    return queryIOVO;
  }
Esempio n. 2
0
  public QueryInputOutputVO listAllUsers(String userAdmin, QueryInputOutputVO queryIOVO)
      throws MSMApplicationException {
    if (queryIOVO == null) {
      queryIOVO = new QueryInputOutputVO();
    }

    String sqlCommand = "SELECT U FROM NdgUser U WHERE userAdmin like '" + userAdmin + "'";

    if ((queryIOVO.getFilterText() != null) && (queryIOVO.getFilterFields() != null)) {
      sqlCommand +=
          SqlUtil.getFilterCondition(queryIOVO.getFilterText(), queryIOVO.getFilterFields());
    }

    if ((queryIOVO.getSortField() != null) && (queryIOVO.getIsDescending() != null)) {
      sqlCommand += SqlUtil.getSortCondition(queryIOVO.getSortField(), queryIOVO.getIsDescending());
    }

    Query q = manager.createQuery(sqlCommand);
    queryIOVO.setRecordCount(q.getResultList().size());

    if ((queryIOVO.getPageNumber() != null) && (queryIOVO.getRecordsPerPage() != null)) {
      q.setFirstResult((queryIOVO.getPageNumber() - 1) * queryIOVO.getRecordsPerPage());
      q.setMaxResults(queryIOVO.getRecordsPerPage());
    }

    ArrayList<Object> ret = new ArrayList<Object>();
    ArrayList<NdgUser> al = (ArrayList<NdgUser>) q.getResultList();

    if (al.isEmpty()) {
      throw new UserNotFoundException();
    } else {
      Iterator<NdgUser> it = al.iterator();

      while (it.hasNext()) {
        NdgUser user = it.next();
        UserVO vo = new UserVO();
        RoleVO roleVO = new RoleVO();
        roleVO.setName(user.getRole().getRoleName());
        vo.setRole(roleVO);

        CompanyVO companyVO = new CompanyVO();
        companyVO.setCompanyName(user.getCompany().getCompanyName());
        companyVO.setCompanyCountry(user.getCompany().getCompanyCountry());
        companyVO.setCompanyIndustry(user.getCompany().getCompanyIndustry());
        companyVO.setCompanySize(user.getCompany().getCompanySize());
        companyVO.setCompanyType(user.getCompany().getCompanyType());
        companyVO.setIdCompany(user.getCompany().getIdCompany());
        vo.setCompany(companyVO);

        vo.setUsername(user.getUsername());
        vo.setEmail(user.getEmail());
        vo.setFirstName(user.getFirstName());
        vo.setLastName(user.getLastName());
        vo.setPassword(user.getPassword());
        vo.setCountryCode(user.getCountryCode());
        vo.setAreaCode(user.getAreaCode());
        vo.setPhoneNumber(user.getPhoneNumber());
        vo.setUserAdmin(user.getUserAdmin());
        vo.setUserValidated(user.getUserValidated());

        ret.add(vo);
      }

      queryIOVO.setQueryResult(ret);
    }

    return queryIOVO;
  }