コード例 #1
0
 /**
  * Create a {@link JpaSurvey} from the data in survey
  *
  * @param survey
  * @return
  */
 @Transactional
 @Override
 public SurveyDTO createSurvey(SurveyDTO survey) {
   // remove questions/answers if they are present - only create the survey
   JpaSurvey jpaSurvey = surveyMapper.toJpaSurvey(survey);
   jpaSurvey.setLastUpdateDate(new Timestamp(new Date().getTime()));
   jpaSurvey = jpaSurveyDao.createSurvey(jpaSurvey);
   return surveyMapper.toSurvey(jpaSurvey);
 }
コード例 #2
0
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 @Override
 public SurveyDTO getSurveyByName(String surveyName) {
   JpaSurvey jpaSurvey = jpaSurveyDao.getSurveyByCanonicalName(surveyName);
   if (jpaSurvey == null) {
     return null;
   }
   SurveyDTO result = surveyMapper.toSurvey(jpaSurvey);
   result.retrieveText(this);
   return result;
 }
コード例 #3
0
 /**
  * Search for {@link JpaSurvey} specified by id.
  *
  * @param id
  * @return
  */
 @Override
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 public SurveyDTO getSurvey(long id) {
   JpaSurvey jpaSurvey = jpaSurveyDao.getSurvey(id);
   if (jpaSurvey == null) {
     return null;
   }
   SurveyDTO result = surveyMapper.toSurvey(jpaSurvey);
   result.retrieveText(this);
   return result;
 }
コード例 #4
0
  /**
   * Search for survey questions for the specified survey. Return only the question data.
   *
   * @param surveyId
   * @return
   */
  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
  @Override
  public List<SurveyQuestionDTO> getSurveyQuestions(Long surveyId) {
    JpaSurvey survey = jpaSurveyDao.getSurvey(surveyId);
    if (survey == null) {
      return null;
    }

    SurveyDTO surveyDTO = surveyMapper.toSurvey(survey);

    return Lists.newArrayList(surveyDTO.getSurveyQuestions());
  }
コード例 #5
0
  /**
   * Update base survey data. Questions/answer relationships will not be included in the update.
   *
   * @param survey
   * @return
   */
  @Transactional
  @Override
  public SurveyDTO updateSurvey(SurveyDTO survey) {
    JpaSurvey existingSurvey = jpaSurveyDao.getSurvey(survey.getId());
    if (existingSurvey == null || existingSurvey.getStatus() == PublishedState.PUBLISHED) {
      log.warn("Cannot update survey");
      return null;
    }

    // remove question/answer elements
    survey.setSurveyQuestions(null);

    JpaSurvey jpaSurvey = surveyMapper.toJpaSurvey(survey);
    jpaSurvey.setLastUpdateDate(new Timestamp(new Date().getTime()));
    jpaSurvey = jpaSurveyDao.updateSurvey(jpaSurvey);

    return surveyMapper.toSurvey(jpaSurvey);
  }