Esempio n. 1
0
  private UserVO userPojoToVo(NdgUser user) {
    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.setCompanyType(user.getCompany().getCompanyType());
    companyVO.setCompanyCountry(user.getCompany().getCompanyCountry());
    companyVO.setCompanyIndustry(user.getCompany().getCompanyIndustry());
    companyVO.setCompanySize(user.getCompany().getCompanySize());
    vo.setCompany(companyVO);

    vo.setUsername(user.getUsername());
    vo.setPassword(user.getPassword());
    vo.setFirstName(user.getFirstName());
    vo.setLastName(user.getLastName());
    vo.setEmail(user.getEmail());
    vo.setUserAdmin(user.getUserAdmin());

    vo.setCountryCode(user.getCountryCode());
    vo.setAreaCode(user.getAreaCode());
    vo.setPhoneNumber(user.getPhoneNumber());
    vo.setRetCode(UserVO.AUTHENTICATED);
    vo.setUserValidated(user.getUserValidated());
    vo.setValidationKey(user.getValidationKey());

    vo.setHasFullPermissions(user.getHasFullPermissions());
    return vo;
  }
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;
  }