Skip to content

Commit

Permalink
Fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
usserwoutV2 committed Mar 3, 2024
2 parents 6494cc5 + ae80829 commit a83a299
Show file tree
Hide file tree
Showing 40 changed files with 1,309 additions and 21 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
14 changes: 14 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: running test with github actions
on: pull_request

jobs:
test:
runs-on: ubuntu-latest
name: run unit tests on java 17
steps:
- uses: actions/checkout@master
- name: setup java
uses: actions/setup-java@v1
with:
java-version: 17
- run: gradle test -p backend/app/
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# UGent-6


WIP (ik ga korte uitleg schrijven hoe je dit lokaal kan opzetten)
# dependencies
docker compose
https://github.com/SELab-2/UGent-6/wiki
12 changes: 10 additions & 2 deletions backend/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
Expand Down Expand Up @@ -32,11 +32,19 @@ dependencies {
implementation 'com.auth0:java-jwt:3.18.2'
implementation 'com.auth0:jwks-rsa:0.18.0'
implementation 'javax.servlet:javax.servlet-api:4.0.1'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'org.postgresql:postgresql'

implementation "org.springframework.boot:spring-boot-devtools"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}

tasks.named('test') {
tasks.named('test',Test) {
useJUnitPlatform()
maxHeapSize = '1G'

testLogging {
events "passed"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public FilterRegistrationBean<JwtAuthenticationFilter> filterRegistrationBean()

FilterRegistrationBean<JwtAuthenticationFilter> filter = new FilterRegistrationBean<>();
filter.setFilter(new JwtAuthenticationFilter(tenantId));
filter.addUrlPatterns("/api/*");
filter.addUrlPatterns("/api/ietswatiknietwiltesten");
return filter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest request,
//logger.info(jwt.getClaims());


User user = new User(displayName,firstName,lastName, email, groups, oid);
User user = new User(displayName, firstName,lastName, email, groups, oid);

Auth authUser = new Auth(user, new ArrayList<>());
SecurityContextHolder.getContext().setAuthentication(authUser);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.ugent.pidgeon.controllers;
import com.ugent.pidgeon.model.Auth;
import com.ugent.pidgeon.model.User;
import com.ugent.pidgeon.postgre.repository.UserRepository;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthTestController {
@Autowired
private UserRepository userRepository;

@GetMapping("/api/test")
public User testApi(HttpServletRequest request, Auth auth) {
Expand Down
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";
// }
}
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;
}
}
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;
}
}
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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ugent.pidgeon.controllers;

import com.ugent.pidgeon.postgre.models.CourseEntity;
import com.ugent.pidgeon.postgre.models.types.CourseRelation;
import com.ugent.pidgeon.postgre.models.UserEntity;
import com.ugent.pidgeon.postgre.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JpaUserController {
@Autowired
private UserRepository userRepository;

Logger logger = LoggerFactory.getLogger(JpaUserController.class);
@GetMapping("/api/users")
public String getUsers() {
StringBuilder res = new StringBuilder();
for (UserEntity user : userRepository.findAll()) {
res.append(user.getName()).append("(").append(user.getRole().toString()).append(") in courses: ");
for (UserRepository.CourseWithRelation course : userRepository.findCoursesByUserId(user.getId())) {
CourseEntity courseEntity = course.getCourse();
CourseRelation courseRelation = course.getRelation();
res.append(courseEntity.getName()).append("(").append(courseRelation.toString()).append("), ");
}
res.append("\n");
}

return res.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.util.Assert;

import java.util.Collection;

import com.ugent.pidgeon.model.User;
public class Auth extends AbstractAuthenticationToken {
private static final long serialVersionUID = 620L;

Expand Down
Loading

0 comments on commit a83a299

Please sign in to comment.