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

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


  @Override
  public void swapQuestionPosition(Question questionToSwap, List<Question> questions, boolean up) {
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet res = null;
    Question nearQuestionToSwap = null;
    try {
      for (int i = 0; i < questions.size(); i++) {
        Question question = questions.get(i);
        if (question.getId() == questionToSwap.getId()) {
          if (up && i>0) {
            nearQuestionToSwap = questions.get(i-1);
          } else if (!up && i<(questions.size()-1)) {
            nearQuestionToSwap = questions.get(i+1);
          }
View Full Code Here


        // FIXME usare le costanti per lo shift?
        if (null == survey) {
          survey = this.buildSurveyRecordFromResultSet(res);
        }
        Integer questionId = res.getInt(18);
        Question question = null;
        if (null == currentQuestionId || !questionId.equals(currentQuestionId)) {
          question = this.buildQuestionRecordFromResultSet(res, 18);
          if (null == question) continue;
          survey.getQuestions().add(question);
          currentQuestionId = questionId;
        } else {
          question = survey.getQuestion(currentQuestionId);
        }
        Choice choice = this.buildChoiceRecordFromResultSet(res, 25);
        if (null == choice) {
          continue;
        }
        if (null == question.getChoice(choice.getId())) {
          question.getChoices().add(choice);
        }
      }
    } catch (Throwable t) {
      processDaoException(t, "Error while loading the survey ID "+id, "loadSurvey");
    } finally {
View Full Code Here

      stat.executeUpdate();
      // SAVE QUESTIONS
      if (null != survey.getQuestions() && !survey.getQuestions().isEmpty()) {
        Iterator<Question> itr = survey.getQuestions().iterator();
        while (itr.hasNext()) {
          Question currentQuestion = itr.next();
          currentQuestion.setSurveyId(survey.getId());
          this.saveQuestion(conn, currentQuestion);
        }
      }
      conn.commit();
    } catch (Throwable t) {
View Full Code Here

 
  protected Survey getFakeActiveSurvey() throws Throwable {
    Survey survey = new Survey();
    String xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"test\">me</property><property key=\"test2\">me too</property></properties>";
    String xmlBarrali="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">You should NOT see THIS in the DB!</property><property key=\"it\">NON dovresti vedere QUESTO nel database!</property></properties>";
    Question question = this.getFakeQuestion();
    Question question2 = this.getFakeQuestion();
    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
View Full Code Here

   */
  protected Survey getFakeActiveSurvey(String description, String title) throws Throwable {
    Survey survey = new Survey();
    String xmlDescription="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">"+description+"_en</property><property key=\"it\">"+description+"_it</property></properties>";
    String xmlTitle="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">"+title+"_en</property><property key=\"it\">"+title+"_it+</property></properties>";
    Question question = this.getFakeQuestion();
    Question question2 = this.getFakeQuestion();
    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
View Full Code Here

   * This will assign the fake question to the survey ID 1
   * @return a question object not existing in the database
   * @throws Throwable
   */
  protected Question getFakeQuestion() throws Throwable {
    Question question = new Question();
    String xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"test\">me</property><property key=\"test2\">me too</property></properties>";
    ApsProperties prop = new ApsProperties();
    Choice choice1 = this.getFakeChoice();
    Choice choice2 = this.getFakeChoice();
    List<Choice> choiceList = new ArrayList<Choice>();
    try {
      choiceList.add(choice1);
      choiceList.add(choice2);
      prop.loadFromXml(xml);
      question.setQuestions(prop);
      question.setId(2); // this will be changed when saving...
      question.setMaxResponseNumber(2677);
      question.setMinResponseNumber(1977);
      question.setPos(0);
      question.setSingleChoice(false);
      question.setSurveyId(1);
      choice1.setId(2); // will be changed upon saving
      choice1.setPos(0);
      choice1.setQuestionId(question.getId());
      choice1.setId(2); // will be changed upon saving
      choice2.setPos(10); // this is set on purpose to test save in sorted position method
      choice2.setQuestionId(question.getId());
      question.setChoices(choiceList);
    } catch (Throwable t) {
      throw t;
    }
    return question;
  }
View Full Code Here

   */
  protected Survey getFakeActiveSurvey() throws Throwable {
    Survey survey = new Survey();
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"test\">me</property><property key=\"test2\">me too</property></properties>";
    String xmlImageDescr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">You should NOT see THIS in the DB!</property><property key=\"it\">NON dovresti vedere QUESTO nel database!</property></properties>";
    Question question = this.getFakeQuestion();
    Question question2 = this.getFakeQuestion();
    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
View Full Code Here

   */
  protected Survey getFakeActiveSurvey(String description, String title) throws Throwable {
    Survey survey = new Survey();
    String xmlDescription="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">"+description+"_en</property><property key=\"it\">"+description+"_it</property></properties>";
    String xmlTitle="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"en\">"+title+"_en</property><property key=\"it\">"+title+"_it+</property></properties>";
    Question question = this.getFakeQuestion();
    question.setPos(1);
    Question question2 = this.getFakeQuestion();
    question2.setPos(2);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
View Full Code Here

   * This will assign the fake question to the survey ID 1
   * @return a question object not existing in the database
   * @throws Throwable
   */
  protected Question getFakeQuestion() throws Throwable {
    Question question = new Question();
    String xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?><properties><property key=\"test\">me</property><property key=\"test2\">me too</property></properties>";
    ApsProperties prop = new ApsProperties();
    Choice choice1 = this.getFakeChoice();
    Choice choice2 = this.getFakeChoice();
    List<Choice> choiceList = new ArrayList<Choice>();
    try {
      choiceList.add(choice1);
      choiceList.add(choice2);
      prop.loadFromXml(xml);
      question.setQuestions(prop);
      question.setId(2); // this will be changed when saving...
      question.setMaxResponseNumber(2677);
      question.setMinResponseNumber(1977);
      question.setPos(0);
      question.setSingleChoice(false);
      question.setSurveyId(1);
      choice1.setId(2); // will be changed upon saving
      choice1.setPos(0);
      choice1.setQuestionId(question.getId());
      choice1.setId(2); // will be changed upon saving
      choice2.setPos(10); // this is set on purpose to test save in sorted position method
      choice2.setQuestionId(question.getId());
      question.setChoices(choiceList);
    } catch (Throwable t) {
      throw t;
    }
    return question;
  }
View Full Code Here

   * @param res the result set containing the record of the question
   * @param shift The number of the first column containing the data of the questions within the result set.
   * @return the 'question' object requested
   */
  protected Question buildQuestionRecordFromResultSet(ResultSet res, int shift) {
    Question question = null;
    if (null == res) return null;
    if (shift > 0) --shift;
    try {
      int id = res.getInt(shift + 1);
      if (id > 0) {
        question = new Question();
        question.setChoices(new ArrayList<Choice>());
        question.setId(id);
        question.setSurveyId(res.getInt(shift + 2));
        ApsProperties prop = new ApsProperties();
        prop.loadFromXml(res.getString(shift + 3));
        question.setQuestions(prop);
        question.setPos(res.getInt(shift + 4));
        question.setSingleChoice(res.getBoolean(shift + 5));
        question.setMinResponseNumber(res.getInt(shift + 6));
        question.setMaxResponseNumber(res.getInt(shift + 7));
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "buildQuestionRecordFromResultSet",
          "Error while building a 'question' object from the result set");
    }
View Full Code Here

TOP

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

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.