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

Development: Ensure correct @Repository annotation usage #9610

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package de.tum.cit.aet.artemis.assessment.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;
import java.util.Optional;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.assessment.domain.LongFeedbackText;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;

@Profile(PROFILE_CORE)
@Repository
public interface LongFeedbackTextRepository extends ArtemisJpaRepository<LongFeedbackText, Long> {

@Query("""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package de.tum.cit.aet.artemis.atlas.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Profile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.atlas.domain.LearningObject;
import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency;
Expand All @@ -21,6 +25,8 @@
/**
* Spring Data JPA repository for the {@link CourseCompetency} entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface CourseCompetencyRepository extends ArtemisJpaRepository<CourseCompetency, Long> {

@Query("""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package de.tum.cit.aet.artemis.atlas.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite;
import de.tum.cit.aet.artemis.core.domain.Course;
Expand All @@ -14,10 +18,10 @@
/**
* Spring Data JPA repository for the {@link Prerequisite} entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface PrerequisiteRepository extends ArtemisJpaRepository<Prerequisite, Long> {

List<Prerequisite> findAllByCourseIdOrderById(long courseId);

@Query("""
SELECT p
FROM Prerequisite p
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package de.tum.cit.aet.artemis.communication.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import org.springframework.context.annotation.Profile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.communication.domain.Post;

@Profile(PROFILE_CORE)
@Repository
public interface CustomPostRepository {

Page<Long> findPostIdsWithSpecification(Specification<Post> specification, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package de.tum.cit.aet.artemis.core.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.domain.Authority;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;

/**
* Spring Data JPA repository for the Authority entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface AuthorityRepository extends ArtemisJpaRepository<Authority, String> {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package de.tum.cit.aet.artemis.core.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.domain.MigrationChangelog;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;

@Profile(PROFILE_CORE)
@Repository
public interface MigrationChangeRepository extends ArtemisJpaRepository<MigrationChangelog, String> {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.tum.cit.aet.artemis.core.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;
import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD;

import java.time.Instant;
Expand All @@ -9,19 +10,23 @@

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.domain.PersistentAuditEvent;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;

/**
* Spring Data JPA repository for the PersistentAuditEvent entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface PersistenceAuditEventRepository extends ArtemisJpaRepository<PersistentAuditEvent, Long> {

@EntityGraph(type = LOAD, attributePaths = { "data" })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package de.tum.cit.aet.artemis.iris.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS;
import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD;

import java.util.Collections;
import java.util.List;

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.domain.DomainObject;
import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
Expand All @@ -21,6 +24,8 @@
* Repository interface for managing {@link IrisTextExerciseChatSession} entities.
* Provides custom queries for finding text exercise chat sessions based on different criteria.
*/
@Profile(PROFILE_IRIS)
@Repository
public interface IrisTextExerciseChatSessionRepository extends ArtemisJpaRepository<IrisTextExerciseChatSession, Long> {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package de.tum.cit.aet.artemis.programming.repository;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;
import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD;

import java.util.Optional;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.domain.build.BuildPlan;

@Profile(PROFILE_CORE)
@Repository
public interface BuildPlanRepository extends ArtemisJpaRepository<BuildPlan, Long> {

@Query("""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package de.tum.cit.aet.artemis.programming.repository.hestia;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.Optional;
import java.util.Set;

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
Expand All @@ -15,6 +19,8 @@
/**
* Spring Data repository for the CodeHint entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface CodeHintRepository extends ArtemisJpaRepository<CodeHint, Long> {

Set<CodeHint> findByExerciseId(Long exerciseId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package de.tum.cit.aet.artemis.programming.repository.hestia;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.Optional;
import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
import de.tum.cit.aet.artemis.programming.domain.hestia.ExerciseHintActivation;

@Profile(PROFILE_CORE)
@Repository
public interface ExerciseHintActivationRepository extends ArtemisJpaRepository<ExerciseHintActivation, Long> {

@Query("""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package de.tum.cit.aet.artemis.programming.repository.hestia;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.Optional;
import java.util.Set;

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
Expand All @@ -15,6 +19,8 @@
/**
* Spring Data repository for the ProgrammingExerciseSolutionEntry entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface ProgrammingExerciseSolutionEntryRepository extends ArtemisJpaRepository<ProgrammingExerciseSolutionEntry, Long> {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package de.tum.cit.aet.artemis.programming.repository.hestia;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;
import java.util.Optional;
import java.util.Set;

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
Expand All @@ -16,37 +20,10 @@
/**
* Spring Data repository for the ProgrammingExerciseTask entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface ProgrammingExerciseTaskRepository extends ArtemisJpaRepository<ProgrammingExerciseTask, Long> {

JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
Set<ProgrammingExerciseTask> findByExerciseId(Long exerciseId);

/**
* Gets a task with its programming exercise, test cases and solution entries of the test cases
*
* @param entryId The id of the task
* @return The task with the given ID if found
* @throws EntityNotFoundException If no task with the given ID was found
*/
@NotNull
default ProgrammingExerciseTask findByIdWithTestCaseAndSolutionEntriesElseThrow(long entryId) throws EntityNotFoundException {
return getValueElseThrow(findByIdWithTestCaseAndSolutionEntries(entryId), entryId);
}

/**
* Gets a task with its programming exercise, test cases and solution entries of the test cases
*
* @param entryId The id of the task
* @return The task with the given ID
*/
@Query("""
SELECT t
FROM ProgrammingExerciseTask t
LEFT JOIN FETCH t.testCases tc
LEFT JOIN FETCH tc.solutionEntries
WHERE t.id = :entryId
""")
Optional<ProgrammingExerciseTask> findByIdWithTestCaseAndSolutionEntries(@Param("entryId") long entryId);

/**
* Gets all tasks with its test cases and solution entries of the test case for a programming exercise
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository;
import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository;
import de.tum.cit.aet.artemis.atlas.repository.KnowledgeAreaRepository;
import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository;
import de.tum.cit.aet.artemis.atlas.repository.ScienceSettingRepository;
import de.tum.cit.aet.artemis.atlas.repository.SourceRepository;
import de.tum.cit.aet.artemis.atlas.repository.StandardizedCompetencyRepository;
import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService;
import de.tum.cit.aet.artemis.atlas.test_repository.CompetencyProgressTestRepository;
import de.tum.cit.aet.artemis.atlas.test_repository.LearningPathTestRepository;
import de.tum.cit.aet.artemis.atlas.test_repository.PrerequisiteTestRepository;
import de.tum.cit.aet.artemis.atlas.test_repository.ScienceEventTestRepository;
import de.tum.cit.aet.artemis.core.service.feature.FeatureToggleService;
import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService;
Expand Down Expand Up @@ -74,7 +74,7 @@ public abstract class AbstractAtlasIntegrationTest extends AbstractSpringIntegra
protected ScienceEventTestRepository scienceEventRepository;

@Autowired
protected PrerequisiteRepository prerequisiteRepository;
protected PrerequisiteTestRepository prerequisiteRepository;

@Autowired
protected CompetencyJolRepository competencyJolRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.stereotype.Service;

import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite;
import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository;
import de.tum.cit.aet.artemis.atlas.test_repository.PrerequisiteTestRepository;
import de.tum.cit.aet.artemis.core.domain.Course;

/**
Expand All @@ -17,7 +17,7 @@
public class PrerequisiteUtilService {

@Autowired
private PrerequisiteRepository prerequisiteRepository;
private PrerequisiteTestRepository prerequisiteRepository;

JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
/**
* Creates and saves a Prerequisite competency for the given Course.
Expand Down
Loading
Loading