This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from IT-REX-Platform/feature/ITREX-538
Feature/itrex 538
- Loading branch information
Showing
20 changed files
with
616 additions
and
4 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/de/uni_stuttgart/it_rex/quiz/domain/enumeration/QUESTIONTYPE.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.uni_stuttgart.it_rex.quiz.domain.enumeration; | ||
|
||
/** | ||
* The QUESTIONTYPE enumeration. | ||
*/ | ||
public enum QUESTIONTYPE { | ||
SINGLE_CHOICE, MULTIPLE_CHOICE, NUMERIC | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/de/uni_stuttgart/it_rex/quiz/domain/enumeration/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Enumerations. | ||
*/ | ||
package de.uni_stuttgart.it_rex.quiz.domain.enumeration; |
100 changes: 100 additions & 0 deletions
100
src/main/java/de/uni_stuttgart/it_rex/quiz/domain/written_entities/Quiz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package de.uni_stuttgart.it_rex.quiz.domain.written_entities; | ||
|
||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
import org.springframework.data.mongodb.core.mapping.Field; | ||
import org.springframework.data.mongodb.core.mapping.DBRef; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
/** | ||
* A Quiz. | ||
*/ | ||
@Document(collection = "quiz") | ||
public class Quiz implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
private UUID id; | ||
|
||
@Field("content") | ||
private String content; | ||
|
||
// @DBRef | ||
// @Field("b") | ||
// private Set<EntityB> bs = new HashSet<>(); | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
public boolean isNew() { | ||
return (getId() == null); | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
// public Set<EntityB> getBs() { | ||
// return bs; | ||
// } | ||
|
||
// public EntityA bs(Set<EntityB> entityBS) { | ||
// this.bs = entityBS; | ||
// return this; | ||
// } | ||
|
||
// public EntityA addB(EntityB entityB) { | ||
// this.bs.add(entityB); | ||
// entityB.setA(this); | ||
// return this; | ||
// } | ||
|
||
// public EntityA removeB(EntityB entityB) { | ||
// this.bs.remove(entityB); | ||
// entityB.setA(null); | ||
// return this; | ||
// } | ||
|
||
// public void setBs(Set<EntityB> entityBS) { | ||
// this.bs = entityBS; | ||
// } | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof Quiz)) { | ||
return false; | ||
} | ||
return id != null && id.equals(((Quiz) o).id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 31; | ||
} | ||
|
||
// prettier-ignore | ||
@Override | ||
public String toString() { | ||
return "Quiz{" + | ||
"id=" + getId() + | ||
", content='" + getContent() + "'" + | ||
"}"; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/de/uni_stuttgart/it_rex/quiz/domain/written_entities/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* JPA domain objects. | ||
*/ | ||
package de.uni_stuttgart.it_rex.quiz.domain.written_entities; |
17 changes: 17 additions & 0 deletions
17
src/main/java/de/uni_stuttgart/it_rex/quiz/repository/written/QuizRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.uni_stuttgart.it_rex.quiz.repository.written; | ||
|
||
import de.uni_stuttgart.it_rex.quiz.domain.written_entities.Quiz; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
/** | ||
* Spring Data MongoDB repository for the Quiz entity. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Repository | ||
public interface QuizRepository extends MongoRepository<Quiz, UUID> { | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
src/main/java/de/uni_stuttgart/it_rex/quiz/repository/written/QuizUuidListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.uni_stuttgart.it_rex.quiz.repository.written; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener; | ||
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent; | ||
import org.springframework.stereotype.Component; | ||
|
||
import de.uni_stuttgart.it_rex.quiz.domain.written_entities.Quiz; | ||
|
||
@Component | ||
public class QuizUuidListener extends AbstractMongoEventListener<Quiz> { | ||
|
||
@Override | ||
public void onBeforeConvert(BeforeConvertEvent<Quiz> event) { | ||
Quiz quiz = event.getSource(); | ||
if (quiz.isNew()) { | ||
quiz.setId(UUID.randomUUID()); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/de/uni_stuttgart/it_rex/quiz/repository/written/UuidConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.uni_stuttgart.it_rex.quiz.repository.written; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener; | ||
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent; | ||
import org.springframework.stereotype.Component; | ||
|
||
import de.uni_stuttgart.it_rex.quiz.domain.written_entities.Quiz; | ||
|
||
// @Component | ||
// public class UuidConverter implements Converter<User, DBObject> { | ||
// @Override | ||
// public DBObject convert(User user) { | ||
// DBObject dbObject = new BasicDBObject(); | ||
// dbObject.put("name", user.getName()); | ||
// dbObject.put("age", user.getAge()); | ||
// if (user.getEmailAddress() != null) { | ||
// DBObject emailDbObject = new BasicDBObject(); | ||
// emailDbObject.put("value", user.getEmailAddress().getValue()); | ||
// dbObject.put("email", emailDbObject); | ||
// } | ||
// dbObject.removeField("_class"); | ||
// return dbObject; | ||
// } | ||
// } |
4 changes: 4 additions & 0 deletions
4
src/main/java/de/uni_stuttgart/it_rex/quiz/repository/written/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Spring Data JPA repositories. | ||
*/ | ||
package de.uni_stuttgart.it_rex.quiz.repository.written; |
48 changes: 48 additions & 0 deletions
48
src/main/java/de/uni_stuttgart/it_rex/quiz/service/dto/written_dtos/AnswerTypeDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package de.uni_stuttgart.it_rex.quiz.service.dto.written_dtos; | ||
|
||
|
||
import java.io.Serializable; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
|
||
|
||
public class AnswerTypeDTO implements Serializable{ | ||
|
||
public enum ANSWER_TYPE { | ||
SINGLE_CHOICE, | ||
MULTIPLE_CHOICE, | ||
NUMERIC | ||
}; | ||
|
||
/** | ||
* Identifier. | ||
*/ | ||
private UUID id; | ||
|
||
private ANSWER_TYPE type; | ||
|
||
} | ||
|
||
// public class ChoiceAnswer { | ||
// private String content; | ||
// private Boolean correct; | ||
// } | ||
|
||
// public class NumericAnswer { | ||
// private Float content; | ||
// private Float epsilon; | ||
// } | ||
|
||
// public class ChoiceAnswerTypeDTO extends AnswerTypeDTO { | ||
// private List<ChoiceAnswer> answer; | ||
// } | ||
|
||
// public class NumericAnswerTypeDTO extends AnswerTypeDTO { | ||
// private NumericAnswer answer; | ||
// } | ||
|
||
|
||
|
27 changes: 27 additions & 0 deletions
27
src/main/java/de/uni_stuttgart/it_rex/quiz/service/dto/written_dtos/QuestionDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.uni_stuttgart.it_rex.quiz.service.dto.written_dtos; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class QuestionDTO implements Serializable { | ||
/** | ||
* Identifier. | ||
*/ | ||
private UUID id; | ||
|
||
/** | ||
* Course id. | ||
*/ | ||
private UUID courseId; | ||
|
||
private String question; | ||
|
||
private AnswerTypeDTO answer; | ||
|
||
// for later impls | ||
// for search | ||
// private List<String> tags; | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/de/uni_stuttgart/it_rex/quiz/service/dto/written_dtos/QuizDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package de.uni_stuttgart.it_rex.quiz.service.dto.written_dtos; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class QuizDTO implements Serializable { | ||
/** | ||
* Identifier. | ||
*/ | ||
private UUID id; | ||
|
||
/** | ||
* Title of the chapter. | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* Course id. | ||
*/ | ||
private UUID courseId; | ||
|
||
/** | ||
* List of questions | ||
*/ | ||
private List<QuestionDTO> questions; | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public UUID getCourseId() { | ||
return courseId; | ||
} | ||
|
||
public void setCourseId(UUID courseId) { | ||
this.courseId = courseId; | ||
} | ||
|
||
public List<QuestionDTO> getQuestions() { | ||
return questions; | ||
} | ||
|
||
public void setQuestions(List<QuestionDTO> questions) { | ||
this.questions = questions; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/de/uni_stuttgart/it_rex/quiz/service/dto/written_dtos/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Data Transfer Objects. | ||
*/ | ||
package de.uni_stuttgart.it_rex.quiz.service.dto.written_dtos; |
4 changes: 0 additions & 4 deletions
4
src/main/java/de/uni_stuttgart/it_rex/quiz/service/dto_written/package-info.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/java/de/uni_stuttgart/it_rex/quiz/service/mapper/EntityMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.uni_stuttgart.it_rex.quiz.service.mapper; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 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); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/de/uni_stuttgart/it_rex/quiz/service/mapper/written/QuizMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.uni_stuttgart.it_rex.quiz.service.mapper.written; | ||
|
||
|
||
import de.uni_stuttgart.it_rex.quiz.domain.written_entities.Quiz; | ||
import de.uni_stuttgart.it_rex.quiz.service.dto.written_dtos.QuizDTO; | ||
import de.uni_stuttgart.it_rex.quiz.service.mapper.EntityMapper; | ||
|
||
import java.util.UUID; | ||
|
||
import org.mapstruct.*; | ||
|
||
/** | ||
* Mapper for the entity {@link Quiz} and its DTO {@link QuizDTO}. | ||
*/ | ||
@Mapper(componentModel = "spring", uses = {}) | ||
public interface QuizMapper extends EntityMapper<QuizDTO, Quiz> { | ||
|
||
// default UUID idToId(String id) { | ||
// if (id == null) { | ||
// return null; | ||
// } | ||
// return UUID.fromString(id); | ||
// } | ||
|
||
// default String idToId(UUID id) { | ||
// if (id == null) { | ||
// return null; | ||
// } | ||
// return id.toString(); | ||
// } | ||
} |
Oops, something went wrong.