Examples of Voter


Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

    }
    return recordsId;
  }
 
  public Voter getVoter(String username, String ipAddress, int surveyId) {
    Voter voter = null;
    Connection conn = null;
    PreparedStatement stat=null;
    ResultSet res = null;
    try {
      conn = this.getConnection();
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

 
  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.aps.system.services.collect.IVoterDAO#getVoterbyId(int)
   */
  public Voter getVoterById(int id) {
    Voter voter = null;
    Connection conn = null;
    try {
      conn=this.getConnection();
      voter=this.getVoterById(conn, id);
    } catch (Throwable t) {
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

 
  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.aps.system.services.collect.IVoterDAO#getVoterbyId(java.sql.Connection, int)
   */
  public Voter getVoterById(Connection conn, int id) {
    Voter voter = null;
    PreparedStatement stat = null;
    ResultSet res = null;
    try {
      stat = conn.prepareStatement(GET_VOTER_BY_ID);
      stat.setInt(1, id);
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

    }
    return voter;
  }
 
  private Voter buildVoterByResultSet(ResultSet res) {
    Voter voter = null;
    try {
      if (res.next()) {
        voter = new Voter();
        voter.setId(res.getInt(1)); // 1
        voter.setAge(res.getShort(2)); // 2
        voter.setCountry(res.getString(3)); // 3
        String sex = res.getString(4);
        if (null != sex && sex.length()>0) {
          voter.setSex(sex.charAt(0)); // 4
        }
        voter.setDate(res.getDate(5)); // 5
        voter.setSurveyid(res.getInt(6)); // 6
        voter.setUsername(res.getString(7)); // 7
        voter.setIpaddress(res.getString(8)); // 8 
      }
    } catch (Throwable t) {
      processDaoException(t, "Error loading voting user", "buildVoterByResultSet");
    }
    return voter;
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

 
  @Override
  public String save() {
    try {
      VoterResponse userResponse =  this.getVoterResponse();
      Voter voter = userResponse.getVoter();
      voter.setAge(this.getAge().shortValue());
      voter.setCountry(this.getCountry());
      voter.setSex(this.getSex().toCharArray()[0]);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "saveVoterProfile");
      return FAILURE;
    }
    return SUCCESS;
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

  private static boolean isVotedByIpAddressAndUser(SurveyRecord surveyInfo, HttpServletRequest request) throws ApsSystemException {
    String remoteAddress = request.getRemoteAddr();
    IVoterManager voterManager = (IVoterManager) ApsWebApplicationUtils.getBean(SurveySystemConstants.SURVEY_VOTER_MANAGER, request);
    UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
    Voter voter = voterManager.getVoter(currentUser.getUsername(), remoteAddress, surveyInfo.getId());
    return (voter != null);
  }
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

    ApsSystemUtils.getLogger().debug(this.getClass().getName() + ": initiated ");   
  }
 
  @Override
  public Voter getVoter(String username, String ipAddress, int surveyId) throws ApsSystemException {
    Voter voter = null;
    try {
      voter = this.getVoterDAO().getVoter(username, ipAddress, surveyId);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "getVoter");
            throw new ApsSystemException("Errore getting the voter " + username + " by IP "+ ipAddress + " and idSurvey " + surveyId, t);
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

 
  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.aps.system.services.collect.IVoterManager#getVoterById(int)
   */
  public Voter getVoterById(int id) throws ApsSystemException {
    Voter voter=null;
    try {
      voter=this.getVoterDAO().getVoterById(id);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "getVoterById");
            throw new ApsSystemException("Error finding the voter of ID "+id, t);
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

  private void init() {
    this._voterManager = (IVoterManager) this.getService(SurveySystemConstants.SURVEY_VOTER_MANAGER);
  }
 
  public void testSaveLoadDelete() throws Throwable {
    Voter voter = this.getFakeVoter();
    try {
      this.getVoterManager().saveVoter(voter);
      voter = this.getVoterManager().getVoterById(voter.getId());
      assertFalse(voter.getId() == -1);
      assertEquals(31, voter.getAge());
      assertEquals("it", voter.getCountry());
      assertEquals("M", voter.getSex().toString());
      assertNotNull(voter.getDate());
      assertEquals(1, voter.getSurveyid());
      assertEquals("192.168.10.1", voter.getIpaddress());
      assertNotNull(voter);
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getVoterManager().deleteVoterById(voter.getId());
    }
  }
View Full Code Here

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.Voter

    }
  }
 
  public void testSearchByIds() throws Throwable {
    List<Integer> list = null;
    Voter voter1 = this.getFakeVoter();
    Voter voter2 = this.getFakeVoter();
    Voter voter3 = this.getFakeVoter();
    Date date=new Date();
    try {
      voter1.setIpaddress("192.168.10.1");
      voter2.setIpaddress("192.168.10.2");
      voter3.setIpaddress("192.168.10.3");
      voter1.setSex('F');
      voter2.setSex('f');
      voter3.setSex('M');
      voter1.setCountry("jp");
      voter2.setCountry("it");
      voter3.setCountry("is");
      voter1.setAge(Integer.valueOf(31).shortValue());
      voter2.setAge(Integer.valueOf(32).shortValue());
      voter3.setAge(Integer.valueOf(31).shortValue());
      date.setTime(Long.valueOf("11111111111"));
      voter3.setDate(date);
      this.getVoterManager().saveVoter(voter1);
      this.getVoterManager().saveVoter(voter2);
      this.getVoterManager().saveVoter(voter3);     
      list=this.getVoterManager().searchVotersByIds(null, null, null, null, null, null, null);
      assertNotNull(list);
      assertEquals(4, list.size());
      list=this.getVoterManager().searchVotersByIds(-1, null, null, null, null, null, null);
      assertNull(list);
      list=this.getVoterManager().searchVotersByIds(null, 31, null, null, null, null, null);
      assertNotNull(list);
      assertEquals(2, list.size());
      list=this.getVoterManager().searchVotersByIds(null, null, "is", null, null, null, null);
      assertNotNull(list);
      assertEquals(1, list.size());
      list=this.getVoterManager().searchVotersByIds(null, null, null, 'f', null, null, null);
      assertNotNull(list);
      assertEquals(2, list.size());
      list=this.getVoterManager().searchVotersByIds(null, null, null, null, voter2.getDate(), null, null);
      assertNotNull(list);
      assertEquals(2, list.size());
      list=this.getVoterManager().searchVotersByIds(null, null, null, null, null, 1, null);
      assertNotNull(list);
      assertEquals(3, list.size());
      list=this.getVoterManager().searchVotersByIds(null, null, null, null, null, null, "192.168.10.2");
      assertNotNull(list);
      assertEquals(1, list.size());
      assertEquals((int) voter2.getId(), (int)list.get(0));
      list=this.getVoterManager().searchVotersByIds(voter2.getId(), 32, "IT", 'F', voter2.getDate(), 1, "192.168.10.2");
      assertNotNull(list);
      assertEquals(1, list.size());
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getVoterManager().deleteVoterById(voter1.getId());
      this.getVoterManager().deleteVoterById(voter2.getId());
      this.getVoterManager().deleteVoterById(voter3.getId());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.