コード例 #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
  /**
   * 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);
  }