Reformat with 120 line length

This commit is contained in:
Andreas Svanberg 2024-12-02 10:58:48 +01:00
parent f3d0940c88
commit b599ab9a94
976 changed files with 4203 additions and 15172 deletions
core/src/main/java/se/su/dsv/scipro
CoreConfig.javaDataInitializer.javaRepositoryConfiguration.java
activityplan
checklist
daisyExternal/http
data/facade
file
finalseminar
finalthesis
firstmeeting
forum
gdpr
generalsystemsettings
grading
group
integration
mail
match

@ -212,9 +212,7 @@ public class CoreConfig {
} }
@Bean @Bean
public GradingHistory gradingHistory( public GradingHistory gradingHistory(GradingHistoryEventRepository gradingHistoryEventRepository) {
GradingHistoryEventRepository gradingHistoryEventRepository
) {
return new GradingHistory(gradingHistoryEventRepository); return new GradingHistory(gradingHistoryEventRepository);
} }
@ -324,32 +322,22 @@ public class CoreConfig {
} }
@Bean @Bean
public ApplicationPeriodProjectTypeServiceImpl applicationPeriodProjectTypeService( public ApplicationPeriodProjectTypeServiceImpl applicationPeriodProjectTypeService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ApplicationPeriodProjectTypeServiceImpl(em); return new ApplicationPeriodProjectTypeServiceImpl(em);
} }
@Bean @Bean
public ApplicationPeriodServiceImpl applicationPeriodService( public ApplicationPeriodServiceImpl applicationPeriodService(Provider<EntityManager> em, Clock clock) {
Provider<EntityManager> em,
Clock clock
) {
return new ApplicationPeriodServiceImpl(em, clock); return new ApplicationPeriodServiceImpl(em, clock);
} }
@Bean @Bean
public AuthenticationServiceImpl authenticationService( public AuthenticationServiceImpl authenticationService(Set<AuthenticationProvider> authenticationProviders) {
Set<AuthenticationProvider> authenticationProviders
) {
return new AuthenticationServiceImpl(authenticationProviders); return new AuthenticationServiceImpl(authenticationProviders);
} }
@Bean @Bean
public LocalAuthentication localAuthentication( public LocalAuthentication localAuthentication(UserService userService, PasswordService passwordService) {
UserService userService,
PasswordService passwordService
) {
return new LocalAuthentication(userService, passwordService); return new LocalAuthentication(userService, passwordService);
} }
@ -430,12 +418,7 @@ public class CoreConfig {
FileReferenceRepository fileReferenceRepository, FileReferenceRepository fileReferenceRepository,
FileDescriptionRepo fileDescriptionRepository FileDescriptionRepo fileDescriptionRepository
) { ) {
return new FileServiceImpl( return new FileServiceImpl(em, fileReferenceRepository, fileDescriptionRepository, fileStore);
em,
fileReferenceRepository,
fileDescriptionRepository,
fileStore
);
} }
@Bean @Bean
@ -446,16 +429,12 @@ public class CoreConfig {
} }
@Bean @Bean
public FinalSeminarOppositionServiceImpl finalSeminarOppositionService( public FinalSeminarOppositionServiceImpl finalSeminarOppositionService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new FinalSeminarOppositionServiceImpl(em); return new FinalSeminarOppositionServiceImpl(em);
} }
@Bean @Bean
public FinalSeminarRespondentServiceImpl finalSeminarRespondentService( public FinalSeminarRespondentServiceImpl finalSeminarRespondentService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new FinalSeminarRespondentServiceImpl(em); return new FinalSeminarRespondentServiceImpl(em);
} }
@ -545,16 +524,12 @@ public class CoreConfig {
} }
@Bean @Bean
public GeneralSystemSettingsServiceImpl generalSystemSettingsService( public GeneralSystemSettingsServiceImpl generalSystemSettingsService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new GeneralSystemSettingsServiceImpl(em); return new GeneralSystemSettingsServiceImpl(em);
} }
@Bean @Bean
public GradeCalculatorServiceImpl gradeCalculatorService( public GradeCalculatorServiceImpl gradeCalculatorService(GradingReportService gradingReportService) {
GradingReportService gradingReportService
) {
return new GradeCalculatorServiceImpl(gradingReportService); return new GradeCalculatorServiceImpl(gradingReportService);
} }
@ -649,9 +624,7 @@ public class CoreConfig {
} }
@Bean @Bean
public MilestonePhaseTemplateServiceImpl milestonePhaseTemplateService( public MilestonePhaseTemplateServiceImpl milestonePhaseTemplateService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new MilestonePhaseTemplateServiceImpl(em); return new MilestonePhaseTemplateServiceImpl(em);
} }
@ -754,18 +727,11 @@ public class CoreConfig {
PlagiarismRequestRepository plagiarismRequestRepository, PlagiarismRequestRepository plagiarismRequestRepository,
UrkundSubmissionRepository urkundSubmissionRepository UrkundSubmissionRepository urkundSubmissionRepository
) { ) {
return new PlagiarismControlImpl( return new PlagiarismControlImpl(plagiarismRequestRepository, urkundSubmissionRepository, fileService);
plagiarismRequestRepository,
urkundSubmissionRepository,
fileService
);
} }
@Bean @Bean
public PreliminaryMatchServiceImpl preliminaryMatchService( public PreliminaryMatchServiceImpl preliminaryMatchService(Provider<EntityManager> em, IdeaService ideaService) {
Provider<EntityManager> em,
IdeaService ideaService
) {
return new PreliminaryMatchServiceImpl(em, ideaService); return new PreliminaryMatchServiceImpl(em, ideaService);
} }
@ -783,9 +749,7 @@ public class CoreConfig {
} }
@Bean @Bean
public ProjectFinalSeminarStatisticsServiceImpl projectFinalSeminarStatisticsService( public ProjectFinalSeminarStatisticsServiceImpl projectFinalSeminarStatisticsService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ProjectFinalSeminarStatisticsServiceImpl(em); return new ProjectFinalSeminarStatisticsServiceImpl(em);
} }
@ -812,9 +776,7 @@ public class CoreConfig {
} }
@Bean @Bean
public ProjectPeopleStatisticsServiceImpl projectPeopleStatisticsService( public ProjectPeopleStatisticsServiceImpl projectPeopleStatisticsService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ProjectPeopleStatisticsServiceImpl(em); return new ProjectPeopleStatisticsServiceImpl(em);
} }
@ -850,16 +812,12 @@ public class CoreConfig {
} }
@Bean @Bean
public ReceiverConfigurationServiceImpl receiverConfigurationService( public ReceiverConfigurationServiceImpl receiverConfigurationService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ReceiverConfigurationServiceImpl(em); return new ReceiverConfigurationServiceImpl(em);
} }
@Bean @Bean
public ReviewerDeadlineFollowupServiceImpl reviewerDeadlineFollowupService( public ReviewerDeadlineFollowupServiceImpl reviewerDeadlineFollowupService(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ReviewerDeadlineFollowupServiceImpl(em); return new ReviewerDeadlineFollowupServiceImpl(em);
} }
@ -981,10 +939,7 @@ public class CoreConfig {
} }
@Bean @Bean
public UrkundApiImpl urkundApi( public UrkundApiImpl urkundApi(UrkundSettingsRepository urkundSettingsRepository, FileService fileService) {
UrkundSettingsRepository urkundSettingsRepository,
FileService fileService
) {
return new UrkundApiImpl(urkundSettingsRepository, fileService); return new UrkundApiImpl(urkundSettingsRepository, fileService);
} }
@ -1072,11 +1027,7 @@ public class CoreConfig {
ActivityFinalSeminarRepository activityFinalSeminarRepository, ActivityFinalSeminarRepository activityFinalSeminarRepository,
EventBus eventBus EventBus eventBus
) { ) {
return new FinalSeminarActivityHandler( return new FinalSeminarActivityHandler(activityPlanFacade, activityFinalSeminarRepository, eventBus);
activityPlanFacade,
activityFinalSeminarRepository,
eventBus
);
} }
@Bean @Bean
@ -1085,11 +1036,7 @@ public class CoreConfig {
ProjectForumService projectForumService, ProjectForumService projectForumService,
ActivityThreadRepository activityThreadRepository ActivityThreadRepository activityThreadRepository
) { ) {
return new PostActivityUploadToForum( return new PostActivityUploadToForum(projectForumService, activityThreadRepository, eventBus);
projectForumService,
activityThreadRepository,
eventBus
);
} }
@Bean @Bean
@ -1140,10 +1087,7 @@ public class CoreConfig {
} }
@Bean @Bean
public ProjectStartNotifier projectStartNotifier( public ProjectStartNotifier projectStartNotifier(EventBus eventBus, NotificationController notificationController) {
EventBus eventBus,
NotificationController notificationController
) {
return new ProjectStartNotifier(eventBus, notificationController); return new ProjectStartNotifier(eventBus, notificationController);
} }
@ -1165,9 +1109,7 @@ public class CoreConfig {
} }
@Bean @Bean
public CommentThreadServiceImpl commentThreadService( public CommentThreadServiceImpl commentThreadService(CommentThreadRepo commentThreadRepository) {
CommentThreadRepo commentThreadRepository
) {
return new CommentThreadServiceImpl(commentThreadRepository); return new CommentThreadServiceImpl(commentThreadRepository);
} }

@ -104,13 +104,9 @@ public class DataInitializer implements Lifecycle {
private void createApplicationPeriodIfNotDone() { private void createApplicationPeriodIfNotDone() {
ApplicationPeriod applicationPeriod = new ApplicationPeriod("HT 2014"); ApplicationPeriod applicationPeriod = new ApplicationPeriod("HT 2014");
applicationPeriod.setStartDate( applicationPeriod.setStartDate(LocalDate.now().minusDays(APPLICATION_PERIOD_START_MINUS_DAYS));
LocalDate.now().minusDays(APPLICATION_PERIOD_START_MINUS_DAYS)
);
applicationPeriod.setEndDate(LocalDate.now().plusDays(APPLICATION_PERIOD_END_PLUS_DAYS)); applicationPeriod.setEndDate(LocalDate.now().plusDays(APPLICATION_PERIOD_END_PLUS_DAYS));
applicationPeriod.setCourseStartDate( applicationPeriod.setCourseStartDate(LocalDate.now().plusDays(APPLICATION_PERIOD_COURSE_START_PLUS_DAYS));
LocalDate.now().plusDays(APPLICATION_PERIOD_COURSE_START_PLUS_DAYS)
);
applicationPeriod.setCourseStartTime(LocalTime.of(8, 0)); applicationPeriod.setCourseStartTime(LocalTime.of(8, 0));
applicationPeriod = save(applicationPeriod); applicationPeriod = save(applicationPeriod);
applicationPeriod.setProjectTypes(new HashSet<>(Collections.singletonList(bachelorClass))); applicationPeriod.setProjectTypes(new HashSet<>(Collections.singletonList(bachelorClass)));
@ -153,13 +149,7 @@ public class DataInitializer implements Lifecycle {
createProject(PROJECT_2, eve_employee, sid_student, simon_student, eric_employee); createProject(PROJECT_2, eve_employee, sid_student, simon_student, eric_employee);
} }
private void createProject( private void createProject(String title, User headSupervisor, User student1, User student2, User reviewer) {
String title,
User headSupervisor,
User student1,
User student2,
User reviewer
) {
Project project = Project.builder() Project project = Project.builder()
.title(title) .title(title)
.projectType(bachelorClass) .projectType(bachelorClass)
@ -205,13 +195,7 @@ public class DataInitializer implements Lifecycle {
} }
private User createUser(String firstName, String lastName) { private User createUser(String firstName, String lastName) {
User user = save( User user = save(User.builder().firstName(firstName).lastName(lastName).emailAddress(firstName + MAIL).build());
User.builder()
.firstName(firstName)
.lastName(lastName)
.emailAddress(firstName + MAIL)
.build()
);
addUserName(user); addUserName(user);
user = addPassword(user); user = addPassword(user);
return user; return user;
@ -296,9 +280,7 @@ public class DataInitializer implements Lifecycle {
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
new GradingCriterionPointTemplate.Builder() new GradingCriterionPointTemplate.Builder()
.point(1) .point(1)
.description( .description("För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem.")
"För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem."
)
.descriptionEn( .descriptionEn(
"Requirement for 1 point: that the thesis introduces the subject and problem of the thesis." "Requirement for 1 point: that the thesis introduces the subject and problem of the thesis."
) )
@ -323,12 +305,7 @@ public class DataInitializer implements Lifecycle {
) )
.build() .build()
); );
gradingReportTemplate.addProjectCriterion( gradingReportTemplate.addProjectCriterion("U3 Problem", "U3 Problem", 1, gradingCriterionPointTemplates);
"U3 Problem",
"U3 Problem",
1,
gradingCriterionPointTemplates
);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
@ -473,12 +450,7 @@ public class DataInitializer implements Lifecycle {
) )
.build() .build()
); );
gradingReportTemplate.addProjectCriterion( gradingReportTemplate.addProjectCriterion("U8 Resultat", "U8 Result", 1, gradingCriterionPointTemplates);
"U8 Resultat",
"U8 Result",
1,
gradingCriterionPointTemplates
);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
@ -692,12 +664,7 @@ public class DataInitializer implements Lifecycle {
.build() .build()
); );
gradingReportTemplate gradingReportTemplate
.addIndividualCriterion( .addIndividualCriterion("Ö4 Deadlines", "Ö4 Deadlines", 0, gradingCriterionPointTemplates)
"Ö4 Deadlines",
"Ö4 Deadlines",
0,
gradingCriterionPointTemplates
)
.setFx(false); .setFx(false);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
@ -775,9 +742,7 @@ public class DataInitializer implements Lifecycle {
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
new GradingCriterionPointTemplate.Builder() new GradingCriterionPointTemplate.Builder()
.point(1) .point(1)
.description( .description("För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem.")
"För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem."
)
.descriptionEn( .descriptionEn(
"Requirement for 1 point: that the thesis introduces the subject and problem of the thesis." "Requirement for 1 point: that the thesis introduces the subject and problem of the thesis."
) )
@ -802,12 +767,7 @@ public class DataInitializer implements Lifecycle {
) )
.build() .build()
); );
gradingReportTemplateMaster.addProjectCriterion( gradingReportTemplateMaster.addProjectCriterion("U3 Problem", "U3 Problem", 1, gradingCriterionPointTemplates);
"U3 Problem",
"U3 Problem",
1,
gradingCriterionPointTemplates
);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
@ -947,9 +907,7 @@ public class DataInitializer implements Lifecycle {
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
new GradingCriterionPointTemplate.Builder() new GradingCriterionPointTemplate.Builder()
.point(3) .point(3)
.description( .description("För 3 poäng krävs dessutom: att det finns ett betydande djup i dataanalysen.")
"För 3 poäng krävs dessutom: att det finns ett betydande djup i dataanalysen."
)
.descriptionEn( .descriptionEn(
"For 3 points the following is also required: that there is a meaningful depth to the data analysis." "For 3 points the following is also required: that there is a meaningful depth to the data analysis."
) )
@ -996,12 +954,7 @@ public class DataInitializer implements Lifecycle {
) )
.build() .build()
); );
gradingReportTemplateMaster.addProjectCriterion( gradingReportTemplateMaster.addProjectCriterion("U8 Resultat", "U8 Result", 2, gradingCriterionPointTemplates);
"U8 Resultat",
"U8 Result",
2,
gradingCriterionPointTemplates
);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
@ -1224,12 +1177,7 @@ public class DataInitializer implements Lifecycle {
.build() .build()
); );
gradingReportTemplateMaster gradingReportTemplateMaster
.addIndividualCriterion( .addIndividualCriterion("Ö4 Deadlines", "Ö4 Deadlines", 0, gradingCriterionPointTemplates)
"Ö4 Deadlines",
"Ö4 Deadlines",
0,
gradingCriterionPointTemplates
)
.setFx(false); .setFx(false);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
@ -1307,9 +1255,7 @@ public class DataInitializer implements Lifecycle {
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(
new GradingCriterionPointTemplate.Builder() new GradingCriterionPointTemplate.Builder()
.point(1) .point(1)
.description( .description("För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem.")
"För 1 poäng krävs: att uppsatsen ger en introduktion till uppsatsens ämne och problem."
)
.descriptionEn( .descriptionEn(
"Requirement for 1 point: that the thesis introduces the subject and problem of the thesis." "Requirement for 1 point: that the thesis introduces the subject and problem of the thesis."
) )
@ -1712,12 +1658,7 @@ public class DataInitializer implements Lifecycle {
.build() .build()
); );
gradingReportTemplateMagister gradingReportTemplateMagister
.addIndividualCriterion( .addIndividualCriterion("Ö4 Deadlines", "Ö4 Deadlines", 0, gradingCriterionPointTemplates)
"Ö4 Deadlines",
"Ö4 Deadlines",
0,
gradingCriterionPointTemplates
)
.setFx(false); .setFx(false);
gradingCriterionPointTemplates = initPointTemplates(); gradingCriterionPointTemplates = initPointTemplates();
@ -1768,28 +1709,18 @@ public class DataInitializer implements Lifecycle {
private List<GradingCriterionPointTemplate> initPointTemplates() { private List<GradingCriterionPointTemplate> initPointTemplates() {
List<GradingCriterionPointTemplate> gradingCriterionPointTemplates = new ArrayList<>(); List<GradingCriterionPointTemplate> gradingCriterionPointTemplates = new ArrayList<>();
gradingCriterionPointTemplates.add( gradingCriterionPointTemplates.add(new GradingCriterionPointTemplate.Builder().point(0).build());
new GradingCriterionPointTemplate.Builder().point(0).build()
);
return gradingCriterionPointTemplates; return gradingCriterionPointTemplates;
} }
private void createDefaultProjectTypesIfNotDone() { private void createDefaultProjectTypesIfNotDone() {
bachelorClass = new ProjectType( bachelorClass = new ProjectType(ProjectType.BACHELOR, "Bachelor", "Bachelor degree thesis project");
ProjectType.BACHELOR,
"Bachelor",
"Bachelor degree thesis project"
);
bachelorClass = save(bachelorClass); bachelorClass = save(bachelorClass);
masterClass = new ProjectType(ProjectType.MASTER, "Master", "Master degree thesis project"); masterClass = new ProjectType(ProjectType.MASTER, "Master", "Master degree thesis project");
save(masterClass); save(masterClass);
magisterClass = new ProjectType( magisterClass = new ProjectType(ProjectType.MAGISTER, "Magister", "One-year-Master degree thesis project");
ProjectType.MAGISTER,
"Magister",
"One-year-Master degree thesis project"
);
save(magisterClass); save(magisterClass);
final ProjectType phdClass = new ProjectType(DegreeType.NONE, "PhD", "PhD project"); final ProjectType phdClass = new ProjectType(DegreeType.NONE, "PhD", "PhD project");
@ -1955,11 +1886,7 @@ public class DataInitializer implements Lifecycle {
MilestonePhaseTemplate milestonePhaseTemplate, MilestonePhaseTemplate milestonePhaseTemplate,
String code String code
) { ) {
MilestoneActivityTemplate milestoneActivityTemplate = new MilestoneActivityTemplate( MilestoneActivityTemplate milestoneActivityTemplate = new MilestoneActivityTemplate(type, title, description);
type,
title,
description
);
milestoneActivityTemplate.addProjectType(bachelorClass); milestoneActivityTemplate.addProjectType(bachelorClass);
milestoneActivityTemplate.addProjectType(masterClass); milestoneActivityTemplate.addProjectType(masterClass);
milestoneActivityTemplate.addProjectType(magisterClass); milestoneActivityTemplate.addProjectType(magisterClass);
@ -1969,10 +1896,7 @@ public class DataInitializer implements Lifecycle {
} }
private MilestonePhaseTemplate createMileStonePhase(String title, String description) { private MilestonePhaseTemplate createMileStonePhase(String title, String description) {
MilestonePhaseTemplate milestonePhaseTemplate1 = new MilestonePhaseTemplate( MilestonePhaseTemplate milestonePhaseTemplate1 = new MilestonePhaseTemplate(title, description);
title,
description
);
return save(milestonePhaseTemplate1); return save(milestonePhaseTemplate1);
} }

@ -55,9 +55,7 @@ import se.su.dsv.scipro.system.UserRepoImpl;
public class RepositoryConfiguration { public class RepositoryConfiguration {
@Bean @Bean
public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository( public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new GradingHistoryEventRepositoryImpl(em); return new GradingHistoryEventRepositoryImpl(em);
} }
@ -67,9 +65,7 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public ActivityFinalSeminarRepositoryImpl activityFinalSeminarRepository( public ActivityFinalSeminarRepositoryImpl activityFinalSeminarRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ActivityFinalSeminarRepositoryImpl(em); return new ActivityFinalSeminarRepositoryImpl(em);
} }
@ -151,9 +147,7 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public ForumPostReadStateRepositoryImpl forumPostReadStateRepository( public ForumPostReadStateRepositoryImpl forumPostReadStateRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ForumPostReadStateRepositoryImpl(em); return new ForumPostReadStateRepositoryImpl(em);
} }
@ -178,16 +172,12 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public MilestoneActivityTemplateRepositoryImpl milestoneActivityTemplateRepository( public MilestoneActivityTemplateRepositoryImpl milestoneActivityTemplateRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new MilestoneActivityTemplateRepositoryImpl(em); return new MilestoneActivityTemplateRepositoryImpl(em);
} }
@Bean @Bean
public NationalSubjectCategoryRepositoryImpl nationalSubjectCategoryRepository( public NationalSubjectCategoryRepositoryImpl nationalSubjectCategoryRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new NationalSubjectCategoryRepositoryImpl(em); return new NationalSubjectCategoryRepositoryImpl(em);
} }
@ -227,9 +217,7 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public PublicationMetadataRepositoryImpl publicationMetadataRepository( public PublicationMetadataRepositoryImpl publicationMetadataRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new PublicationMetadataRepositoryImpl(em); return new PublicationMetadataRepositoryImpl(em);
} }
@ -239,9 +227,7 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public ReviewerDeadlineSettingsRepositoryImpl reviewerDeadlineSettingsRepository( public ReviewerDeadlineSettingsRepositoryImpl reviewerDeadlineSettingsRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new ReviewerDeadlineSettingsRepositoryImpl(em); return new ReviewerDeadlineSettingsRepositoryImpl(em);
} }
@ -296,9 +282,7 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public SupervisorGradingReportRepositoryImpl supervisorGradingReportRepository( public SupervisorGradingReportRepositoryImpl supervisorGradingReportRepository(Provider<EntityManager> em) {
Provider<EntityManager> em
) {
return new SupervisorGradingReportRepositoryImpl(em); return new SupervisorGradingReportRepositoryImpl(em);
} }
} }

