Generate question bank domain model from JDL
This commit is contained in:
1 parent
1d97cc4e31
commit
1d74d8f04b
160 files changed
+26900
-2
No files matched your search
@@ -0,0 +1,112 @@
|
||||
package com.example.questionbank.service;
|
||||
|
||||
import com.example.questionbank.domain.Choice;
|
||||
import com.example.questionbank.repository.ChoiceRepository;
|
||||
import com.example.questionbank.service.dto.ChoiceDTO;
|
||||
import com.example.questionbank.service.mapper.ChoiceMapper;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Service Implementation for managing {@link com.example.questionbank.domain.Choice}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ChoiceService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChoiceService.class);
|
||||
|
||||
private final ChoiceRepository choiceRepository;
|
||||
|
||||
private final ChoiceMapper choiceMapper;
|
||||
|
||||
public ChoiceService(ChoiceRepository choiceRepository, ChoiceMapper choiceMapper) {
|
||||
this.choiceRepository = choiceRepository;
|
||||
this.choiceMapper = choiceMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a choice.
|
||||
*
|
||||
* @param choiceDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ChoiceDTO save(ChoiceDTO choiceDTO) {
|
||||
LOG.debug("Request to save Choice : {}", choiceDTO);
|
||||
Choice choice = choiceMapper.toEntity(choiceDTO);
|
||||
choice = choiceRepository.save(choice);
|
||||
return choiceMapper.toDto(choice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a choice.
|
||||
*
|
||||
* @param choiceDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ChoiceDTO update(ChoiceDTO choiceDTO) {
|
||||
LOG.debug("Request to update Choice : {}", choiceDTO);
|
||||
Choice choice = choiceMapper.toEntity(choiceDTO);
|
||||
choice = choiceRepository.save(choice);
|
||||
return choiceMapper.toDto(choice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially update a choice.
|
||||
*
|
||||
* @param choiceDTO the entity to update partially.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public Optional<ChoiceDTO> partialUpdate(ChoiceDTO choiceDTO) {
|
||||
LOG.debug("Request to partially update Choice : {}", choiceDTO);
|
||||
|
||||
return choiceRepository
|
||||
.findById(choiceDTO.getId())
|
||||
.map(existingChoice -> {
|
||||
choiceMapper.partialUpdate(existingChoice, choiceDTO);
|
||||
|
||||
return existingChoice;
|
||||
})
|
||||
.map(choiceRepository::save)
|
||||
.map(choiceMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the choices.
|
||||
*
|
||||
* @return the list of entities.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<ChoiceDTO> findAll() {
|
||||
LOG.debug("Request to get all Choices");
|
||||
return choiceRepository.findAll().stream().map(choiceMapper::toDto).collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one choice by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
* @return the entity.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<ChoiceDTO> findOne(Long id) {
|
||||
LOG.debug("Request to get Choice : {}", id);
|
||||
return choiceRepository.findById(id).map(choiceMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the choice by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
LOG.debug("Request to delete Choice : {}", id);
|
||||
choiceRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.example.questionbank.service;
|
||||
|
||||
import com.example.questionbank.domain.ExamAnswer;
|
||||
import com.example.questionbank.repository.ExamAnswerRepository;
|
||||
import com.example.questionbank.service.dto.ExamAnswerDTO;
|
||||
import com.example.questionbank.service.mapper.ExamAnswerMapper;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Service Implementation for managing {@link com.example.questionbank.domain.ExamAnswer}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ExamAnswerService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExamAnswerService.class);
|
||||
|
||||
private final ExamAnswerRepository examAnswerRepository;
|
||||
|
||||
private final ExamAnswerMapper examAnswerMapper;
|
||||
|
||||
public ExamAnswerService(ExamAnswerRepository examAnswerRepository, ExamAnswerMapper examAnswerMapper) {
|
||||
this.examAnswerRepository = examAnswerRepository;
|
||||
this.examAnswerMapper = examAnswerMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a examAnswer.
|
||||
*
|
||||
* @param examAnswerDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ExamAnswerDTO save(ExamAnswerDTO examAnswerDTO) {
|
||||
LOG.debug("Request to save ExamAnswer : {}", examAnswerDTO);
|
||||
ExamAnswer examAnswer = examAnswerMapper.toEntity(examAnswerDTO);
|
||||
examAnswer = examAnswerRepository.save(examAnswer);
|
||||
return examAnswerMapper.toDto(examAnswer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a examAnswer.
|
||||
*
|
||||
* @param examAnswerDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ExamAnswerDTO update(ExamAnswerDTO examAnswerDTO) {
|
||||
LOG.debug("Request to update ExamAnswer : {}", examAnswerDTO);
|
||||
ExamAnswer examAnswer = examAnswerMapper.toEntity(examAnswerDTO);
|
||||
examAnswer = examAnswerRepository.save(examAnswer);
|
||||
return examAnswerMapper.toDto(examAnswer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially update a examAnswer.
|
||||
*
|
||||
* @param examAnswerDTO the entity to update partially.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public Optional<ExamAnswerDTO> partialUpdate(ExamAnswerDTO examAnswerDTO) {
|
||||
LOG.debug("Request to partially update ExamAnswer : {}", examAnswerDTO);
|
||||
|
||||
return examAnswerRepository
|
||||
.findById(examAnswerDTO.getId())
|
||||
.map(existingExamAnswer -> {
|
||||
examAnswerMapper.partialUpdate(existingExamAnswer, examAnswerDTO);
|
||||
|
||||
return existingExamAnswer;
|
||||
})
|
||||
.map(examAnswerRepository::save)
|
||||
.map(examAnswerMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the examAnswers.
|
||||
*
|
||||
* @return the list of entities.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<ExamAnswerDTO> findAll() {
|
||||
LOG.debug("Request to get all ExamAnswers");
|
||||
return examAnswerRepository.findAll().stream().map(examAnswerMapper::toDto).collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one examAnswer by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
* @return the entity.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<ExamAnswerDTO> findOne(Long id) {
|
||||
LOG.debug("Request to get ExamAnswer : {}", id);
|
||||
return examAnswerRepository.findById(id).map(examAnswerMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the examAnswer by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
LOG.debug("Request to delete ExamAnswer : {}", id);
|
||||
examAnswerRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.example.questionbank.service;
|
||||
|
||||
import com.example.questionbank.domain.ExamAttempt;
|
||||
import com.example.questionbank.repository.ExamAttemptRepository;
|
||||
import com.example.questionbank.service.dto.ExamAttemptDTO;
|
||||
import com.example.questionbank.service.mapper.ExamAttemptMapper;
|
||||
import java.util.Optional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Service Implementation for managing {@link com.example.questionbank.domain.ExamAttempt}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ExamAttemptService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExamAttemptService.class);
|
||||
|
||||
private final ExamAttemptRepository examAttemptRepository;
|
||||
|
||||
private final ExamAttemptMapper examAttemptMapper;
|
||||
|
||||
public ExamAttemptService(ExamAttemptRepository examAttemptRepository, ExamAttemptMapper examAttemptMapper) {
|
||||
this.examAttemptRepository = examAttemptRepository;
|
||||
this.examAttemptMapper = examAttemptMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a examAttempt.
|
||||
*
|
||||
* @param examAttemptDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ExamAttemptDTO save(ExamAttemptDTO examAttemptDTO) {
|
||||
LOG.debug("Request to save ExamAttempt : {}", examAttemptDTO);
|
||||
ExamAttempt examAttempt = examAttemptMapper.toEntity(examAttemptDTO);
|
||||
examAttempt = examAttemptRepository.save(examAttempt);
|
||||
return examAttemptMapper.toDto(examAttempt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a examAttempt.
|
||||
*
|
||||
* @param examAttemptDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public ExamAttemptDTO update(ExamAttemptDTO examAttemptDTO) {
|
||||
LOG.debug("Request to update ExamAttempt : {}", examAttemptDTO);
|
||||
ExamAttempt examAttempt = examAttemptMapper.toEntity(examAttemptDTO);
|
||||
examAttempt = examAttemptRepository.save(examAttempt);
|
||||
return examAttemptMapper.toDto(examAttempt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially update a examAttempt.
|
||||
*
|
||||
* @param examAttemptDTO the entity to update partially.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public Optional<ExamAttemptDTO> partialUpdate(ExamAttemptDTO examAttemptDTO) {
|
||||
LOG.debug("Request to partially update ExamAttempt : {}", examAttemptDTO);
|
||||
|
||||
return examAttemptRepository
|
||||
.findById(examAttemptDTO.getId())
|
||||
.map(existingExamAttempt -> {
|
||||
examAttemptMapper.partialUpdate(existingExamAttempt, examAttemptDTO);
|
||||
|
||||
return existingExamAttempt;
|
||||
})
|
||||
.map(examAttemptRepository::save)
|
||||
.map(examAttemptMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the examAttempts.
|
||||
*
|
||||
* @param pageable the pagination information.
|
||||
* @return the list of entities.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Page<ExamAttemptDTO> findAll(Pageable pageable) {
|
||||
LOG.debug("Request to get all ExamAttempts");
|
||||
return examAttemptRepository.findAll(pageable).map(examAttemptMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the examAttempts with eager load of many-to-many relationships.
|
||||
*
|
||||
* @return the list of entities.
|
||||
*/
|
||||
public Page<ExamAttemptDTO> findAllWithEagerRelationships(Pageable pageable) {
|
||||
return examAttemptRepository.findAllWithEagerRelationships(pageable).map(examAttemptMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one examAttempt by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
* @return the entity.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<ExamAttemptDTO> findOne(Long id) {
|
||||
LOG.debug("Request to get ExamAttempt : {}", id);
|
||||
return examAttemptRepository.findOneWithEagerRelationships(id).map(examAttemptMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the examAttempt by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
LOG.debug("Request to delete ExamAttempt : {}", id);
|
||||
examAttemptRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.example.questionbank.service;
|
||||
|
||||
import com.example.questionbank.domain.Question;
|
||||
import com.example.questionbank.repository.QuestionRepository;
|
||||
import com.example.questionbank.service.dto.QuestionDTO;
|
||||
import com.example.questionbank.service.mapper.QuestionMapper;
|
||||
import java.util.Optional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Service Implementation for managing {@link com.example.questionbank.domain.Question}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class QuestionService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(QuestionService.class);
|
||||
|
||||
private final QuestionRepository questionRepository;
|
||||
|
||||
private final QuestionMapper questionMapper;
|
||||
|
||||
public QuestionService(QuestionRepository questionRepository, QuestionMapper questionMapper) {
|
||||
this.questionRepository = questionRepository;
|
||||
this.questionMapper = questionMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a question.
|
||||
*
|
||||
* @param questionDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public QuestionDTO save(QuestionDTO questionDTO) {
|
||||
LOG.debug("Request to save Question : {}", questionDTO);
|
||||
Question question = questionMapper.toEntity(questionDTO);
|
||||
question = questionRepository.save(question);
|
||||
return questionMapper.toDto(question);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a question.
|
||||
*
|
||||
* @param questionDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public QuestionDTO update(QuestionDTO questionDTO) {
|
||||
LOG.debug("Request to update Question : {}", questionDTO);
|
||||
Question question = questionMapper.toEntity(questionDTO);
|
||||
question = questionRepository.save(question);
|
||||
return questionMapper.toDto(question);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially update a question.
|
||||
*
|
||||
* @param questionDTO the entity to update partially.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public Optional<QuestionDTO> partialUpdate(QuestionDTO questionDTO) {
|
||||
LOG.debug("Request to partially update Question : {}", questionDTO);
|
||||
|
||||
return questionRepository
|
||||
.findById(questionDTO.getId())
|
||||
.map(existingQuestion -> {
|
||||
questionMapper.partialUpdate(existingQuestion, questionDTO);
|
||||
|
||||
return existingQuestion;
|
||||
})
|
||||
.map(questionRepository::save)
|
||||
.map(questionMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the questions.
|
||||
*
|
||||
* @param pageable the pagination information.
|
||||
* @return the list of entities.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Page<QuestionDTO> findAll(Pageable pageable) {
|
||||
LOG.debug("Request to get all Questions");
|
||||
return questionRepository.findAll(pageable).map(questionMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the questions with eager load of many-to-many relationships.
|
||||
*
|
||||
* @return the list of entities.
|
||||
*/
|
||||
public Page<QuestionDTO> findAllWithEagerRelationships(Pageable pageable) {
|
||||
return questionRepository.findAllWithEagerRelationships(pageable).map(questionMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one question by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
* @return the entity.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<QuestionDTO> findOne(Long id) {
|
||||
LOG.debug("Request to get Question : {}", id);
|
||||
return questionRepository.findOneWithEagerRelationships(id).map(questionMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the question by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
LOG.debug("Request to delete Question : {}", id);
|
||||
questionRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.example.questionbank.service;
|
||||
|
||||
import com.example.questionbank.domain.Subject;
|
||||
import com.example.questionbank.repository.SubjectRepository;
|
||||
import com.example.questionbank.service.dto.SubjectDTO;
|
||||
import com.example.questionbank.service.mapper.SubjectMapper;
|
||||
import java.util.Optional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Service Implementation for managing {@link com.example.questionbank.domain.Subject}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SubjectService {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SubjectService.class);
|
||||
|
||||
private final SubjectRepository subjectRepository;
|
||||
|
||||
private final SubjectMapper subjectMapper;
|
||||
|
||||
public SubjectService(SubjectRepository subjectRepository, SubjectMapper subjectMapper) {
|
||||
this.subjectRepository = subjectRepository;
|
||||
this.subjectMapper = subjectMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a subject.
|
||||
*
|
||||
* @param subjectDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public SubjectDTO save(SubjectDTO subjectDTO) {
|
||||
LOG.debug("Request to save Subject : {}", subjectDTO);
|
||||
Subject subject = subjectMapper.toEntity(subjectDTO);
|
||||
subject = subjectRepository.save(subject);
|
||||
return subjectMapper.toDto(subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a subject.
|
||||
*
|
||||
* @param subjectDTO the entity to save.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public SubjectDTO update(SubjectDTO subjectDTO) {
|
||||
LOG.debug("Request to update Subject : {}", subjectDTO);
|
||||
Subject subject = subjectMapper.toEntity(subjectDTO);
|
||||
subject = subjectRepository.save(subject);
|
||||
return subjectMapper.toDto(subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially update a subject.
|
||||
*
|
||||
* @param subjectDTO the entity to update partially.
|
||||
* @return the persisted entity.
|
||||
*/
|
||||
public Optional<SubjectDTO> partialUpdate(SubjectDTO subjectDTO) {
|
||||
LOG.debug("Request to partially update Subject : {}", subjectDTO);
|
||||
|
||||
return subjectRepository
|
||||
.findById(subjectDTO.getId())
|
||||
.map(existingSubject -> {
|
||||
subjectMapper.partialUpdate(existingSubject, subjectDTO);
|
||||
|
||||
return existingSubject;
|
||||
})
|
||||
.map(subjectRepository::save)
|
||||
.map(subjectMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the subjects.
|
||||
*
|
||||
* @param pageable the pagination information.
|
||||
* @return the list of entities.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Page<SubjectDTO> findAll(Pageable pageable) {
|
||||
LOG.debug("Request to get all Subjects");
|
||||
return subjectRepository.findAll(pageable).map(subjectMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one subject by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
* @return the entity.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<SubjectDTO> findOne(Long id) {
|
||||
LOG.debug("Request to get Subject : {}", id);
|
||||
return subjectRepository.findById(id).map(subjectMapper::toDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the subject by id.
|
||||
*
|
||||
* @param id the id of the entity.
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
LOG.debug("Request to delete Subject : {}", id);
|
||||
subjectRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.example.questionbank.service.dto;
|
||||
|
||||
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.example.questionbank.domain.Choice} entity.
|
||||
*/
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class ChoiceDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
private OptionKey optionKey;
|
||||
|
||||
@NotNull
|
||||
@Size(max = 500)
|
||||
private String content;
|
||||
|
||||
@NotNull
|
||||
@Min(value = 1)
|
||||
@Max(value = 4)
|
||||
private Integer displayOrder;
|
||||
|
||||
@NotNull
|
||||
private Boolean correct;
|
||||
|
||||
@NotNull
|
||||
private QuestionDTO question;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public OptionKey getOptionKey() {
|
||||
return optionKey;
|
||||
}
|
||||
|
||||
public void setOptionKey(OptionKey optionKey) {
|
||||
this.optionKey = optionKey;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Integer getDisplayOrder() {
|
||||
return displayOrder;
|
||||
}
|
||||
|
||||
public void setDisplayOrder(Integer displayOrder) {
|
||||
this.displayOrder = displayOrder;
|
||||
}
|
||||
|
||||
public Boolean getCorrect() {
|
||||
return correct;
|
||||
}
|
||||
|
||||
public void setCorrect(Boolean correct) {
|
||||
this.correct = correct;
|
||||
}
|
||||
|
||||
public QuestionDTO getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(QuestionDTO question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ChoiceDTO)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ChoiceDTO choiceDTO = (ChoiceDTO) o;
|
||||
if (this.id == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.id, choiceDTO.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChoiceDTO{" +
|
||||
"id=" + getId() +
|
||||
", optionKey='" + getOptionKey() + "'" +
|
||||
", content='" + getContent() + "'" +
|
||||
", displayOrder=" + getDisplayOrder() +
|
||||
", correct='" + getCorrect() + "'" +
|
||||
", question=" + getQuestion() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.example.questionbank.service.dto;
|
||||
|
||||
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.example.questionbank.domain.ExamAnswer} entity.
|
||||
*/
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class ExamAnswerDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Size(max = 2000)
|
||||
private String questionTextSnapshot;
|
||||
|
||||
@Size(max = 2000)
|
||||
private String explanationSnapshot;
|
||||
|
||||
private OptionKey selectedOption;
|
||||
|
||||
@Size(max = 500)
|
||||
private String selectedContentSnapshot;
|
||||
|
||||
private Boolean correct;
|
||||
|
||||
@Min(value = 0)
|
||||
private Integer awardedPoints;
|
||||
|
||||
@NotNull
|
||||
private QuestionDTO question;
|
||||
|
||||
@NotNull
|
||||
private ExamAttemptDTO attempt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getQuestionTextSnapshot() {
|
||||
return questionTextSnapshot;
|
||||
}
|
||||
|
||||
public void setQuestionTextSnapshot(String questionTextSnapshot) {
|
||||
this.questionTextSnapshot = questionTextSnapshot;
|
||||
}
|
||||
|
||||
public String getExplanationSnapshot() {
|
||||
return explanationSnapshot;
|
||||
}
|
||||
|
||||
public void setExplanationSnapshot(String explanationSnapshot) {
|
||||
this.explanationSnapshot = explanationSnapshot;
|
||||
}
|
||||
|
||||
public OptionKey getSelectedOption() {
|
||||
return selectedOption;
|
||||
}
|
||||
|
||||
public void setSelectedOption(OptionKey selectedOption) {
|
||||
this.selectedOption = selectedOption;
|
||||
}
|
||||
|
||||
public String getSelectedContentSnapshot() {
|
||||
return selectedContentSnapshot;
|
||||
}
|
||||
|
||||
public void setSelectedContentSnapshot(String selectedContentSnapshot) {
|
||||
this.selectedContentSnapshot = selectedContentSnapshot;
|
||||
}
|
||||
|
||||
public Boolean getCorrect() {
|
||||
return correct;
|
||||
}
|
||||
|
||||
public void setCorrect(Boolean correct) {
|
||||
this.correct = correct;
|
||||
}
|
||||
|
||||
public Integer getAwardedPoints() {
|
||||
return awardedPoints;
|
||||
}
|
||||
|
||||
public void setAwardedPoints(Integer awardedPoints) {
|
||||
this.awardedPoints = awardedPoints;
|
||||
}
|
||||
|
||||
public QuestionDTO getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(QuestionDTO question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public ExamAttemptDTO getAttempt() {
|
||||
return attempt;
|
||||
}
|
||||
|
||||
public void setAttempt(ExamAttemptDTO attempt) {
|
||||
this.attempt = attempt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ExamAnswerDTO)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ExamAnswerDTO examAnswerDTO = (ExamAnswerDTO) o;
|
||||
if (this.id == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.id, examAnswerDTO.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExamAnswerDTO{" +
|
||||
"id=" + getId() +
|
||||
", questionTextSnapshot='" + getQuestionTextSnapshot() + "'" +
|
||||
", explanationSnapshot='" + getExplanationSnapshot() + "'" +
|
||||
", selectedOption='" + getSelectedOption() + "'" +
|
||||
", selectedContentSnapshot='" + getSelectedContentSnapshot() + "'" +
|
||||
", correct='" + getCorrect() + "'" +
|
||||
", awardedPoints=" + getAwardedPoints() +
|
||||
", question=" + getQuestion() +
|
||||
", attempt=" + getAttempt() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.example.questionbank.service.dto;
|
||||
|
||||
import com.example.questionbank.domain.enumeration.AttemptStatus;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.example.questionbank.domain.ExamAttempt} entity.
|
||||
*/
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class ExamAttemptDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
private Instant startedAt;
|
||||
|
||||
private Instant submittedAt;
|
||||
|
||||
@NotNull
|
||||
private AttemptStatus status;
|
||||
|
||||
@Min(value = 0)
|
||||
private Integer score;
|
||||
|
||||
@NotNull
|
||||
private SubjectDTO subject;
|
||||
|
||||
@NotNull
|
||||
private UserDTO user;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Instant getStartedAt() {
|
||||
return startedAt;
|
||||
}
|
||||
|
||||
public void setStartedAt(Instant startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
}
|
||||
|
||||
public Instant getSubmittedAt() {
|
||||
return submittedAt;
|
||||
}
|
||||
|
||||
public void setSubmittedAt(Instant submittedAt) {
|
||||
this.submittedAt = submittedAt;
|
||||
}
|
||||
|
||||
public AttemptStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(AttemptStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public SubjectDTO getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(SubjectDTO subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public UserDTO getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserDTO user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ExamAttemptDTO)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ExamAttemptDTO examAttemptDTO = (ExamAttemptDTO) o;
|
||||
if (this.id == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.id, examAttemptDTO.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExamAttemptDTO{" +
|
||||
"id=" + getId() +
|
||||
", startedAt='" + getStartedAt() + "'" +
|
||||
", submittedAt='" + getSubmittedAt() + "'" +
|
||||
", status='" + getStatus() + "'" +
|
||||
", score=" + getScore() +
|
||||
", subject=" + getSubject() +
|
||||
", user=" + getUser() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.example.questionbank.service.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.example.questionbank.domain.Question} entity.
|
||||
*/
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class QuestionDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 5, max = 2000)
|
||||
private String prompt;
|
||||
|
||||
@Size(max = 2000)
|
||||
private String explanation;
|
||||
|
||||
@NotNull
|
||||
private Boolean active;
|
||||
|
||||
@NotNull
|
||||
private SubjectDTO subject;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
public void setPrompt(String prompt) {
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public String getExplanation() {
|
||||
return explanation;
|
||||
}
|
||||
|
||||
public void setExplanation(String explanation) {
|
||||
this.explanation = explanation;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public SubjectDTO getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(SubjectDTO subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof QuestionDTO)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QuestionDTO questionDTO = (QuestionDTO) o;
|
||||
if (this.id == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.id, questionDTO.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QuestionDTO{" +
|
||||
"id=" + getId() +
|
||||
", prompt='" + getPrompt() + "'" +
|
||||
", explanation='" + getExplanation() + "'" +
|
||||
", active='" + getActive() + "'" +
|
||||
", subject=" + getSubject() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.example.questionbank.service.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.example.questionbank.domain.Subject} entity.
|
||||
*/
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class SubjectDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 2, max = 100)
|
||||
private String name;
|
||||
|
||||
@Size(max = 1000)
|
||||
private String description;
|
||||
|
||||
@NotNull
|
||||
private Boolean active;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof SubjectDTO)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SubjectDTO subjectDTO = (SubjectDTO) o;
|
||||
if (this.id == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.id, subjectDTO.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.id);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SubjectDTO{" +
|
||||
"id=" + getId() +
|
||||
", name='" + getName() + "'" +
|
||||
", description='" + getDescription() + "'" +
|
||||
", active='" + getActive() + "'" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import com.example.questionbank.domain.Choice;
|
||||
import com.example.questionbank.domain.Question;
|
||||
import com.example.questionbank.service.dto.ChoiceDTO;
|
||||
import com.example.questionbank.service.dto.QuestionDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity {@link Choice} and its DTO {@link ChoiceDTO}.
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ChoiceMapper extends EntityMapper<ChoiceDTO, Choice> {
|
||||
@Mapping(target = "question", source = "question", qualifiedByName = "questionId")
|
||||
ChoiceDTO toDto(Choice s);
|
||||
|
||||
@Named("questionId")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
QuestionDTO toDtoQuestionId(Question question);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.mapstruct.BeanMapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.NullValuePropertyMappingStrategy;
|
||||
|
||||
/**
|
||||
* Contract for a generic dto to entity mapper.
|
||||
*
|
||||
* @param <D> - DTO type parameter.
|
||||
* @param <E> - Entity type parameter.
|
||||
*/
|
||||
|
||||
public interface EntityMapper<D, E> {
|
||||
E toEntity(D dto);
|
||||
|
||||
D toDto(E entity);
|
||||
|
||||
List<E> toEntity(List<D> dtoList);
|
||||
|
||||
List<D> toDto(List<E> entityList);
|
||||
|
||||
@Named("partialUpdate")
|
||||
@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
||||
void partialUpdate(@MappingTarget E entity, D dto);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import com.example.questionbank.domain.ExamAnswer;
|
||||
import com.example.questionbank.domain.ExamAttempt;
|
||||
import com.example.questionbank.domain.Question;
|
||||
import com.example.questionbank.service.dto.ExamAnswerDTO;
|
||||
import com.example.questionbank.service.dto.ExamAttemptDTO;
|
||||
import com.example.questionbank.service.dto.QuestionDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity {@link ExamAnswer} and its DTO {@link ExamAnswerDTO}.
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ExamAnswerMapper extends EntityMapper<ExamAnswerDTO, ExamAnswer> {
|
||||
@Mapping(target = "question", source = "question", qualifiedByName = "questionId")
|
||||
@Mapping(target = "attempt", source = "attempt", qualifiedByName = "examAttemptId")
|
||||
ExamAnswerDTO toDto(ExamAnswer s);
|
||||
|
||||
@Named("questionId")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
QuestionDTO toDtoQuestionId(Question question);
|
||||
|
||||
@Named("examAttemptId")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
ExamAttemptDTO toDtoExamAttemptId(ExamAttempt examAttempt);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import com.example.questionbank.domain.ExamAttempt;
|
||||
import com.example.questionbank.domain.Subject;
|
||||
import com.example.questionbank.domain.User;
|
||||
import com.example.questionbank.service.dto.ExamAttemptDTO;
|
||||
import com.example.questionbank.service.dto.SubjectDTO;
|
||||
import com.example.questionbank.service.dto.UserDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity {@link ExamAttempt} and its DTO {@link ExamAttemptDTO}.
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface ExamAttemptMapper extends EntityMapper<ExamAttemptDTO, ExamAttempt> {
|
||||
@Mapping(target = "subject", source = "subject", qualifiedByName = "subjectName")
|
||||
@Mapping(target = "user", source = "user", qualifiedByName = "userLogin")
|
||||
ExamAttemptDTO toDto(ExamAttempt s);
|
||||
|
||||
@Named("subjectName")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
@Mapping(target = "name", source = "name")
|
||||
SubjectDTO toDtoSubjectName(Subject subject);
|
||||
|
||||
@Named("userLogin")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
@Mapping(target = "login", source = "login")
|
||||
UserDTO toDtoUserLogin(User user);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import com.example.questionbank.domain.Question;
|
||||
import com.example.questionbank.domain.Subject;
|
||||
import com.example.questionbank.service.dto.QuestionDTO;
|
||||
import com.example.questionbank.service.dto.SubjectDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity {@link Question} and its DTO {@link QuestionDTO}.
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface QuestionMapper extends EntityMapper<QuestionDTO, Question> {
|
||||
@Mapping(target = "subject", source = "subject", qualifiedByName = "subjectName")
|
||||
QuestionDTO toDto(Question s);
|
||||
|
||||
@Named("subjectName")
|
||||
@BeanMapping(ignoreByDefault = true)
|
||||
@Mapping(target = "id", source = "id")
|
||||
@Mapping(target = "name", source = "name")
|
||||
SubjectDTO toDtoSubjectName(Subject subject);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.questionbank.service.mapper;
|
||||
|
||||
import com.example.questionbank.domain.Subject;
|
||||
import com.example.questionbank.service.dto.SubjectDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity {@link Subject} and its DTO {@link SubjectDTO}.
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface SubjectMapper extends EntityMapper<SubjectDTO, Subject> {}
|
||||
Reference in new issue
Block a user