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

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


    }
  }
 
  public void testSearchSurvey() throws Throwable {
    List<Integer> result = null;
    SurveyRecord survey = null;
    Set<String> col1 = new HashSet<String>();
    col1.add("ignoredToo");
    Set<String> col2 = new HashSet<String>();
    col2.add("ignoREd");
    try {
      // test by ID
//      searchSurveyByIds(id, description, group, isActive, isQuestionnaire, title, isPublic)
      result = this.getSurveyManager().searchSurvey(1, null, null, null, null, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals("ignored", survey.getGroupName().trim());
      // test by descr
      result = this.getSurveyManager().searchSurvey(null, "n-1", null, null, null, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals("ignored", survey.getGroupName().trim());
//      l=this.getSurveyManager().searchSurveyByIds(null, "<survey>", null, null, null, null, null);
//      assertNull(l);
      // test by group
      result = this.getSurveyManager().searchSurvey(null, null, col1, null, null, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals("ignoredToo", survey.getGroupName().trim());
      // test by isActive
      result = this.getSurveyManager().searchSurvey(null, null, null, false, null, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(2, survey.getId());
      // test by isActive (2)
      result = this.getSurveyManager().searchSurvey(null, null, null, true, null, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(1, survey.getId());
      // test by isQuestionnaire     
      result = this.getSurveyManager().searchSurvey(null, null, null, null, false, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(2, survey.getId());
      // test by isQuestionnaire (2)
      result = this.getSurveyManager().searchSurvey(null, null, null, null, true, null, null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(1, survey.getId());
      // test by profileUser
      result = this.getSurveyManager().searchSurvey(null, null, null, null, null, "lo-1", null);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(1, survey.getId());     
      result = this.getSurveyManager().searchSurvey(null, null, null, null, null, "mucci", null);
      assertNotNull(result);
      assertTrue(result.isEmpty());
      // test by isRestricted
      result = this.getSurveyManager().searchSurvey(null, null, null, null, null, null, true);     
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      // test by isRestricted (2)
      result = this.getSurveyManager().searchSurvey(null, null, null, null, null, null, false);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(1, survey.getId());
      // test all fields
      result = this.getSurveyManager().searchSurvey(1, "ne-1", col2, true, true, "le-1", false);
      assertNotNull(result);
      assertEquals(1, result.size());
      survey = this.getSurveyManager().loadSurvey(result.get(0));
      assertEquals(1, survey.getId());
      // This should match all the surveys!
      result = this.getSurveyManager().searchSurvey(null, null, null, null, null, null, null);
      assertNotNull(result);
      assertEquals(2, result.size());
    } catch (Throwable t) {
View Full Code Here


 
  /* (non-Javadoc)
   * @see com.agiletec.plugins.jpsurvey.apsadmin.survey.IQuestionAction#addNewQuestion()
   */
  public String addNewQuestion() {
    SurveyRecord survey = null;
    Question fakeQuestion = new Question();
    try {
      if (this.getQuestionId() == null ) {
        setStrutsAction(ApsAdminSystemConstants.ADD);
        // we have no choice but to load the titles from the survey
        survey = this.getSurveyManager().loadSurvey(this.getSurveyId());
        if (null != survey) {
          fakeQuestion.setId(-1);
          fakeQuestion.setSurveyId(this.getSurveyId());
          fakeQuestion.setExtraInfo(survey.isQuestionnaire(), survey.getTitles());
          this.setQuestion(fakeQuestion);
        }
      } else {
        if (this.getActionErrors().isEmpty()) return this.editSingleQuestion();
      }
View Full Code Here

    }
    return currentLang;
  }
 
  public SurveyRecord getSurveyInfo() {
    SurveyRecord survey = null;
    try {
      survey = this.getSurveyManager().loadSurvey(this.getSurveyId());
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "getSurveyInfo");
      throw new RuntimeException("Error loading survey: " + this.getSurveyId(), t);
View Full Code Here

  }
 
  public Boolean getVoted() {
    Boolean voted = new Boolean(false);
    try {
      SurveyRecord surveyInfo = this.getSurveyInfo();
      voted = CheckVotingUtil.isSurveyVoted(surveyInfo, this.getRequest());
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "getVoted");
      throw new RuntimeException("Error in check vote", t);
    }
View Full Code Here

public class SurveyImageAction extends SurveyResourceFinderAction implements ISurveyImageAction {
 
  @Override
  public String associateSurveyImage() {
    SurveyRecord survey = null;
    try {
      if (null != this.getSurveyId()) {
        survey = this.getSurveyManager().loadSurvey(this.getSurveyId());
        if (null != survey) {
          this.setTitles(survey.getTitles());
        }
      } else {
        this.addActionError(this.getText("message.surveyAction.sysError", new String[]{"surveyId"}));
        return INPUT;
      }
View Full Code Here

    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "intercept", "Error parsing idSurvey '" + surveyIdString + "'");
    }
   
    ISurveyManager surveyManager = (ISurveyManager) ApsWebApplicationUtils.getBean(SurveySystemConstants.SURVEY_MANAGER, request);
    SurveyRecord surveyInfo = surveyManager.loadSurvey(surveyId);
    if (null == surveyInfo) {
      return "nullRequiredSurvey";
    }
   
    //SE NON ABILITATO A GRUPPO, ESCI
    String checkGroup = this.checkSurveyGroup(surveyInfo, request);
    if (null != checkGroup) return checkGroup;
   
    Date today = new Date();
    boolean started = (today.getTime() > surveyInfo.getStartDate().getTime());
   
    //SE NON INIZIATO, ESCI
    if (!started) return "surveyNotBegunYet";
   
    boolean expired = (null != surveyInfo.getEndDate() && today.getTime() > surveyInfo.getEndDate().getTime());
   
    //SE ATTIVO, non scaduto E NON ABILITATO A RISULTATI PARZIALI, ESCI
    if (started && !expired && !surveyInfo.isPublicPartialResult()) {
      return "partialResultNotAllowed";
    }
   
    //SE SCADUTO E NON ABILITATO A RISULTATI TOTALI, ESCI
    if (expired && !surveyInfo.isPublicResult()) {
      return "finalResultNotAllowed";
    }
   
    return invocation.invoke();
 
View Full Code Here

      List<Integer> list = this.getSurveyDAO().searchSurvey(null, null, groups, true, isQuestionnaire, null, null);
      if (null != list) {
        Iterator<Integer> itr = list.iterator();
        while (itr.hasNext()) {
          Integer currentId = itr.next();
          SurveyRecord survey = this.getSurveyDAO().loadSurvey(currentId);
          if ((survey.isArchive() && archive) || (survey.isOpen() && !archive)) {
            result.add(currentId);
          }
        }
      }
    } catch (Throwable t) {
View Full Code Here

 
  public int doStartTag() throws JspException {
    ISurveyManager surveyManager = (ISurveyManager) ApsWebApplicationUtils.getBean(SurveySystemConstants.SURVEY_MANAGER, pageContext);
    ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER,pageContext);
    IResourceManager resourceManager = (IResourceManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.RESOURCE_MANAGER, this.pageContext);
    SurveyRecord survey = null
    try {
      String defaultLang = langManager.getDefaultLang().getCode();
      survey = surveyManager.loadSurvey(this.getSurveyId());
      if (this._preferredLang == null) {
        this._preferredLang = defaultLang;
      }
      this.pageContext.setAttribute(this.getCtxName(), survey);
      // fetch image
      if (null != this.getCtxImageUrl() && null != survey.getImageId()) {
        ImageResource resource = (ImageResource) resourceManager.loadResource(survey.getImageId());
        if (null != this.getImageDimension() && null != resource.getImagePath(this.getImageDimension())) {
          this.pageContext.setAttribute(this.getCtxImageUrl(), resource.getImagePath(this.getImageDimension()));
        } else {
          this.pageContext.setAttribute(this.getCtxImageUrl(), resource.getImagePath("0"));
        }
View Full Code Here

TOP

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

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.