@ -7,10 +7,7 @@ public class ActivityFileUploadedEvent {
private final Activity activity; private final Activity activity;
private final FileDescription fileDescription; private final FileDescription fileDescription;
public ActivityFileUploadedEvent( public ActivityFileUploadedEvent(final Activity activity, final FileDescription fileDescription) {
final Activity activity,
final FileDescription fileDescription
) {
this.activity = activity; this.activity = activity;
this.fileDescription = fileDescription; this.fileDescription = fileDescription;
} }

@ -105,12 +105,7 @@ public class ActivityPlan extends DomainObject {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(this.getId(), this.getActivities(), this.getProject(), this.getStartDate());
this.getId(),
this.getActivities(),
this.getProject(),
this.getStartDate()
);
} }
@Override @Override

@ -20,12 +20,7 @@ public interface ActivityPlanFacade {
void addActivitiesFromTemplate(Project project, ActivityPlanTemplate template, Date startDate); void addActivitiesFromTemplate(Project project, ActivityPlanTemplate template, Date startDate);
ActivityPlanTemplate createTemplateFromSchedule( ActivityPlanTemplate createTemplateFromSchedule(ActivityPlan schedule, User user, String name, String description);
ActivityPlan schedule,
User user,
String name,
String description
);
void deleteActivity(Activity event); void deleteActivity(Activity event);
@ -33,12 +28,7 @@ public interface ActivityPlanFacade {
//moving from activityservice //moving from activityservice
List<Activity> findEventsByProject(final Project project, Pageable pageable); List<Activity> findEventsByProject(final Project project, Pageable pageable);
List<Activity> findEventsByProject( List<Activity> findEventsByProject(final Project project, final Date from, final Date to, Pageable pageable);
final Project project,
final Date from,
final Date to,
Pageable pageable
);
long countEventsByProject(final Project project, final Date from, final Date to); long countEventsByProject(final Project project, final Date from, final Date to);
Checklist createChecklist(Project project, ChecklistTemplate template); Checklist createChecklist(Project project, ChecklistTemplate template);

@ -192,19 +192,13 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
ActivityPlanTemplate template, ActivityPlanTemplate template,
final Date startDate final Date startDate
) { ) {
ActivityPlanTemplate reloadedTemplate = activityPlanTemplateService.findOne( ActivityPlanTemplate reloadedTemplate = activityPlanTemplateService.findOne(template.getId()); //Reload lazily linked entities
template.getId()
); //Reload lazily linked entities
int accumulatedOffset = 0; int accumulatedOffset = 0;
for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) { for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) {
accumulatedOffset += eventTemplate.getDaysOffset(); accumulatedOffset += eventTemplate.getDaysOffset();
final Date dateForEvent = daysService.workDaysAfter(startDate, accumulatedOffset); final Date dateForEvent = daysService.workDaysAfter(startDate, accumulatedOffset);
final String title = eventTemplate.getTitle() != null final String title = eventTemplate.getTitle() != null ? eventTemplate.getTitle() : "no title";
? eventTemplate.getTitle() final String desc = eventTemplate.getDescription() != null ? eventTemplate.getDescription() : "";
: "no title";
final String desc = eventTemplate.getDescription() != null
? eventTemplate.getDescription()
: "";
final ChecklistTemplate checklistTemplate = eventTemplate.getChecklistTemplate(); final ChecklistTemplate checklistTemplate = eventTemplate.getChecklistTemplate();
final Action action = eventTemplate.getAction(); final Action action = eventTemplate.getAction();
if (checklistTemplate != null) { if (checklistTemplate != null) {
@ -245,15 +239,10 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
Date previousActivityDate = null; Date previousActivityDate = null;
// Fucking Hibernate that replaces the original TreeSet with an unsorted implementation because it can. // Fucking Hibernate that replaces the original TreeSet with an unsorted implementation because it can.
SortedSet<Activity> activities = new TreeSet<>( SortedSet<Activity> activities = new TreeSet<>(new Activity.ByDateComparator().thenComparing(Activity::getId));
new Activity.ByDateComparator().thenComparing(Activity::getId)
);
activities.addAll(schedule.getActivities()); activities.addAll(schedule.getActivities());
for (final Activity activity : activities) { for (final Activity activity : activities) {
final ActivityTemplate activityTemplate = createTemplateFromActivity( final ActivityTemplate activityTemplate = createTemplateFromActivity(previousActivityDate, activity);
previousActivityDate,
activity
);
template.addActivity(activityTemplate); template.addActivity(activityTemplate);
previousActivityDate = activity.getDate(); previousActivityDate = activity.getDate();
} }
@ -268,17 +257,13 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
eventTemplate.setDescription(event.getDescription()); eventTemplate.setDescription(event.getDescription());
eventTemplate.setAction(event.getAction()); eventTemplate.setAction(event.getAction());
if (event.getChecklist() != null) { if (event.getChecklist() != null) {
eventTemplate.setChecklistTemplate( eventTemplate.setChecklistTemplate(checklistTemplateService.findByName(event.getChecklist().getName()));
checklistTemplateService.findByName(event.getChecklist().getName())
);
} }
return eventTemplate; return eventTemplate;
} }
private int daysBetween(Date previousEventDate, Date currentEventDate) { private int daysBetween(Date previousEventDate, Date currentEventDate) {
return previousEventDate == null return previousEventDate == null ? 0 : daysService.workDaysBetween(previousEventDate, currentEventDate);
? 0
: daysService.workDaysBetween(previousEventDate, currentEventDate);
} }
@Override @Override
@ -307,21 +292,12 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
} }
@Override @Override
public List<Activity> findEventsByProject( public List<Activity> findEventsByProject(Project project, Date from, Date to, Pageable pageable) {
Project project,
Date from,
Date to,
Pageable pageable
) {
final Date dateFrom = from != null ? from : new Date(0); final Date dateFrom = from != null ? from : new Date(0);
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE; final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
QActivity event = QActivity.activity; QActivity event = QActivity.activity;
return activityService.findAll( return activityService.findAll(
allOf( allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo)),
event.activityPlan.project.eq(project),
event.date.after(dateFrom),
event.date.before(dateTo)
),
pageable pageable
); );
} }
@ -332,11 +308,7 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE; final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
QActivity event = QActivity.activity; QActivity event = QActivity.activity;
return activityService.count( return activityService.count(
allOf( allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo))
event.activityPlan.project.eq(project),
event.date.after(dateFrom),
event.date.before(dateTo)
)
); );
} }
@ -361,10 +333,7 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
.build(); .build();
checklist.setCategories(categories); checklist.setCategories(categories);
for (String question : template.getQuestions()) { for (String question : template.getQuestions()) {
ChecklistQuestion clQuestion = new ChecklistQuestion( ChecklistQuestion clQuestion = new ChecklistQuestion(question, checklist.getNumberOfQuestions());
question,
checklist.getNumberOfQuestions()
);
clQuestion = checklistQuestionRepo.save(clQuestion); clQuestion = checklistQuestionRepo.save(clQuestion);
checklist.addQuestion(clQuestion); checklist.addQuestion(clQuestion);
} }

@ -5,9 +5,7 @@ import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
public class ActivityPlanServiceImpl public class ActivityPlanServiceImpl extends AbstractServiceImpl<ActivityPlan, Long> implements ActivityPlanService {
extends AbstractServiceImpl<ActivityPlan, Long>
implements ActivityPlanService {
@Inject @Inject
public ActivityPlanServiceImpl(Provider<EntityManager> em) { public ActivityPlanServiceImpl(Provider<EntityManager> em) {

@ -50,16 +50,8 @@ public class ActivityPlanTemplateServiceImpl
private static Predicate filterString(String filterString) { private static Predicate filterString(String filterString) {
return QActivityPlanTemplate.activityPlanTemplate.title return QActivityPlanTemplate.activityPlanTemplate.title
.containsIgnoreCase(filterString) .containsIgnoreCase(filterString)
.or( .or(QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase(filterString))
QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase( .or(QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(filterString));
filterString
)
)
.or(
QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(
filterString
)
);
} }
@Override @Override

@ -5,9 +5,7 @@ import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
public class ActivityServiceImpl public class ActivityServiceImpl extends AbstractServiceImpl<Activity, Long> implements ActivityService {
extends AbstractServiceImpl<Activity, Long>
implements ActivityService {
@Inject @Inject
public ActivityServiceImpl(Provider<EntityManager> em) { public ActivityServiceImpl(Provider<EntityManager> em) {

@ -56,10 +56,7 @@ public class Checklist extends DomainObject {
@JoinTable( @JoinTable(
name = "checklist_checklist_question", name = "checklist_checklist_question",
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"), joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn( inverseJoinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id")
name = "checklist_question_id",
referencedColumnName = "id"
)
) )
private List<ChecklistQuestion> questions = new ArrayList<>(); private List<ChecklistQuestion> questions = new ArrayList<>();
@ -67,18 +64,12 @@ public class Checklist extends DomainObject {
@JoinTable( @JoinTable(
name = "checklist_checklist_category", name = "checklist_checklist_category",
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"), joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn( inverseJoinColumns = @JoinColumn(name = "checklist_category_id", referencedColumnName = "id")
name = "checklist_category_id",
referencedColumnName = "id"
)
) )
private List<se.su.dsv.scipro.checklist.ChecklistCategory> categories = new ArrayList<>(); private List<se.su.dsv.scipro.checklist.ChecklistCategory> categories = new ArrayList<>();
@ElementCollection(fetch = FetchType.EAGER) @ElementCollection(fetch = FetchType.EAGER)
@CollectionTable( @CollectionTable(name = "checklist_user_last_open_date", joinColumns = @JoinColumn(name = "checklist_id"))
name = "checklist_user_last_open_date",
joinColumns = @JoinColumn(name = "checklist_id")
)
@Column(name = "last_open_date") @Column(name = "last_open_date")
@SuppressWarnings("JpaDataSourceORMInspection") // false warning from IntelliJ for the @MapKeyJoinColumn @SuppressWarnings("JpaDataSourceORMInspection") // false warning from IntelliJ for the @MapKeyJoinColumn
@MapKeyJoinColumn(name = "user_id") @MapKeyJoinColumn(name = "user_id")

@ -47,13 +47,7 @@ public class ChecklistCategory extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return ( return ("ChecklistCategory(id=" + this.getId() + ", categoryName=" + this.getCategoryName() + ")");
"ChecklistCategory(id=" +
this.getId() +
", categoryName=" +
this.getCategoryName() +
")"
);
} }
@Override @Override

@ -5,9 +5,7 @@ import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class ChecklistCategoryRepoImpl public class ChecklistCategoryRepoImpl extends GenericRepo<ChecklistCategory, Long> implements ChecklistCategoryRepo {
extends GenericRepo<ChecklistCategory, Long>
implements ChecklistCategoryRepo {
@Inject @Inject
public ChecklistCategoryRepoImpl(Provider<EntityManager> em) { public ChecklistCategoryRepoImpl(Provider<EntityManager> em) {

@ -5,9 +5,7 @@ import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class ChecklistQuestionRepoImpl public class ChecklistQuestionRepoImpl extends GenericRepo<ChecklistQuestion, Long> implements ChecklistQuestionRepo {
extends GenericRepo<ChecklistQuestion, Long>
implements ChecklistQuestionRepo {
@Inject @Inject
public ChecklistQuestionRepoImpl(Provider<EntityManager> em) { public ChecklistQuestionRepoImpl(Provider<EntityManager> em) {

@ -11,9 +11,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public class ChecklistServiceImpl public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> implements ChecklistService {
extends AbstractServiceImpl<Checklist, Long>
implements ChecklistService {
@Inject @Inject
public ChecklistServiceImpl(Provider<EntityManager> em) { public ChecklistServiceImpl(Provider<EntityManager> em) {
@ -27,10 +25,7 @@ public class ChecklistServiceImpl
.join(QActivityPlan.activityPlan.activities, QActivity.activity) .join(QActivityPlan.activityPlan.activities, QActivity.activity)
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion) .join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer) .join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
.where( .where(QActivityPlan.activityPlan.project.eq(project), QChecklistAnswer.checklistAnswer.answer.eq(answer))
QActivityPlan.activityPlan.project.eq(project),
QChecklistAnswer.checklistAnswer.answer.eq(answer)
)
.fetchFirst(); .fetchFirst();
} }

@ -46,10 +46,7 @@ public class ChecklistTemplate extends DomainObject {
private int templateNumber = DEFAULT_TEMPLATE_NUMBER; private int templateNumber = DEFAULT_TEMPLATE_NUMBER;
@ElementCollection @ElementCollection
@CollectionTable( @CollectionTable(name = "checklist_template_question", joinColumns = @JoinColumn(name = "checklist_template_id"))
name = "checklist_template_question",
joinColumns = @JoinColumn(name = "checklist_template_id")
)
@Column(name = "question") @Column(name = "question")
private List<String> questions = new ArrayList<>(1); private List<String> questions = new ArrayList<>(1);
@ -61,10 +58,7 @@ public class ChecklistTemplate extends DomainObject {
@JoinTable( @JoinTable(
name = "checklist_template_checklist_category", name = "checklist_template_checklist_category",
joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"), joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn( inverseJoinColumns = @JoinColumn(name = "checklist_category_id", referencedColumnName = "id")
name = "checklist_category_id",
referencedColumnName = "id"
)
) )
private List<ChecklistCategory> categories = new ArrayList<>(); private List<ChecklistCategory> categories = new ArrayList<>();

@ -6,8 +6,7 @@ import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface ChecklistTemplateService public interface ChecklistTemplateService
extends extends GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
void upChecklistTemplate(ChecklistTemplate checklistTemplate); void upChecklistTemplate(ChecklistTemplate checklistTemplate);
void downChecklistTemplate(ChecklistTemplate checklistTemplate); void downChecklistTemplate(ChecklistTemplate checklistTemplate);
void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate); void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate);

@ -26,27 +26,20 @@ public class ChecklistTemplateServiceImpl
@Override @Override
public List<ChecklistTemplate> findAll(String filterString, Pageable pageable) { public List<ChecklistTemplate> findAll(String filterString, Pageable pageable) {
String filter = filterString == null ? "" : filterString; String filter = filterString == null ? "" : filterString;
return findAll( return findAll(filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)), pageable);
filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)),
pageable
);
} }
@Override @Override
public long count(String filterString) { public long count(String filterString) {
String filter = filterString == null ? "" : filterString; String filter = filterString == null ? "" : filterString;
return count( return count(filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter)));
filterStringIsCreatorName(filter).or(filterStringIsChecklistTemplateName(filter))
);
} }
@Transactional @Transactional
@Override @Override
public void upChecklistTemplate(ChecklistTemplate checklistTemplate) { public void upChecklistTemplate(ChecklistTemplate checklistTemplate) {
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1) != null) { if (findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1) != null) {
ChecklistTemplate downChecklistTemplate = findByTemplateNumber( ChecklistTemplate downChecklistTemplate = findByTemplateNumber(checklistTemplate.getTemplateNumber() + 1);
checklistTemplate.getTemplateNumber() + 1
);
downChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber()); downChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() + 1); checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() + 1);
save(downChecklistTemplate); save(downChecklistTemplate);
@ -62,9 +55,7 @@ public class ChecklistTemplateServiceImpl
@Override @Override
public void downChecklistTemplate(ChecklistTemplate checklistTemplate) { public void downChecklistTemplate(ChecklistTemplate checklistTemplate) {
if (findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1) != null) { if (findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1) != null) {
ChecklistTemplate upChecklistTemplate = findByTemplateNumber( ChecklistTemplate upChecklistTemplate = findByTemplateNumber(checklistTemplate.getTemplateNumber() - 1);
checklistTemplate.getTemplateNumber() - 1
);
upChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber()); upChecklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber());
checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() - 1); checklistTemplate.setTemplateNumber(checklistTemplate.getTemplateNumber() - 1);
save(upChecklistTemplate); save(upChecklistTemplate);
@ -76,9 +67,7 @@ public class ChecklistTemplateServiceImpl
@Override @Override
public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) { public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) {
for (ChecklistTemplate clt : findAll( for (ChecklistTemplate clt : findAll(
QChecklistTemplate.checklistTemplate.templateNumber.gt( QChecklistTemplate.checklistTemplate.templateNumber.gt(checklistTemplate.getTemplateNumber())
checklistTemplate.getTemplateNumber()
)
)) { )) {
clt.setTemplateNumber(clt.getTemplateNumber() - 1); clt.setTemplateNumber(clt.getTemplateNumber() - 1);
} }
@ -89,9 +78,7 @@ public class ChecklistTemplateServiceImpl
public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) { public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) {
return findAll( return findAll(
allOf( allOf(
QChecklistTemplate.checklistTemplate.projectTypes QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()),
.any()
.eq(project.getProjectType()),
QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER) QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER)
) )
); );
@ -99,9 +86,7 @@ public class ChecklistTemplateServiceImpl
@Override @Override
public List<ChecklistTemplate> findByProject(Project project) { public List<ChecklistTemplate> findByProject(Project project) {
return findAll( return findAll(QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()));
QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType())
);
} }
@Override @Override

