@Transactional(readOnly = true, propagation = Propagation.SUPPORTS) @Override public ResponseDTO getResponse(long id) { JpaResponse jpaResponse = jpaSurveyDao.getResponse(id); log.debug(jpaResponse.toString()); return jpaResponse == null ? null : surveyMapper.toResponse(jpaResponse); }
@Transactional @Override public ResponseDTO createResponse(ResponseDTO response) { JpaResponse jpaResponse = surveyMapper.toJpaResponse(response); jpaSurveyDao.createResponse(jpaResponse); return surveyMapper.toResponse(jpaResponse); }
@Transactional @Override public ResponseDTO updateResponse(ResponseDTO response) { JpaResponse existingResponse = jpaSurveyDao.getResponse(response.getId()); if (existingResponse == null) { log.warn("Cannot update response - does not exist", response.toString()); return null; } JpaResponse jpaResponse = surveyMapper.toJpaResponse(response); log.debug("existing response: " + existingResponse.toString()); log.debug("source DTO response: " + response.toString()); log.debug("mapped response: " + jpaResponse.toString()); jpaResponse = jpaSurveyDao.updateResponse(jpaResponse); log.debug("updated response: " + jpaResponse.toString()); return surveyMapper.toResponse(jpaResponse); }
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS) @Override public ResponseDTO getResponseByUserAndSurvey(String user, long surveyId) { JpaResponse jpaResponse = jpaSurveyDao.getResponseByUserAndSurvey(user, surveyId); return jpaResponse == null ? null : surveyMapper.toResponse(jpaResponse); }