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

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.survey.model.Choice


      if (null != this.getQuestionId()) {
        choiceList = getSurveyManager().getQuestionChoices(this.getQuestionId());
        if (null!= choiceList) {
          Iterator<Choice> itr = choiceList.iterator();
          while (itr.hasNext()) {
            Choice current = itr.next();
            if (current.isFreeText()) {
              this.addActionError(this.getText("message.questionAction.noMoreFreeText"));
              return "noMoreFreeText";
            }
          }
        } 
View Full Code Here


      this.checkSingleResponse(question, choiseId);
    }
  }
 
  private void checkSingleResponse(Question question, Integer choiseId) {
    Choice choise = question.getChoice(choiseId);
    if (null == choise) {
      this.addActionError(this.getText("jpsurvey.front.notCompatibleResponse"));
      ApsSystemUtils.getLogger().error("Single response'" + choiseId +
          "' non compatibile con quelle ammesse in Domanda '" + question.getId() +
          "' di questionario '" + this.getVoterResponse().getSurvey().getId() + "'");
    } else {
      if (choise.isFreeText() && (null == this.getInsertedFreeText() || this.getInsertedFreeText().trim().length() == 0)) {
        this.addActionError(this.getText("jpsurvey.front.freeTextRequired"));
      }
    }
  }
View Full Code Here

      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();
View Full Code Here

      assertTrue(actual.getQuestions().isEmpty());
      for (Question question: survey.getQuestions()) {
        Question actualQuestion = this.getSurveyManager().loadQuestion(question.getId());
        assertNull(actualQuestion);
        for (Choice choice: question.getChoices()) {
          Choice actualChoice = this.getSurveyManager().loadChoice(choice.getId());
          assertNull(actualChoice);
        }
      }
    } catch (Throwable t) {
      throw t;
View Full Code Here

  }
 
  @Override
  public void swapChoicePosition(int id, boolean isUp) throws ApsSystemException {
    try {
      Choice choice = this.getChoiceDAO().loadChoice(id);
      if (null == choice) {
        return;
      }
      List<Choice> choices = this.getQuestionDAO().getQuestionChoices(choice.getQuestionId());
      //this.getChoiceDAO().swapChoicePosition(id, isUp);
      this.getChoiceDAO().swapChoicePosition(choice, choices, isUp);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "swapChoicePosition");
      throw new ApsSystemException("Error while swapping two choices in a question", t);
View Full Code Here

  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.apsadmin.survey.IChoiceAction#listChoice()
   */
  public String editSingleChoice() {
    Choice choice = null;
    try {
      if (null == this.getChoiceId()) {
        this.addActionError(this.getText("message.surveyAction.cannotProceed"));
        return INPUT;
      }
      choice = this.getSurveyManager().loadChoice(this.getChoiceId());
      this.setChoice(choice);
      if (null != choice) {
        this.setChoices(choice.getChoices());
      } else {
        this.addActionError(this.getText("message.surveyAction.cannotProceed"));
        return INPUT;
      }
    } catch (Throwable t) {
View Full Code Here

  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.apsadmin.survey.IChoiceAction#saveChoice()
   */
  public String saveChoice() {
    Choice choice = null;
    try {
      if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
        choice = this.getSurveyManager().loadChoice(this.getChoiceId());
      }
      if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
        choice = new Choice();
        choice.setQuestionId(this.getQuestionId());
        choice.setFreeText(false);
      }
      choice.setChoices(_choices);
      if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
        this.getSurveyManager().updateChoice(choice);
      }
      if (this.getStrutsAction() == ApsAdminSystemConstants.ADD) {
        this.getSurveyManager().saveChoiceInSortedPosition(choice);
        this.setChoiceId(choice.getId());
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "saveChoice");
      return FAILURE;
    }
View Full Code Here

  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.apsadmin.survey.IChoiceAction#addNewFreeText()
   */
  public String addNewFreeText() {
    Choice choice = null;
    // fake XML common for every free text option record
    String xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"ERROR\">YOU SHOULD _NOT_ SEE THIS</property></properties>";   
    ApsProperties prop = new ApsProperties();
    this.setStrutsAction(ApsAdminSystemConstants.ADD);
    try {
      if (null == this.getQuestionId() || null == this.getStrutsAction()) {
        this.addActionError(this.getText("message.surveyAction.cannotProceed"));
        return INPUT;
      }
      prop.loadFromXml(xml);
      if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
        this.addActionError(this.getText("message.choiceAction.unexpextedAction", new String[]{this.getText("_choice"), this.getText("freeText")}));
        return INPUT;
      }
      choice = new Choice();
      choice.setChoices(prop);
      choice.setQuestionId(this.getQuestionId());
      choice.setFreeText(true);
      this.getSurveyManager().saveChoiceInSortedPosition(choice);
      this.setChoiceId(choice.getId());
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addNewFreeText");
      return FAILURE;
    }
    return SUCCESS;
View Full Code Here

  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.apsadmin.survey.IChoiceAction#addNewChoice()
   */
  public String addNewChoice() {
    Question question = null;
    Choice fakeChoice = new Choice(); // this is a dummy used only to contain extra infos!
    try {
      question = this.getSurveyManager().loadQuestion(this.getQuestionId());
      if (null != question) {
        fakeChoice.setExtraInfo(question.getSurveyId(), question.isQuestionnaire(), question.getSurveyTitles(), question.getQuestions());
      }
      fakeChoice.setId(-1);
      fakeChoice.setQuestionId(this.getQuestionId());
      this.setChoice(fakeChoice);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addNewChoice");
      return FAILURE;
    }
View Full Code Here

        int questionnaireValue = res.getInt(13);
        boolean questionnaire = questionnaireValue == 1 ? true:false;
        ApsProperties titles = new ApsProperties();
        titles.loadFromXml(res.getString(14));
        question.setExtraInfo(questionnaire, titles);
        Choice choice = this.buildChoiceRecordFromResultSet(res, 8);
        if (null == choice) continue;
        choice.setExtraInfo(question.getSurveyId(), question.isQuestionnaire(), question.getSurveyTitles(), question.getQuestions());
        if (null == question.getChoice(choice.getId())) {
          question.getChoices().add(choice);
        }
      }
    } catch (Throwable t) {
      processDaoException(t, "Error while loading the question of ID "+id, "loadQuestion");
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpsurvey.aps.system.services.survey.model.Choice

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.