@ -73,11 +73,7 @@ public interface DaisyAPI {
PublishingConsent getPublishingConsent(int projectId, int personId); PublishingConsent getPublishingConsent(int projectId, int personId);
boolean setPublishingConsent( boolean setPublishingConsent(int projectId, int personId, PublishingConsentLevel publishingConsentLevel);
int projectId,
int personId,
PublishingConsentLevel publishingConsentLevel
);
List<ResearchSubject> getNationalResearchSubjects(int organisationId); List<ResearchSubject> getNationalResearchSubjects(int organisationId);
} }

@ -48,8 +48,7 @@ public class DaisyAPIImpl implements DaisyAPI {
@Named("daisy.api.password") final String password @Named("daisy.api.password") final String password
) { ) {
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.client = ClientBuilder.newClient() this.client = ClientBuilder.newClient().register(HttpAuthenticationFeature.basic(user, password));
.register(HttpAuthenticationFeature.basic(user, password));
this.objectFactory = new ObjectFactory(); this.objectFactory = new ObjectFactory();
} }
@ -122,9 +121,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(id)) .path(String.valueOf(id))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Person.class)) : Optional.empty();
? Optional.of(response.readEntity(Person.class))
: Optional.empty();
} }
@Override @Override
@ -134,9 +131,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(userName) .path(userName)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Person.class)) : Optional.empty();
? Optional.of(response.readEntity(Person.class))
: Optional.empty();
} }
@Override @Override
@ -174,10 +169,7 @@ public class DaisyAPIImpl implements DaisyAPI {
@Override @Override
public Response deleteProject(Integer projectId) { public Response deleteProject(Integer projectId) {
return thesis() return thesis().path(String.valueOf(projectId)).request(MediaType.APPLICATION_XML_TYPE).delete();
.path(String.valueOf(projectId))
.request(MediaType.APPLICATION_XML_TYPE)
.delete();
} }
@Override @Override
@ -187,10 +179,7 @@ public class DaisyAPIImpl implements DaisyAPI {
@Override @Override
public Program getProgram(Integer id) { public Program getProgram(Integer id) {
return program() return program().path(String.valueOf(id)).request(MediaType.APPLICATION_XML_TYPE).get(Program.class);
.path(String.valueOf(id))
.request(MediaType.APPLICATION_XML_TYPE)
.get(Program.class);
} }
@Override @Override
@ -199,9 +188,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(projectIdentifier)) .path(String.valueOf(projectIdentifier))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Thesis.class)) : Optional.empty();
? Optional.of(response.readEntity(Thesis.class))
: Optional.empty();
} }
@Override @Override
@ -217,9 +204,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(authorId)) .path(String.valueOf(authorId))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(); .get();
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.ofNullable(response.readEntity(String.class)) : Optional.empty();
? Optional.ofNullable(response.readEntity(String.class))
: Optional.empty();
} }
@Override @Override
@ -231,11 +216,7 @@ public class DaisyAPIImpl implements DaisyAPI {
} }
@Override @Override
public PhotoResult getPhoto( public PhotoResult getPhoto(final Integer personId, final int requesterId, final boolean alwaysShow) {
final Integer personId,
final int requesterId,
final boolean alwaysShow
) {
final Response response; final Response response;
try { try {
response = person() response = person()
@ -292,11 +273,7 @@ public class DaisyAPIImpl implements DaisyAPI {
} }
@Override @Override
public boolean sendPublicationFile( public boolean sendPublicationFile(final long projectId, final String filename, final InputStream data) {
final long projectId,
final String filename,
final InputStream data
) {
final String asciiOnlyFilename = asciify(filename); final String asciiOnlyFilename = asciify(filename);
final Response response = thesis() final Response response = thesis()
.path(Long.toString(projectId)) .path(Long.toString(projectId))
@ -328,10 +305,7 @@ public class DaisyAPIImpl implements DaisyAPI {
} }
@Override @Override
public List<ProgramAdmission> getProgramAdmissions( public List<ProgramAdmission> getProgramAdmissions(final Program program, final Semester admissionSemester) {
final Program program,
final Semester admissionSemester
) {
return program() return program()
.path(String.valueOf(program.getId())) .path(String.valueOf(program.getId()))
.path("admissions") .path("admissions")
@ -410,11 +384,7 @@ public class DaisyAPIImpl implements DaisyAPI {
} }
@Override @Override
public boolean setPublishingConsent( public boolean setPublishingConsent(int projectId, int personId, PublishingConsentLevel publishingConsentLevel) {
int projectId,
int personId,
PublishingConsentLevel publishingConsentLevel
) {
final Invocation.Builder request = thesis() final Invocation.Builder request = thesis()
.path(Integer.toString(projectId)) .path(Integer.toString(projectId))
.path("author") .path("author")

@ -29,22 +29,12 @@ public class MailFacade implements Serializable {
@Inject @Inject
private GeneralSystemSettingsService generalSystemSettingsService; private GeneralSystemSettingsService generalSystemSettingsService;
private Set<Recipient> addProjectAuthors( private Set<Recipient> addProjectAuthors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
ProjectStatus ps,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate); final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
return authorsFromProjects(filter); return authorsFromProjects(filter);
} }
private Set<Recipient> addProjectSupervisors( private Set<Recipient> addProjectSupervisors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
ProjectStatus ps,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate); final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
return supervisorsFromProjects(filter); return supervisorsFromProjects(filter);
} }
@ -59,12 +49,7 @@ public class MailFacade implements Serializable {
return coSupervisorsFromProjects(filter); return coSupervisorsFromProjects(filter);
} }
private Set<Recipient> addProjectReviewers( private Set<Recipient> addProjectReviewers(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) {
ProjectStatus ps,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate); final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
return reviewersFromProjects(filter); return reviewersFromProjects(filter);
} }
@ -148,12 +133,7 @@ public class MailFacade implements Serializable {
} }
} }
public Set<Recipient> getRecipients( public Set<Recipient> getRecipients(MailChoice choice, Set<ProjectType> pc, Date startDate, Date endDate) {
MailChoice choice,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
switch (choice) { switch (choice) {
case THESIS_SUPPORT: case THESIS_SUPPORT:
return addThesisSupport(); return addThesisSupport();
@ -167,15 +147,9 @@ public class MailFacade implements Serializable {
return addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate); return addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate);
case ALL_FOLLOWERS: case ALL_FOLLOWERS:
Set<Recipient> allFollowers = new HashSet<>(); Set<Recipient> allFollowers = new HashSet<>();
allFollowers.addAll( allFollowers.addAll(addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate) allFollowers.addAll(addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate));
); allFollowers.addAll(addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
allFollowers.addAll(
addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate)
);
allFollowers.addAll(
addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate)
);
return allFollowers; return allFollowers;
case AUTHORS_MATCHED_IDEA: case AUTHORS_MATCHED_IDEA:
IdeaService.Filter matchedFilter = setIdeaParams( IdeaService.Filter matchedFilter = setIdeaParams(

@ -171,9 +171,7 @@ public class FileDescription extends DomainObject {
} }
private String getSubdirectory() { private String getSubdirectory() {
return Long.toString( return Long.toString((id / FILES_PER_SUBDIRECTORY) * FILES_PER_SUBDIRECTORY + FILES_PER_SUBDIRECTORY);
(id / FILES_PER_SUBDIRECTORY) * FILES_PER_SUBDIRECTORY + FILES_PER_SUBDIRECTORY
);
} }
public boolean isDataAvailable() { public boolean isDataAvailable() {

@ -5,9 +5,7 @@ import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class FileDescriptionRepoImpl public class FileDescriptionRepoImpl extends GenericRepo<FileDescription, Long> implements FileDescriptionRepo {
extends GenericRepo<FileDescription, Long>
implements FileDescriptionRepo {
@Inject @Inject
public FileDescriptionRepoImpl(Provider<EntityManager> em) { public FileDescriptionRepoImpl(Provider<EntityManager> em) {

@ -6,9 +6,7 @@ import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractRepository; import se.su.dsv.scipro.system.AbstractRepository;
public class FileReferenceRepositoryImpl public class FileReferenceRepositoryImpl extends AbstractRepository implements FileReferenceRepository {
extends AbstractRepository
implements FileReferenceRepository {
@Inject @Inject
public FileReferenceRepositoryImpl(final Provider<EntityManager> em) { public FileReferenceRepositoryImpl(final Provider<EntityManager> em) {

@ -7,9 +7,7 @@ import jakarta.transaction.Transactional;
import java.io.InputStream; import java.io.InputStream;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
public class FileServiceImpl public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long> implements FileService {
extends AbstractServiceImpl<FileDescription, Long>
implements FileService {
private final FileReferenceRepository fileReferenceRepository; private final FileReferenceRepository fileReferenceRepository;
private final FileDescriptionRepo fileDescriptionRepository; private final FileDescriptionRepo fileDescriptionRepository;

@ -99,12 +99,7 @@ public class ProjectFile extends DomainObject {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(this.getId(), this.getProject(), this.getFileSource(), this.getFileDescription());
this.getId(),
this.getProject(),
this.getFileSource(),
this.getFileDescription()
);
} }
@Override @Override

@ -10,9 +10,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable; import se.su.dsv.scipro.system.Pageable;
public class ProjectFileRepositoryImpl public class ProjectFileRepositoryImpl extends AbstractServiceImpl<ProjectFile, Long> implements ProjectFileRepository {
extends AbstractServiceImpl<ProjectFile, Long>
implements ProjectFileRepository {
@Inject @Inject
public ProjectFileRepositoryImpl(final Provider<EntityManager> em) { public ProjectFileRepositoryImpl(final Provider<EntityManager> em) {
@ -39,10 +37,7 @@ public class ProjectFileRepositoryImpl
} }
@Override @Override
public Optional<ProjectFile> findProjectFile( public Optional<ProjectFile> findProjectFile(final FileDescription fileDescription, final Project project) {
final FileDescription fileDescription,
final Project project
) {
return Optional.ofNullable( return Optional.ofNullable(
findOne( findOne(
Expressions.allOf( Expressions.allOf(

@ -12,20 +12,14 @@ public class ProjectFileServiceImpl implements ProjectFileService {
private final ProjectFileRepository projectFileRepository; private final ProjectFileRepository projectFileRepository;
@Inject @Inject
public ProjectFileServiceImpl( public ProjectFileServiceImpl(final FileService fileService, final ProjectFileRepository projectFileRepository) {
final FileService fileService,
final ProjectFileRepository projectFileRepository
) {
this.fileService = fileService; this.fileService = fileService;
this.projectFileRepository = projectFileRepository; this.projectFileRepository = projectFileRepository;
} }
@Override @Override
@Transactional @Transactional
public ProjectFile store( public ProjectFile store(final ProjectFileUpload projectFileUpload, final FileSource fileSource) {
final ProjectFileUpload projectFileUpload,
final FileSource fileSource
) {
final FileReference fileDescription = fileService.storeFile(projectFileUpload); final FileReference fileDescription = fileService.storeFile(projectFileUpload);
return createProjectFile(fileDescription, projectFileUpload.getProject(), fileSource); return createProjectFile(fileDescription, projectFileUpload.getProject(), fileSource);
} }
@ -37,10 +31,7 @@ public class ProjectFileServiceImpl implements ProjectFileService {
final Project project, final Project project,
final FileSource fileSource final FileSource fileSource
) { ) {
Optional<ProjectFile> existing = projectFileRepository.findProjectFile( Optional<ProjectFile> existing = projectFileRepository.findProjectFile(fileDescription, project);
fileDescription,
project
);
if (existing.isPresent()) { if (existing.isPresent()) {
return existing.get(); return existing.get();
} }
@ -48,11 +39,7 @@ public class ProjectFileServiceImpl implements ProjectFileService {
return createProjectFile(reference, project, fileSource); return createProjectFile(reference, project, fileSource);
} }
private ProjectFile createProjectFile( private ProjectFile createProjectFile(FileReference reference, Project project, FileSource fileSource) {
FileReference reference,
Project project,
FileSource fileSource
) {
final ProjectFile projectFile = new ProjectFile(); final ProjectFile projectFile = new ProjectFile();
projectFile.setFileReference(reference); projectFile.setFileReference(reference);
projectFile.setFileSource(fileSource); projectFile.setFileSource(fileSource);

@ -23,9 +23,7 @@ public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRe
@Override @Override
public Optional<Author> findByProjectAndUser(Project project, User user) { public Optional<Author> findByProjectAndUser(Project project, User user) {
final QAuthor author = QAuthor.author; final QAuthor author = QAuthor.author;
final Author author1 = from(author) final Author author1 = from(author).where(author.project.eq(project), author.user.eq(user)).fetchOne();
.where(author.project.eq(project), author.user.eq(user))
.fetchOne();
return Optional.ofNullable(author1); return Optional.ofNullable(author1);
} }

@ -241,9 +241,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
return Collections.unmodifiableSet(activeParticipations); return Collections.unmodifiableSet(activeParticipations);
} }
public void setActiveParticipations( public void setActiveParticipations(Collection<FinalSeminarActiveParticipation> activeParticipations) {
Collection<FinalSeminarActiveParticipation> activeParticipations
) {
this.activeParticipations.clear(); this.activeParticipations.clear();
this.activeParticipations.addAll(activeParticipations); this.activeParticipations.addAll(activeParticipations);
} }
@ -273,9 +271,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminar)) return false; if (!(o instanceof FinalSeminar)) return false;
final FinalSeminar other = (FinalSeminar) o; final FinalSeminar other = (FinalSeminar) o;
return ( return (other.canEqual(this) && super.equals(o) && Objects.equals(this.getId(), other.getId()));
other.canEqual(this) && super.equals(o) && Objects.equals(this.getId(), other.getId())
);
} }
@Override @Override
@ -371,9 +367,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
return getNotGradedParticipations(respondents); return getNotGradedParticipations(respondents);
} }
private Collection<User> getNotGradedParticipations( private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) {
Set<? extends FinalSeminarParticipation> participations
) {
List<User> result = new ArrayList<>(); List<User> result = new ArrayList<>();
for (FinalSeminarParticipation participation : participations) { for (FinalSeminarParticipation participation : participations) {
if (participation.getGrade() == null) { if (participation.getGrade() == null) {

@ -40,9 +40,7 @@ public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarActiveParticipation)) return false; if (!(o instanceof FinalSeminarActiveParticipation)) return false;
final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o; final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o;
return ( return (other.canEqual(this) && super.equals(o) && Objects.equals(this.project, other.project));
other.canEqual(this) && super.equals(o) && Objects.equals(this.project, other.project)
);
} }
@Override @Override

@ -5,8 +5,5 @@ import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface FinalSeminarActiveParticipationRepository { public interface FinalSeminarActiveParticipationRepository {
List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel( List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType);
User user,
ProjectType projectType
);
} }

@ -18,17 +18,10 @@ public class FinalSeminarActiveParticipationRepositoryImpl
} }
@Override @Override
public List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel( public List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType) {
User user,
ProjectType projectType
) {
return from(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation) return from(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation)
.where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.user.eq(user)) .where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.user.eq(user))
.where( .where(QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.project.projectType.eq(projectType))
QFinalSeminarActiveParticipation.finalSeminarActiveParticipation.project.projectType.eq(
projectType
)
)
.fetch(); .fetch();
} }
} }

@ -3,7 +3,6 @@ package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface FinalSeminarActiveParticipationService public interface FinalSeminarActiveParticipationService extends GenericService<FinalSeminarActiveParticipation, Long> {
extends GenericService<FinalSeminarActiveParticipation, Long> {
FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar, User user); FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar, User user);
} }

@ -20,10 +20,7 @@ public class FinalSeminarActiveParticipationServiceImpl
} }
@Override @Override
public FinalSeminarActiveParticipation findByFinalSeminarUser( public FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar, User user) {
FinalSeminar finalSeminar,
User user
) {
for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) { for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) {
if (fsap.getUser().equals(user)) { if (fsap.getUser().equals(user)) {
return fsap; return fsap;

@ -57,15 +57,10 @@ public class FinalSeminarCreationSubscribers {
); );
} }
private List<User> getSubscribersStillNeedingOppositionOrParticipation( private List<User> getSubscribersStillNeedingOppositionOrParticipation(List<Author> subscribers) {
List<Author> subscribers
) {
return subscribers return subscribers
.stream() .stream()
.filter( .filter(subscriber -> onlyFailedOppositions(subscriber) || onlyFailedParticipations(subscriber))
subscriber ->
onlyFailedOppositions(subscriber) || onlyFailedParticipations(subscriber)
)
.map(Author::getUser) .map(Author::getUser)
.toList(); .toList();
} }

@ -2,8 +2,4 @@ package se.su.dsv.scipro.finalseminar;
import java.time.LocalDateTime; import java.time.LocalDateTime;
public record FinalSeminarMovedEvent( public record FinalSeminarMovedEvent(FinalSeminar finalSeminar, LocalDateTime from, LocalDateTime to) {}
FinalSeminar finalSeminar,
LocalDateTime from,
LocalDateTime to
) {}

@ -46,12 +46,7 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// JPA-mappings of other tables referencing to this table (final_seminar_opposition) // JPA-mappings of other tables referencing to this table (final_seminar_opposition)
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@OneToOne( @OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "finalSeminarOpposition")
optional = true,
orphanRemoval = true,
cascade = CascadeType.ALL,
mappedBy = "finalSeminarOpposition"
)
private OppositionReport oppositionReport; private OppositionReport oppositionReport;
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -105,11 +100,7 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarOpposition)) return false; if (!(o instanceof FinalSeminarOpposition)) return false;
final FinalSeminarOpposition other = (FinalSeminarOpposition) o; final FinalSeminarOpposition other = (FinalSeminarOpposition) o;
return ( return (other.canEqual(this) && super.equals(o) && Objects.equals(this.getProject(), other.getProject()));
other.canEqual(this) &&
super.equals(o) &&
Objects.equals(this.getProject(), other.getProject())
);
} }
@Override @Override

@ -9,8 +9,6 @@ import se.su.dsv.scipro.system.User;
@Transactional @Transactional
public interface FinalSeminarOppositionRepo public interface FinalSeminarOppositionRepo
extends extends JpaRepository<FinalSeminarOpposition, Long>, QueryDslPredicateExecutor<FinalSeminarOpposition> {
JpaRepository<FinalSeminarOpposition, Long>,
QueryDslPredicateExecutor<FinalSeminarOpposition> {
List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType); List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType);
} }

