Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
Browse files Browse the repository at this point in the history
…cle/add-filter-search-finished-buildjobs

# Conflicts:
#	src/main/java/de/tum/in/www1/artemis/repository/BuildJobRepository.java
  • Loading branch information
BBesrour committed Jun 21, 2024
2 parents 6f8cfbc + c63f448 commit efe7a0e
Show file tree
Hide file tree
Showing 151 changed files with 477 additions and 709 deletions.
2 changes: 1 addition & 1 deletion docs/dev/guidelines/criteria-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ In order to use Criteria Builder and benefit from Specifications, we need to adj
.. code-block:: java
@Repository
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
public interface UserRepository extends ArtemisJpaRepository<User, Long>, JpaSpecificationExecutor<User> {
}
3. **(Optional) Show queries:** To ease debugging, generated queries can be displayed by enabling the output of executed SQL probes.
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/guidelines/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ An example for a simple method is finding a single entity by ID:

.. code-block:: java
default StudentExam findByIdElseThrow(Long studentExamId) throws EntityNotFoundException {
return findById(studentExamId).orElseThrow(() -> new EntityNotFoundException("Student Exam", studentExamId));
default Course findByIdWithLecturesElseThrow(long courseId) {
return getValueElseThrow(findWithEagerLecturesById(courseId), courseId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import de.tum.in.www1.artemis.repository.base.RepositoryImpl;

@Profile(PROFILE_CORE)
@Configuration
@EnableJpaRepositories(basePackages = "de.tum.in.www1.artemis.repository")
@EnableJpaRepositories(basePackages = "de.tum.in.www1.artemis.repository", repositoryBaseClass = RepositoryImpl.class)
@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware")
@EnableTransactionManagement
public class DatabaseConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

import java.util.List;

import jakarta.validation.constraints.NotNull;

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

import de.tum.in.www1.artemis.domain.modeling.ApollonDiagram;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

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

List<ApollonDiagram> findDiagramsByCourseId(Long courseId);

Expand All @@ -38,9 +35,4 @@ public interface ApollonDiagramRepository extends JpaRepository<ApollonDiagram,
""")
@Cacheable(cacheNames = "diagramTitle", key = "#diagramId", unless = "#result == null")
String getDiagramTitle(@Param("diagramId") Long diagramId);

@NotNull
default ApollonDiagram findByIdElseThrow(Long apollonDiagramId) throws EntityNotFoundException {
return findById(apollonDiagramId).orElseThrow(() -> new EntityNotFoundException("ApollonDiagram", apollonDiagramId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import java.util.List;

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

import de.tum.in.www1.artemis.domain.Attachment;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;

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

@Query("""
SELECT a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
import jakarta.validation.constraints.NotNull;

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

import de.tum.in.www1.artemis.domain.enumeration.AttachmentType;
import de.tum.in.www1.artemis.domain.lecture.AttachmentUnit;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;

/**
* Spring Data JPA repository for the Attachment Unit entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface AttachmentUnitRepository extends JpaRepository<AttachmentUnit, Long> {
public interface AttachmentUnitRepository extends ArtemisJpaRepository<AttachmentUnit, Long> {

@Query("""
SELECT lectureUnit
Expand Down Expand Up @@ -61,10 +61,4 @@ default List<AttachmentUnit> findAllByLectureIdAndAttachmentTypeElseThrow(Long l
WHERE attachmentUnit.id = :attachmentUnitId
""")
AttachmentUnit findOneWithSlides(@Param("attachmentUnitId") long attachmentUnitId);

@NotNull
default AttachmentUnit findByIdElseThrow(Long attachmentUnitId) throws EntityNotFoundException {
return findById(attachmentUnitId).orElseThrow(() -> new EntityNotFoundException("AttachmentUnit", attachmentUnitId));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import de.tum.in.www1.artemis.domain.Authority;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

/**
* Spring Data JPA repository for the Authority entity.
*/
public interface AuthorityRepository extends JpaRepository<Authority, String> {
public interface AuthorityRepository extends ArtemisJpaRepository<Authority, String> {

/**
* @return an unmodifiable list of all the authorities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import java.util.List;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import de.tum.in.www1.artemis.domain.AuxiliaryRepository;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

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

List<AuxiliaryRepository> findByExerciseId(Long exerciseId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@
import java.util.Set;

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

import de.tum.in.www1.artemis.domain.Bonus;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

/**
* Spring Data JPA repository for the Bonus entity
*/
@Profile(PROFILE_CORE)
@Repository
public interface BonusRepository extends JpaRepository<Bonus, Long> {

default Bonus findByIdElseThrow(long bonusId) throws EntityNotFoundException {
return findById(bonusId).orElseThrow(() -> new EntityNotFoundException("Bonus", bonusId));
}
public interface BonusRepository extends ArtemisJpaRepository<Bonus, Long> {

@Query("""
SELECT gs.bonusFrom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -21,12 +20,13 @@
import de.tum.in.www1.artemis.domain.BuildJob;
import de.tum.in.www1.artemis.domain.Result;
import de.tum.in.www1.artemis.domain.enumeration.BuildStatus;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.service.connectors.localci.dto.DockerImageBuild;
import de.tum.in.www1.artemis.service.connectors.localci.dto.ResultBuildJob;

@Profile(PROFILE_CORE)
@Repository
public interface BuildJobRepository extends JpaRepository<BuildJob, Long>, JpaSpecificationExecutor<BuildJob> {
public interface BuildJobRepository extends ArtemisJpaRepository<BuildJob, Long>, JpaSpecificationExecutor<BuildJob> {

Optional<BuildJob> findFirstByParticipationIdOrderByBuildStartDateDesc(Long participationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import static de.tum.in.www1.artemis.config.Constants.PROFILE_CORE;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import de.tum.in.www1.artemis.domain.BuildLogEntry;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

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

@Transactional // ok because of delete
@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static de.tum.in.www1.artemis.domain.statistics.BuildLogStatisticsEntry.BuildJobPartDuration;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -14,14 +13,15 @@
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.ProgrammingSubmission;
import de.tum.in.www1.artemis.domain.statistics.BuildLogStatisticsEntry;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.dto.BuildLogStatisticsDTO;

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

@Query("""
SELECT new de.tum.in.www1.artemis.web.rest.dto.BuildLogStatisticsDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import java.util.Optional;

import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import de.tum.in.www1.artemis.domain.BuildPlan;
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;

public interface BuildPlanRepository extends JpaRepository<BuildPlan, Long> {
public interface BuildPlanRepository extends ArtemisJpaRepository<BuildPlan, Long> {

@Query("""
SELECT buildPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -17,11 +16,12 @@

import de.tum.in.www1.artemis.domain.competency.Competency;
import de.tum.in.www1.artemis.domain.competency.CompetencyProgress;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;

@Profile(PROFILE_CORE)
@Repository
public interface CompetencyProgressRepository extends JpaRepository<CompetencyProgress, Long> {
public interface CompetencyProgressRepository extends ArtemisJpaRepository<CompetencyProgress, Long> {

@Transactional // ok because of delete
@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -14,13 +13,14 @@

import de.tum.in.www1.artemis.domain.competency.CompetencyRelation;
import de.tum.in.www1.artemis.domain.competency.RelationType;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

/**
* Spring Data JPA repository for the Competency Relation entity.
*/
@Profile(PROFILE_CORE)
@Repository
public interface CompetencyRelationRepository extends JpaRepository<CompetencyRelation, Long> {
public interface CompetencyRelationRepository extends ArtemisJpaRepository<CompetencyRelation, Long> {

@Transactional // ok because of delete
@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
import org.springframework.context.annotation.Profile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.in.www1.artemis.domain.Course;
import de.tum.in.www1.artemis.domain.competency.Competency;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;

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

@Query("""
SELECT c
Expand Down Expand Up @@ -199,10 +199,6 @@ default Competency findByIdWithConsecutiveCoursesElseThrow(long competencyId) {
return findByIdWithConsecutiveCourses(competencyId).orElseThrow(() -> new EntityNotFoundException("Competency", competencyId));
}

default Competency findByIdElseThrow(long competencyId) {
return findById(competencyId).orElseThrow(() -> new EntityNotFoundException("Competency", competencyId));
}

default Competency findWithLectureUnitsAndExercisesByIdElseThrow(long competencyId) {
return findWithLectureUnitsAndExercisesById(competencyId).orElseThrow(() -> new EntityNotFoundException("Competency", competencyId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -23,14 +22,14 @@
import de.tum.in.www1.artemis.domain.leaderboard.tutor.TutorLeaderboardComplaintResponses;
import de.tum.in.www1.artemis.domain.leaderboard.tutor.TutorLeaderboardComplaints;
import de.tum.in.www1.artemis.domain.leaderboard.tutor.TutorLeaderboardMoreFeedbackRequests;
import de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException;
import de.tum.in.www1.artemis.repository.base.ArtemisJpaRepository;

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

@Query("""
SELECT c
Expand Down Expand Up @@ -522,7 +521,7 @@ SELECT COUNT(c)
""")
List<TutorLeaderboardAnsweredMoreFeedbackRequests> findTutorLeaderboardAnsweredMoreFeedbackRequestsByExerciseId(@Param("exerciseId") long exerciseId);

default Complaint findByIdElseThrow(Long complaintId) {
return findByIdWithEagerAssessor(complaintId).orElseThrow(() -> new EntityNotFoundException("Complaint", complaintId));
default Complaint findWithEagerAssessorByIdElseThrow(Long complaintId) {
return getValueElseThrow(findByIdWithEagerAssessor(complaintId), complaintId);
}
}
Loading

0 comments on commit efe7a0e

Please sign in to comment.