Package com.agiletec.plugins.jpsurvey.aps.system.services.collect.model

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


        return SUCCESS;
      }
      Question question = this.getCurrentQuestion();
      for (int i=0; i<this.getChoiceIds().size(); i++) {
        Integer choiceId = this.getChoiceIds().get(i);
        SingleQuestionResponse singleResponse = new SingleQuestionResponse();
        singleResponse.setChoiceId(choiceId);
        singleResponse.setQuestionId(question.getId());
        Choice choice = question.getChoice(choiceId);
        if (choice.isFreeText()) {
          singleResponse.setFreeText(this.getInsertedFreeText().trim());
        }
        currentVotingInfoBean.getVoterResponse().getResponses().add(singleResponse);
      }
      currentVotingInfoBean.setNextIndex();
    } catch (Throwable t) {
View Full Code Here


      // collect all the answers
      responses = getResponseManager().aggregateResponseByIds(null, null, this.getChoiceId(), null);
      if (null != responses) {
        itr = responses.iterator();
        while (itr.hasNext()) {
          SingleQuestionResponse current = itr.next();
          list.add(current.getFreeText());
        }
        // aggregate them
        for (int scan = 0; scan < list.size(); scan++) {
          String currentFreeTextKey = list.get(scan).toLowerCase().trim();
          int currentFreeTextValue = 1;
View Full Code Here

    try {
      conn = this.getConnection();
      conn.setAutoCommit(false);
      stat = conn.prepareStatement(SAVE_RESPONSE);
      for (int i=0; i<responses.size(); i++) {
        SingleQuestionResponse result = responses.get(i);
        stat.setInt(1, result.getVoterId()); // 1
        stat.setInt(2, result.getQuestionId()); // 2
        stat.setInt(3, result.getChoiceId()); // 3
        if (null!=result.getFreeText()) {
          stat.setString(4, result.getFreeText()); // 4
        } else {
          stat.setNull(4, java.sql.Types.VARCHAR); // 4
        }
        stat.addBatch();
        stat.clearParameters();
View Full Code Here

 
  private List<SingleQuestionResponse> createListFromResultSet(ResultSet res) {
    List<SingleQuestionResponse> list=new ArrayList<SingleQuestionResponse>();
    try {
      while (res.next()) {
        SingleQuestionResponse response=this.createRecordFromResultSet(res);
        list.add(response);
      }
    }
    catch (Throwable t) {
      this.processDaoException(t, "Error building the vote result list", "createListFromResultSet");
View Full Code Here

    if (list.isEmpty()) return null;
    return list;
  }
 
  private SingleQuestionResponse createRecordFromResultSet(ResultSet res) {
    SingleQuestionResponse response = new SingleQuestionResponse();
    try {
      response.setVoterId(res.getInt(1)); // 1
      response.setQuestionId(res.getInt(2)); // 2
      response.setChoiceId(res.getInt(3)); // 3
      response.setFreeText(res.getString(4)); // 4
    } catch (Throwable t) {
      this.processDaoException(t, "Error creating the 'response' onject form resulset", "createRecordFromResultSet");
    }
    return response;
  }
View Full Code Here

  private void init() {
    this._responseManager = (IResponseManager) this.getService(SurveySystemConstants.SURVEY_RESPONSE_MANAGER);
  }
 
  public void testSaveResponse() throws Throwable {
    SingleQuestionResponse response = this.getFakeResponse();
    try {
      this.getResponseManager().submitResponse(response);
    } catch (Throwable t) {
      throw t;
    } finally {
View Full Code Here

      this.getResponseManager().deleteResponse(response);
    }
  }
 
  public void testAggregateResults() throws Throwable {
    SingleQuestionResponse r1 = this.getFakeResponse();
    SingleQuestionResponse r2 = this.getFakeResponse();
    SingleQuestionResponse r3 = this.getFakeResponse();
    List<SingleQuestionResponse> list = null;
    try {
      r1.setFreeText("0123456789");
      r2.setChoiceId(2);
      r3.setQuestionId(2);
      r3.setChoiceId(2);
      this.getResponseManager().submitResponse(r1);
      this.getResponseManager().submitResponse(r3);
      this.getResponseManager().submitResponse(r2);
      list = this.getResponseManager().aggregateResponseByIds(-1, null, null, null);
      assertNull(list);
View Full Code Here

      survey = this.getSurveyManager().loadSurvey(survey.getId());
      for (Question question: survey.getQuestions()) {
        // WE SUPPOSE THAT ALL THE CHOICES CAN BE ANSWERED
        int choiceAnswered = 0;
        for (Choice choice: question.getChoices()) {
          SingleQuestionResponse response = this.getFakeResponse();
          if (choice.isFreeText()) response.setFreeText("Forza Cagliari!");
          response.setChoiceId(choice.getId());
          response.setQuestionId(question.getId());
          response.setVoterId(1); // ALWAYS THE SAME VOTER
          this._responseManager.submitResponse(response);
          choiceAnswered++;
        }
        List<SingleQuestionResponse> list = this._responseManager.aggregateResponseByIds(null, question.getId(), null, null);
        assertEquals(choiceAnswered, list.size());
View Full Code Here

      survey = this.getSurveyManager().loadSurvey(survey.getId());
      for (Question question: survey.getQuestions()) {
        // WE SUPPOSE THAT ALL THE CHOICES CAN BE ANSWERED
        int choiceAnswered = 0;
        for (Choice choice: question.getChoices()) {
          SingleQuestionResponse response = this.getFakeResponse();
          if (choice.isFreeText()) response.setFreeText("Forza Milan!");
          response.setChoiceId(choice.getId());
          response.setQuestionId(question.getId());
          response.setVoterId(1); // ALWAYS THE SAME VOTER
          this._responseManager.submitResponse(response);
          choiceAnswered++;
        }
        this._responseManager.deleteResponseByQuestionId(question.getId());
        List<SingleQuestionResponse> list = this._responseManager.aggregateResponseByIds(null, question.getId(), null, null);
View Full Code Here

      this.getSurveyManager().deleteSurvey(survey.getId());
    }
  }
 
  private SingleQuestionResponse getFakeResponse() {
    SingleQuestionResponse response = new SingleQuestionResponse();
    response.setQuestionId(1);
    response.setChoiceId(1);
    response.setVoterId(1);
    response.setFreeText("Non è bello ciò che è bello");
    return response;
  }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpsurvey.aps.system.services.collect.model.SingleQuestionResponse

Copyright © 2018 www.massapicom. 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.