@ -18,15 +18,10 @@ public class FinalSeminarOppositionRepoImpl
} }
@Override @Override
public List<FinalSeminarOpposition> findByOpposingUserAndType( public List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType) {
User user,
ProjectType projectType
) {
return createQuery() return createQuery()
.where(QFinalSeminarOpposition.finalSeminarOpposition.user.eq(user)) .where(QFinalSeminarOpposition.finalSeminarOpposition.user.eq(user))
.where( .where(QFinalSeminarOpposition.finalSeminarOpposition.project.projectType.eq(projectType))
QFinalSeminarOpposition.finalSeminarOpposition.project.projectType.eq(projectType)
)
.fetch(); .fetch();
} }
} }

@ -2,8 +2,7 @@ package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface FinalSeminarOppositionService public interface FinalSeminarOppositionService extends GenericService<FinalSeminarOpposition, Long> {
extends GenericService<FinalSeminarOpposition, Long> {
@Override @Override
void delete(Long aLong); void delete(Long aLong);
} }

@ -6,9 +6,7 @@ import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractRepository; import se.su.dsv.scipro.system.AbstractRepository;
public class FinalSeminarRepositoryImpl public class FinalSeminarRepositoryImpl extends AbstractRepository implements FinalSeminarRepository {
extends AbstractRepository
implements FinalSeminarRepository {
@Inject @Inject
public FinalSeminarRepositoryImpl(Provider<EntityManager> em) { public FinalSeminarRepositoryImpl(Provider<EntityManager> em) {

@ -3,7 +3,6 @@ package se.su.dsv.scipro.finalseminar;
import java.util.List; import java.util.List;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface FinalSeminarRespondentService public interface FinalSeminarRespondentService extends GenericService<FinalSeminarRespondent, Long> {
extends GenericService<FinalSeminarRespondent, Long> {
List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar); List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar);
} }

@ -6,11 +6,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.util.Either; import se.su.dsv.scipro.util.Either;
public interface FinalSeminarScheduling { public interface FinalSeminarScheduling {
Either<SchedulingError, FinalSeminar> schedule( Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details);
Project project,
LocalDateTime when,
FinalSeminarDetails details
);
LocalDate getEarliestSeminarDate(); LocalDate getEarliestSeminarDate();

@ -20,10 +20,11 @@ public interface FinalSeminarService
Project project Project project
); );
Either< Either<ActiveParticipationRegistrationErrorStatus, FinalSeminarActiveParticipation> attemptAddActiveParticipation(
ActiveParticipationRegistrationErrorStatus, User student,
FinalSeminarActiveParticipation FinalSeminar finalSeminar,
> attemptAddActiveParticipation(User student, FinalSeminar finalSeminar, Project project); Project project
);
Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor( Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(
User student, User student,
@ -31,20 +32,13 @@ public interface FinalSeminarService
Project project Project project
); );
Either< Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(
ParticipateError,
FinalSeminarActiveParticipation
> attemptAddActiveParticipationAsSupervisor(
User student, User student,
FinalSeminar finalSeminar, FinalSeminar finalSeminar,
Project project Project project
); );
Either<OppositionRegistrationErrorStatus, Void> canOppose( Either<OppositionRegistrationErrorStatus, Void> canOppose(User Student, FinalSeminar finalSeminar, Project project);
User Student,
FinalSeminar finalSeminar,
Project project
);
Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate( Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(
User student, User student,
@ -185,10 +179,7 @@ public interface FinalSeminarService
Objects.equals(this.getLazyDeleted(), other.getLazyDeleted()) && Objects.equals(this.getLazyDeleted(), other.getLazyDeleted()) &&
Objects.equals(this.getExempted(), other.getExempted()) && Objects.equals(this.getExempted(), other.getExempted()) &&
Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects()) && Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects()) &&
Objects.equals( Objects.equals(this.getOnlyActiveOrCompletedProjects(), other.getOnlyActiveOrCompletedProjects()) &&
this.getOnlyActiveOrCompletedProjects(),
other.getOnlyActiveOrCompletedProjects()
) &&
Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor()) && Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor()) &&
Objects.equals(this.getDegreeType(), other.getDegreeType()) && Objects.equals(this.getDegreeType(), other.getDegreeType()) &&
Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants) Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants)

