Package com.agiletec.aps.util

Examples of com.agiletec.aps.util.ApsProperties


      if (res.next()) {
        choice = this.buildChoiceRecordFromResultSet(res, 1);
        // process get extra info
        int surveyId = res.getInt(6);
        boolean questionnaire = res.getInt(7) == 1 ? true:false;
        ApsProperties surveyTitle = new ApsProperties();
        surveyTitle.loadFromXml(res.getString(8));
        ApsProperties questionTitle = new ApsProperties();
        questionTitle.loadFromXml(res.getString(9));
        choice.setExtraInfo(surveyId, questionnaire, surveyTitle, questionTitle);
      }
    } catch (Throwable t) {
      processDaoException(t, "Error while loading the choice of ID "+id, "loadChoice");
    } finally {
View Full Code Here


public class TestSurveyManager extends ApsPluginBaseTestCase {
 
  public void testLoadSurvey() throws Throwable {
    Survey survey = null;
    ApsProperties prop = null;
    try {
      survey = this.getSurveyManager().loadSurvey(0);
      assertNull(survey);
      survey = this.getSurveyManager().loadSurvey(1);
      assertNotNull(survey);
      assertEquals("ignored", survey.getGroupName());
      assertNotNull(survey.getDescriptions());
      assertTrue(survey.isActive());
      assertTrue(survey.isGatherUserInfo());
      assertTrue(survey.isPublicResult());
      assertFalse(survey.isPublicPartialResult());
      assertTrue(survey.isQuestionnaire());
      assertNotNull(survey.getTitles());
      assertFalse(survey.isRestricted());
      assertNotNull(survey.getQuestions());
      assertFalse(survey.getQuestions().isEmpty());
      assertEquals(2, survey.getQuestions().size());
      assertEquals("IMG001", survey.getImageId());
      prop = survey.getImageDescriptions();
      assertEquals("Barrali di notte", prop.getProperty("it"));
      // questions must belong to the same survey
      assertTrue(survey.getQuestions().get(0).getSurveyId() == survey.getId());
      assertTrue(survey.getQuestions().get(0).getSurveyId() == survey.getQuestions().get(1).getSurveyId());
      assertNotNull(survey.getQuestions().get(0).getChoices());
      // check choices size
View Full Code Here

    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
    prop.loadFromXml(xml);
    survey.setDescriptions(prop);
    survey.setGroupName("fake");
    survey.setStartDate(date);
    survey.setEndDate(null);
    survey.setActive(true);
    survey.setPublicPartialResult(false);
    survey.setPublicResult(true);
    survey.setQuestionnaire(false);
    survey.setGatherUserInfo(true);
    survey.setRestricted(true);
    survey.setTitles(prop);
    survey.setImageId("IMGXXX");
    prop = new ApsProperties();
    prop.loadFromXml(xmlBarrali);
    survey.setImageDescriptions(prop);
    survey.setQuestions(questions);
    return survey;
  }
View Full Code Here

    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
    prop.loadFromXml(xmlDescription);
    survey.setDescriptions(prop);
    survey.setGroupName("fake");
    survey.setStartDate(date);
    survey.setEndDate(null);
    survey.setActive(true);
    survey.setPublicPartialResult(false);
    survey.setPublicResult(true);
    survey.setQuestionnaire(false);
    survey.setGatherUserInfo(true);
    survey.setRestricted(true);
    prop = new ApsProperties();
    prop.loadFromXml(xmlTitle);
    survey.setTitles(prop);
    survey.setImageId("IMGXXX");
    prop = new ApsProperties();
    prop.loadFromXml(xmlDescription);
    survey.setImageDescriptions(prop);
    survey.setQuestions(questions);
    return survey;
  }
View Full Code Here

  public String joinCategory() {
    try {
      String categoryCode = this.getCategoryCode();
      Category category = this.getCategoryManager().getCategory(categoryCode);
      if (null != category && !category.getCode().equals(category.getParentCode())) {
        ApsProperties currentCats = this.getCategories();
        currentCats.put(category.getCode(), category.getFullTitle());
        this.setXmlCategories(currentCats.toXml());
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "joinCategory");
      return FAILURE;
    }
View Full Code Here

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

  }
 
  protected Choice getFakeChoice() throws Throwable {
    Choice choice = new Choice();
    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();
    try {
      prop.loadFromXml(xml);
      choice.setChoices(prop);
      choice.setFreeText(true);
      choice.setPos(96);
      choice.setQuestionId(2);
    } catch (Throwable t) {
View Full Code Here

  public String removeCategory() {
    try {
      String categoryCode = this.getCategoryCode();
      Category category = this.getCategoryManager().getCategory(categoryCode);
      if (null != category) {
        ApsProperties currentCats = this.getCategories();
        currentCats.remove(categoryCode);
        this.setXmlCategories(currentCats.toXml());
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "removeCategory");
      return FAILURE;
    }
View Full Code Here

    }
    return SUCCESS;
  }

  public ApsProperties getCategories() throws Throwable {
    ApsProperties properties = new ApsProperties();
    if (null != this.getXmlCategories() && this.getXmlCategories().trim().length() > 0) {
      properties.loadFromXml(this.getXmlCategories());
    }
    this.purgeCategories(properties);
    return properties;
  }
View Full Code Here

    question2.setPos(1);
    List<Question> questions = new ArrayList<Question>();
    questions.add(question);
    questions.add(question2);
    Date date = new Date();
    ApsProperties prop = new ApsProperties();
    prop.loadFromXml(xml);
    survey.setDescriptions(prop);
    survey.setGroupName("fake");
    survey.setStartDate(date);
    survey.setEndDate(null);
    survey.setActive(true);
    survey.setPublicPartialResult(false);
    survey.setPublicResult(true);
    survey.setQuestionnaire(false);
    survey.setGatherUserInfo(true);
    survey.setRestricted(true);
    survey.setTitles(prop);
    survey.setImageId("IMGXXX");
    prop = new ApsProperties();
    prop.loadFromXml(xmlImageDescr);
    survey.setImageDescriptions(prop);
    survey.setQuestions(questions);
    return survey;
  }
View Full Code Here

TOP

Related Classes of com.agiletec.aps.util.ApsProperties

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.