-
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 #29 from SELab-2/feature/jpa
JPA setup
- Loading branch information
Showing
50 changed files
with
1,351 additions
and
97 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,14 @@ | ||
FROM eclipse-temurin:17-jdk-alpine | ||
VOLUME /tmp | ||
COPY build/libs/*T.jar app.jar | ||
ENTRYPOINT ["java","-jar","/app.jar"] | ||
FROM gradle:jdk17 AS build | ||
COPY --chown=gradle:gradle . /home/gradle/src | ||
WORKDIR /home/gradle/src | ||
RUN gradle build --no-daemon | ||
|
||
FROM eclipse-temurin:17 | ||
|
||
EXPOSE 8080 | ||
|
||
RUN mkdir /app | ||
|
||
COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar | ||
ENTRYPOINT ["java", "-jar","/app/spring-boot-application.jar"] | ||
|
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
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
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
2 changes: 1 addition & 1 deletion
2
...ent/selab2/config/OAuth2ClientConfig.java → ...nt/pidgeon/config/OAuth2ClientConfig.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
2 changes: 1 addition & 1 deletion
2
...va/com/ugent/selab2/config/WebConfig.java → ...a/com/ugent/pidgeon/config/WebConfig.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
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
55 changes: 55 additions & 0 deletions
55
backend/app/src/main/java/com/ugent/pidgeon/controllers/JpaCourseController.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,55 @@ | ||
package com.ugent.pidgeon.controllers; | ||
|
||
import com.ugent.pidgeon.postgre.models.CourseEntity; | ||
import com.ugent.pidgeon.postgre.models.GroupClusterEntity; | ||
import com.ugent.pidgeon.postgre.models.ProjectEntity; | ||
import com.ugent.pidgeon.postgre.models.UserEntity; | ||
import com.ugent.pidgeon.postgre.repository.CourseRepository; | ||
import com.ugent.pidgeon.postgre.repository.GroupClusterRepository; | ||
import com.ugent.pidgeon.postgre.repository.ProjectRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
public class JpaCourseController { | ||
@Autowired | ||
private CourseRepository courseRepository; | ||
|
||
@Autowired | ||
private GroupClusterRepository groupClusterRepository; | ||
|
||
@Autowired | ||
private ProjectRepository projectRepository; | ||
|
||
@GetMapping("/api/courses") | ||
public String getCourses() { | ||
StringBuilder res = new StringBuilder(); | ||
for (CourseEntity course : courseRepository.findAll()) { | ||
res.append(course.getName()).append(" with users: "); | ||
for (CourseRepository.UserWithRelation user : courseRepository.findUsersByCourseId(course.getId())) { | ||
UserEntity userEntity = user.getUser(); | ||
String relation = user.getRelation(); | ||
res.append(userEntity.getName()).append("(").append(relation).append("), "); | ||
} | ||
res.append("- with group clusters:"); | ||
for (GroupClusterEntity groupcluster: groupClusterRepository.findByCourseId(course.getId())) { | ||
res.append(groupcluster.getName()).append(" (").append(groupcluster.getGroupAmount()).append("), "); | ||
} | ||
res.append("- with projects:"); | ||
for (ProjectEntity project: projectRepository.findByCourseId(course.getId())) { | ||
res.append(project.getName()).append(", "); | ||
} | ||
res.append("|\n"); | ||
} | ||
|
||
return res.toString(); | ||
} | ||
|
||
// @GetMapping("/api/course") | ||
// public String addCourse(String name, String description) { | ||
// CourseEntity course = new CourseEntity("test", "added to test creating with contstructing"); | ||
// course.setId(1); | ||
// courseRepository.save(course); | ||
// return "Course added"; | ||
// } | ||
} |
55 changes: 55 additions & 0 deletions
55
backend/app/src/main/java/com/ugent/pidgeon/controllers/JpaGroupController.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,55 @@ | ||
package com.ugent.pidgeon.controllers; | ||
|
||
import com.ugent.pidgeon.postgre.models.GroupEntity; | ||
import com.ugent.pidgeon.postgre.models.GroupFeedbackEntity; | ||
import com.ugent.pidgeon.postgre.models.SubmissionEntity; | ||
import com.ugent.pidgeon.postgre.models.UserEntity; | ||
import com.ugent.pidgeon.postgre.repository.GroupFeedbackRepository; | ||
import com.ugent.pidgeon.postgre.repository.GroupRepository; | ||
import com.ugent.pidgeon.postgre.repository.SubmissionRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RestController | ||
public class JpaGroupController { | ||
|
||
@Autowired | ||
private GroupRepository groupRepository; | ||
|
||
@Autowired | ||
private GroupFeedbackRepository groupFeedbackRepository; | ||
|
||
@Autowired | ||
SubmissionRepository submissionRepository; | ||
|
||
@GetMapping("/api/groups") | ||
public List<String> getGroups() { | ||
List<String> res = new ArrayList<>(); | ||
for (GroupEntity group : groupRepository.findAll()) { | ||
StringBuilder groupString = new StringBuilder(); | ||
groupString.append(group.getName()).append("-with users: "); | ||
for (UserEntity user : groupRepository.findCourseUsersByGroupId(group.getId())) { | ||
groupString.append(user.getName()).append(", "); | ||
} | ||
List<Long> projectIds = groupRepository.findProjectsByGroupId(group.getId()); | ||
groupString.append("-with grades: "); | ||
for (long projectId : projectIds) { | ||
GroupFeedbackEntity feedback = groupFeedbackRepository.findByGroupIdAndProjectId(group.getId(), projectId); | ||
groupString.append(feedback.getGrade()).append(", "); | ||
} | ||
groupString.append("-with submissions: "); | ||
for (long projectId : projectIds) { | ||
for (SubmissionEntity submission : submissionRepository.findByGroupIdAndProjectId(group.getId(), projectId)) { | ||
groupString.append(submission.getSubmissionTime()).append(", "); | ||
} | ||
} | ||
groupString.append("|"); | ||
res.add(groupString.toString()); | ||
} | ||
return res; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
backend/app/src/main/java/com/ugent/pidgeon/controllers/JpaProjectController.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,39 @@ | ||
package com.ugent.pidgeon.controllers; | ||
|
||
import com.ugent.pidgeon.postgre.models.DeadlineEntity; | ||
import com.ugent.pidgeon.postgre.models.ProjectEntity; | ||
import com.ugent.pidgeon.postgre.models.TestEntity; | ||
import com.ugent.pidgeon.postgre.repository.ProjectRepository; | ||
import com.ugent.pidgeon.postgre.repository.TestRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@RestController | ||
public class JpaProjectController { | ||
@Autowired | ||
private ProjectRepository projectRepository; | ||
|
||
@Autowired | ||
private TestRepository testRepository; | ||
|
||
@GetMapping("/api/projects") | ||
public List<String> getProjects() { | ||
List<String> res = new ArrayList<>(); | ||
for (ProjectEntity project : projectRepository.findAll()) { | ||
StringBuilder projectString = new StringBuilder(project.getName()); | ||
Optional<TestEntity> test = testRepository.findById(project.getId()); | ||
test.ifPresent(testEntity -> projectString.append(" with test: ").append(testEntity.getId())); | ||
projectString.append(" with deadlines: "); | ||
for (DeadlineEntity deadline : project.getDeadlines()) { | ||
projectString.append(deadline.getDeadline()); | ||
} | ||
res.add(projectString.toString()); | ||
} | ||
return res; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/app/src/main/java/com/ugent/pidgeon/controllers/JpaSubmissionController.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,38 @@ | ||
package com.ugent.pidgeon.controllers; | ||
|
||
import com.ugent.pidgeon.postgre.models.FileEntity; | ||
import com.ugent.pidgeon.postgre.models.SubmissionEntity; | ||
import com.ugent.pidgeon.postgre.repository.FileRepository; | ||
import com.ugent.pidgeon.postgre.repository.SubmissionRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@RestController | ||
public class JpaSubmissionController { | ||
@Autowired | ||
private SubmissionRepository submissionRepository; | ||
|
||
@Autowired | ||
private FileRepository fileRepository; | ||
|
||
@GetMapping("/api/submissions") | ||
public List<String> getSubmissions() { | ||
List<String> res = new ArrayList<>(); | ||
for (SubmissionEntity submission : submissionRepository.findAll()) { | ||
StringBuilder submissionString = new StringBuilder(); | ||
submissionString.append(submission.getSubmissionTime()).append(" with files: "); | ||
Optional<FileEntity> file = fileRepository.findById(submission.getFileId()); | ||
file.ifPresent(fileEntity -> submissionString.append(fileEntity.getName()).append(", ")); | ||
|
||
submissionString.append("|"); | ||
res.add(submissionString.toString()); | ||
} | ||
return res; | ||
} | ||
|
||
} |
Oops, something went wrong.