@ -27,9 +27,7 @@ import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import se.su.dsv.scipro.util.Either; import se.su.dsv.scipro.util.Either;
public class FinalSeminarServiceImpl public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, Long> implements FinalSeminarService {
extends AbstractServiceImpl<FinalSeminar, Long>
implements FinalSeminarService {
@Inject @Inject
FinalSeminarSettingsService finalSeminarSettingsService; FinalSeminarSettingsService finalSeminarSettingsService;
@ -135,11 +133,7 @@ public class FinalSeminarServiceImpl
return Either.right(persisted); return Either.right(persisted);
} }
private FinalSeminar setDetails( private FinalSeminar setDetails(FinalSeminar finalSeminar, LocalDateTime when, FinalSeminarDetails details) {
FinalSeminar finalSeminar,
LocalDateTime when,
FinalSeminarDetails details
) {
Instant instant = when.atZone(clock.getZone()).toInstant(); Instant instant = when.atZone(clock.getZone()).toInstant();
finalSeminar.setStartDate(Date.from(instant)); finalSeminar.setStartDate(Date.from(instant));
return updateDetails(finalSeminar, details); return updateDetails(finalSeminar, details);
@ -158,10 +152,7 @@ public class FinalSeminarServiceImpl
return moveSeminar(finalSeminar, to); return moveSeminar(finalSeminar, to);
} }
private Either<MovingError, FinalSeminar> moveSeminar( private Either<MovingError, FinalSeminar> moveSeminar(FinalSeminar finalSeminar, LocalDateTime to) {
FinalSeminar finalSeminar,
LocalDateTime to
) {
ZonedDateTime oldTime = finalSeminar.getStartDate().toInstant().atZone(clock.getZone()); ZonedDateTime oldTime = finalSeminar.getStartDate().toInstant().atZone(clock.getZone());
Instant instant = to.atZone(clock.getZone()).toInstant(); Instant instant = to.atZone(clock.getZone()).toInstant();
finalSeminar.setStartDate(Date.from(instant)); finalSeminar.setStartDate(Date.from(instant));
@ -173,10 +164,7 @@ public class FinalSeminarServiceImpl
@Override @Override
@Transactional @Transactional
public FinalSeminar updateDetails( public FinalSeminar updateDetails(FinalSeminar finalSeminar, FinalSeminarDetails finalSeminarDetails) {
FinalSeminar finalSeminar,
FinalSeminarDetails finalSeminarDetails
) {
finalSeminar.setRoom(finalSeminarDetails.location()); finalSeminar.setRoom(finalSeminarDetails.location());
finalSeminar.setExtraInfo(finalSeminarDetails.extraInfo()); finalSeminar.setExtraInfo(finalSeminarDetails.extraInfo());
finalSeminar.setManualParticipants(finalSeminarDetails.manualParticipants()); finalSeminar.setManualParticipants(finalSeminarDetails.manualParticipants());
@ -251,19 +239,18 @@ public class FinalSeminarServiceImpl
if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) { if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) {
return Either.left(new TooManyOpponents()); return Either.left(new TooManyOpponents());
} }
for (FinalSeminarOpposition opposition : finalSeminarOppositionRepository.findByOpposingUserAndType( List<FinalSeminarOpposition> oppositions = finalSeminarOppositionRepository.findByOpposingUserAndType(
Student, Student,
project.getProjectType() project.getProjectType()
)) { );
for (FinalSeminarOpposition opposition : oppositions) {
if (opposition.getGrade() == null) { if (opposition.getGrade() == null) {
return Either.left(new UngradedOpposition()); return Either.left(new UngradedOpposition());
} else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) { } else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) {
return Either.left(new AlreadyOpposed()); return Either.left(new AlreadyOpposed());
} }
} }
int oppositionPriorityDays = finalSeminarSettingsService int oppositionPriorityDays = finalSeminarSettingsService.getInstance().getOppositionPriorityDays();
.getInstance()
.getOppositionPriorityDays();
final Instant seminarDate = finalSeminar.getDateCreated().toInstant(); final Instant seminarDate = finalSeminar.getDateCreated().toInstant();
final Instant available = seminarDate.plus(Period.ofDays(oppositionPriorityDays)); final Instant available = seminarDate.plus(Period.ofDays(oppositionPriorityDays));
if (available.isAfter(Instant.now()) && findByProject(project) == null) { if (available.isAfter(Instant.now()) && findByProject(project) == null) {
@ -333,11 +320,7 @@ public class FinalSeminarServiceImpl
} }
} }
private FinalSeminarOpposition createAndSaveOpposition( private FinalSeminarOpposition createAndSaveOpposition(User student, FinalSeminar finalSeminar, Project project) {
User student,
FinalSeminar finalSeminar,
Project project
) {
FinalSeminarOpposition opposition = new FinalSeminarOpposition(); FinalSeminarOpposition opposition = new FinalSeminarOpposition();
opposition.setUser(student); opposition.setUser(student);
opposition.setFinalSeminar(finalSeminar); opposition.setFinalSeminar(finalSeminar);
@ -352,11 +335,7 @@ public class FinalSeminarServiceImpl
public Either< public Either<
ActiveParticipationRegistrationErrorStatus, ActiveParticipationRegistrationErrorStatus,
FinalSeminarActiveParticipation FinalSeminarActiveParticipation
> attemptAddActiveParticipation( > attemptAddActiveParticipation(final User student, final FinalSeminar finalSeminar, final Project project) {
final User student,
final FinalSeminar finalSeminar,
final Project project
) {
return canActiveParticipate(student, finalSeminar).map(allowed -> return canActiveParticipate(student, finalSeminar).map(allowed ->
createAndSaveActiveParticipation(student, finalSeminar, project) createAndSaveActiveParticipation(student, finalSeminar, project)
); );
@ -364,10 +343,7 @@ public class FinalSeminarServiceImpl
@Override @Override
@Transactional @Transactional
public Either< public Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(
ParticipateError,
FinalSeminarActiveParticipation
> attemptAddActiveParticipationAsSupervisor(
User student, User student,
FinalSeminar finalSeminar, FinalSeminar finalSeminar,
Project project Project project
@ -455,9 +431,7 @@ public class FinalSeminarServiceImpl
bb.and(onlyNonManualParticipantsFilter()); bb.and(onlyNonManualParticipantsFilter());
} }
if (params.getDegreeType() != null) { if (params.getDegreeType() != null) {
bb.and( bb.and(QFinalSeminar.finalSeminar.project.projectType.degreeType.eq(params.getDegreeType()));
QFinalSeminar.finalSeminar.project.projectType.degreeType.eq(params.getDegreeType())
);
} }
if (params.getHeadSupervisor() != null) { if (params.getHeadSupervisor() != null) {
bb.and(hasHeadSupervisor(params.getHeadSupervisor())); bb.and(hasHeadSupervisor(params.getHeadSupervisor()));
@ -478,10 +452,7 @@ public class FinalSeminarServiceImpl
} }
private BooleanExpression onlyActiveOrCompletedProjectsFilter() { private BooleanExpression onlyActiveOrCompletedProjectsFilter() {
return QFinalSeminar.finalSeminar.project.projectStatus.in( return QFinalSeminar.finalSeminar.project.projectStatus.in(ProjectStatus.ACTIVE, ProjectStatus.COMPLETED);
ProjectStatus.ACTIVE,
ProjectStatus.COMPLETED
);
} }
@Override @Override
@ -507,12 +478,7 @@ public class FinalSeminarServiceImpl
return project return project
.getProjectParticipants() .getProjectParticipants()
.stream() .stream()
.map(author -> .map(author -> findFinalSeminarOppositionsByOpponentAndProjectType(project.getProjectType(), author))
findFinalSeminarOppositionsByOpponentAndProjectType(
project.getProjectType(),
author
)
)
.flatMap(List::stream) .flatMap(List::stream)
.toList(); .toList();
} }
@ -520,10 +486,7 @@ public class FinalSeminarServiceImpl
@Override @Override
public boolean hasHadFinalSeminar(Project project) { public boolean hasHadFinalSeminar(Project project) {
FinalSeminar finalSeminar = findByProject(project); FinalSeminar finalSeminar = findByProject(project);
return ( return (finalSeminar != null && finalSeminar.getStartDate().toInstant().isBefore(clock.instant()));
finalSeminar != null &&
finalSeminar.getStartDate().toInstant().isBefore(clock.instant())
);
} }
@Override @Override
@ -573,9 +536,7 @@ public class FinalSeminarServiceImpl
authorRepository authorRepository
.findByProjectAndUser(project, user) .findByProjectAndUser(project, user)
.ifPresent(author -> .ifPresent(author ->
author.setSubscribedToFinalSeminarNotifications( author.setSubscribedToFinalSeminarNotifications(!author.isSubscribedToFinalSeminarNotifications())
!author.isSubscribedToFinalSeminarNotifications()
)
); );
} }
@ -585,12 +546,7 @@ public class FinalSeminarServiceImpl
return seminar.oppositions return seminar.oppositions
.any() .any()
.grade.isNull() .grade.isNull()
.or( .or(seminar.activeParticipations.any().grade.isNull().or(seminar.respondents.any().grade.isNull()));
seminar.activeParticipations
.any()
.grade.isNull()
.or(seminar.respondents.any().grade.isNull())
);
} else { } else {
return seminar.startDate return seminar.startDate
.between(after, before) .between(after, before)

@ -146,8 +146,7 @@ public class FinalSeminarSettings extends DomainObject {
super.equals(o) && super.equals(o) &&
Objects.equals(this.getId(), other.getId()) && Objects.equals(this.getId(), other.getId()) &&
this.getDaysAheadToCreate() == other.getDaysAheadToCreate() && this.getDaysAheadToCreate() == other.getDaysAheadToCreate() &&
this.getDaysAheadToRegisterParticipation() == this.getDaysAheadToRegisterParticipation() == other.getDaysAheadToRegisterParticipation() &&
other.getDaysAheadToRegisterParticipation() &&
this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition() && this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition() &&
this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis() && this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis() &&
this.isThesisMustBePDF() == other.isThesisMustBePDF() && this.isThesisMustBePDF() == other.isThesisMustBePDF() &&

@ -14,9 +14,7 @@ import se.su.dsv.scipro.system.User;
public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController { public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController {
private static final Logger LOGGER = LoggerFactory.getLogger( private static final Logger LOGGER = LoggerFactory.getLogger(FinalSeminarUploadControllerImpl.class);
FinalSeminarUploadControllerImpl.class
);
private final FileService fileDescriptionService; private final FileService fileDescriptionService;
private final FinalSeminarService finalSeminarService; private final FinalSeminarService finalSeminarService;
@ -57,10 +55,7 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
@Override @Override
@Transactional @Transactional
public SeminarDocumentUpload replaceSeminarDocument( public SeminarDocumentUpload replaceSeminarDocument(final FinalSeminar finalSeminar, final FileUpload fileUpload) {
final FinalSeminar finalSeminar,
final FileUpload fileUpload
) {
if (finalSeminar.getDocument() != null) { if (finalSeminar.getDocument() != null) {
// if someone else deletes the document while it is being replaced // if someone else deletes the document while it is being replaced
fileDescriptionService.delete(finalSeminar.getDocument()); fileDescriptionService.delete(finalSeminar.getDocument());
@ -94,10 +89,7 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
seminar.setDocumentUploadDate(new Date()); seminar.setDocumentUploadDate(new Date());
seminar = finalSeminarService.save(seminar); seminar = finalSeminarService.save(seminar);
plagiarismControl.submit( plagiarismControl.submit(fileReference.getFileDescription(), seminar.getProject().getHeadSupervisor());
fileReference.getFileDescription(),
seminar.getProject().getHeadSupervisor()
);
eventBus.post(new FinalSeminarThesisUploadedEvent(seminar)); eventBus.post(new FinalSeminarThesisUploadedEvent(seminar));
} }

@ -9,9 +9,7 @@ import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface FinalThesisService public interface FinalThesisService
extends extends GenericService<FinalThesis, Long>, FilteredService<FinalThesis, Long, FinalThesisService.Filter> {
GenericService<FinalThesis, Long>,
FilteredService<FinalThesis, Long, FinalThesisService.Filter> {
FinalThesis upload(ProjectFileUpload fileUpload, String englishTitle, String swedishTitle); FinalThesis upload(ProjectFileUpload fileUpload, String englishTitle, String swedishTitle);
boolean hasFinalThesis(Project project); boolean hasFinalThesis(Project project);

@ -27,9 +27,7 @@ import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable; import se.su.dsv.scipro.system.Pageable;
@Named @Named
public class FinalThesisServiceImpl public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Long> implements FinalThesisService {
extends AbstractServiceImpl<FinalThesis, Long>
implements FinalThesisService {
protected final NotificationController notificationController; protected final NotificationController notificationController;
protected final ProjectFileService projectFileService; protected final ProjectFileService projectFileService;
@ -59,15 +57,9 @@ public class FinalThesisServiceImpl
@Override @Override
@Transactional @Transactional
public FinalThesis upload( public FinalThesis upload(ProjectFileUpload fileUpload, String englishTitle, String swedishTitle) {
ProjectFileUpload fileUpload,
String englishTitle,
String swedishTitle
) {
ProjectFile fileDescription = storeFinalThesisFile(fileUpload); ProjectFile fileDescription = storeFinalThesisFile(fileUpload);
final FileReference reference = fileService.createReference( final FileReference reference = fileService.createReference(fileDescription.getFileDescription());
fileDescription.getFileDescription()
);
FinalThesis finalThesis = new FinalThesis(); FinalThesis finalThesis = new FinalThesis();
finalThesis.setDocument(reference); finalThesis.setDocument(reference);
finalThesis.setProject(fileUpload.getProject()); finalThesis.setProject(fileUpload.getProject());
@ -93,9 +85,7 @@ public class FinalThesisServiceImpl
@Override @Override
public FileDescription getFinalThesisFileDescription(Project project) { public FileDescription getFinalThesisFileDescription(Project project) {
return hasFinalThesis(project) return hasFinalThesis(project) ? findByProject(project).getDocument().getFileDescription() : null;
? findByProject(project).getDocument().getFileDescription()
: null;
} }
@Override @Override
@ -111,10 +101,7 @@ public class FinalThesisServiceImpl
private FinalThesis findByProject0(Project project) { private FinalThesis findByProject0(Project project) {
return from(QFinalThesis.finalThesis) return from(QFinalThesis.finalThesis)
.where(QFinalThesis.finalThesis.project.eq(project)) .where(QFinalThesis.finalThesis.project.eq(project))
.orderBy( .orderBy(QFinalThesis.finalThesis.dateCreated.desc(), QFinalThesis.finalThesis.id.desc())
QFinalThesis.finalThesis.dateCreated.desc(),
QFinalThesis.finalThesis.id.desc()
)
.fetch() .fetch()
.get(0); .get(0);
} }
@ -165,10 +152,7 @@ public class FinalThesisServiceImpl
finalThesis.setEnglishTitle(englishTitle); finalThesis.setEnglishTitle(englishTitle);
finalThesis.setSwedishTitle(swedishTitle); finalThesis.setSwedishTitle(swedishTitle);
save(finalThesis); save(finalThesis);
plagiarismControl.submit( plagiarismControl.submit(finalThesis.getDocument().getFileDescription(), project.getHeadSupervisor());
finalThesis.getDocument().getFileDescription(),
project.getHeadSupervisor()
);
eventBus.post(new FinalThesisApprovedEvent(project)); eventBus.post(new FinalThesisApprovedEvent(project));
notificationController.notifyProject( notificationController.notifyProject(
project, project,

@ -76,9 +76,7 @@ public class FirstMeetingReminderWorker extends AbstractWorker {
.filter(idea -> needRemindingToday(idea, today)) .filter(idea -> needRemindingToday(idea, today))
.collect(Collectors.groupingBy(idea -> idea.getMatch().getSupervisor())); .collect(Collectors.groupingBy(idea -> idea.getMatch().getSupervisor()));
final String baseURL = generalSystemSettingsService final String baseURL = generalSystemSettingsService.getGeneralSystemSettingsInstance().getSciproURL();
.getGeneralSystemSettingsInstance()
.getSciproURL();
beginTransaction(); beginTransaction();
needReminding needReminding
@ -218,10 +216,7 @@ public class FirstMeetingReminderWorker extends AbstractWorker {
Scheduler scheduler, Scheduler scheduler,
Provider<FirstMeetingReminderWorker> firstMeetingReminderWorker Provider<FirstMeetingReminderWorker> firstMeetingReminderWorker
) { ) {
scheduler scheduler.schedule("First meeting reminders").runBy(firstMeetingReminderWorker).dailyAt(11, 30);
.schedule("First meeting reminders")
.runBy(firstMeetingReminderWorker)
.dailyAt(11, 30);
} }
} }
} }

@ -18,10 +18,7 @@ public class FirstMeetingServiceImpl
private final ActivityPlanFacade activityPlanFacade; private final ActivityPlanFacade activityPlanFacade;
@Inject @Inject
public FirstMeetingServiceImpl( public FirstMeetingServiceImpl(final Provider<EntityManager> em, final ActivityPlanFacade activityPlanFacade) {
final Provider<EntityManager> em,
final ActivityPlanFacade activityPlanFacade
) {
super(em, ProjectFirstMeeting.class, QProjectFirstMeeting.projectFirstMeeting); super(em, ProjectFirstMeeting.class, QProjectFirstMeeting.projectFirstMeeting);
this.activityPlanFacade = activityPlanFacade; this.activityPlanFacade = activityPlanFacade;
} }
@ -29,9 +26,7 @@ public class FirstMeetingServiceImpl
@Override @Override
public Optional<ProjectFirstMeeting> findByProject(final Project project) { public Optional<ProjectFirstMeeting> findByProject(final Project project) {
return Optional.ofNullable( return Optional.ofNullable(
findOne( findOne(QProjectFirstMeeting.projectFirstMeeting.activity.activityPlan.project.eq(project))
QProjectFirstMeeting.projectFirstMeeting.activity.activityPlan.project.eq(project)
)
); );
} }
@ -44,9 +39,7 @@ public class FirstMeetingServiceImpl
final String description final String description
) { ) {
final Optional<ProjectFirstMeeting> optFirstMeeting = findByProject(project); final Optional<ProjectFirstMeeting> optFirstMeeting = findByProject(project);
final ProjectFirstMeeting firstMeeting = optFirstMeeting.orElseGet( final ProjectFirstMeeting firstMeeting = optFirstMeeting.orElseGet(ProjectFirstMeeting::new);
ProjectFirstMeeting::new
);
final Activity activity = optFirstMeeting final Activity activity = optFirstMeeting
.map(ProjectFirstMeeting::getActivity) .map(ProjectFirstMeeting::getActivity)
.orElseGet(() -> createNewActivity(project)); .orElseGet(() -> createNewActivity(project));
@ -62,11 +55,7 @@ public class FirstMeetingServiceImpl
return activity; return activity;
} }
private Activity updateActivity( private Activity updateActivity(final Activity activity, final Date date, final String description) {
final Activity activity,
final Date date,
final String description
) {
activity.setDate(date); activity.setDate(date);
activity.setDescription(description); activity.setDescription(description);
return activityPlanFacade.saveActivity(activity); return activityPlanFacade.saveActivity(activity);

@ -7,9 +7,7 @@ import se.su.dsv.scipro.forum.dataobjects.ForumThread;
import se.su.dsv.scipro.forum.dataobjects.QForumThread; import se.su.dsv.scipro.forum.dataobjects.QForumThread;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class AbstractThreadRepositoryImpl public class AbstractThreadRepositoryImpl extends GenericRepo<ForumThread, Long> implements AbstractThreadRepository {
extends GenericRepo<ForumThread, Long>
implements AbstractThreadRepository {
@Inject @Inject
public AbstractThreadRepositoryImpl(Provider<EntityManager> em) { public AbstractThreadRepositoryImpl(Provider<EntityManager> em) {

@ -7,12 +7,7 @@ import se.su.dsv.scipro.forum.dataobjects.ForumThread;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface BasicForumService extends Serializable { public interface BasicForumService extends Serializable {
ForumPost createReply( ForumPost createReply(ForumThread forumThread, User poster, String content, Set<Attachment> attachments);
ForumThread forumThread,
User poster,
String content,
Set<Attachment> attachments
);
boolean setRead(User user, ForumPost post, boolean read); boolean setRead(User user, ForumPost post, boolean read);

@ -95,12 +95,7 @@ public class BasicForumServiceImpl implements BasicForumService {
return state; return state;
} }
private ForumPost createForumPost( private ForumPost createForumPost(User user, String content, ForumThread forumThread, Set<Attachment> fileUploads) {
User user,
String content,
ForumThread forumThread,
Set<Attachment> fileUploads
) {
final HashSet<FileReference> storedAttachments = fileUploads final HashSet<FileReference> storedAttachments = fileUploads
.stream() .stream()
.map(attachment -> attachment.createReference(fileService)) .map(attachment -> attachment.createReference(fileService))

@ -11,9 +11,7 @@ import se.su.dsv.scipro.system.User;
@Transactional @Transactional
public interface ForumPostReadStateRepository public interface ForumPostReadStateRepository
extends extends JpaRepository<ForumPostReadState, ForumPostReadStateId>, QueryDslPredicateExecutor<ForumPostReadState> {
JpaRepository<ForumPostReadState, ForumPostReadStateId>,
QueryDslPredicateExecutor<ForumPostReadState> {
ForumPostReadState find(User user, ForumPost post); ForumPostReadState find(User user, ForumPost post);
void setThreadRead(User user, ForumThread forumThread, boolean read); void setThreadRead(User user, ForumThread forumThread, boolean read);

@ -11,8 +11,7 @@ import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
import se.su.dsv.scipro.util.Pair; import se.su.dsv.scipro.util.Pair;
@Transactional @Transactional
public interface ForumPostRepository public interface ForumPostRepository extends JpaRepository<ForumPost, Long>, QueryDslPredicateExecutor<ForumPost> {
extends JpaRepository<ForumPost, Long>, QueryDslPredicateExecutor<ForumPost> {
List<ForumPost> findByThread(ForumThread forumThread); List<ForumPost> findByThread(ForumThread forumThread);
List<Pair<ProjectThread, ForumPost>> latestPost(Project project, int amount); List<Pair<ProjectThread, ForumPost>> latestPost(Project project, int amount);

@ -17,9 +17,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
import se.su.dsv.scipro.util.Pair; import se.su.dsv.scipro.util.Pair;
public class ForumPostRepositoryImpl public class ForumPostRepositoryImpl extends GenericRepo<ForumPost, Long> implements ForumPostRepository {
extends GenericRepo<ForumPost, Long>
implements ForumPostRepository {
@Inject @Inject
public ForumPostRepositoryImpl(Provider<EntityManager> em) { public ForumPostRepositoryImpl(Provider<EntityManager> em) {
@ -28,12 +26,7 @@ public class ForumPostRepositoryImpl
@Override @Override
public List<ForumPost> findByThread(ForumThread forumThread) { public List<ForumPost> findByThread(ForumThread forumThread) {
return findAll( return findAll(allOf(QForumPost.forumPost.forumThread.eq(forumThread), QForumPost.forumPost.deleted.isFalse()));
allOf(
QForumPost.forumPost.forumThread.eq(forumThread),
QForumPost.forumPost.deleted.isFalse()
)
);
} }
@Override @Override
@ -48,9 +41,7 @@ public class ForumPostRepositoryImpl
.limit(amount) .limit(amount)
.fetch() .fetch()
.stream() .stream()
.map(tuple -> .map(tuple -> new Pair<>(tuple.get(QProjectThread.projectThread), tuple.get(QForumPost.forumPost)))
new Pair<>(tuple.get(QProjectThread.projectThread), tuple.get(QForumPost.forumPost))
)
.toList(); .toList();
} }
} }

@ -9,24 +9,13 @@ import se.su.dsv.scipro.system.User;
public interface GroupForumService { public interface GroupForumService {
GroupThread findOne(long threadId); GroupThread findOne(long threadId);
GroupThread createThread( GroupThread createThread(Group group, User user, String subject, String content, Set<Attachment> fileUploads);
Group group,
User user,
String subject,
String content,
Set<Attachment> fileUploads
);
void markRead(User user, GroupThread groupThread); void markRead(User user, GroupThread groupThread);
List<GroupThread> getThreads(Group group); List<GroupThread> getThreads(Group group);
ForumPost createReply( ForumPost createReply(GroupThread groupThread, User poster, String content, Set<Attachment> attachments);
GroupThread groupThread,
User poster,
String content,
Set<Attachment> attachments
);
List<ForumPost> getPosts(GroupThread groupThread); List<ForumPost> getPosts(GroupThread groupThread);
} }

@ -72,12 +72,7 @@ public class GroupForumServiceImpl implements GroupForumService {
final String content, final String content,
final Set<Attachment> attachments final Set<Attachment> attachments
) { ) {
ForumPost reply = basicForumService.createReply( ForumPost reply = basicForumService.createReply(groupThread.getForumThread(), poster, content, attachments);
groupThread.getForumThread(),
poster,
content,
attachments
);
eventBus.post(new NewGroupForumReplyEvent(groupThread, reply)); eventBus.post(new NewGroupForumReplyEvent(groupThread, reply));
return reply; return reply;
} }

@ -9,9 +9,7 @@ import se.su.dsv.scipro.forum.dataobjects.QGroupThread;
import se.su.dsv.scipro.group.Group; import se.su.dsv.scipro.group.Group;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class GroupThreadRepositoryImpl public class GroupThreadRepositoryImpl extends GenericRepo<GroupThread, Long> implements GroupThreadRepository {
extends GenericRepo<GroupThread, Long>
implements GroupThreadRepository {
@Inject @Inject
public GroupThreadRepositoryImpl(Provider<EntityManager> em) { public GroupThreadRepositoryImpl(Provider<EntityManager> em) {

@ -8,20 +8,9 @@ import se.su.dsv.scipro.system.User;
import se.su.dsv.scipro.util.Pair; import se.su.dsv.scipro.util.Pair;
public interface ProjectForumService { public interface ProjectForumService {
ProjectThread createThread( ProjectThread createThread(Project project, User user, String subject, String content, Set<Attachment> fileUploads);
Project project,
User user,
String subject,
String content,
Set<Attachment> fileUploads
);
ForumPost createReply( ForumPost createReply(ProjectThread projectThread, User poster, String content, Set<Attachment> attachments);
ProjectThread projectThread,
User poster,
String content,
Set<Attachment> attachments
);
void markRead(User user, ProjectThread thread); void markRead(User user, ProjectThread thread);

@ -78,12 +78,7 @@ public class ProjectForumServiceImpl implements ProjectForumService {
final String content, final String content,
final Set<Attachment> attachments final Set<Attachment> attachments
) { ) {
ForumPost reply = basicForumService.createReply( ForumPost reply = basicForumService.createReply(projectThread.getForumThread(), poster, content, attachments);
projectThread.getForumThread(),
poster,
content,
attachments
);
reply reply
.getAttachments() .getAttachments()
.forEach(attachment -> .forEach(attachment ->

@ -9,9 +9,7 @@ import se.su.dsv.scipro.forum.dataobjects.QProjectThread;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.GenericRepo; import se.su.dsv.scipro.system.GenericRepo;
public class ProjectThreadRepositoryImpl public class ProjectThreadRepositoryImpl extends GenericRepo<ProjectThread, Long> implements ProjectThreadRepository {
extends GenericRepo<ProjectThread, Long>
implements ProjectThreadRepository {
@Inject @Inject
public ProjectThreadRepositoryImpl(Provider<EntityManager> em) { public ProjectThreadRepositoryImpl(Provider<EntityManager> em) {

@ -90,22 +90,14 @@ public class ForumNotifications {
.map(Notification::getNotificationEvent) .map(Notification::getNotificationEvent)
.distinct() .distinct()
.forEach(notificationEvent -> { .forEach(notificationEvent -> {
ForumNotification connection = new ForumNotification( ForumNotification connection = new ForumNotification(event.getMessage(), notificationEvent);
event.getMessage(),
notificationEvent
);
forumNotificationRepository.save(connection); forumNotificationRepository.save(connection);
}); });
} }
private void sendAndConnect( private void sendAndConnect(ForumPost post, Function<NotificationSource, Set<Notification>> send) {
ForumPost post,
Function<NotificationSource, Set<Notification>> send
) {
NotificationSource notificationSource = new NotificationSource(); NotificationSource notificationSource = new NotificationSource();
notificationSource.setMessage( notificationSource.setMessage(String.format("Posted by %s\n\n%s", getPostedBy(post), post.getContent()));
String.format("Posted by %s\n\n%s", getPostedBy(post), post.getContent())
);
notificationSource.setAdditionalMessage(post.getSubject()); notificationSource.setAdditionalMessage(post.getSubject());
send send
@ -133,11 +125,7 @@ public class ForumNotifications {
forumNotificationRepository forumNotificationRepository
.findByForumPost(forumPostReadEvent.post()) .findByForumPost(forumPostReadEvent.post())
.ifPresent(connection -> .ifPresent(connection ->
notificationService.setRead( notificationService.setRead(forumPostReadEvent.user(), connection.getNotificationEvent(), true)
forumPostReadEvent.user(),
connection.getNotificationEvent(),
true
)
); );
} }
} }

@ -92,11 +92,7 @@ public class ZipReporter implements Reporter {
@Override @Override
public Path generate(final User user) throws IOException { public Path generate(final User user) throws IOException {
final Path zipFile = Files.createTempFile( final Path zipFile = Files.createTempFile(Paths.get(FileDescription.FILE_ROOT), "gdpr-report-", ".zip");
Paths.get(FileDescription.FILE_ROOT),
"gdpr-report-",
".zip"
);
try (final FileSystem zipFileFS = getZipFileSystem(zipFile)) { try (final FileSystem zipFileFS = getZipFileSystem(zipFile)) {
final List<FileDescription> uploadedFiles = fileDescriptionService.findAll( final List<FileDescription> uploadedFiles = fileDescriptionService.findAll(
QFileDescription.fileDescription.uploader.eq(user) QFileDescription.fileDescription.uploader.eq(user)
@ -122,15 +118,7 @@ public class ZipReporter implements Reporter {
dt("E-mail"), dt("E-mail"),
dd(text(user.getEmailAddress())), dd(text(user.getEmailAddress())),
dt("Usernames"), dt("Usernames"),
dd( dd(ul(user.getUsernames().stream().map(username -> li(textL(username.getUsername()))).toList())),
ul(
user
.getUsernames()
.stream()
.map(username -> li(textL(username.getUsername())))
.toList()
)
),
dt("Created"), dt("Created"),
dd(text(dateString(user.getDateCreated()))), dd(text(dateString(user.getDateCreated()))),
dt("Program admissions"), dt("Program admissions"),
@ -139,18 +127,14 @@ public class ZipReporter implements Reporter {
user user
.getPrograms() .getPrograms()
.stream() .stream()
.map(program -> .map(program -> li(textL(program.getNameEn() + " (" + program.getCode() + ")")))
li(textL(program.getNameEn() + " (" + program.getCode() + ")"))
)
.toList() .toList()
) )
) )
) )
); );
if (user.getUnit() != null) { if (user.getUnit() != null) {
personalInformation.addAll( personalInformation.addAll(List.of(dt("Unit"), dd(text(user.getUnit().getTitle()))));
List.of(dt("Unit"), dd(text(user.getUnit().getTitle())))
);
} }
if (!user.getLanguages().isEmpty()) { if (!user.getLanguages().isEmpty()) {
final String languages = user final String languages = user
@ -158,9 +142,7 @@ public class ZipReporter implements Reporter {
.stream() .stream()
.map(Language::name) .map(Language::name)
.collect(Collectors.joining(", ")); .collect(Collectors.joining(", "));
personalInformation.addAll( personalInformation.addAll(List.of(dt("Supervising languages"), dd(text(languages))));
List.of(dt("Supervising languages"), dd(text(languages)))
);
} }
if (!user.getResearchAreas().isEmpty()) { if (!user.getResearchAreas().isEmpty()) {
final String researchAreas = user final String researchAreas = user
@ -172,14 +154,7 @@ public class ZipReporter implements Reporter {
} }
final List<Html.Node> reportData = new LinkedList<>( final List<Html.Node> reportData = new LinkedList<>(
Arrays.asList( Arrays.asList(
h1( h1(text("GDPR report for " + user.getFullName() + " generated on " + dateString(new Date()))),
text(
"GDPR report for " +
user.getFullName() +
" generated on " +
dateString(new Date())
)
),
h2(text("Personal data")), h2(text("Personal data")),
dl(personalInformation), dl(personalInformation),
h2(text("Authorships")), h2(text("Authorships")),
@ -344,8 +319,7 @@ public class ZipReporter implements Reporter {
supervisorshipReport.addAll(reviewerInteraction(user, project)); supervisorshipReport.addAll(reviewerInteraction(user, project));
supervisorshipReport.addAll(reviewerApprovals(project)); supervisorshipReport.addAll(reviewerApprovals(project));
final List<SupervisorGradingReport> gradingReports = final List<SupervisorGradingReport> gradingReports = gradingReportService.getSupervisorGradingReports(project);
gradingReportService.getSupervisorGradingReports(project);
for (SupervisorGradingReport gradingReport : gradingReports) { for (SupervisorGradingReport gradingReport : gradingReports) {
if (hasAnyAssessment(gradingReport)) { if (hasAnyAssessment(gradingReport)) {
supervisorshipReport.addAll(gradingReportHtml(gradingReport)); supervisorshipReport.addAll(gradingReportHtml(gradingReport));
@ -538,13 +512,7 @@ public class ZipReporter implements Reporter {
) )
), ),
dt("Language"), dt("Language"),
dd( dd(text(Optional.ofNullable(project.getLanguage()).map(Language::name).orElse("None")))
text(
Optional.ofNullable(project.getLanguage())
.map(Language::name)
.orElse("None")
)
)
) )
) )
) )
@ -554,19 +522,15 @@ public class ZipReporter implements Reporter {
children.addAll(finalSeminarReport(finalSeminar)); children.addAll(finalSeminarReport(finalSeminar));
} }
final List<FinalSeminarOpposition> oppositions = final List<FinalSeminarOpposition> oppositions =
finalSeminarService.findFinalSeminarOppositionsByOpponentAndProjectType( finalSeminarService.findFinalSeminarOppositionsByOpponentAndProjectType(project.getProjectType(), user);
project.getProjectType(),
user
);
if (!oppositions.isEmpty()) { if (!oppositions.isEmpty()) {
List<FinalSeminar> seminars = oppositions List<FinalSeminar> seminars = oppositions.stream().map(FinalSeminarParticipation::getFinalSeminar).toList();
.stream()
.map(FinalSeminarParticipation::getFinalSeminar)
.toList();
children.addAll(oppositionsReport("Oppositions", seminars)); children.addAll(oppositionsReport("Oppositions", seminars));
} }
final List<FinalSeminarActiveParticipation> participations = final List<FinalSeminarActiveParticipation> participations = finalSeminarService.findUserParticipating(
finalSeminarService.findUserParticipating(project, user); project,
user
);
if (!participations.isEmpty()) { if (!participations.isEmpty()) {
List<FinalSeminar> seminars = participations List<FinalSeminar> seminars = participations
.stream() .stream()
@ -574,17 +538,11 @@ public class ZipReporter implements Reporter {
.toList(); .toList();
children.addAll(oppositionsReport("Active participations", seminars)); children.addAll(oppositionsReport("Active participations", seminars));
} }
final List<PeerRequest> peerRequests = peerRequestService.findByRequesterAndProject( final List<PeerRequest> peerRequests = peerRequestService.findByRequesterAndProject(user, project);
user,
project
);
if (!peerRequests.isEmpty()) { if (!peerRequests.isEmpty()) {
children.addAll(peerRequestsReport(peerRequests)); children.addAll(peerRequestsReport(peerRequests));
} }
final List<PeerReview> peerReviews = peerReviewService.findNonExpiredReviewsByProjectAuthor( final List<PeerReview> peerReviews = peerReviewService.findNonExpiredReviewsByProjectAuthor(user, project);
user,
project
);
if (!peerReviews.isEmpty()) { if (!peerReviews.isEmpty()) {
children.addAll(peerReviewsReport(peerReviews)); children.addAll(peerReviewsReport(peerReviews));
} }
@ -592,18 +550,10 @@ public class ZipReporter implements Reporter {
return li(children); return li(children);
} }
private List<Node> oppositionsReport( private List<Node> oppositionsReport(final String heading, final List<FinalSeminar> oppositions) {
final String heading,
final List<FinalSeminar> oppositions
) {
return Arrays.asList( return Arrays.asList(
h4(text(heading)), h4(text(heading)),
ul( ul(oppositions.stream().map(opposition -> li(finalSeminarParticipantReport(opposition))).toList())
oppositions
.stream()
.map(opposition -> li(finalSeminarParticipantReport(opposition)))
.toList()
)
); );
} }
@ -648,9 +598,7 @@ public class ZipReporter implements Reporter {
private List<Node> peerReviewReport(final PeerReview peerReview) { private List<Node> peerReviewReport(final PeerReview peerReview) {
final List<Node> nodes = new LinkedList<>(); final List<Node> nodes = new LinkedList<>();
nodes.addAll( nodes.addAll(Arrays.asList(dt("Started"), dd(text(dateString(peerReview.getDateCreated())))));
Arrays.asList(dt("Started"), dd(text(dateString(peerReview.getDateCreated()))))
);
nodes.addAll(Arrays.asList(dt("Status"), dd(text(peerReview.getStatus().name())))); nodes.addAll(Arrays.asList(dt("Status"), dd(text(peerReview.getStatus().name()))));
if (peerReview.getComment() != null) { if (peerReview.getComment() != null) {
nodes.addAll(Arrays.asList(dt("Comment"), dd(text(peerReview.getComment())))); nodes.addAll(Arrays.asList(dt("Comment"), dd(text(peerReview.getComment()))));
@ -682,9 +630,7 @@ public class ZipReporter implements Reporter {
dd( dd(
text( text(
answer.getAnswer().name() + answer.getAnswer().name() +
Optional.ofNullable( Optional.ofNullable(answer.getMotivation())
answer.getMotivation()
)
.map(m -> " - " + m) .map(m -> " - " + m)
.orElse("") .orElse("")
) )
@ -706,12 +652,7 @@ public class ZipReporter implements Reporter {
private List<Node> peerRequestsReport(final List<PeerRequest> peerRequests) { private List<Node> peerRequestsReport(final List<PeerRequest> peerRequests) {
return Arrays.asList( return Arrays.asList(
h4(text("Peer requests")), h4(text("Peer requests")),
ul( ul(peerRequests.stream().map(peerRequest -> li(peerRequestReport(peerRequest))).toList())
peerRequests
.stream()
.map(peerRequest -> li(peerRequestReport(peerRequest)))
.toList()
)
); );
} }
@ -783,8 +724,7 @@ public class ZipReporter implements Reporter {
return date.toString(); return date.toString();
} }
private void copyFiles(final FileSystem zipFileFS, final List<FileDescription> all) private void copyFiles(final FileSystem zipFileFS, final List<FileDescription> all) throws IOException {
throws IOException {
final Path uploadedFiles = zipFileFS.getPath("Attachments"); final Path uploadedFiles = zipFileFS.getPath("Attachments");
Files.createDirectories(uploadedFiles); Files.createDirectories(uploadedFiles);
for (final FileDescription fileDescription : all) { for (final FileDescription fileDescription : all) {

@ -392,16 +392,10 @@ public class GeneralSystemSettings extends DomainObject {
Objects.equals(this.getReviewerSupportMail(), other.getReviewerSupportMail()) && Objects.equals(this.getReviewerSupportMail(), other.getReviewerSupportMail()) &&
Objects.equals(this.getThesisSupportMail(), other.getThesisSupportMail()) && Objects.equals(this.getThesisSupportMail(), other.getThesisSupportMail()) &&
Objects.equals(this.getExternalRoomBookingURL(), other.getExternalRoomBookingURL()) && Objects.equals(this.getExternalRoomBookingURL(), other.getExternalRoomBookingURL()) &&
Objects.equals( Objects.equals(this.getExternalGettingStartedWithIdeaURL(), other.getExternalGettingStartedWithIdeaURL()) &&
this.getExternalGettingStartedWithIdeaURL(),
other.getExternalGettingStartedWithIdeaURL()
) &&
Objects.equals(this.getExternalGradingURL(), other.getExternalGradingURL()) && Objects.equals(this.getExternalGradingURL(), other.getExternalGradingURL()) &&
this.isFinalSurveyAvailable() == other.isFinalSurveyAvailable() && this.isFinalSurveyAvailable() == other.isFinalSurveyAvailable() &&
Objects.equals( Objects.equals(this.getActiveProjectIdeaSupportMail(), other.getActiveProjectIdeaSupportMail())
this.getActiveProjectIdeaSupportMail(),
other.getActiveProjectIdeaSupportMail()
)
); );
} }

@ -68,13 +68,7 @@ public final class GradingBasis {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(criteria, overallMotivation, locked, rejectionComment, rejectionCommentFeedback);
criteria,
overallMotivation,
locked,
rejectionComment,
rejectionCommentFeedback
);
} }
@Override @Override
@ -151,9 +145,7 @@ public final class GradingBasis {
.stream() .stream()
.mapToInt(Requirement::points) .mapToInt(Requirement::points)
.max() .max()
.orElseThrow(() -> .orElseThrow(() -> new IllegalStateException("Criterion without requirements: " + title()));
new IllegalStateException("Criterion without requirements: " + title())
);
} }
public record Requirement(int points, String description) {} public record Requirement(int points, String description) {}

@ -27,28 +27,18 @@ public class GradingHistory
public List<Event> getTimeline(Project project) { public List<Event> getTimeline(Project project) {
ArrayList<Event> events = new ArrayList<>(); ArrayList<Event> events = new ArrayList<>();
Collection<SubmissionEvent> submissions = gradingHistoryEventRepository.findSubmissions( Collection<SubmissionEvent> submissions = gradingHistoryEventRepository.findSubmissions(project);
project
);
for (SubmissionEvent submission : submissions) { for (SubmissionEvent submission : submissions) {
if (submission.getCorrections() == null || submission.getCorrections().isBlank()) { if (submission.getCorrections() == null || submission.getCorrections().isBlank()) {
events.add( events.add(new Event.InitialSubmission(submission.getWhen(), submission.getAuthor()));
new Event.InitialSubmission(submission.getWhen(), submission.getAuthor())
);
} else { } else {
events.add( events.add(
new Event.Resubmitted( new Event.Resubmitted(submission.getWhen(), submission.getAuthor(), submission.getCorrections())
submission.getWhen(),
submission.getAuthor(),
submission.getCorrections()
)
); );
} }
} }
Collection<RejectionEvent> rejections = gradingHistoryEventRepository.findRejections( Collection<RejectionEvent> rejections = gradingHistoryEventRepository.findRejections(project);
project
);
for (RejectionEvent rejection : rejections) { for (RejectionEvent rejection : rejections) {
events.add(new Event.Rejected(rejection.getWhen(), rejection.getReason())); events.add(new Event.Rejected(rejection.getWhen(), rejection.getReason()));
} }

@ -8,9 +8,7 @@ import java.util.Collection;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractRepository; import se.su.dsv.scipro.system.AbstractRepository;
public class GradingHistoryEventRepositoryImpl public class GradingHistoryEventRepositoryImpl extends AbstractRepository implements GradingHistoryEventRepository {
extends AbstractRepository
implements GradingHistoryEventRepository {
@Inject @Inject
public GradingHistoryEventRepositoryImpl(Provider<EntityManager> em) { public GradingHistoryEventRepositoryImpl(Provider<EntityManager> em) {
@ -25,9 +23,7 @@ public class GradingHistoryEventRepositoryImpl
@Override @Override
public Collection<RejectionEvent> findRejections(Project project) { public Collection<RejectionEvent> findRejections(Project project) {
return from(QRejectionEvent.rejectionEvent) return from(QRejectionEvent.rejectionEvent).where(QRejectionEvent.rejectionEvent.project.eq(project)).fetch();
.where(QRejectionEvent.rejectionEvent.project.eq(project))
.fetch();
} }
@Override @Override
@ -38,9 +34,7 @@ public class GradingHistoryEventRepositoryImpl
@Override @Override
public Collection<ApprovedEvent> findApprovals(Project project) { public Collection<ApprovedEvent> findApprovals(Project project) {
return from(QApprovedEvent.approvedEvent) return from(QApprovedEvent.approvedEvent).where(QApprovedEvent.approvedEvent.project.eq(project)).fetch();
.where(QApprovedEvent.approvedEvent.project.eq(project))
.fetch();
} }
@Override @Override

@ -20,10 +20,7 @@ public record GradingReportTemplateUpdate(
for (GradeLimit gradeLimit1 : gradeLimits) { for (GradeLimit gradeLimit1 : gradeLimits) {
for (GradeLimit gradeLimit2 : gradeLimits) { for (GradeLimit gradeLimit2 : gradeLimits) {
if ( if (gradeLimit1 != gradeLimit2 && gradeLimit1.minimumPoints() == gradeLimit2.minimumPoints()) {
gradeLimit1 != gradeLimit2 &&
gradeLimit1.minimumPoints() == gradeLimit2.minimumPoints()
) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Duplicate minimum points on grades: %s and %s".formatted( "Duplicate minimum points on grades: %s and %s".formatted(
gradeLimit1.grade(), gradeLimit1.grade(),

@ -11,12 +11,7 @@ public interface GradingService {
*/ */
List<Examination> getExaminations(String token, long projectId, long authorId); List<Examination> getExaminations(String token, long projectId, long authorId);
Either<GetGradeError, Optional<Result>> getResult( Either<GetGradeError, Optional<Result>> getResult(String token, long projectId, long authorId, long examinationId);
String token,
long projectId,
long authorId,
long examinationId
);
Either<ReportGradeError, Void> reportGrade( Either<ReportGradeError, Void> reportGrade(
String token, String token,

@ -31,11 +31,7 @@ public class GradingServiceImpl implements GradingService {
} }
@Override @Override
public List<Examination> getExaminations( public List<Examination> getExaminations(final String token, final long projectId, final long authorId) {
final String token,
final long projectId,
final long authorId
) {
final WebTarget client = service(); final WebTarget client = service();
final Response response = client final Response response = client
.path("thesis") .path("thesis")

@ -10,8 +10,7 @@ import java.io.IOException;
public class GradingTypeConverter extends JsonDeserializer<Grade.Type> { public class GradingTypeConverter extends JsonDeserializer<Grade.Type> {
@Override @Override
public Grade.Type deserialize(final JsonParser p, final DeserializationContext ctxt) public Grade.Type deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
throws IOException {
if (p.currentTokenId() == JsonTokenId.ID_STRING) { if (p.currentTokenId() == JsonTokenId.ID_STRING) {
final String text = p.getText(); final String text = p.getText();
switch (text) { switch (text) {
@ -22,12 +21,7 @@ public class GradingTypeConverter extends JsonDeserializer<Grade.Type> {
case "T": case "T":
return Grade.Type.CREDITED; return Grade.Type.CREDITED;
default: default:
throw new InvalidFormatException( throw new InvalidFormatException(p, "Invalid grade type", text, Grade.Type.class);
p,
"Invalid grade type",
text,
Grade.Type.class
);
} }
} }
throw new InvalidFormatException(p, "Grade type must be a string", null, Grade.Type.class); throw new InvalidFormatException(p, "Grade type must be a string", null, Grade.Type.class);

@ -2,7 +2,4 @@ package se.su.dsv.scipro.grading;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
public record Name( public record Name(@JsonProperty("swedish") String swedish, @JsonProperty("english") String english) {}
@JsonProperty("swedish") String swedish,
@JsonProperty("english") String english
) {}

@ -30,9 +30,7 @@ public class NationalSubjectCategoryRepositoryImpl
@Override @Override
public Optional<NationalSubjectCategory> findByExternalId(Integer externalId) { public Optional<NationalSubjectCategory> findByExternalId(Integer externalId) {
NationalSubjectCategory nationalSubjectCategory = from( NationalSubjectCategory nationalSubjectCategory = from(QNationalSubjectCategory.nationalSubjectCategory)
QNationalSubjectCategory.nationalSubjectCategory
)
.where(QNationalSubjectCategory.nationalSubjectCategory.externalId.eq(externalId)) .where(QNationalSubjectCategory.nationalSubjectCategory.externalId.eq(externalId))
.select(QNationalSubjectCategory.nationalSubjectCategory) .select(QNationalSubjectCategory.nationalSubjectCategory)
.fetchOne(); .fetchOne();

@ -9,9 +9,7 @@ public class NationalSubjectCategoryServiceImpl implements NationalSubjectCatego
private final NationalSubjectCategoryRepository nationalSubjectCategoryRepository; private final NationalSubjectCategoryRepository nationalSubjectCategoryRepository;
@Inject @Inject
public NationalSubjectCategoryServiceImpl( public NationalSubjectCategoryServiceImpl(NationalSubjectCategoryRepository nationalSubjectCategoryRepository) {
NationalSubjectCategoryRepository nationalSubjectCategoryRepository
) {
this.nationalSubjectCategoryRepository = nationalSubjectCategoryRepository; this.nationalSubjectCategoryRepository = nationalSubjectCategoryRepository;
} }

@ -7,9 +7,7 @@ import jakarta.transaction.Transactional;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractRepository; import se.su.dsv.scipro.system.AbstractRepository;
public class PublicationMetadataRepositoryImpl public class PublicationMetadataRepositoryImpl extends AbstractRepository implements PublicationMetadataRepository {
extends AbstractRepository
implements PublicationMetadataRepository {
@Inject @Inject
public PublicationMetadataRepositoryImpl(Provider<EntityManager> em) { public PublicationMetadataRepositoryImpl(Provider<EntityManager> em) {

@ -7,8 +7,5 @@ public interface PublicationMetadataService {
void save(PublicationMetadata publicationMetadata); void save(PublicationMetadata publicationMetadata);
boolean hasSuppliedPublicationMetadata( boolean hasSuppliedPublicationMetadata(Project project, boolean noNationalSubjectCategoriesAvailable);
Project project,
boolean noNationalSubjectCategoriesAvailable
);
} }

@ -10,9 +10,7 @@ public class PublicationMetadataServiceImpl implements PublicationMetadataServic
private final PublicationMetadataRepository publicationMetadataRepository; private final PublicationMetadataRepository publicationMetadataRepository;
@Inject @Inject
public PublicationMetadataServiceImpl( public PublicationMetadataServiceImpl(PublicationMetadataRepository publicationMetadataRepository) {
PublicationMetadataRepository publicationMetadataRepository
) {
this.publicationMetadataRepository = publicationMetadataRepository; this.publicationMetadataRepository = publicationMetadataRepository;
} }
@ -34,15 +32,11 @@ public class PublicationMetadataServiceImpl implements PublicationMetadataServic
} }
@Override @Override
public boolean hasSuppliedPublicationMetadata( public boolean hasSuppliedPublicationMetadata(Project project, boolean noNationalSubjectCategoriesAvailable) {
Project project,
boolean noNationalSubjectCategoriesAvailable
) {
final PublicationMetadata metadata = getByProject(project); final PublicationMetadata metadata = getByProject(project);
return ( return (
notBlank(metadata.getAbstractEnglish()) && notBlank(metadata.getAbstractEnglish()) &&
(project.getLanguage() == Language.ENGLISH || (project.getLanguage() == Language.ENGLISH || notBlank(metadata.getAbstractSwedish())) &&
notBlank(metadata.getAbstractSwedish())) &&
(noNationalSubjectCategoriesAvailable || metadata.getNationalSubjectCategory() != null) (noNationalSubjectCategoriesAvailable || metadata.getNationalSubjectCategory() != null)
); );
} }

@ -11,10 +11,7 @@ public class GroupFacadeImpl implements GroupFacade {
return true; return true;
} }
for (Project project : group.getProjects()) { for (Project project : group.getProjects()) {
if ( if (project.getHeadSupervisor().equals(user) || project.getCoSupervisors().contains(user)) {
project.getHeadSupervisor().equals(user) ||
project.getCoSupervisors().contains(user)
) {
return true; return true;
} }
} }

@ -8,8 +8,7 @@ import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface GroupService public interface GroupService extends GenericService<Group, Long>, FilteredService<Group, Long, GroupService.Filter> {
extends GenericService<Group, Long>, FilteredService<Group, Long, GroupService.Filter> {
List<Group> findAll(final Filter filter); List<Group> findAll(final Filter filter);
class Filter implements Serializable { class Filter implements Serializable {

@ -8,7 +8,6 @@ import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
@Transactional @Transactional
public interface ActivityFinalSeminarRepository public interface ActivityFinalSeminarRepository
extends extends JpaRepository<ActivityFinalSeminar, Long>, QueryDslPredicateExecutor<ActivityFinalSeminar> {
JpaRepository<ActivityFinalSeminar, Long>, QueryDslPredicateExecutor<ActivityFinalSeminar> {
Optional<ActivityFinalSeminar> findByFinalSeminar(FinalSeminar finalSeminar); Optional<ActivityFinalSeminar> findByFinalSeminar(FinalSeminar finalSeminar);
} }

@ -18,8 +18,6 @@ public class ActivityFinalSeminarRepositoryImpl
@Override @Override
public Optional<ActivityFinalSeminar> findByFinalSeminar(final FinalSeminar finalSeminar) { public Optional<ActivityFinalSeminar> findByFinalSeminar(final FinalSeminar finalSeminar) {
return Optional.ofNullable( return Optional.ofNullable(findOne(QActivityFinalSeminar.activityFinalSeminar.finalSeminar.eq(finalSeminar)));
findOne(QActivityFinalSeminar.activityFinalSeminar.finalSeminar.eq(finalSeminar))
);
} }
} }

@ -45,27 +45,18 @@ public class FinalSeminarActivityHandler {
synchronizeFinalSeminarActivity(finalSeminar, finalSeminar.getStartDate()); synchronizeFinalSeminarActivity(finalSeminar, finalSeminar.getStartDate());
} }
private void synchronizeFinalSeminarActivity( private void synchronizeFinalSeminarActivity(final FinalSeminar finalSeminar, final Date finalSeminarStartDate) {
final FinalSeminar finalSeminar,
final Date finalSeminarStartDate
) {
final Optional<ActivityFinalSeminar> optFinalSeminarActivity = final Optional<ActivityFinalSeminar> optFinalSeminarActivity =
activityFinalSeminarRepository.findByFinalSeminar(finalSeminar); activityFinalSeminarRepository.findByFinalSeminar(finalSeminar);
if (optFinalSeminarActivity.isPresent()) { if (optFinalSeminarActivity.isPresent()) {
updateActivity( updateActivity(optFinalSeminarActivity.get().getActivity(), finalSeminar.getStartDate());
optFinalSeminarActivity.get().getActivity(),
finalSeminar.getStartDate()
);
} else { } else {
createNewActivity(finalSeminar, finalSeminarStartDate); createNewActivity(finalSeminar, finalSeminarStartDate);
} }
} }
private void createNewActivity( private void createNewActivity(final FinalSeminar finalSeminar, final Date finalSeminarStartDate) {
final FinalSeminar finalSeminar,
final Date finalSeminarStartDate
) {
final Activity activity = Activity.builder() final Activity activity = Activity.builder()
.activityPlan(activityPlanFacade.retrieveActivityPlan(finalSeminar.getProject())) .activityPlan(activityPlanFacade.retrieveActivityPlan(finalSeminar.getProject()))
.date(finalSeminarStartDate) .date(finalSeminarStartDate)
@ -75,10 +66,7 @@ public class FinalSeminarActivityHandler {
.build(); .build();
activity.setAction(Action.FINAL_SEMINAR); activity.setAction(Action.FINAL_SEMINAR);
final Activity savedActivity = activityPlanFacade.saveActivity(activity); final Activity savedActivity = activityPlanFacade.saveActivity(activity);
final ActivityFinalSeminar finalSeminarActivity = new ActivityFinalSeminar( final ActivityFinalSeminar finalSeminarActivity = new ActivityFinalSeminar(savedActivity, finalSeminar);
savedActivity,
finalSeminar
);
activityFinalSeminarRepository.save(finalSeminarActivity); activityFinalSeminarRepository.save(finalSeminarActivity);
} }

@ -148,13 +148,7 @@ class ActivityThread {
@Override @Override
public String toString() { public String toString() {
return ( return ("ActivityThread.Id(threadId=" + this.getThreadId() + ", activityId=" + this.getActivityId() + ")");
"ActivityThread.Id(threadId=" +
this.getThreadId() +
", activityId=" +
this.getActivityId() +
")"
);
} }
} }
} }

@ -37,9 +37,7 @@ public class PostActivityUploadToForum {
final User uploader = fileDescription.getUploader(); final User uploader = fileDescription.getUploader();
final Set<Attachment> attachments = Set.of(Attachment.existing(fileDescription)); final Set<Attachment> attachments = Set.of(Attachment.existing(fileDescription));
final Optional<ProjectThread> activityThread = activityThreadRepository.findByActivity( final Optional<ProjectThread> activityThread = activityThreadRepository.findByActivity(activity);
activity
);
if (activityThread.isPresent()) { if (activityThread.isPresent()) {
final ProjectThread projectThread = activityThread.get(); final ProjectThread projectThread = activityThread.get();
projectForumService.createReply( projectForumService.createReply(

@ -17,21 +17,16 @@ class Failure extends SMTPMailResult {
@Override @Override
public void log(final Logger logger) { public void log(final Logger logger) {
logger.info( logger.info(
"Failed to deliver the mail to all recipients. Specified recipients: " + "Failed to deliver the mail to all recipients. Specified recipients: " + Arrays.toString(getAllRecipients())
Arrays.toString(getAllRecipients())
); );
if (exception.getValidSentAddresses() != null) { if (exception.getValidSentAddresses() != null) {
logger.info("Delivered to: " + Arrays.toString(exception.getValidSentAddresses())); logger.info("Delivered to: " + Arrays.toString(exception.getValidSentAddresses()));
} }
if (exception.getValidUnsentAddresses() != null) { if (exception.getValidUnsentAddresses() != null) {
logger.warn( logger.warn("Could not deliver to: " + Arrays.toString(exception.getValidUnsentAddresses()));
"Could not deliver to: " + Arrays.toString(exception.getValidUnsentAddresses())
);
} }
if (exception.getInvalidAddresses() != null) { if (exception.getInvalidAddresses() != null) {
logger.error( logger.error("Invalid email found: " + Arrays.toString(exception.getInvalidAddresses()));
"Invalid email found: " + Arrays.toString(exception.getInvalidAddresses())
);
} }
} }
} }

@ -8,8 +8,7 @@ import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface MailEventService public interface MailEventService
extends extends GenericService<MailEvent, Long>, FilteredService<MailEvent, Long, MailEventService.Filter> {
GenericService<MailEvent, Long>, FilteredService<MailEvent, Long, MailEventService.Filter> {
Iterable<MailEvent> findUnsent(); Iterable<MailEvent> findUnsent();
class Filter implements Serializable { class Filter implements Serializable {
@ -71,12 +70,7 @@ public interface MailEventService
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(this.getUser(), this.getSubject(), this.getSentAfter(), this.getSentBefore());
this.getUser(),
this.getSubject(),
this.getSentAfter(),
this.getSentBefore()
);
} }
@Override @Override

@ -9,9 +9,7 @@ import java.util.List;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable; import se.su.dsv.scipro.system.Pageable;
public class MailEventServiceImpl public class MailEventServiceImpl extends AbstractServiceImpl<MailEvent, Long> implements MailEventService {
extends AbstractServiceImpl<MailEvent, Long>
implements MailEventService {
@Inject @Inject
public MailEventServiceImpl(Provider<EntityManager> em) { public MailEventServiceImpl(Provider<EntityManager> em) {

@ -37,8 +37,7 @@ public class MailEventWorker extends AbstractWorker {
return; return;
} }
GeneralSystemSettings systemSettings = GeneralSystemSettings systemSettings = systemSettingsService.getGeneralSystemSettingsInstance();
systemSettingsService.getGeneralSystemSettingsInstance();
this.beginTransaction(); this.beginTransaction();
Iterable<MailEvent> unsent = mailEventService.findUnsent(); Iterable<MailEvent> unsent = mailEventService.findUnsent();
@ -52,10 +51,7 @@ public class MailEventWorker extends AbstractWorker {
mailEvent = mailEventService.findOne(mailEvent.getId()); mailEvent = mailEventService.findOne(mailEvent.getId());
String subject = mailEvent.getSubject(); String subject = mailEvent.getSubject();
String fromName = Objects.requireNonNullElse( String fromName = Objects.requireNonNullElse(mailEvent.getFromName(), systemSettings.getMailFromName());
mailEvent.getFromName(),
systemSettings.getMailFromName()
);
String fromEmail = Objects.requireNonNullElse( String fromEmail = Objects.requireNonNullElse(
mailEvent.getFromEmail(), mailEvent.getFromEmail(),
@ -97,8 +93,7 @@ public class MailEventWorker extends AbstractWorker {
private String[] generateRecipients(final MailEvent mailEvent) { private String[] generateRecipients(final MailEvent mailEvent) {
final Set<User> recipients = filteredRecipients(mailEvent.getRecipients()); final Set<User> recipients = filteredRecipients(mailEvent.getRecipients());
final String[] recipientsEmails = new String[recipients.size() + final String[] recipientsEmails = new String[recipients.size() + mailEvent.getNonUserRecipients().size()];
mailEvent.getNonUserRecipients().size()];
int i = 0; int i = 0;
for (User u : recipients) { for (User u : recipients) {
recipientsEmails[i] = u.getEmailAddress(); recipientsEmails[i] = u.getEmailAddress();

@ -11,11 +11,7 @@ public class RedirectingMailer extends SMTPMailer {
private final String redirectTo; private final String redirectTo;
@Inject @Inject
public RedirectingMailer( public RedirectingMailer(final Session session, final String redirectTo, FileService fileDescriptionService) {
final Session session,
final String redirectTo,
FileService fileDescriptionService
) {
super(session, fileDescriptionService); super(session, fileDescriptionService);
this.redirectTo = redirectTo; this.redirectTo = redirectTo;
} }

@ -19,10 +19,7 @@ public class AddActivityPlanOnProjectStart {
} }
@Inject @Inject
public AddActivityPlanOnProjectStart( public AddActivityPlanOnProjectStart(final ActivityPlanFacade activityPlanFacade, final EventBus eventBus) {
final ActivityPlanFacade activityPlanFacade,
final EventBus eventBus
) {
this(activityPlanFacade); this(activityPlanFacade);
eventBus.register(this); eventBus.register(this);
} }
@ -46,11 +43,7 @@ public class AddActivityPlanOnProjectStart {
.atTime(applicationPeriod.getCourseStartTime()) .atTime(applicationPeriod.getCourseStartTime())
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.systemDefault())
.toInstant(); .toInstant();
activityPlanFacade.addActivitiesFromTemplate( activityPlanFacade.addActivitiesFromTemplate(project, template, Date.from(courseStartDate));
project,
template,
Date.from(courseStartDate)
);
}); });
} }
} }

@ -29,12 +29,7 @@ public class ApplicationPeriod extends DomainObject {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@OneToMany( @OneToMany(fetch = FetchType.LAZY, mappedBy = "applicationPeriod", cascade = CascadeType.ALL, orphanRemoval = true)
fetch = FetchType.LAZY,
mappedBy = "applicationPeriod",
cascade = CascadeType.ALL,
orphanRemoval = true
)
private Set<ApplicationPeriodProjectType> projectTypes = new HashSet<>(); private Set<ApplicationPeriodProjectType> projectTypes = new HashSet<>();
private String name; private String name;
@ -51,20 +46,10 @@ public class ApplicationPeriod extends DomainObject {
@Column(name = "course_end_date") @Column(name = "course_end_date")
private LocalDate courseEndDate; private LocalDate courseEndDate;
@OneToMany( @OneToMany(fetch = FetchType.LAZY, mappedBy = "applicationPeriod", cascade = CascadeType.ALL, orphanRemoval = true)
fetch = FetchType.LAZY,
mappedBy = "applicationPeriod",
cascade = CascadeType.ALL,
orphanRemoval = true
)
private Set<ApplicationPeriodExemption> applicationPeriodExemptions = new HashSet<>(); private Set<ApplicationPeriodExemption> applicationPeriodExemptions = new HashSet<>();
@OneToMany( @OneToMany(fetch = FetchType.LAZY, mappedBy = "applicationPeriod", cascade = CascadeType.ALL, orphanRemoval = true)
fetch = FetchType.LAZY,
mappedBy = "applicationPeriod",
cascade = CascadeType.ALL,
orphanRemoval = true
)
private Set<Target> targets = new HashSet<>(); private Set<Target> targets = new HashSet<>();
public ApplicationPeriod() {} public ApplicationPeriod() {}
@ -77,9 +62,7 @@ public class ApplicationPeriod extends DomainObject {
return Collections.unmodifiableSet(applicationPeriodExemptions); return Collections.unmodifiableSet(applicationPeriodExemptions);
} }
public void setApplicationPeriodExemptions( public void setApplicationPeriodExemptions(final Set<ApplicationPeriodExemption> applicationPeriodExemptions) {
final Set<ApplicationPeriodExemption> applicationPeriodExemptions
) {
this.applicationPeriodExemptions = new HashSet<>(applicationPeriodExemptions); this.applicationPeriodExemptions = new HashSet<>(applicationPeriodExemptions);
} }
@ -96,11 +79,7 @@ public class ApplicationPeriod extends DomainObject {
} }
public long noOfExemptedStudents() { public long noOfExemptedStudents() {
return applicationPeriodExemptions return applicationPeriodExemptions.stream().map(ApplicationPeriodExemption::getUser).distinct().count();
.stream()
.map(ApplicationPeriodExemption::getUser)
.distinct()
.count();
} }
public boolean hasApplicationPeriodExemptions() { public boolean hasApplicationPeriodExemptions() {

@ -37,8 +37,7 @@ public class ApplicationPeriodExemption implements Serializable {
@EmbeddedId @EmbeddedId
@AttributeOverride(name = "type", column = @Column(name = "type")) @AttributeOverride(name = "type", column = @Column(name = "type"))
private ApplicationPeriodExemptionId applicationperiodexemptionId = private ApplicationPeriodExemptionId applicationperiodexemptionId = new ApplicationPeriodExemptionId();
new ApplicationPeriodExemptionId();
@MapsId("studentId") @MapsId("studentId")
@ManyToOne(optional = false) @ManyToOne(optional = false)
@ -90,9 +89,7 @@ public class ApplicationPeriodExemption implements Serializable {
return this.grantedOn; return this.grantedOn;
} }
public void setApplicationperiodexemptionId( public void setApplicationperiodexemptionId(ApplicationPeriodExemptionId applicationperiodexemptionId) {
ApplicationPeriodExemptionId applicationperiodexemptionId
) {
this.applicationperiodexemptionId = applicationperiodexemptionId; this.applicationperiodexemptionId = applicationperiodexemptionId;
} }
@ -158,10 +155,7 @@ public class ApplicationPeriodExemption implements Serializable {
final ApplicationPeriodExemption other = (ApplicationPeriodExemption) o; final ApplicationPeriodExemption other = (ApplicationPeriodExemption) o;
return ( return (
other.canEqual(this) && other.canEqual(this) &&
Objects.equals( Objects.equals(this.getApplicationperiodexemptionId(), other.getApplicationperiodexemptionId()) &&
this.getApplicationperiodexemptionId(),
other.getApplicationperiodexemptionId()
) &&
Objects.equals(this.getEndDate(), other.getEndDate()) && Objects.equals(this.getEndDate(), other.getEndDate()) &&
Objects.equals(this.getType(), other.getType()) Objects.equals(this.getType(), other.getType())
); );
@ -173,10 +167,6 @@ public class ApplicationPeriodExemption implements Serializable {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(this.getApplicationperiodexemptionId(), this.getEndDate(), this.getType());
this.getApplicationperiodexemptionId(),
this.getEndDate(),
this.getType()
);
} }
} }

@ -15,8 +15,7 @@ import se.su.dsv.scipro.system.ProjectType;
public class ApplicationPeriodProjectType implements Serializable { public class ApplicationPeriodProjectType implements Serializable {
@EmbeddedId @EmbeddedId
private ApplicationPeriodProjectTypeId applicationPeriodProjectTypeId = private ApplicationPeriodProjectTypeId applicationPeriodProjectTypeId = new ApplicationPeriodProjectTypeId();
new ApplicationPeriodProjectTypeId();
@MapsId("applicationPeriodId") @MapsId("applicationPeriodId")
@ManyToOne @ManyToOne
@ -34,10 +33,7 @@ public class ApplicationPeriodProjectType implements Serializable {
protected ApplicationPeriodProjectType() {} protected ApplicationPeriodProjectType() {}
public ApplicationPeriodProjectType( public ApplicationPeriodProjectType(ApplicationPeriod applicationPeriod, ProjectType projectType) {
ApplicationPeriod applicationPeriod,
ProjectType projectType
) {
this.applicationPeriod = applicationPeriod; this.applicationPeriod = applicationPeriod;
this.projectType = projectType; this.projectType = projectType;
} }

@ -5,8 +5,5 @@ import se.su.dsv.scipro.system.ProjectType;
public interface ApplicationPeriodProjectTypeService public interface ApplicationPeriodProjectTypeService
extends GenericService<ApplicationPeriodProjectType, ApplicationPeriodProjectTypeId> { extends GenericService<ApplicationPeriodProjectType, ApplicationPeriodProjectTypeId> {
ApplicationPeriodProjectType findOne( ApplicationPeriodProjectType findOne(ApplicationPeriod applicationPeriod, ProjectType projectType);
ApplicationPeriod applicationPeriod,
ProjectType projectType
);
} }

@ -13,30 +13,19 @@ public class ApplicationPeriodProjectTypeServiceImpl
@Inject @Inject
public ApplicationPeriodProjectTypeServiceImpl(Provider<EntityManager> em) { public ApplicationPeriodProjectTypeServiceImpl(Provider<EntityManager> em) {
super( super(em, ApplicationPeriodProjectType.class, QApplicationPeriodProjectType.applicationPeriodProjectType);
em,
ApplicationPeriodProjectType.class,
QApplicationPeriodProjectType.applicationPeriodProjectType
);
} }
@Override @Override
public ApplicationPeriodProjectType findOne( public ApplicationPeriodProjectType findOne(ApplicationPeriod applicationPeriod, ProjectType projectType) {
ApplicationPeriod applicationPeriod,
ProjectType projectType
) {
return findOne(byApplicationPeriod(applicationPeriod).and(byProjectType(projectType))); return findOne(byApplicationPeriod(applicationPeriod).and(byProjectType(projectType)));
} }
public static BooleanExpression byApplicationPeriod(ApplicationPeriod applicationPeriod) { public static BooleanExpression byApplicationPeriod(ApplicationPeriod applicationPeriod) {
return QApplicationPeriodProjectType.applicationPeriodProjectType.applicationPeriod.eq( return QApplicationPeriodProjectType.applicationPeriodProjectType.applicationPeriod.eq(applicationPeriod);
applicationPeriod
);
} }
public static BooleanExpression byProjectType(ProjectType projectType) { public static BooleanExpression byProjectType(ProjectType projectType) {
return QApplicationPeriodProjectType.applicationPeriodProjectType.projectType.eq( return QApplicationPeriodProjectType.applicationPeriodProjectType.projectType.eq(projectType);
projectType
);
} }
} }

@ -11,10 +11,7 @@ public interface ApplicationPeriodService extends GenericService<ApplicationPeri
List<StudentPeriod> getCurrentStudentPeriods(final User student); List<StudentPeriod> getCurrentStudentPeriods(final User student);
List<ProjectType> getTypesForStudent(ApplicationPeriod applicationPeriod, User student); List<ProjectType> getTypesForStudent(ApplicationPeriod applicationPeriod, User student);
List<ApplicationPeriod> getCurrentSupervisorPeriods(User supervisor); List<ApplicationPeriod> getCurrentSupervisorPeriods(User supervisor);
Collection<ApplicationPeriod> getPreviousPeriods( Collection<ApplicationPeriod> getPreviousPeriods(ApplicationPeriod applicationPeriod, int limit);
ApplicationPeriod applicationPeriod,
int limit
);
ApplicationPeriod getCurrentPeriod(final ProjectType pc); ApplicationPeriod getCurrentPeriod(final ProjectType pc);
ApplicationPeriod getPreviousPeriodByProjectType(ProjectType projectType); ApplicationPeriod getPreviousPeriodByProjectType(ProjectType projectType);
boolean courseStartHasPassed(final ApplicationPeriod ap); boolean courseStartHasPassed(final ApplicationPeriod ap);

@ -46,25 +46,20 @@ public class ApplicationPeriodServiceImpl
public List<StudentPeriod> getCurrentStudentPeriods(User student) { public List<StudentPeriod> getCurrentStudentPeriods(User student) {
LocalDate currentDate = LocalDate.now(clock); LocalDate currentDate = LocalDate.now(clock);
Set<ApplicationPeriod> phs = new HashSet<>(getCurrentPeriods(currentDate)); Set<ApplicationPeriod> phs = new HashSet<>(getCurrentPeriods(currentDate));
QApplicationPeriodExemption exemption = QApplicationPeriodExemption exemption = QApplicationPeriodExemption.applicationPeriodExemption;
QApplicationPeriodExemption.applicationPeriodExemption;
final List<ApplicationPeriodExemption> currentExemptions = from(exemption) final List<ApplicationPeriodExemption> currentExemptions = from(exemption)
.where( .where(
allOf( allOf(exemption.user.eq(student), anyOf(exemption.endDate.goe(currentDate), exemption.endDate.isNull()))
exemption.user.eq(student),
anyOf(exemption.endDate.goe(currentDate), exemption.endDate.isNull())
)
) )
.fetch(); .fetch();
final Map<ApplicationPeriod, List<ApplicationPeriodExemption.Type>> periodExemptions = final Map<ApplicationPeriod, List<ApplicationPeriodExemption.Type>> periodExemptions = currentExemptions
currentExemptions .stream()
.stream() .collect(
.collect( Collectors.groupingBy(
Collectors.groupingBy( ApplicationPeriodExemption::getApplicationPeriod,
ApplicationPeriodExemption::getApplicationPeriod, Collectors.mapping(ApplicationPeriodExemption::getType, Collectors.toList())
Collectors.mapping(ApplicationPeriodExemption::getType, Collectors.toList()) )
) );
);
final List<StudentPeriod> studentPeriods = new ArrayList<>(); final List<StudentPeriod> studentPeriods = new ArrayList<>();
for (ApplicationPeriod openApplicationPeriod : phs) { for (ApplicationPeriod openApplicationPeriod : phs) {
@ -97,10 +92,7 @@ public class ApplicationPeriodServiceImpl
@Override @Override
public List<ProjectType> getTypesForStudent(ApplicationPeriod applicationPeriod, User student) { public List<ProjectType> getTypesForStudent(ApplicationPeriod applicationPeriod, User student) {
if ( if (student.getDegreeType() == DegreeType.NONE || hasTypeExemption(applicationPeriod, student)) {
student.getDegreeType() == DegreeType.NONE ||
hasTypeExemption(applicationPeriod, student)
) {
return new ArrayList<>(applicationPeriod.getProjectTypes()); return new ArrayList<>(applicationPeriod.getProjectTypes());
} else { } else {
return applicationPeriod return applicationPeriod
@ -114,11 +106,7 @@ public class ApplicationPeriodServiceImpl
private boolean hasTypeExemption(ApplicationPeriod applicationPeriod, User student) { private boolean hasTypeExemption(ApplicationPeriod applicationPeriod, User student) {
return ( return (
null != null !=
getExemptionForExemptionType( getExemptionForExemptionType(applicationPeriod, student, ApplicationPeriodExemption.Type.PROJECT_TYPE)
applicationPeriod,
student,
ApplicationPeriodExemption.Type.PROJECT_TYPE
)
); );
} }
@ -127,8 +115,7 @@ public class ApplicationPeriodServiceImpl
User student, User student,
ApplicationPeriodExemption.Type type ApplicationPeriodExemption.Type type
) { ) {
final QApplicationPeriodExemption QApe = final QApplicationPeriodExemption QApe = QApplicationPeriodExemption.applicationPeriodExemption;
QApplicationPeriodExemption.applicationPeriodExemption;
return from(QApe) return from(QApe)
.where( .where(
allOf( allOf(
@ -144,27 +131,18 @@ public class ApplicationPeriodServiceImpl
public boolean hasIdeaSizeExemption(User student, ApplicationPeriod applicationPeriod) { public boolean hasIdeaSizeExemption(User student, ApplicationPeriod applicationPeriod) {
return ( return (
null != null !=
getExemptionForExemptionType( getExemptionForExemptionType(applicationPeriod, student, ApplicationPeriodExemption.Type.NUMBER_OF_AUTHORS)
applicationPeriod,
student,
ApplicationPeriodExemption.Type.NUMBER_OF_AUTHORS
)
); );
} }
@Override @Override
public List<ApplicationPeriod> getCurrentSupervisorPeriods(final User supervisor) { public List<ApplicationPeriod> getCurrentSupervisorPeriods(final User supervisor) {
LocalDateTime now = LocalDateTime.now(clock); LocalDateTime now = LocalDateTime.now(clock);
return findAll( return findAll(Expressions.allOf(startedBeforeOrAt(now.toLocalDate()), courseStartAfterOrAt(now)));
Expressions.allOf(startedBeforeOrAt(now.toLocalDate()), courseStartAfterOrAt(now))
);
} }
@Override @Override
public Collection<ApplicationPeriod> getPreviousPeriods( public Collection<ApplicationPeriod> getPreviousPeriods(ApplicationPeriod applicationPeriod, int limit) {
ApplicationPeriod applicationPeriod,
int limit
) {
return findAll( return findAll(
endedBefore(applicationPeriod.getStartDate()), endedBefore(applicationPeriod.getStartDate()),
new PageRequest(0, limit, new Sort(Sort.Direction.DESC, "startDate")) new PageRequest(0, limit, new Sort(Sort.Direction.DESC, "startDate"))
@ -179,9 +157,7 @@ public class ApplicationPeriodServiceImpl
@Transactional @Transactional
public ApplicationPeriod getCurrentPeriod(ProjectType pc) { public ApplicationPeriod getCurrentPeriod(ProjectType pc) {
final LocalDate currentDate = LocalDate.now(clock); final LocalDate currentDate = LocalDate.now(clock);
return findOne( return findOne(startedBeforeOrAt(currentDate).and(endedAfterOrAt(currentDate)).and(haveProjectType(pc)));
startedBeforeOrAt(currentDate).and(endedAfterOrAt(currentDate)).and(haveProjectType(pc))
);
} }
@Override @Override
@ -218,11 +194,7 @@ public class ApplicationPeriodServiceImpl
@Override @Override
public boolean hasCurrentSelectSupervisorIdeaExemption(ApplicationPeriod ap, User student) { public boolean hasCurrentSelectSupervisorIdeaExemption(ApplicationPeriod ap, User student) {
return hasCurrentExemption( return hasCurrentExemption(ap, student, ApplicationPeriodExemption.Type.SELECT_SUPERVISOR_IDEA);
ap,
student,
ApplicationPeriodExemption.Type.SELECT_SUPERVISOR_IDEA
);
} }
private boolean hasCurrentExemption( private boolean hasCurrentExemption(
@ -231,24 +203,13 @@ public class ApplicationPeriodServiceImpl
ApplicationPeriodExemption.Type type ApplicationPeriodExemption.Type type
) { ) {
final LocalDate today = LocalDate.now(); final LocalDate today = LocalDate.now();
final ApplicationPeriodExemption exemption = getExemptionForExemptionType( final ApplicationPeriodExemption exemption = getExemptionForExemptionType(applicationPeriod, student, type);
applicationPeriod,
student,
type
);
return exemption != null && !today.isAfter(exemption.getEndDate()); return exemption != null && !today.isAfter(exemption.getEndDate());
} }
@Override @Override
public boolean hasCurrentSubmitIdeaExemption( public boolean hasCurrentSubmitIdeaExemption(ApplicationPeriod applicationPeriod, User student) {
ApplicationPeriod applicationPeriod, return hasCurrentExemption(applicationPeriod, student, ApplicationPeriodExemption.Type.SUBMIT_STUDENT_IDEA);
User student
) {
return hasCurrentExemption(
applicationPeriod,
student,
ApplicationPeriodExemption.Type.SUBMIT_STUDENT_IDEA
);
} }
@Override @Override
@ -275,40 +236,24 @@ public class ApplicationPeriodServiceImpl
@Override @Override
public List<ApplicationPeriod> findUpcomingPeriods() { public List<ApplicationPeriod> findUpcomingPeriods() {
return findAll( return findAll(QApplicationPeriod.applicationPeriod.courseStartDateTime.after(LocalDateTime.now(clock)));
QApplicationPeriod.applicationPeriod.courseStartDateTime.after(LocalDateTime.now(clock))
);
} }
@Override @Override
public boolean isVisibleForSupervisors(final ApplicationPeriod applicationPeriod) { public boolean isVisibleForSupervisors(final ApplicationPeriod applicationPeriod) {
final LocalDate now = LocalDate.now(clock); final LocalDate now = LocalDate.now(clock);
return !( return !(now.isBefore(applicationPeriod.getStartDate()) || now.isAfter(applicationPeriod.getCourseStartDate()));
now.isBefore(applicationPeriod.getStartDate()) ||
now.isAfter(applicationPeriod.getCourseStartDate())
);
} }
private boolean periodsOverlap( private boolean periodsOverlap(LocalDate p1Start, LocalDate p1End, LocalDate p2Start, LocalDate p2End) {
LocalDate p1Start,
LocalDate p1End,
LocalDate p2Start,
LocalDate p2End
) {
return p2Start.isBefore(p1End) && p2End.isAfter(p1Start); return p2Start.isBefore(p1End) && p2End.isAfter(p1Start);
} }
private boolean isEditing( private boolean isEditing(final ApplicationPeriod newPeriod, final ApplicationPeriod foundPeriod) {
final ApplicationPeriod newPeriod,
final ApplicationPeriod foundPeriod
) {
return (newPeriod.getId() != null && newPeriod.equals(foundPeriod)); return (newPeriod.getId() != null && newPeriod.equals(foundPeriod));
} }
private boolean projectTypeMatch( private boolean projectTypeMatch(final Set<ProjectType> fromNewPeriod, final Set<ProjectType> fromOldPeriod) {
final Set<ProjectType> fromNewPeriod,
final Set<ProjectType> fromOldPeriod
) {
for (ProjectType projectType : fromNewPeriod) { for (ProjectType projectType : fromNewPeriod) {
if (fromOldPeriod.contains(projectType)) { if (fromOldPeriod.contains(projectType)) {
return true; return true;

Some files were not shown because too many files have changed in this diff Show More