/** * Create a {@link JpaQuestion} from the data in question * * @param question * @return */ @Transactional @Override public QuestionDTO createQuestion(QuestionDTO question) { JpaQuestion jpaQuestion = surveyMapper.toJpaQuestion(question); jpaQuestion = jpaSurveyDao.createQuestion(jpaQuestion); QuestionDTO newQuestion = surveyMapper.toQuestion(jpaQuestion); return newQuestion; }
/** * Update question details including embedded answer data * * @param question * @return {@link QuestionDTO} or null on error */ @Transactional @Override public QuestionDTO updateQuestion(QuestionDTO question) { JpaQuestion existingQuestion = jpaSurveyDao.getQuestion(question.getId()); if (existingQuestion.getStatus() == PublishedState.PUBLISHED) { log.warn("Cannot update question in PUBLISHED state"); return null; } JpaQuestion jpaQuestion = surveyMapper.toJpaQuestion(question); jpaSurveyDao.updateQuestion(jpaQuestion); return surveyMapper.toQuestion(jpaQuestion); }