Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of M-Elo #1

Merged
merged 14 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Execute tests
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
uses: gradle/gradle-build-action@v3
with:
arguments: cleanTest test jacocoTestReport sonar

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# syntax=docker/dockerfile:experimental
FROM gradle:7.6.2-jdk17 AS build
FROM gradle:8-jdk21 AS build
WORKDIR /workspace/app

COPY . /workspace/app
RUN gradle clean build -x test
RUN mkdir -p build/dependency && (cd build/dependency; jar -xf ../libs/*-SNAPSHOT.jar)

FROM eclipse-temurin:17-jdk
FROM eclipse-temurin:21-jdk
VOLUME /tmp
ARG DEPENDENCY=/workspace/app/build/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","de.unistuttgart.iste.gits.flashcard_service.FlashcardServiceApplication"]
ENTRYPOINT ["java","-cp","app:app/lib/*","de.unistuttgart.iste.meitrex.flashcard_service.FlashcardServiceApplication"]
25 changes: 13 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'
id "io.github.kobylynskyi.graphql.codegen" version "5.7.2"
id "org.sonarqube" version "4.0.0.2929"
id 'org.springframework.boot' version '3.2.+'
id 'io.spring.dependency-management' version '1.+'
id "io.github.kobylynskyi.graphql.codegen" version "5.+"
id "org.sonarqube" version "4.+"
id "jacoco"

}

group = 'de.unistuttgart.iste.gits'
group = 'de.unistuttgart.iste.meitrex'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
sourceCompatibility = '21'

def jacocoEnabled = System.properties.getProperty("jacocoEnabled") ?: "true"

Expand All @@ -21,6 +21,7 @@ if (jacocoEnabled.toBoolean()) {
}

sonarqube {

properties {
property("sonar.projectKey", "MEITREX_flashcard_service")
property("sonar.organization", "meitrex")
Expand All @@ -34,7 +35,7 @@ graphqlCodegen {
// all config options:
// https://github.com/kobylynskyi/graphql-java-codegen/blob/main/docs/codegen-options.md
outputDir = new File("$buildDir/generated")
packageName = "de.unistuttgart.iste.gits.generated.dto"
packageName = "de.unistuttgart.iste.meitrex.generated.dto"
generatedAnnotation = "jakarta.annotation.Generated"
modelValidationAnnotation = "jakarta.validation.constraints.NotNull"
generateApis = false // set to false as the generator does not support spring boot graphQL
Expand Down Expand Up @@ -67,7 +68,7 @@ repositories {
}

dependencies {
implementation 'de.unistuttgart.iste.gits:gits-common:0.6.4'
implementation 'de.unistuttgart.iste.meitrex:meitrex-common:1.1.1'
implementation 'com.google.code.findbugs:jsr305:3.0.2' // removes a gradle warning about an unknown annotation
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-graphql'
Expand All @@ -84,18 +85,18 @@ dependencies {
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'de.unistuttgart.iste.gits:gits-common-test:0.3.2'
testImplementation 'de.unistuttgart.iste.meitrex:meitrex-common-test:1.0.1'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework:spring-webflux'
testImplementation 'org.springframework.graphql:spring-graphql-test'
testImplementation "org.mockito:mockito-core:3.+"
testImplementation 'org.hamcrest:hamcrest:2.+'
testImplementation "org.testcontainers:postgresql:1.18.3"
testImplementation "org.testcontainers:junit-jupiter:1.18.3"
testImplementation "org.testcontainers:postgresql:1.+"
testImplementation "org.testcontainers:junit-jupiter:1.+"
}

tasks.named('test') {
useJUnitPlatform()
}

tasks.withType(Test).configureEach { testLogging.showStandardStreams = true }
tasks.withType(Test).configureEach { testLogging.showStandardStreams = true }
2 changes: 1 addition & 1 deletion components/pubsub.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: gits
name: meitrex
spec:
type: pubsub.redis
version: v1
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jacoco {
toolVersion = "0.8.8"
toolVersion = "0.8.11"
}

test {
Expand All @@ -9,8 +9,8 @@ test {

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
xml.required.set(true)
html.required.set(true)
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
7 changes: 4 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ rootProject.name = 'flashcard_service'

sourceControl {
gitRepository(uri('https://github.com/MEITREX/common')) {
producesModule('de.unistuttgart.iste.gits:gits-common')
producesModule('de.unistuttgart.iste.meitrex:meitrex-common')
}
gitRepository(uri('https://github.com/MEITREX/common_test')) {
producesModule('de.unistuttgart.iste.gits:gits-common-test')
}
producesModule('de.unistuttgart.iste.meitrex:meitrex-common-test')

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service;
package de.unistuttgart.iste.meitrex.flashcard_service;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.unistuttgart.iste.gits.flashcard_service.config;
package de.unistuttgart.iste.meitrex.flashcard_service.config;


import de.unistuttgart.iste.gits.common.dapr.MockTopicPublisher;
import de.unistuttgart.iste.gits.common.dapr.TopicPublisher;
import de.unistuttgart.iste.meitrex.common.dapr.MockTopicPublisher;
import de.unistuttgart.iste.meitrex.common.dapr.TopicPublisher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.config;
package de.unistuttgart.iste.meitrex.flashcard_service.config;

import graphql.scalars.ExtendedScalars;
import graphql.validation.rules.OnValidationErrorStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.config;
package de.unistuttgart.iste.meitrex.flashcard_service.config;

import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.unistuttgart.iste.gits.flashcard_service.config;
package de.unistuttgart.iste.meitrex.flashcard_service.config;

import de.unistuttgart.iste.gits.common.user_handling.RequestHeaderUserProcessor;
import de.unistuttgart.iste.meitrex.common.user_handling.RequestHeaderUserProcessor;
import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.unistuttgart.iste.gits.flashcard_service.config;
package de.unistuttgart.iste.meitrex.flashcard_service.config;


import de.unistuttgart.iste.gits.common.dapr.TopicPublisher;
import de.unistuttgart.iste.meitrex.common.dapr.TopicPublisher;
import io.dapr.client.DaprClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package de.unistuttgart.iste.gits.flashcard_service.controller;

import de.unistuttgart.iste.gits.common.exception.NoAccessToCourseException;
import de.unistuttgart.iste.gits.common.user_handling.LoggedInUser;
import de.unistuttgart.iste.gits.common.user_handling.LoggedInUser.UserRoleInCourse;
import de.unistuttgart.iste.gits.flashcard_service.persistence.entity.FlashcardSetEntity;
import de.unistuttgart.iste.gits.flashcard_service.service.FlashcardService;
import de.unistuttgart.iste.gits.flashcard_service.service.FlashcardUserProgressDataService;
import de.unistuttgart.iste.gits.generated.dto.*;
package de.unistuttgart.iste.meitrex.flashcard_service.controller;

import de.unistuttgart.iste.meitrex.generated.dto.Flashcard;
import de.unistuttgart.iste.meitrex.generated.dto.FlashcardSet;
import de.unistuttgart.iste.meitrex.common.exception.NoAccessToCourseException;
import de.unistuttgart.iste.meitrex.common.user_handling.LoggedInUser;
import de.unistuttgart.iste.meitrex.common.user_handling.LoggedInUser.UserRoleInCourse;
import de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity.FlashcardSetEntity;
import de.unistuttgart.iste.meitrex.flashcard_service.service.FlashcardService;
import de.unistuttgart.iste.meitrex.flashcard_service.service.FlashcardUserProgressDataService;
import de.unistuttgart.iste.meitrex.generated.dto.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.graphql.data.method.annotation.*;
Expand All @@ -15,8 +17,8 @@
import java.util.List;
import java.util.UUID;

import static de.unistuttgart.iste.gits.common.user_handling.UserCourseAccessValidator.validateUserHasAccessToCourse;
import static de.unistuttgart.iste.gits.common.user_handling.UserCourseAccessValidator.validateUserHasAccessToCourses;
import static de.unistuttgart.iste.meitrex.common.user_handling.UserCourseAccessValidator.validateUserHasAccessToCourse;
import static de.unistuttgart.iste.meitrex.common.user_handling.UserCourseAccessValidator.validateUserHasAccessToCourses;


@Slf4j
Expand All @@ -28,7 +30,7 @@ public class FlashcardController {
private final FlashcardUserProgressDataService progressDataService;

@QueryMapping
public List<Flashcard> flashcardsByIds(@Argument(name = "ids") final List<UUID> ids,
public List<Flashcard> flashcardsByIds(@Argument(name = "itemIds") final List<UUID> ids,
@ContextValue final LoggedInUser currentUser) {
final List<UUID> courseIds = flashcardService.getCourseIdsForFlashcardIds(ids);

Expand Down Expand Up @@ -67,7 +69,7 @@ public List<Flashcard> dueFlashcardsByCourseId(@Argument final UUID courseId,
@SchemaMapping(typeName = "Flashcard", field = "userProgressData")
public FlashcardProgressData flashcardUserProgressData(final Flashcard flashcard,
@ContextValue final LoggedInUser currentUser) {
return progressDataService.getProgressData(flashcard.getId(), currentUser.getId());
return progressDataService.getProgressData(flashcard.getItemId(), currentUser.getId());
}

@MutationMapping
Expand All @@ -82,11 +84,16 @@ public FlashcardSetMutation mutateFlashcardSet(@Argument final UUID assessmentId
}

@SchemaMapping(typeName = "FlashcardSetMutation")
public Flashcard createFlashcard(@Argument(name = "input") final CreateFlashcardInput input,
public Flashcard _internal_noauth_createFlashcard(@Argument(name = "input") final CreateFlashcardInput input,
final FlashcardSetMutation mutation) {
return flashcardService.createFlashcard(mutation.getAssessmentId(), input);
}

@SchemaMapping(typeName = "FlashcardSetMutation")
public Flashcard _internal_noauth_updateFlashcard(@Argument(name = "input") final UpdateFlashcardInput input) {
return flashcardService.updateFlashcard(input);
}

@SchemaMapping(typeName = "FlashcardSetMutation")
public Flashcard updateFlashcard(@Argument(name = "input") final UpdateFlashcardInput input) {
return flashcardService.updateFlashcard(input);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.unistuttgart.iste.gits.flashcard_service.controller;
package de.unistuttgart.iste.meitrex.flashcard_service.controller;

import de.unistuttgart.iste.gits.common.event.ContentChangeEvent;
import de.unistuttgart.iste.gits.flashcard_service.service.FlashcardService;
import de.unistuttgart.iste.meitrex.common.event.ContentChangeEvent;
import de.unistuttgart.iste.meitrex.flashcard_service.service.FlashcardService;
import io.dapr.Topic;
import io.dapr.client.domain.CloudEvent;
import lombok.RequiredArgsConstructor;
Expand All @@ -19,7 +19,7 @@ public class SubscriptionController {

private final FlashcardService flashcardService;

@Topic(name = "content-changed", pubsubName = "gits")
@Topic(name = "content-changed", pubsubName = "meitrex")
@PostMapping(path = "/flashcard-service/content-changed-pubsub")
public Mono<Void> updateAssociation(@RequestBody CloudEvent<ContentChangeEvent> cloudEvent) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.unistuttgart.iste.gits.flashcard_service.exception;
package de.unistuttgart.iste.meitrex.flashcard_service.exception;

import de.unistuttgart.iste.gits.common.exception.ExceptionToGraphQlErrorConverter;
import de.unistuttgart.iste.meitrex.common.exception.ExceptionToGraphQlErrorConverter;
import graphql.GraphQLError;
import graphql.schema.DataFetchingEnvironment;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.persistence.entity;
package de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;
Expand All @@ -14,8 +14,7 @@
public class FlashcardEntity {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
private UUID itemId;

@OneToMany(mappedBy = "flashcard", cascade = CascadeType.ALL, orphanRemoval = true)
private List<FlashcardSideEntity> sides;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.persistence.entity;
package de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;
Expand All @@ -11,6 +11,7 @@
@Entity(name = "FlashcardProgressData")
@Data
@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class FlashcardProgressDataEntity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.persistence.entity;
package de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;
Expand All @@ -8,6 +8,9 @@

@Entity(name = "FlashcardProgressDataLog")
@Data
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class FlashcardProgressDataLogEntity {
Expand All @@ -30,4 +33,8 @@ public class FlashcardProgressDataLogEntity {
@EqualsAndHashCode.Exclude
@ToString.Exclude
private FlashcardProgressDataEntity flashcardProgressData;

public boolean getSuccess() {
return success;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.unistuttgart.iste.gits.flashcard_service.persistence.entity;
package de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity;

import de.unistuttgart.iste.gits.common.persistence.IWithId;
import de.unistuttgart.iste.meitrex.common.persistence.IWithId;
import jakarta.persistence.*;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.unistuttgart.iste.gits.flashcard_service.persistence.entity;
package de.unistuttgart.iste.meitrex.flashcard_service.persistence.entity;

import jakarta.persistence.*;
import lombok.*;
Expand Down
Loading
Loading