Enforce code formatting via Prettier #44

Merged
tozh4728 merged 6 commits from prettier into develop 2024-12-02 14:18:04 +01:00
976 changed files with 4203 additions and 15172 deletions
Showing only changes of commit b599ab9a94 - Show all commits

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.system.GenericRepo;
public class AbstractThreadRepositoryImpl
extends GenericRepo<ForumThread, Long>
implements AbstractThreadRepository {
public class AbstractThreadRepositoryImpl extends GenericRepo<ForumThread, Long> implements AbstractThreadRepository {
@Inject
public AbstractThreadRepositoryImpl(Provider<EntityManager> em) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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