Enforce code formatting via Prettier #44

Merged
tozh4728 merged 6 commits from prettier into develop 2024-12-02 14:18:04 +01:00
1682 changed files with 41209 additions and 27692 deletions

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
# Prettier enforces LF line endings in all files
# If git is configured with core.autocrlf=true, it may convert LF to CRLF when
# checking out files depending on your OS. This will cause Prettier to change it
# causing Git to show every file as modified.
*.java text eol=lf

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ fitnesse/target/
daisy-integration/target/ daisy-integration/target/
war/target/ war/target/
api/target/ api/target/
node_modules/

4
.prettierrc.yaml Normal file
View File

@ -0,0 +1,4 @@
tabWidth: 4
printWidth: 120
plugins:
- prettier-plugin-java

View File

@ -11,3 +11,17 @@ and get an access token.
Once the token has been obtained go to the [Swagger UI](http://localhost:8080/api/swagger) to interact with the API. Once the token has been obtained go to the [Swagger UI](http://localhost:8080/api/swagger) to interact with the API.
Click the "Authorize" button in the top right and paste the access token to log in. Click the "Authorize" button in the top right and paste the access token to log in.
## Code formatting
This project uses [prettier-java](https://github.com/jhipster/prettier-java)
to format all Java code. To reformat the code run
`./mvnw validate frontend:npm@reformat -pl .`.
Yes it's a mouthful but unfortunately the [prettier-maven-plugin](https://github.com/HubSpot/prettier-maven-plugin)
does not work due to an [outstanding issue](https://github.com/HubSpot/prettier-maven-plugin/issues/79).
An easier way to reformat code is to set IntelliJ to do it on save. Go to
`Settings -> Language & Frameworks -> JavaScript -> Prettier` and then check
`Automatic Prettier Configuration`, set `Run for files` to `**/*.{java}`,
and finally check `Run on save`.
The formatting is validated by CI, but you should do it beforehand with a simple `./mvnw verify -pl .`.

View File

@ -1,16 +1,16 @@
package se.su.dsv.scipro.api; package se.su.dsv.scipro.api;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import java.util.Optional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import se.su.dsv.scipro.system.UserService; import se.su.dsv.scipro.system.UserService;
import java.util.Optional;
@RestController @RestController
public class ApiController { public class ApiController {
private final UserService userService; private final UserService userService;
@Inject @Inject

View File

@ -3,6 +3,8 @@ package se.su.dsv.scipro;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.time.Clock;
import java.util.Set;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -201,11 +203,9 @@ import se.su.dsv.scipro.system.UserServiceImpl;
import se.su.dsv.scipro.thesislink.ExternalLinkServiceImpl; import se.su.dsv.scipro.thesislink.ExternalLinkServiceImpl;
import se.su.dsv.scipro.workerthreads.WorkerDataServiceImpl; import se.su.dsv.scipro.workerthreads.WorkerDataServiceImpl;
import java.time.Clock;
import java.util.Set;
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
public class CoreConfig { public class CoreConfig {
@Bean @Bean
public EventBus eventBus() { public EventBus eventBus() {
return new EventBus(); return new EventBus();
@ -221,8 +221,8 @@ public class CoreConfig {
@Value("${oauth.uri}") String uri, @Value("${oauth.uri}") String uri,
@Value("${oauth.redirectUri}") String redirectUri, @Value("${oauth.redirectUri}") String redirectUri,
@Value("${oauth.clientId}") String clientId, @Value("${oauth.clientId}") String clientId,
@Value("${oauth.clientSecret}") String clientSecret) @Value("${oauth.clientSecret}") String clientSecret
{ ) {
return new OAuthSettings(uri, redirectUri, clientId, clientSecret); return new OAuthSettings(uri, redirectUri, clientId, clientSecret);
} }
@ -235,8 +235,8 @@ public class CoreConfig {
public DaisyAPIImpl daisyAPI( public DaisyAPIImpl daisyAPI(
@Value("${daisy.api.url}") final String baseUrl, @Value("${daisy.api.url}") final String baseUrl,
@Value("${daisy.api.username}") final String user, @Value("${daisy.api.username}") final String user,
@Value("${daisy.api.password}") final String password) @Value("${daisy.api.password}") final String password
{ ) {
return new DaisyAPIImpl(baseUrl, user, password); return new DaisyAPIImpl(baseUrl, user, password);
} }
@ -256,9 +256,15 @@ public class CoreConfig {
FileService fileDescriptionService, FileService fileDescriptionService,
EventBus eventBus, EventBus eventBus,
DaysService daysService, DaysService daysService,
ReviewerDeadlineSettingsService reviewerDeadlineSettingsService) ReviewerDeadlineSettingsService reviewerDeadlineSettingsService
{ ) {
return new FinalSeminarApprovalServiceImpl(em, fileDescriptionService, eventBus, daysService, reviewerDeadlineSettingsService); return new FinalSeminarApprovalServiceImpl(
em,
fileDescriptionService,
eventBus,
daysService,
reviewerDeadlineSettingsService
);
} }
@Bean @Bean
@ -267,9 +273,15 @@ public class CoreConfig {
FileService fileDescriptionService, FileService fileDescriptionService,
EventBus eventBus, EventBus eventBus,
DaysService daysService, DaysService daysService,
ReviewerDeadlineSettingsService reviewerDeadlineSettingsService) ReviewerDeadlineSettingsService reviewerDeadlineSettingsService
{ ) {
return new RoughDraftApprovalServiceImpl(em, eventBus, fileDescriptionService, daysService, reviewerDeadlineSettingsService); return new RoughDraftApprovalServiceImpl(
em,
eventBus,
fileDescriptionService,
daysService,
reviewerDeadlineSettingsService
);
} }
@Bean @Bean
@ -294,10 +306,14 @@ public class CoreConfig {
ChecklistTemplateService checklistTemplateService, ChecklistTemplateService checklistTemplateService,
DaysService daysService, DaysService daysService,
FileService fileService FileService fileService
) ) {
{ return new ActivityPlanFacadeImpl(
return new ActivityPlanFacadeImpl(eventBus, projectFileService, checklistTemplateService, daysService, eventBus,
fileService); projectFileService,
checklistTemplateService,
daysService,
fileService
);
} }
@Bean @Bean
@ -321,10 +337,7 @@ public class CoreConfig {
} }
@Bean @Bean
public LocalAuthentication localAuthentication( public LocalAuthentication localAuthentication(UserService userService, PasswordService passwordService) {
UserService userService,
PasswordService passwordService)
{
return new LocalAuthentication(userService, passwordService); return new LocalAuthentication(userService, passwordService);
} }
@ -334,10 +347,15 @@ public class CoreConfig {
ForumPostReadStateRepository readStateRepository, ForumPostReadStateRepository readStateRepository,
AbstractThreadRepository threadRepository, AbstractThreadRepository threadRepository,
FileService fileService, FileService fileService,
EventBus eventBus) EventBus eventBus
{ ) {
return new BasicForumServiceImpl(forumPostRepository, readStateRepository, threadRepository, fileService, return new BasicForumServiceImpl(
eventBus); forumPostRepository,
readStateRepository,
threadRepository,
fileService,
eventBus
);
} }
@Bean @Bean
@ -373,8 +391,8 @@ public class CoreConfig {
@Bean @Bean
public DeliveryConfigurationServiceImpl deliveryConfigurationService( public DeliveryConfigurationServiceImpl deliveryConfigurationService(
Provider<EntityManager> em, Provider<EntityManager> em,
UserProfileService userProfileService) UserProfileService userProfileService
{ ) {
return new DeliveryConfigurationServiceImpl(em, userProfileService); return new DeliveryConfigurationServiceImpl(em, userProfileService);
} }
@ -398,13 +416,15 @@ public class CoreConfig {
Provider<EntityManager> em, Provider<EntityManager> em,
FileStore fileStore, FileStore fileStore,
FileReferenceRepository fileReferenceRepository, FileReferenceRepository fileReferenceRepository,
FileDescriptionRepo fileDescriptionRepository) FileDescriptionRepo fileDescriptionRepository
{ ) {
return new FileServiceImpl(em, fileReferenceRepository, fileDescriptionRepository, fileStore); return new FileServiceImpl(em, fileReferenceRepository, fileDescriptionRepository, fileStore);
} }
@Bean @Bean
public FinalSeminarActiveParticipationServiceImpl finalSeminarActiveParticipationService(Provider<EntityManager> em) { public FinalSeminarActiveParticipationServiceImpl finalSeminarActiveParticipationService(
Provider<EntityManager> em
) {
return new FinalSeminarActiveParticipationServiceImpl(em); return new FinalSeminarActiveParticipationServiceImpl(em);
} }
@ -428,8 +448,8 @@ public class CoreConfig {
FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository, FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository,
FinalSeminarRepository finalSeminarRepository, FinalSeminarRepository finalSeminarRepository,
Clock clock, Clock clock,
RoughDraftApprovalService roughDraftApprovalService) RoughDraftApprovalService roughDraftApprovalService
{ ) {
return new FinalSeminarServiceImpl( return new FinalSeminarServiceImpl(
em, em,
eventBus, eventBus,
@ -439,7 +459,8 @@ public class CoreConfig {
finalSeminarActiveParticipationRepository, finalSeminarActiveParticipationRepository,
finalSeminarRepository, finalSeminarRepository,
clock, clock,
roughDraftApprovalService); roughDraftApprovalService
);
} }
@Bean @Bean
@ -455,10 +476,17 @@ public class CoreConfig {
ProjectFileService projectFileService, ProjectFileService projectFileService,
ProjectService projectService, ProjectService projectService,
FinalSeminarSettingsService finalSeminarSettingsService, FinalSeminarSettingsService finalSeminarSettingsService,
PlagiarismControl plagiarismControl) PlagiarismControl plagiarismControl
{ ) {
return new FinalSeminarUploadControllerImpl(projectService, fileService, finalSeminarSettingsService, return new FinalSeminarUploadControllerImpl(
finalSeminarService, eventBus, projectFileService, plagiarismControl); projectService,
fileService,
finalSeminarSettingsService,
finalSeminarService,
eventBus,
projectFileService,
plagiarismControl
);
} }
@Bean @Bean
@ -469,17 +497,24 @@ public class CoreConfig {
FileService fileService, FileService fileService,
EventBus eventBus, EventBus eventBus,
PlagiarismControl plagiarismControl, PlagiarismControl plagiarismControl,
GradingReportService gradingReportService) GradingReportService gradingReportService
{ ) {
return new FinalThesisServiceImpl(em, notification, projectFile, return new FinalThesisServiceImpl(
fileService, eventBus, plagiarismControl, gradingReportService); em,
notification,
projectFile,
fileService,
eventBus,
plagiarismControl,
gradingReportService
);
} }
@Bean @Bean
public FirstMeetingServiceImpl firstMeetingService( public FirstMeetingServiceImpl firstMeetingService(
Provider<EntityManager> em, Provider<EntityManager> em,
ActivityPlanFacade activityPlanFacade) ActivityPlanFacade activityPlanFacade
{ ) {
return new FirstMeetingServiceImpl(em, activityPlanFacade); return new FirstMeetingServiceImpl(em, activityPlanFacade);
} }
@ -505,23 +540,24 @@ public class CoreConfig {
Clock clock, Clock clock,
SupervisorGradingReportRepository supervisorGradingReportRepository, SupervisorGradingReportRepository supervisorGradingReportRepository,
GradingReportTemplateRepoImpl gradingReportTemplateRepo, GradingReportTemplateRepoImpl gradingReportTemplateRepo,
ProjectTypeService projectTypeService) ProjectTypeService projectTypeService
{ ) {
return new GradingReportServiceImpl( return new GradingReportServiceImpl(
eventBus, eventBus,
thesisSubmissionHistoryService, thesisSubmissionHistoryService,
clock, clock,
supervisorGradingReportRepository, supervisorGradingReportRepository,
gradingReportTemplateRepo, gradingReportTemplateRepo,
projectTypeService); projectTypeService
);
} }
@Bean @Bean
public GroupForumServiceImpl groupForumService( public GroupForumServiceImpl groupForumService(
EventBus eventBus, EventBus eventBus,
GroupThreadRepository groupThreadRepository, GroupThreadRepository groupThreadRepository,
BasicForumService basicForumService) BasicForumService basicForumService
{ ) {
return new GroupForumServiceImpl(groupThreadRepository, basicForumService, eventBus); return new GroupForumServiceImpl(groupThreadRepository, basicForumService, eventBus);
} }
@ -540,10 +576,19 @@ public class CoreConfig {
GeneralSystemSettingsService generalSystemSettingsService, GeneralSystemSettingsService generalSystemSettingsService,
TargetRepository targetRepository, TargetRepository targetRepository,
IdeaRepository ideaRepository, IdeaRepository ideaRepository,
Clock clock) Clock clock
{ ) {
return new IdeaServiceImpl(em, applicationPeriodService, firstMeetingRepository, notificationController, return new IdeaServiceImpl(
projectService, generalSystemSettingsService, targetRepository, ideaRepository, clock); em,
applicationPeriodService,
firstMeetingRepository,
notificationController,
projectService,
generalSystemSettingsService,
targetRepository,
ideaRepository,
clock
);
} }
@Bean @Bean
@ -573,8 +618,8 @@ public class CoreConfig {
@Bean @Bean
public MilestoneActivityTemplateServiceImpl milestoneActivityTemplateService( public MilestoneActivityTemplateServiceImpl milestoneActivityTemplateService(
MilestoneActivityTemplateRepository milestoneActivityTemplateRepository) MilestoneActivityTemplateRepository milestoneActivityTemplateRepository
{ ) {
return new MilestoneActivityTemplateServiceImpl(milestoneActivityTemplateRepository); return new MilestoneActivityTemplateServiceImpl(milestoneActivityTemplateRepository);
} }
@ -586,8 +631,8 @@ public class CoreConfig {
@Bean @Bean
public MilestoneServiceImpl milestoneService( public MilestoneServiceImpl milestoneService(
Provider<EntityManager> em, Provider<EntityManager> em,
NotificationController notificationController) NotificationController notificationController
{ ) {
return new MilestoneServiceImpl(notificationController, em); return new MilestoneServiceImpl(notificationController, em);
} }
@ -598,8 +643,8 @@ public class CoreConfig {
@Bean @Bean
public NationalSubjectCategoryServiceImpl nationalSubjectCategoryService( public NationalSubjectCategoryServiceImpl nationalSubjectCategoryService(
NationalSubjectCategoryRepository nationalSubjectCategoryRepository) NationalSubjectCategoryRepository nationalSubjectCategoryRepository
{ ) {
return new NationalSubjectCategoryServiceImpl(nationalSubjectCategoryRepository); return new NationalSubjectCategoryServiceImpl(nationalSubjectCategoryRepository);
} }
@ -623,10 +668,14 @@ public class CoreConfig {
OppositionReportRepo oppositionReportRepository, OppositionReportRepo oppositionReportRepository,
GradingReportTemplateRepo gradingReportTemplateRepository, GradingReportTemplateRepo gradingReportTemplateRepository,
FileService fileService, FileService fileService,
FinalSeminarOppositionRepo finalSeminarOppositionRepository) FinalSeminarOppositionRepo finalSeminarOppositionRepository
{ ) {
return new OppositionReportServiceImpl(oppositionReportRepository, gradingReportTemplateRepository, return new OppositionReportServiceImpl(
fileService, finalSeminarOppositionRepository); oppositionReportRepository,
gradingReportTemplateRepository,
fileService,
finalSeminarOppositionRepository
);
} }
@Bean @Bean
@ -642,26 +691,33 @@ public class CoreConfig {
EventBus eventBus, EventBus eventBus,
ProjectFileService projectFileService, ProjectFileService projectFileService,
DaysService daisyService, DaysService daisyService,
Clock clock) Clock clock
{ ) {
return new PeerPortalImpl(fileService, peerReviewRepository, peerRequestRepository, return new PeerPortalImpl(
eventBus, projectFileService, daisyService, clock); fileService,
peerReviewRepository,
peerRequestRepository,
eventBus,
projectFileService,
daisyService,
clock
);
} }
@Bean @Bean
public PeerRequestServiceImpl peerRequestService( public PeerRequestServiceImpl peerRequestService(
Provider<EntityManager> em, Provider<EntityManager> em,
EventBus eventBus, EventBus eventBus,
FileService fileService) FileService fileService
{ ) {
return new PeerRequestServiceImpl(em, eventBus, fileService); return new PeerRequestServiceImpl(em, eventBus, fileService);
} }
@Bean @Bean
public PeerReviewServiceImpl peerReviewService( public PeerReviewServiceImpl peerReviewService(
Provider<EntityManager> em, Provider<EntityManager> em,
PeerReviewRepository peerReviewRepository) PeerReviewRepository peerReviewRepository
{ ) {
return new PeerReviewServiceImpl(em, peerReviewRepository); return new PeerReviewServiceImpl(em, peerReviewRepository);
} }
@ -669,8 +725,8 @@ public class CoreConfig {
public PlagiarismControlImpl plagiarismControl( public PlagiarismControlImpl plagiarismControl(
FileService fileService, FileService fileService,
PlagiarismRequestRepository plagiarismRequestRepository, PlagiarismRequestRepository plagiarismRequestRepository,
UrkundSubmissionRepository urkundSubmissionRepository) UrkundSubmissionRepository urkundSubmissionRepository
{ ) {
return new PlagiarismControlImpl(plagiarismRequestRepository, urkundSubmissionRepository, fileService); return new PlagiarismControlImpl(plagiarismRequestRepository, urkundSubmissionRepository, fileService);
} }
@ -687,8 +743,8 @@ public class CoreConfig {
@Bean @Bean
public ProjectFileServiceImpl projectFileService( public ProjectFileServiceImpl projectFileService(
FileService fileService, FileService fileService,
ProjectFileRepository projectFileRepository) ProjectFileRepository projectFileRepository
{ ) {
return new ProjectFileServiceImpl(fileService, projectFileRepository); return new ProjectFileServiceImpl(fileService, projectFileRepository);
} }
@ -703,10 +759,15 @@ public class CoreConfig {
BasicForumService basicForumService, BasicForumService basicForumService,
ProjectThreadRepository projectThreadRepository, ProjectThreadRepository projectThreadRepository,
ForumPostRepository postRepository, ForumPostRepository postRepository,
ProjectFileService projectFileService) ProjectFileService projectFileService
{ ) {
return new ProjectForumServiceImpl(projectThreadRepository, return new ProjectForumServiceImpl(
postRepository, projectFileService, basicForumService, eventBus); projectThreadRepository,
postRepository,
projectFileService,
basicForumService,
eventBus
);
} }
@Bean @Bean
@ -724,8 +785,8 @@ public class CoreConfig {
Provider<EntityManager> em, Provider<EntityManager> em,
EventBus eventBus, EventBus eventBus,
ProjectRepo projectRepo, ProjectRepo projectRepo,
Clock clock) Clock clock
{ ) {
return new ProjectServiceImpl(projectRepo, clock, eventBus, em); return new ProjectServiceImpl(projectRepo, clock, eventBus, em);
} }
@ -736,8 +797,8 @@ public class CoreConfig {
@Bean @Bean
public PublicationMetadataServiceImpl publicationMetadataService( public PublicationMetadataServiceImpl publicationMetadataService(
PublicationMetadataRepository publicationMetadataRepository) PublicationMetadataRepository publicationMetadataRepository
{ ) {
return new PublicationMetadataServiceImpl(publicationMetadataRepository); return new PublicationMetadataServiceImpl(publicationMetadataRepository);
} }
@ -745,8 +806,8 @@ public class CoreConfig {
public ReflectionServiceImpl reflectionService( public ReflectionServiceImpl reflectionService(
AuthorRepository authorRepository, AuthorRepository authorRepository,
FinalSeminarServiceImpl finalSeminarService, FinalSeminarServiceImpl finalSeminarService,
EventBus eventBus) EventBus eventBus
{ ) {
return new ReflectionServiceImpl(authorRepository, finalSeminarService, eventBus); return new ReflectionServiceImpl(authorRepository, finalSeminarService, eventBus);
} }
@ -774,11 +835,23 @@ public class CoreConfig {
GradingReportService gradingReportService, GradingReportService gradingReportService,
ReviewerInteractionService reviewerInteractionService, ReviewerInteractionService reviewerInteractionService,
RoughDraftApprovalService roughDraftApprovalService, RoughDraftApprovalService roughDraftApprovalService,
FinalSeminarApprovalService finalSeminarApprovalService) FinalSeminarApprovalService finalSeminarApprovalService
{ ) {
return new ZipReporter(fileService, projectService, finalSeminarService, projectForumService, peerReviewService, return new ZipReporter(
peerRequestService, groupService, groupForumService, ideaService, gradingReportService, fileService,
reviewerInteractionService, roughDraftApprovalService, finalSeminarApprovalService); projectService,
finalSeminarService,
projectForumService,
peerReviewService,
peerRequestService,
groupService,
groupForumService,
ideaService,
gradingReportService,
reviewerInteractionService,
roughDraftApprovalService,
finalSeminarApprovalService
);
} }
@Bean @Bean
@ -795,8 +868,8 @@ public class CoreConfig {
public ReviewerInteractionServiceImpl reviewerInteractionService( public ReviewerInteractionServiceImpl reviewerInteractionService(
ReviewerThreadRepository reviewerThreadRepository, ReviewerThreadRepository reviewerThreadRepository,
BasicForumService forumService, BasicForumService forumService,
EventBus eventBus) EventBus eventBus
{ ) {
return new ReviewerInteractionServiceImpl(reviewerThreadRepository, forumService, eventBus); return new ReviewerInteractionServiceImpl(reviewerThreadRepository, forumService, eventBus);
} }
@ -804,8 +877,8 @@ public class CoreConfig {
public ReviewingServiceImpl reviewingService( public ReviewingServiceImpl reviewingService(
Provider<EntityManager> em, Provider<EntityManager> em,
EventBus eventBus, EventBus eventBus,
FileService fileService) FileService fileService
{ ) {
return new ReviewingServiceImpl(em, fileService, eventBus); return new ReviewingServiceImpl(em, fileService, eventBus);
} }
@ -815,16 +888,21 @@ public class CoreConfig {
DecisionRepository decisionRepository, DecisionRepository decisionRepository,
UserService userService, UserService userService,
ProjectService projectService, ProjectService projectService,
EventBus eventBus) EventBus eventBus
{ ) {
return new ReviewerCapacityServiceImpl(reviewerTargetRepository, decisionRepository, userService, return new ReviewerCapacityServiceImpl(
projectService, eventBus); reviewerTargetRepository,
decisionRepository,
userService,
projectService,
eventBus
);
} }
@Bean @Bean
public ReviewerDeadlineSettingsServiceImpl reviewerDeadlineSettingsService( public ReviewerDeadlineSettingsServiceImpl reviewerDeadlineSettingsService(
ReviewerDeadlineSettingsRepository reviewerDeadlineSettingsRepository) ReviewerDeadlineSettingsRepository reviewerDeadlineSettingsRepository
{ ) {
return new ReviewerDeadlineSettingsServiceImpl(reviewerDeadlineSettingsRepository); return new ReviewerDeadlineSettingsServiceImpl(reviewerDeadlineSettingsRepository);
} }
@ -839,10 +917,15 @@ public class CoreConfig {
QuestionRepository questionRepository, QuestionRepository questionRepository,
FinalThesisService finalThesisService, FinalThesisService finalThesisService,
GeneralSystemSettingsService generalSystemSettingsService, GeneralSystemSettingsService generalSystemSettingsService,
ReflectionService reflectionService) ReflectionService reflectionService
{ ) {
return new SurveyServiceImpl(surveyRepository, questionRepository, finalThesisService, return new SurveyServiceImpl(
generalSystemSettingsService, reflectionService); surveyRepository,
questionRepository,
finalThesisService,
generalSystemSettingsService,
reflectionService
);
} }
@Bean @Bean
@ -856,10 +939,7 @@ public class CoreConfig {
} }
@Bean @Bean
public UrkundApiImpl urkundApi( public UrkundApiImpl urkundApi(UrkundSettingsRepository urkundSettingsRepository, FileService fileService) {
UrkundSettingsRepository urkundSettingsRepository,
FileService fileService)
{
return new UrkundApiImpl(urkundSettingsRepository, fileService); return new UrkundApiImpl(urkundSettingsRepository, fileService);
} }
@ -868,8 +948,8 @@ public class CoreConfig {
UrkundApi urkundApi, UrkundApi urkundApi,
UrkundSubmissionRepository urkundSubmissionRepository, UrkundSubmissionRepository urkundSubmissionRepository,
Sukat sukat, Sukat sukat,
FileService fileService) FileService fileService
{ ) {
return new UrkundServiceImpl(urkundApi, urkundSubmissionRepository, sukat, fileService); return new UrkundServiceImpl(urkundApi, urkundSubmissionRepository, sukat, fileService);
} }
@ -900,11 +980,16 @@ public class CoreConfig {
MailEventService mailEventService, MailEventService mailEventService,
ReceiverConfigurationService receiverConfigurationService, ReceiverConfigurationService receiverConfigurationService,
DeliveryConfigurationService deliveryConfigurationService, DeliveryConfigurationService deliveryConfigurationService,
Provider<CurrentUser> currentUserProvider) Provider<CurrentUser> currentUserProvider
{ ) {
return new NotificationControllerImpl(notificationService, return new NotificationControllerImpl(
notificationService,
notificationMailFormatter, notificationMailFormatter,
mailEventService, receiverConfigurationService, deliveryConfigurationService, currentUserProvider); mailEventService,
receiverConfigurationService,
deliveryConfigurationService,
currentUserProvider
);
} }
@Bean @Bean
@ -919,10 +1004,16 @@ public class CoreConfig {
RoughDraftApprovalService roughDraftApprovalService, RoughDraftApprovalService roughDraftApprovalService,
FinalSeminarApprovalService finalSeminarApprovalService, FinalSeminarApprovalService finalSeminarApprovalService,
DaysService daysService, DaysService daysService,
Clock clock) Clock clock
{ ) {
return new ReviewerAssignedDeadline(roughDraftApprovalService, finalSeminarApprovalService, return new ReviewerAssignedDeadline(
reviewerDeadlineSettingsService, daysService, eventBus, clock); roughDraftApprovalService,
finalSeminarApprovalService,
reviewerDeadlineSettingsService,
daysService,
eventBus,
clock
);
} }
@Bean @Bean
@ -934,8 +1025,8 @@ public class CoreConfig {
public FinalSeminarActivityHandler finalSeminarActivityHandler( public FinalSeminarActivityHandler finalSeminarActivityHandler(
ActivityPlanFacade activityPlanFacade, ActivityPlanFacade activityPlanFacade,
ActivityFinalSeminarRepository activityFinalSeminarRepository, ActivityFinalSeminarRepository activityFinalSeminarRepository,
EventBus eventBus) EventBus eventBus
{ ) {
return new FinalSeminarActivityHandler(activityPlanFacade, activityFinalSeminarRepository, eventBus); return new FinalSeminarActivityHandler(activityPlanFacade, activityFinalSeminarRepository, eventBus);
} }
@ -943,8 +1034,8 @@ public class CoreConfig {
public PostActivityUploadToForum postActivityUploadToForum( public PostActivityUploadToForum postActivityUploadToForum(
EventBus eventBus, EventBus eventBus,
ProjectForumService projectForumService, ProjectForumService projectForumService,
ActivityThreadRepository activityThreadRepository) ActivityThreadRepository activityThreadRepository
{ ) {
return new PostActivityUploadToForum(projectForumService, activityThreadRepository, eventBus); return new PostActivityUploadToForum(projectForumService, activityThreadRepository, eventBus);
} }
@ -953,10 +1044,14 @@ public class CoreConfig {
EventBus eventBus, EventBus eventBus,
NotificationController notificationController, NotificationController notificationController,
ForumNotificationRepository forumNotificationRepository, ForumNotificationRepository forumNotificationRepository,
NotificationService notificationService) NotificationService notificationService
{ ) {
return new ForumNotifications(eventBus, notificationController, forumNotificationRepository, return new ForumNotifications(
notificationService); eventBus,
notificationController,
forumNotificationRepository,
notificationService
);
} }
@Bean @Bean
@ -965,10 +1060,15 @@ public class CoreConfig {
MilestoneServiceImpl milestoneService, MilestoneServiceImpl milestoneService,
PeerReviewService peerReviewService, PeerReviewService peerReviewService,
MilestoneActivityTemplateService milestoneActivityTemplateService, MilestoneActivityTemplateService milestoneActivityTemplateService,
FinalSeminarService finalSeminarService) FinalSeminarService finalSeminarService
{ ) {
return new ActivateCompletedMilestonesOnNewProjects(peerReviewService, milestoneActivityTemplateService, return new ActivateCompletedMilestonesOnNewProjects(
milestoneService, eventBus, finalSeminarService); peerReviewService,
milestoneActivityTemplateService,
milestoneService,
eventBus,
finalSeminarService
);
} }
@Bean @Bean
@ -976,9 +1076,14 @@ public class CoreConfig {
EventBus eventBus, EventBus eventBus,
FinalSeminarServiceImpl finalSeminarService, FinalSeminarServiceImpl finalSeminarService,
NotificationController notificationController, NotificationController notificationController,
AuthorRepository authorRepository) AuthorRepository authorRepository
{ ) {
return new FinalSeminarCreationSubscribers(authorRepository, finalSeminarService, notificationController, eventBus); return new FinalSeminarCreationSubscribers(
authorRepository,
finalSeminarService,
notificationController,
eventBus
);
} }
@Bean @Bean
@ -989,8 +1094,8 @@ public class CoreConfig {
@Bean @Bean
public AddActivityPlanOnProjectStart addActivityPlanOnProjectStart( public AddActivityPlanOnProjectStart addActivityPlanOnProjectStart(
ActivityPlanFacade activityPlanFacade, ActivityPlanFacade activityPlanFacade,
EventBus eventBus) EventBus eventBus
{ ) {
return new AddActivityPlanOnProjectStart(activityPlanFacade, eventBus); return new AddActivityPlanOnProjectStart(activityPlanFacade, eventBus);
} }
@ -998,8 +1103,8 @@ public class CoreConfig {
public Notifications notifications( public Notifications notifications(
EventBus eventBus, EventBus eventBus,
NotificationController notificationController, NotificationController notificationController,
NotificationService notificationService) NotificationService notificationService
{ ) {
return new Notifications(notificationController, notificationService, eventBus); return new Notifications(notificationController, notificationService, eventBus);
} }
@ -1009,7 +1114,9 @@ public class CoreConfig {
} }
@Bean @Bean
public NotificationEventServiceImpl notificationEventService(NotificationEventRepository notificationEventRepository) { public NotificationEventServiceImpl notificationEventService(
NotificationEventRepository notificationEventRepository
) {
return new NotificationEventServiceImpl(notificationEventRepository); return new NotificationEventServiceImpl(notificationEventRepository);
} }

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,7 @@ import se.su.dsv.scipro.system.UserRepoImpl;
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
public class RepositoryConfiguration { public class RepositoryConfiguration {
@Bean @Bean
public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository(Provider<EntityManager> em) { public GradingHistoryEventRepositoryImpl gradingHistoryEventRepository(Provider<EntityManager> em) {
return new GradingHistoryEventRepositoryImpl(em); return new GradingHistoryEventRepositoryImpl(em);
@ -104,7 +105,9 @@ public class RepositoryConfiguration {
} }
@Bean @Bean
public FinalSeminarActiveParticipationRepositoryImpl finalSeminarActiveParticipationRepository(Provider<EntityManager> em) { public FinalSeminarActiveParticipationRepositoryImpl finalSeminarActiveParticipationRepository(
Provider<EntityManager> em
) {
return new FinalSeminarActiveParticipationRepositoryImpl(em); return new FinalSeminarActiveParticipationRepositoryImpl(em);
} }

View File

@ -1,5 +1,9 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
public enum Action { public enum Action {
NONE, HAND_IN, PEER, FINAL_THESIS, FINAL_SEMINAR NONE,
HAND_IN,
PEER,
FINAL_THESIS,
FINAL_SEMINAR,
} }

View File

@ -1,37 +1,34 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import com.querydsl.core.annotations.QueryInit; import com.querydsl.core.annotations.QueryInit;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Table;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated; import jakarta.persistence.Enumerated;
import jakarta.persistence.GenerationType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import se.su.dsv.scipro.checklist.Checklist;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
import java.io.Serializable; import java.io.Serializable;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.checklist.Checklist;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
@Entity @Entity
@Table(name = "activity") @Table(name = "activity")
@Cacheable(true) @Cacheable(true)
public class Activity extends LazyDeletableDomainObject { public class Activity extends LazyDeletableDomainObject {
public static IActivityPlan builder(){ public static IActivityPlan builder() {
return new Builder(); return new Builder();
} }
@ -41,11 +38,11 @@ public class Activity extends LazyDeletableDomainObject {
private Long id; private Long id;
@Basic @Basic
@Column(name = "title", nullable=false) @Column(name = "title", nullable = false)
private String title; private String title;
@Basic @Basic
@Column(name = "date", nullable=false) @Column(name = "date", nullable = false)
private Date date; private Date date;
@Basic @Basic
@ -59,6 +56,7 @@ public class Activity extends LazyDeletableDomainObject {
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "action") @Column(name = "action")
private Action action = Action.NONE; private Action action = Action.NONE;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity) referencing other tables."> //<editor-fold desc="JPA-mappings of foreign keys in this table (activity) referencing other tables.">
@ -74,6 +72,7 @@ public class Activity extends LazyDeletableDomainObject {
@OneToOne(optional = true, cascade = CascadeType.ALL) @OneToOne(optional = true, cascade = CascadeType.ALL)
@JoinColumn(name = "upload_file_reference_id", referencedColumnName = "id") @JoinColumn(name = "upload_file_reference_id", referencedColumnName = "id")
private FileReference fileUpload; private FileReference fileUpload;
//</editor-fold> //</editor-fold>
//<editor-fold desc="Constructor"> //<editor-fold desc="Constructor">
@ -81,6 +80,7 @@ public class Activity extends LazyDeletableDomainObject {
this.title = ""; this.title = "";
this.description = ""; this.description = "";
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Properties (Getters and Setters)"> //<editor-fold desc="Properties (Getters and Setters)">
@ -156,6 +156,7 @@ public class Activity extends LazyDeletableDomainObject {
public void setFileUpload(FileReference fileUpload) { public void setFileUpload(FileReference fileUpload) {
this.fileUpload = fileUpload; this.fileUpload = fileUpload;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Methods Common To All Objects"> //<editor-fold desc="Methods Common To All Objects">
@ -164,8 +165,7 @@ public class Activity extends LazyDeletableDomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Activity)) return false; if (!(o instanceof Activity)) return false;
final Activity other = (Activity) o; final Activity other = (Activity) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
@Override @Override
@ -174,19 +174,22 @@ public class Activity extends LazyDeletableDomainObject {
} }
@Override @Override
public String toString(){ public String toString() {
return "Event: "+ getTitle()+"@"+getDate(); return "Event: " + getTitle() + "@" + getDate();
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Other methods"> //<editor-fold desc="Other methods">
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
return other instanceof Activity; return other instanceof Activity;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Nested types"> //<editor-fold desc="Nested types">
public static class ByDateComparator implements Comparator<Activity>, Serializable { public static class ByDateComparator implements Comparator<Activity>, Serializable {
@Override @Override
public int compare(Activity o1, Activity o2) { public int compare(Activity o1, Activity o2) {
return o1.getDate().compareTo(o2.getDate()); return o1.getDate().compareTo(o2.getDate());
@ -194,6 +197,7 @@ public class Activity extends LazyDeletableDomainObject {
} }
public static class Builder implements IActivityPlan, IDate, IName, IDescription, IBuild { public static class Builder implements IActivityPlan, IDate, IName, IDescription, IBuild {
private ActivityPlan activityPlan; private ActivityPlan activityPlan;
private Date date; private Date date;
private String name; private String name;
@ -247,7 +251,7 @@ public class Activity extends LazyDeletableDomainObject {
} }
public interface IDate { public interface IDate {
IName date (Date date); IName date(Date date);
} }
public interface IName { public interface IName {

View File

@ -3,6 +3,7 @@ package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.file.FileDescription; import se.su.dsv.scipro.file.FileDescription;
public class ActivityFileUploadedEvent { public class ActivityFileUploadedEvent {
private final Activity activity; private final Activity activity;
private final FileDescription fileDescription; private final FileDescription fileDescription;

View File

@ -11,18 +11,16 @@ import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.DomainObject;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.DomainObject;
@Entity @Entity
@Table(name ="activity_plan") @Table(name = "activity_plan")
@Cacheable(true) @Cacheable(true)
public class ActivityPlan extends DomainObject { public class ActivityPlan extends DomainObject {
@ -38,17 +36,20 @@ public class ActivityPlan extends DomainObject {
@Basic @Basic
@Column(name = "start_date") @Column(name = "start_date")
private Date startDate; private Date startDate;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan) referencing other tables"> //<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan) referencing other tables">
@OneToOne(optional=false) @OneToOne(optional = false)
@JoinColumn(name = "project_id", referencedColumnName = "id") @JoinColumn(name = "project_id", referencedColumnName = "id")
private Project project; private Project project;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of other tables referencing to this table "activity_plan"> //<editor-fold desc="JPA-mappings of other tables referencing to this table "activity_plan">
@OneToMany(mappedBy= "activityPlan",cascade=CascadeType.PERSIST, orphanRemoval = true) @OneToMany(mappedBy = "activityPlan", cascade = CascadeType.PERSIST, orphanRemoval = true)
private Set<Activity> activities = new TreeSet<>(new Activity.ByDateComparator()); private Set<Activity> activities = new TreeSet<>(new Activity.ByDateComparator());
//</editor-fold> //</editor-fold>
//<editor-fold desc="Properties (Getters and Setters)"> //<editor-fold desc="Properties (Getters and Setters)">
@ -84,6 +85,7 @@ public class ActivityPlan extends DomainObject {
public void setActivities(Set<Activity> activities) { public void setActivities(Set<Activity> activities) {
this.activities = activities; this.activities = activities;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Methods Common To All Objects"> //<editor-fold desc="Methods Common To All Objects">
@ -92,11 +94,13 @@ public class ActivityPlan extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ActivityPlan)) return false; if (!(o instanceof ActivityPlan)) return false;
final ActivityPlan other = (ActivityPlan) o; final ActivityPlan other = (ActivityPlan) o;
return other.canEqual(this) return (
&& Objects.equals(this.getId(), other.getId()) other.canEqual(this) &&
&& Objects.equals(this.getActivities(), other.getActivities()) Objects.equals(this.getId(), other.getId()) &&
&& Objects.equals(this.getProject(), other.getProject()) Objects.equals(this.getActivities(), other.getActivities()) &&
&& Objects.equals(this.getStartDate(), other.getStartDate()); Objects.equals(this.getProject(), other.getProject()) &&
Objects.equals(this.getStartDate(), other.getStartDate())
);
} }
@Override @Override
@ -106,19 +110,31 @@ public class ActivityPlan extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ActivityPlan(id=" + this.getId() + ", activities=" + this.getActivities() + ", project=" + return (
this.getProject() + ", startDate=" + this.getStartDate() + ")"; "ActivityPlan(id=" +
this.getId() +
", activities=" +
this.getActivities() +
", project=" +
this.getProject() +
", startDate=" +
this.getStartDate() +
")"
);
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Other methods"> //<editor-fold desc="Other methods">
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
return other instanceof ActivityPlan; return other instanceof ActivityPlan;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Nested types" //<editor-fold desc="Nested types"
private static class Builder implements IProject, IBuild { private static class Builder implements IProject, IBuild {
private Project project; private Project project;
@Override @Override

View File

@ -1,17 +1,15 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.Pageable; import java.util.Date;
import java.util.List;
import se.su.dsv.scipro.checklist.Checklist; import se.su.dsv.scipro.checklist.Checklist;
import se.su.dsv.scipro.checklist.ChecklistTemplate; import se.su.dsv.scipro.checklist.ChecklistTemplate;
import se.su.dsv.scipro.file.ProjectFileUpload; import se.su.dsv.scipro.file.ProjectFileUpload;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.Date;
import java.util.List;
public interface ActivityPlanFacade { public interface ActivityPlanFacade {
Activity saveActivity(Activity event); Activity saveActivity(Activity event);
ActivityPlan retrieveActivityPlan(Project p); ActivityPlan retrieveActivityPlan(Project p);

View File

@ -1,10 +1,14 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import static com.querydsl.core.types.dsl.Expressions.allOf;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.checklist.Checklist; import se.su.dsv.scipro.checklist.Checklist;
import se.su.dsv.scipro.checklist.ChecklistAnswerEnum; import se.su.dsv.scipro.checklist.ChecklistAnswerEnum;
import se.su.dsv.scipro.checklist.ChecklistCategory; import se.su.dsv.scipro.checklist.ChecklistCategory;
@ -21,14 +25,9 @@ import se.su.dsv.scipro.file.ProjectFileService;
import se.su.dsv.scipro.file.ProjectFileUpload; import se.su.dsv.scipro.file.ProjectFileUpload;
import se.su.dsv.scipro.misc.DaysService; import se.su.dsv.scipro.misc.DaysService;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import static com.querydsl.core.types.dsl.Expressions.allOf;
public class ActivityPlanFacadeImpl implements ActivityPlanFacade { public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPlanFacadeImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPlanFacadeImpl.class);
@ -44,17 +43,27 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
@Inject @Inject
ActivityService activityService; // yuck ActivityService activityService; // yuck
@Inject @Inject
ActivityPlanService activityPlanService; //yuck ActivityPlanService activityPlanService; //yuck
@Inject @Inject
ActivityPlanTemplateService activityPlanTemplateService; ActivityPlanTemplateService activityPlanTemplateService;
@Inject @Inject
ChecklistService checklistService; ChecklistService checklistService;
@Inject @Inject
ChecklistQuestionRepo checklistQuestionRepo; ChecklistQuestionRepo checklistQuestionRepo;
@Inject @Inject
public ActivityPlanFacadeImpl(final EventBus eventBus, final ProjectFileService projectFileService, ChecklistTemplateService checklistTemplateService, final DaysService daysService, final FileService fileService) { public ActivityPlanFacadeImpl(
final EventBus eventBus,
final ProjectFileService projectFileService,
ChecklistTemplateService checklistTemplateService,
final DaysService daysService,
final FileService fileService
) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.projectFileService = projectFileService; this.projectFileService = projectFileService;
this.checklistTemplateService = checklistTemplateService; this.checklistTemplateService = checklistTemplateService;
@ -71,13 +80,15 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
* @return The newly created event. * @return The newly created event.
*/ */
@Transactional @Transactional
private Activity createNewActivity(final ActivityPlan ps, private Activity createNewActivity(
final ActivityPlan ps,
String name, String name,
String description, String description,
Action action, Action action,
final Date date, final Date date,
final Checklist checklist, final Checklist checklist,
final boolean editable) { final boolean editable
) {
Activity pse = new Activity(); Activity pse = new Activity();
pse.setActivityPlan(ps); pse.setActivityPlan(ps);
if (date == null) { if (date == null) {
@ -106,8 +117,7 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
if (event.getDescription() == null) { if (event.getDescription() == null) {
event.setDescription(""); event.setDescription("");
} }
if (event.getId() == null)//Attempt to create a new one if this is a transient entity if (event.getId() == null) { //Attempt to create a new one if this is a transient entity
{
return createNewActivity( return createNewActivity(
event.getActivityPlan(), event.getActivityPlan(),
event.getTitle(), event.getTitle(),
@ -115,7 +125,8 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
event.getAction(), event.getAction(),
event.getDate(), event.getDate(),
event.getChecklist(), event.getChecklist(),
event.isEditable()); event.isEditable()
);
} }
return activityService.save(event); return activityService.save(event);
} }
@ -168,14 +179,20 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
@Override @Override
@Transactional @Transactional
public void addActivitiesFromTemplate(final Project project, final ActivityPlanTemplate template, final Date startDate) { public void addActivitiesFromTemplate(
final Project project,
final ActivityPlanTemplate template,
final Date startDate
) {
addActivitiesFromTemplate(retrieveActivityPlan(project), template, startDate); addActivitiesFromTemplate(retrieveActivityPlan(project), template, startDate);
} }
private void addActivitiesFromTemplate(final ActivityPlan schedule, private void addActivitiesFromTemplate(
final ActivityPlan schedule,
ActivityPlanTemplate template, ActivityPlanTemplate template,
final Date startDate) { 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; int accumulatedOffset = 0;
for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) { for (final ActivityTemplate eventTemplate : reloadedTemplate.getActivityTemplates()) {
accumulatedOffset += eventTemplate.getDaysOffset(); accumulatedOffset += eventTemplate.getDaysOffset();
@ -192,7 +209,8 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
action, action,
dateForEvent, dateForEvent,
createChecklist(schedule.getProject(), checklistTemplate), createChecklist(schedule.getProject(), checklistTemplate),
true); true
);
} else { } else {
createNewActivity(schedule, title, desc, action, dateForEvent, null, true); createNewActivity(schedule, title, desc, action, dateForEvent, null, true);
} }
@ -208,7 +226,8 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
final ActivityPlan schedule, final ActivityPlan schedule,
final User user, final User user,
final String name, final String name,
final String description) { final String description
) {
Objects.requireNonNull(schedule, "Schedule may not be null"); Objects.requireNonNull(schedule, "Schedule may not be null");
Objects.requireNonNull(user, "User may not be null"); Objects.requireNonNull(user, "User may not be null");
@ -244,8 +263,7 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
} }
private int daysBetween(Date previousEventDate, Date currentEventDate) { private int daysBetween(Date previousEventDate, Date currentEventDate) {
return previousEventDate == null ? 0 return previousEventDate == null ? 0 : daysService.workDaysBetween(previousEventDate, currentEventDate);
: daysService.workDaysBetween(previousEventDate, currentEventDate);
} }
@Override @Override
@ -278,7 +296,10 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
final Date dateFrom = from != null ? from : new Date(0); final Date dateFrom = from != null ? from : new Date(0);
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE; final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
QActivity event = QActivity.activity; QActivity event = QActivity.activity;
return activityService.findAll(allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo)), pageable); return activityService.findAll(
allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo)),
pageable
);
} }
@Override @Override
@ -286,7 +307,9 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
final Date dateFrom = from != null ? from : new Date(0); final Date dateFrom = from != null ? from : new Date(0);
final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE; final Date dateTo = to != null ? to : FAR_IN_THE_FUTURE;
QActivity event = QActivity.activity; QActivity event = QActivity.activity;
return activityService.count(allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo))); return activityService.count(
allOf(event.activityPlan.project.eq(project), event.date.after(dateFrom), event.date.before(dateTo))
);
} }
private void deleteUpload(Activity activity) { private void deleteUpload(Activity activity) {
@ -303,7 +326,11 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
@Override @Override
public Checklist createChecklist(Project project, ChecklistTemplate template) { public Checklist createChecklist(Project project, ChecklistTemplate template) {
List<ChecklistCategory> categories = new ArrayList<>(template.getCategories()); List<ChecklistCategory> categories = new ArrayList<>(template.getCategories());
Checklist checklist = Checklist.builder().name(template.getName()).project(project).description(template.getDescription()).build(); Checklist checklist = Checklist.builder()
.name(template.getName())
.project(project)
.description(template.getDescription())
.build();
checklist.setCategories(categories); checklist.setCategories(categories);
for (String question : template.getQuestions()) { for (String question : template.getQuestions()) {
ChecklistQuestion clQuestion = new ChecklistQuestion(question, checklist.getNumberOfQuestions()); ChecklistQuestion clQuestion = new ChecklistQuestion(question, checklist.getNumberOfQuestions());
@ -350,5 +377,4 @@ public class ActivityPlanFacadeImpl implements ActivityPlanFacade {
} }
return true; return true;
} }
} }

View File

@ -2,6 +2,4 @@ package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface ActivityPlanService extends GenericService<ActivityPlan, Long> { public interface ActivityPlanService extends GenericService<ActivityPlan, Long> {}
}

View File

@ -1,12 +1,12 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 @Inject
public ActivityPlanServiceImpl(Provider<EntityManager> em) { public ActivityPlanServiceImpl(Provider<EntityManager> em) {
super(em, ActivityPlan.class, QActivityPlan.activityPlan); super(em, ActivityPlan.class, QActivityPlan.activityPlan);

View File

@ -1,11 +1,5 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
@ -19,8 +13,12 @@ import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
@ -35,7 +33,7 @@ public class ActivityPlanTemplate extends DomainObject {
private Long id; private Long id;
@Basic @Basic
@Column(name = "is_sys_admin_template", nullable=false) @Column(name = "is_sys_admin_template", nullable = false)
private boolean isSysAdminTemplate = false; private boolean isSysAdminTemplate = false;
@Basic @Basic
@ -46,18 +44,21 @@ public class ActivityPlanTemplate extends DomainObject {
@Column(name = "description") @Column(name = "description")
@Lob @Lob
private String description; private String description;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables."> //<editor-fold desc="JPA-mappings of foreign keys in this table (activity_plan_template) referencing other tables.">
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(name = "creator_user_id", referencedColumnName = "id") @JoinColumn(name = "creator_user_id", referencedColumnName = "id")
private User creator; private User creator;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of other tables referencing to this table 'activity_plan_template'"> //<editor-fold desc="JPA-mappings of other tables referencing to this table 'activity_plan_template'">
@OneToMany(mappedBy="activityPlanTemplate", orphanRemoval=true, cascade=CascadeType.ALL) @OneToMany(mappedBy = "activityPlanTemplate", orphanRemoval = true, cascade = CascadeType.ALL)
@OrderColumn(name = "number_in_order") @OrderColumn(name = "number_in_order")
private List<ActivityTemplate> activityTemplates = new ArrayList<>(); private List<ActivityTemplate> activityTemplates = new ArrayList<>();
//</editor-fold> //</editor-fold>
//<editor-fold desc="Properties (Getters and Setters)"> //<editor-fold desc="Properties (Getters and Setters)">
@ -102,13 +103,14 @@ public class ActivityPlanTemplate extends DomainObject {
this.creator = creator; this.creator = creator;
} }
public List<ActivityTemplate> getActivityTemplates(){ public List<ActivityTemplate> getActivityTemplates() {
return Collections.unmodifiableList(activityTemplates); return Collections.unmodifiableList(activityTemplates);
} }
public void setActivityTemplates(List<ActivityTemplate> activityTemplates){ public void setActivityTemplates(List<ActivityTemplate> activityTemplates) {
this.activityTemplates = new ArrayList<>(activityTemplates); this.activityTemplates = new ArrayList<>(activityTemplates);
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Methods Common To All Objects"> //<editor-fold desc="Methods Common To All Objects">
@ -117,14 +119,16 @@ public class ActivityPlanTemplate extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ActivityPlanTemplate)) return false; if (!(o instanceof ActivityPlanTemplate)) return false;
final ActivityPlanTemplate other = (ActivityPlanTemplate) o; final ActivityPlanTemplate other = (ActivityPlanTemplate) o;
return other.canEqual(this) return (
&& super.equals(o) other.canEqual(this) &&
&& Objects.equals(this.getId(), other.getId()) super.equals(o) &&
&& Objects.equals(this.getActivityTemplates(), other.getActivityTemplates()) Objects.equals(this.getId(), other.getId()) &&
&& Objects.equals(this.getCreator(), other.getCreator()) Objects.equals(this.getActivityTemplates(), other.getActivityTemplates()) &&
&& Objects.equals(this.getTitle(), other.getTitle()) Objects.equals(this.getCreator(), other.getCreator()) &&
&& Objects.equals(this.getDescription(), other.getDescription()) Objects.equals(this.getTitle(), other.getTitle()) &&
&& this.isSysAdminTemplate() == other.isSysAdminTemplate(); Objects.equals(this.getDescription(), other.getDescription()) &&
this.isSysAdminTemplate() == other.isSysAdminTemplate()
);
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -133,29 +137,47 @@ public class ActivityPlanTemplate extends DomainObject {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(this.getId(), this.getActivityTemplates(), this.getCreator(), this.getTitle(), this.getDescription(), this.isSysAdminTemplate()); return Objects.hash(
this.getId(),
this.getActivityTemplates(),
this.getCreator(),
this.getTitle(),
this.getDescription(),
this.isSysAdminTemplate()
);
} }
@Override @Override
public String toString() { public String toString() {
return "ActivityPlanTemplate(id=" + this.getId() + ", creator=" + this.getCreator() + return (
", title=" + this.getTitle() + ", description=" + this.getDescription() + "ActivityPlanTemplate(id=" +
", isSysAdminTemplate=" + this.isSysAdminTemplate() + ")"; this.getId() +
", creator=" +
this.getCreator() +
", title=" +
this.getTitle() +
", description=" +
this.getDescription() +
", isSysAdminTemplate=" +
this.isSysAdminTemplate() +
")"
);
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Other methods"> //<editor-fold desc="Other methods">
public void addActivity(ActivityTemplate activity){ public void addActivity(ActivityTemplate activity) {
activity.setActivityPlanTemplate(this); activity.setActivityPlanTemplate(this);
activity.setNumberInOrder(activityTemplates.size()); activity.setNumberInOrder(activityTemplates.size());
activityTemplates.add(activity); activityTemplates.add(activity);
} }
public void clearActivities(){ public void clearActivities() {
activityTemplates.clear(); activityTemplates.clear();
} }
public void addActivities(final Collection<ActivityTemplate> activities){ public void addActivities(final Collection<ActivityTemplate> activities) {
activityTemplates.addAll(activities); activityTemplates.addAll(activities);
} }
//</editor-fold> //</editor-fold>

View File

@ -1,18 +1,20 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User;
public interface ActivityPlanTemplateService extends GenericService<ActivityPlanTemplate, Long>, FilteredService<ActivityPlanTemplate, Long, ActivityPlanTemplateService.Filter> { public interface ActivityPlanTemplateService
extends
GenericService<ActivityPlanTemplate, Long>,
FilteredService<ActivityPlanTemplate, Long, ActivityPlanTemplateService.Filter> {
List<ActivityPlanTemplate> findAll(Filter filter); List<ActivityPlanTemplate> findAll(Filter filter);
class Filter implements Serializable { class Filter implements Serializable {
private String filterString; private String filterString;
private User creator; private User creator;
@ -37,9 +39,11 @@ public interface ActivityPlanTemplateService extends GenericService<ActivityPlan
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Filter)) return false; if (!(o instanceof Filter)) return false;
final Filter other = (Filter) o; final Filter other = (Filter) o;
return other.canEqual(this) return (
&& Objects.equals(this.getFilterString(), other.getFilterString()) other.canEqual(this) &&
&& Objects.equals(this.getCreator(), other.getCreator()); Objects.equals(this.getFilterString(), other.getFilterString()) &&
Objects.equals(this.getCreator(), other.getCreator())
);
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -53,7 +57,13 @@ public interface ActivityPlanTemplateService extends GenericService<ActivityPlan
@Override @Override
public String toString() { public String toString() {
return "ActivityPlanTemplateService.Filter(filterString=" + this.getFilterString() + ", creator=" + this.getCreator() + ")"; return (
"ActivityPlanTemplateService.Filter(filterString=" +
this.getFilterString() +
", creator=" +
this.getCreator() +
")"
);
} }
} }
} }

View File

@ -2,17 +2,18 @@ package se.su.dsv.scipro.activityplan;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Predicate;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.List; import java.util.List;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.User;
public class ActivityPlanTemplateServiceImpl
extends AbstractServiceImpl<ActivityPlanTemplate, Long>
implements ActivityPlanTemplateService {
public class ActivityPlanTemplateServiceImpl extends AbstractServiceImpl<ActivityPlanTemplate, Long> implements ActivityPlanTemplateService {
@Inject @Inject
public ActivityPlanTemplateServiceImpl(Provider<EntityManager> em) { public ActivityPlanTemplateServiceImpl(Provider<EntityManager> em) {
super(em, ActivityPlanTemplate.class, QActivityPlanTemplate.activityPlanTemplate); super(em, ActivityPlanTemplate.class, QActivityPlanTemplate.activityPlanTemplate);
@ -31,21 +32,24 @@ public class ActivityPlanTemplateServiceImpl extends AbstractServiceImpl<Activit
protected static Predicate toPredicate(ActivityPlanTemplateService.Filter filter) { protected static Predicate toPredicate(ActivityPlanTemplateService.Filter filter) {
BooleanBuilder predicate = new BooleanBuilder(); BooleanBuilder predicate = new BooleanBuilder();
if (filter.getFilterString()!=null){ if (filter.getFilterString() != null) {
predicate.and(filterString(filter.getFilterString())); predicate.and(filterString(filter.getFilterString()));
} }
if (filter.getCreator()!=null){ if (filter.getCreator() != null) {
predicate.and(creator(filter.getCreator())); predicate.and(creator(filter.getCreator()));
} }
return predicate; return predicate;
} }
private static Predicate creator(User creator) { private static Predicate creator(User creator) {
return QActivityPlanTemplate.activityPlanTemplate.isSysAdminTemplate.isTrue().or(QActivityPlanTemplate.activityPlanTemplate.creator.eq(creator)); return QActivityPlanTemplate.activityPlanTemplate.isSysAdminTemplate
.isTrue()
.or(QActivityPlanTemplate.activityPlanTemplate.creator.eq(creator));
} }
private static Predicate filterString(String filterString) { private static Predicate filterString(String filterString) {
return QActivityPlanTemplate.activityPlanTemplate.title.containsIgnoreCase(filterString) return QActivityPlanTemplate.activityPlanTemplate.title
.containsIgnoreCase(filterString)
.or(QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase(filterString)) .or(QActivityPlanTemplate.activityPlanTemplate.creator.firstName.containsIgnoreCase(filterString))
.or(QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(filterString)); .or(QActivityPlanTemplate.activityPlanTemplate.creator.lastName.containsIgnoreCase(filterString));
} }

View File

@ -2,6 +2,4 @@ package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface ActivityService extends GenericService<Activity, Long> { public interface ActivityService extends GenericService<Activity, Long> {}
}

View File

@ -1,10 +1,9 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 {
@ -12,5 +11,4 @@ public class ActivityServiceImpl extends AbstractServiceImpl<Activity, Long> imp
public ActivityServiceImpl(Provider<EntityManager> em) { public ActivityServiceImpl(Provider<EntityManager> em) {
super(em, Activity.class, QActivity.activity); super(em, Activity.class, QActivity.activity);
} }
} }

View File

@ -1,7 +1,5 @@
package se.su.dsv.scipro.activityplan; package se.su.dsv.scipro.activityplan;
import java.util.Objects;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -14,7 +12,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob; import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects;
import se.su.dsv.scipro.checklist.ChecklistTemplate; import se.su.dsv.scipro.checklist.ChecklistTemplate;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
@ -48,6 +46,7 @@ public class ActivityTemplate extends DomainObject {
@Basic @Basic
@Column(name = "number_in_order", nullable = false) @Column(name = "number_in_order", nullable = false)
private int numberInOrder = Integer.MAX_VALUE; private int numberInOrder = Integer.MAX_VALUE;
//</editor-fold> //</editor-fold>
//<editor-fold desc="JPA-mappings of foreign keys in this table (activity_template) referencing other tables."> //<editor-fold desc="JPA-mappings of foreign keys in this table (activity_template) referencing other tables.">
@ -58,15 +57,16 @@ public class ActivityTemplate extends DomainObject {
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "checklist_template_id", referencedColumnName = "id") @JoinColumn(name = "checklist_template_id", referencedColumnName = "id")
private ChecklistTemplate checklistTemplate; private ChecklistTemplate checklistTemplate;
//</editor-fold> //</editor-fold>
//<editor-fold desc="Constructors"> //<editor-fold desc="Constructors">
public ActivityTemplate() { public ActivityTemplate() {}
}
public ActivityTemplate(int daysOffset) { public ActivityTemplate(int daysOffset) {
this.daysOffset = daysOffset; this.daysOffset = daysOffset;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Properties (Getters and Setters"> //<editor-fold desc="Properties (Getters and Setters">
@ -134,6 +134,7 @@ public class ActivityTemplate extends DomainObject {
public void setChecklistTemplate(ChecklistTemplate checklistTemplate) { public void setChecklistTemplate(ChecklistTemplate checklistTemplate) {
this.checklistTemplate = checklistTemplate; this.checklistTemplate = checklistTemplate;
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Methods Common To All Objects"> //<editor-fold desc="Methods Common To All Objects">
@ -142,8 +143,7 @@ public class ActivityTemplate extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ActivityTemplate)) return false; if (!(o instanceof ActivityTemplate)) return false;
final ActivityTemplate other = (ActivityTemplate) o; final ActivityTemplate other = (ActivityTemplate) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
@Override @Override
@ -153,12 +153,27 @@ public class ActivityTemplate extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ActivityTemplate(id=" + this.getId() + ", title=" + this.getTitle() + return (
", description=" + this.getDescription() + ", activityPlanTemplate=" + "ActivityTemplate(id=" +
this.getActivityPlanTemplate() + ", daysOffset=" + this.getDaysOffset() + ", action=" + this.getId() +
this.getAction() + ", numberInOrder=" + this.getNumberInOrder() + ", checklistTemplate=" + ", title=" +
this.getChecklistTemplate() + ")"; this.getTitle() +
", description=" +
this.getDescription() +
", activityPlanTemplate=" +
this.getActivityPlanTemplate() +
", daysOffset=" +
this.getDaysOffset() +
", action=" +
this.getAction() +
", numberInOrder=" +
this.getNumberInOrder() +
", checklistTemplate=" +
this.getChecklistTemplate() +
")"
);
} }
//</editor-fold> //</editor-fold>
//<editor-fold desc="Other methods"> //<editor-fold desc="Other methods">

View File

@ -18,16 +18,15 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapKeyJoinColumn; import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
@Entity @Entity
@Table(name = "checklist") @Table(name = "checklist")
@ -54,15 +53,19 @@ public class Checklist extends DomainObject {
private Project project; private Project project;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinTable(name = "checklist_checklist_question", @JoinTable(
name = "checklist_checklist_question",
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"), 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<>(); private List<ChecklistQuestion> questions = new ArrayList<>();
@ManyToMany @ManyToMany
@JoinTable(name = "checklist_checklist_category", @JoinTable(
name = "checklist_checklist_category",
joinColumns = @JoinColumn(name = "checklist_id", referencedColumnName = "id"), 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<>(); private List<se.su.dsv.scipro.checklist.ChecklistCategory> categories = new ArrayList<>();
@ElementCollection(fetch = FetchType.EAGER) @ElementCollection(fetch = FetchType.EAGER)
@ -72,8 +75,7 @@ public class Checklist extends DomainObject {
@MapKeyJoinColumn(name = "user_id") @MapKeyJoinColumn(name = "user_id")
private Map<User, Date> userLastOpenDate = new HashMap<>(); private Map<User, Date> userLastOpenDate = new HashMap<>();
protected Checklist() { protected Checklist() {}
}
public int getNumberOfQuestions() { public int getNumberOfQuestions() {
return questions.size(); return questions.size();
@ -148,7 +150,23 @@ public class Checklist extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "Checklist(id=" + this.getId() + ", name=" + this.getName() + ", description=" + this.getDescription() + ", project=" + this.getProject() + ", questions=" + this.getQuestions() + ", categories=" + this.getCategories() + ", userLastOpenDate=" + this.getUserLastOpenDate() + ")"; return (
"Checklist(id=" +
this.getId() +
", name=" +
this.getName() +
", description=" +
this.getDescription() +
", project=" +
this.getProject() +
", questions=" +
this.getQuestions() +
", categories=" +
this.getCategories() +
", userLastOpenDate=" +
this.getUserLastOpenDate() +
")"
);
} }
@Override @Override
@ -156,8 +174,7 @@ public class Checklist extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Checklist)) return false; if (!(o instanceof Checklist)) return false;
final Checklist other = (Checklist) o; final Checklist other = (Checklist) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -170,6 +187,7 @@ public class Checklist extends DomainObject {
} }
private static class Builder implements IName, IProject, IBuild { private static class Builder implements IName, IProject, IBuild {
private final Checklist instance = new Checklist(); private final Checklist instance = new Checklist();
@Override @Override
@ -204,12 +222,9 @@ public class Checklist extends DomainObject {
IBuild project(Project project); IBuild project(Project project);
} }
public interface IBuild { public interface IBuild {
IBuild description(String description); IBuild description(String description);
Checklist build(); Checklist build();
} }
} }

View File

@ -1,7 +1,5 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import java.util.Objects;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -14,13 +12,14 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob; import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
@Entity @Entity
@Table(name = "checklist_answer") @Table(name = "checklist_answer")
public class ChecklistAnswer extends DomainObject { public class ChecklistAnswer extends DomainObject {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Basic JPA-mappings // Basic JPA-mappings
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -49,8 +48,7 @@ public class ChecklistAnswer extends DomainObject {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Constructors // Constructors
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
protected ChecklistAnswer() { protected ChecklistAnswer() {}
}
public ChecklistAnswer(User user) { public ChecklistAnswer(User user) {
this(user, null); this(user, null);
@ -105,8 +103,7 @@ public class ChecklistAnswer extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ChecklistAnswer)) return false; if (!(o instanceof ChecklistAnswer)) return false;
final ChecklistAnswer other = (ChecklistAnswer) o; final ChecklistAnswer other = (ChecklistAnswer) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
@Override @Override
@ -116,8 +113,17 @@ public class ChecklistAnswer extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() + return (
", comment=" + this.getComment() + ")"; "ChecklistAnswer(id=" +
this.getId() +
", answer=" +
this.getAnswer() +
", user=" +
this.getUser() +
", comment=" +
this.getComment() +
")"
);
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------

View File

@ -5,5 +5,5 @@ public enum ChecklistAnswerEnum {
GREEN, GREEN,
YELLOW, YELLOW,
NOT_APPLICABLE, NOT_APPLICABLE,
NO_ANSWER NO_ANSWER,
} }

View File

@ -2,6 +2,4 @@ package se.su.dsv.scipro.checklist;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
public interface ChecklistAnswerService extends GenericService<ChecklistAnswer, Long> { public interface ChecklistAnswerService extends GenericService<ChecklistAnswer, Long> {}
}

View File

@ -1,12 +1,13 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractServiceImpl;
public class ChecklistAnswerServiceImpl extends AbstractServiceImpl<ChecklistAnswer, Long> implements ChecklistAnswerService { public class ChecklistAnswerServiceImpl
extends AbstractServiceImpl<ChecklistAnswer, Long>
implements ChecklistAnswerService {
@Inject @Inject
public ChecklistAnswerServiceImpl(Provider<EntityManager> em) { public ChecklistAnswerServiceImpl(Provider<EntityManager> em) {

View File

@ -1,7 +1,5 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import java.util.Objects;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -9,13 +7,14 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
@Entity @Entity
@Table(name="checklist_category") @Table(name = "checklist_category")
@Cacheable(true) @Cacheable(true)
public class ChecklistCategory extends DomainObject { public class ChecklistCategory extends DomainObject {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@ -23,10 +22,9 @@ public class ChecklistCategory extends DomainObject {
@Column(name = "category_name", unique = true) @Column(name = "category_name", unique = true)
private String categoryName; private String categoryName;
protected ChecklistCategory() { protected ChecklistCategory() {}
}
public ChecklistCategory(final String name){ public ChecklistCategory(final String name) {
categoryName = name; categoryName = name;
} }
@ -49,7 +47,7 @@ public class ChecklistCategory extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ChecklistCategory(id=" + this.getId() + ", categoryName=" + this.getCategoryName() + ")"; return ("ChecklistCategory(id=" + this.getId() + ", categoryName=" + this.getCategoryName() + ")");
} }
@Override @Override
@ -57,8 +55,7 @@ public class ChecklistCategory extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ChecklistCategory)) return false; if (!(o instanceof ChecklistCategory)) return false;
final ChecklistCategory other = (ChecklistCategory) o; final ChecklistCategory other = (ChecklistCategory) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {

View File

@ -4,8 +4,6 @@ import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.JpaRepository; import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor; import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
@Transactional @Transactional
public interface ChecklistCategoryRepo extends JpaRepository<ChecklistCategory, Long>, QueryDslPredicateExecutor<ChecklistCategory> { public interface ChecklistCategoryRepo
extends JpaRepository<ChecklistCategory, Long>, QueryDslPredicateExecutor<ChecklistCategory> {}
}

View File

@ -1,12 +1,12 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import se.su.dsv.scipro.system.GenericRepo;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 @Inject
public ChecklistCategoryRepoImpl(Provider<EntityManager> em) { public ChecklistCategoryRepoImpl(Provider<EntityManager> em) {
super(em, ChecklistCategory.class, QChecklistCategory.checklistCategory); super(em, ChecklistCategory.class, QChecklistCategory.checklistCategory);

View File

@ -1,9 +1,5 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
@ -17,7 +13,9 @@ import jakarta.persistence.JoinTable;
import jakarta.persistence.Lob; import jakarta.persistence.Lob;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
@ -25,6 +23,7 @@ import se.su.dsv.scipro.system.User;
@Table(name = "checklist_question") @Table(name = "checklist_question")
@Cacheable(true) @Cacheable(true)
public class ChecklistQuestion extends DomainObject { public class ChecklistQuestion extends DomainObject {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@ -41,11 +40,11 @@ public class ChecklistQuestion extends DomainObject {
@JoinTable( @JoinTable(
name = "checklist_question_checklist_answer", name = "checklist_question_checklist_answer",
joinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"), joinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "checklist_answer_id", referencedColumnName = "id")) inverseJoinColumns = @JoinColumn(name = "checklist_answer_id", referencedColumnName = "id")
)
private List<ChecklistAnswer> answers = new ArrayList<>(); private List<ChecklistAnswer> answers = new ArrayList<>();
protected ChecklistQuestion() { protected ChecklistQuestion() {}
}
public ChecklistQuestion(String question, int questionNumber) { public ChecklistQuestion(String question, int questionNumber) {
this.question = question; this.question = question;
@ -104,7 +103,17 @@ public class ChecklistQuestion extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ChecklistQuestion(id=" + this.getId() + ", question=" + this.getQuestion() + ", questionNumber=" + this.getQuestionNumber() + ", answers=" + this.getAnswers() + ")"; return (
"ChecklistQuestion(id=" +
this.getId() +
", question=" +
this.getQuestion() +
", questionNumber=" +
this.getQuestionNumber() +
", answers=" +
this.getAnswers() +
")"
);
} }
@Override @Override
@ -112,8 +121,7 @@ public class ChecklistQuestion extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ChecklistQuestion)) return false; if (!(o instanceof ChecklistQuestion)) return false;
final ChecklistQuestion other = (ChecklistQuestion) o; final ChecklistQuestion other = (ChecklistQuestion) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {

View File

@ -4,7 +4,6 @@ import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.JpaRepository; import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor; import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
@Transactional @Transactional
public interface ChecklistQuestionRepo extends JpaRepository<ChecklistQuestion, Long>, QueryDslPredicateExecutor<ChecklistQuestion> { public interface ChecklistQuestionRepo
} extends JpaRepository<ChecklistQuestion, Long>, QueryDslPredicateExecutor<ChecklistQuestion> {}

View File

@ -1,12 +1,12 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import se.su.dsv.scipro.system.GenericRepo;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 @Inject
public ChecklistQuestionRepoImpl(Provider<EntityManager> em) { public ChecklistQuestionRepoImpl(Provider<EntityManager> em) {
super(em, ChecklistQuestion.class, QChecklistQuestion.checklistQuestion); super(em, ChecklistQuestion.class, QChecklistQuestion.checklistQuestion);

View File

@ -5,7 +5,6 @@ import se.su.dsv.scipro.system.GenericService;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
public interface ChecklistService extends GenericService<Checklist, Long> { public interface ChecklistService extends GenericService<Checklist, Long> {
Long countAnswers(Project project, ChecklistAnswerEnum answer); Long countAnswers(Project project, ChecklistAnswerEnum answer);
Long countUnanswered(Project project); Long countUnanswered(Project project);

View File

@ -1,19 +1,18 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.activityplan.QActivity;
import se.su.dsv.scipro.activityplan.QActivityPlan;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;
import java.util.Date;
import se.su.dsv.scipro.activityplan.QActivity;
import se.su.dsv.scipro.activityplan.QActivityPlan;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.Date;
public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> implements ChecklistService { public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> implements ChecklistService {
@Inject @Inject
public ChecklistServiceImpl(Provider<EntityManager> em) { public ChecklistServiceImpl(Provider<EntityManager> em) {
super(em, Checklist.class, QChecklist.checklist); super(em, Checklist.class, QChecklist.checklist);
@ -26,9 +25,7 @@ public class ChecklistServiceImpl extends AbstractServiceImpl<Checklist, Long> i
.join(QActivityPlan.activityPlan.activities, QActivity.activity) .join(QActivityPlan.activityPlan.activities, QActivity.activity)
.join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion) .join(QActivity.activity.checklist.questions, QChecklistQuestion.checklistQuestion)
.join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer) .join(QChecklistQuestion.checklistQuestion.answers, QChecklistAnswer.checklistAnswer)
.where( .where(QActivityPlan.activityPlan.project.eq(project), QChecklistAnswer.checklistAnswer.answer.eq(answer))
QActivityPlan.activityPlan.project.eq(project),
QChecklistAnswer.checklistAnswer.answer.eq(answer))
.fetchFirst(); .fetchFirst();
} }

View File

@ -13,19 +13,19 @@ import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
@Entity @Entity
@Table(name = "checklist_template") @Table(name = "checklist_template")
public class ChecklistTemplate extends DomainObject { public class ChecklistTemplate extends DomainObject {
public static final int MIN_TITLE_LENGTH = 3; public static final int MIN_TITLE_LENGTH = 3;
public static final int DEFAULT_TEMPLATE_NUMBER = 999; public static final int DEFAULT_TEMPLATE_NUMBER = 999;
@ -46,8 +46,7 @@ public class ChecklistTemplate extends DomainObject {
private int templateNumber = DEFAULT_TEMPLATE_NUMBER; private int templateNumber = DEFAULT_TEMPLATE_NUMBER;
@ElementCollection @ElementCollection
@CollectionTable(name = "checklist_template_question", @CollectionTable(name = "checklist_template_question", joinColumns = @JoinColumn(name = "checklist_template_id"))
joinColumns = @JoinColumn(name = "checklist_template_id"))
@Column(name = "question") @Column(name = "question")
private List<String> questions = new ArrayList<>(1); private List<String> questions = new ArrayList<>(1);
@ -56,20 +55,22 @@ public class ChecklistTemplate extends DomainObject {
private User creator; private User creator;
@ManyToMany @ManyToMany
@JoinTable(name = "checklist_template_checklist_category", @JoinTable(
name = "checklist_template_checklist_category",
joinColumns = @JoinColumn(name = "checklist_template_id", referencedColumnName = "id"), 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<>(); private List<ChecklistCategory> categories = new ArrayList<>();
@ManyToMany @ManyToMany
@JoinTable(name = "checklist_template_project_type", @JoinTable(
joinColumns = {@JoinColumn(name = "checklist_template_id")}, name = "checklist_template_project_type",
inverseJoinColumns = {@JoinColumn(name = "project_type_id")}) joinColumns = { @JoinColumn(name = "checklist_template_id") },
inverseJoinColumns = { @JoinColumn(name = "project_type_id") }
)
private Collection<ProjectType> projectTypes = new HashSet<>(); private Collection<ProjectType> projectTypes = new HashSet<>();
public ChecklistTemplate() { public ChecklistTemplate() {}
}
public ChecklistTemplate(String name, User creator) { public ChecklistTemplate(String name, User creator) {
this.name = name; this.name = name;
@ -84,7 +85,7 @@ public class ChecklistTemplate extends DomainObject {
questions.add(question); questions.add(question);
} }
public void clearQuestions(){ public void clearQuestions() {
questions.clear(); questions.clear();
} }
@ -151,7 +152,25 @@ public class ChecklistTemplate extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ChecklistTemplate(id=" + this.getId() + ", name=" + this.getName() + ", description=" + this.getDescription() + ", templateNumber=" + this.getTemplateNumber() + ", questions=" + this.getQuestions() + ", creator=" + this.getCreator() + ", categories=" + this.getCategories() + ", projectTypes=" + this.getProjectTypes() + ")"; return (
"ChecklistTemplate(id=" +
this.getId() +
", name=" +
this.getName() +
", description=" +
this.getDescription() +
", templateNumber=" +
this.getTemplateNumber() +
", questions=" +
this.getQuestions() +
", creator=" +
this.getCreator() +
", categories=" +
this.getCategories() +
", projectTypes=" +
this.getProjectTypes() +
")"
);
} }
@Override @Override
@ -159,8 +178,7 @@ public class ChecklistTemplate extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ChecklistTemplate)) return false; if (!(o instanceof ChecklistTemplate)) return false;
final ChecklistTemplate other = (ChecklistTemplate) o; final ChecklistTemplate other = (ChecklistTemplate) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {

View File

@ -1,12 +1,12 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import java.util.List;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.FilteredService; import se.su.dsv.scipro.system.FilteredService;
import se.su.dsv.scipro.system.GenericService; import se.su.dsv.scipro.system.GenericService;
import java.util.List; public interface ChecklistTemplateService
extends GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
public interface ChecklistTemplateService extends GenericService<ChecklistTemplate, Long>, FilteredService<ChecklistTemplate, Long, String> {
void upChecklistTemplate(ChecklistTemplate checklistTemplate); void upChecklistTemplate(ChecklistTemplate checklistTemplate);
void downChecklistTemplate(ChecklistTemplate checklistTemplate); void downChecklistTemplate(ChecklistTemplate checklistTemplate);
void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate); void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate);

View File

@ -1,19 +1,20 @@
package se.su.dsv.scipro.checklist; package se.su.dsv.scipro.checklist;
import jakarta.transaction.Transactional;
import com.querydsl.core.types.dsl.BooleanExpression;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.persistence.EntityManager;
import java.util.List;
import static com.querydsl.core.types.dsl.Expressions.allOf; import static com.querydsl.core.types.dsl.Expressions.allOf;
public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistTemplate,Long> implements ChecklistTemplateService { import com.querydsl.core.types.dsl.BooleanExpression;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;
import java.util.List;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable;
public class ChecklistTemplateServiceImpl
extends AbstractServiceImpl<ChecklistTemplate, Long>
implements ChecklistTemplateService {
public static final String PEER = "Peer"; public static final String PEER = "Peer";
@ -65,7 +66,9 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
@Transactional @Transactional
@Override @Override
public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) { public void safeDeleteChecklistTemplate(ChecklistTemplate checklistTemplate) {
for (ChecklistTemplate clt : findAll(QChecklistTemplate.checklistTemplate.templateNumber.gt(checklistTemplate.getTemplateNumber()))) { for (ChecklistTemplate clt : findAll(
QChecklistTemplate.checklistTemplate.templateNumber.gt(checklistTemplate.getTemplateNumber())
)) {
clt.setTemplateNumber(clt.getTemplateNumber() - 1); clt.setTemplateNumber(clt.getTemplateNumber() - 1);
} }
delete(checklistTemplate); delete(checklistTemplate);
@ -73,10 +76,12 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
@Override @Override
public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) { public List<ChecklistTemplate> findPeerRequestChecklists(final Project project) {
return findAll(allOf( return findAll(
allOf(
QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()), QChecklistTemplate.checklistTemplate.projectTypes.any().eq(project.getProjectType()),
QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER) QChecklistTemplate.checklistTemplate.categories.any().categoryName.eq(PEER)
)); )
);
} }
@Override @Override
@ -90,7 +95,9 @@ public class ChecklistTemplateServiceImpl extends AbstractServiceImpl<ChecklistT
} }
public static BooleanExpression filterStringIsCreatorName(String filterString) { public static BooleanExpression filterStringIsCreatorName(String filterString) {
return QChecklistTemplate.checklistTemplate.creator.firstName.contains(filterString).or(QChecklistTemplate.checklistTemplate.creator.lastName.contains(filterString)); return QChecklistTemplate.checklistTemplate.creator.firstName
.contains(filterString)
.or(QChecklistTemplate.checklistTemplate.creator.lastName.contains(filterString));
} }
public static BooleanExpression filterStringIsChecklistTemplateName(String filterString) { public static BooleanExpression filterStringIsChecklistTemplateName(String filterString) {

View File

@ -5,5 +5,4 @@ public class ExternalImportException extends RuntimeException {
public ExternalImportException(Throwable e) { public ExternalImportException(Throwable e) {
super(e); super(e);
} }
} }

View File

@ -1,13 +1,12 @@
package se.su.dsv.scipro.daisyExternal.http; package se.su.dsv.scipro.daisyExternal.http;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import se.su.dsv.scipro.io.dto.*;
import java.io.InputStream; import java.io.InputStream;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import se.su.dsv.scipro.io.dto.*;
public interface DaisyAPI { public interface DaisyAPI {
Set<ProjectParticipant> getContributors(Integer projectId); Set<ProjectParticipant> getContributors(Integer projectId);

View File

@ -1,5 +1,9 @@
package se.su.dsv.scipro.daisyExternal.http; package se.su.dsv.scipro.daisyExternal.http;
import static jakarta.ws.rs.client.Entity.xml;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.ProcessingException; import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.Client;
@ -10,16 +14,11 @@ import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.GenericType; import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import se.su.dsv.scipro.io.dto.*;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.InputStream; import java.io.InputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import static jakarta.ws.rs.client.Entity.xml; import se.su.dsv.scipro.io.dto.*;
public class DaisyAPIImpl implements DaisyAPI { public class DaisyAPIImpl implements DaisyAPI {
@ -46,10 +45,10 @@ public class DaisyAPIImpl implements DaisyAPI {
public DaisyAPIImpl( public DaisyAPIImpl(
@Named("daisy.api.url") final String baseUrl, @Named("daisy.api.url") final String baseUrl,
@Named("daisy.api.username") final String user, @Named("daisy.api.username") final String user,
@Named("daisy.api.password") final String password) { @Named("daisy.api.password") final String password
) {
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.client = ClientBuilder.newClient() this.client = ClientBuilder.newClient().register(HttpAuthenticationFeature.basic(user, password));
.register(HttpAuthenticationFeature.basic(user, password));
this.objectFactory = new ObjectFactory(); this.objectFactory = new ObjectFactory();
} }
@ -59,8 +58,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(projectId)) .path(String.valueOf(projectId))
.path(CONTRIBUTOR) .path(CONTRIBUTOR)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -69,8 +67,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(projectId)) .path(String.valueOf(projectId))
.path(AUTHOR) .path(AUTHOR)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -79,8 +76,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(personId)) .path(String.valueOf(personId))
.path(THESES) .path(THESES)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -89,19 +85,16 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(unitId)) .path(String.valueOf(unitId))
.path(SUBUNITS) .path(SUBUNITS)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
public Set<UserName> getUsernames(Integer personId) { public Set<UserName> getUsernames(Integer personId) {
return person() return person()
.path(String.valueOf(personId)) .path(String.valueOf(personId))
.path(USERNAMES) .path(USERNAMES)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -110,8 +103,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(personId)) .path(String.valueOf(personId))
.path(RESEARCH_AREAS) .path(RESEARCH_AREAS)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -120,8 +112,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(unitId)) .path(String.valueOf(unitId))
.path(SUPERVISORS) .path(SUPERVISORS)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -130,9 +121,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(id)) .path(String.valueOf(id))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Person.class)) : Optional.empty();
? Optional.of(response.readEntity(Person.class))
: Optional.empty();
} }
@Override @Override
@ -142,9 +131,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(userName) .path(userName)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Person.class)) : Optional.empty();
? Optional.of(response.readEntity(Person.class))
: Optional.empty();
} }
@Override @Override
@ -168,9 +155,7 @@ public class DaisyAPIImpl implements DaisyAPI {
@Override @Override
public Response createProject(ThesisToBeCreated project) { public Response createProject(ThesisToBeCreated project) {
return thesis() return thesis().request(MediaType.APPLICATION_XML_TYPE).post(xml(project));
.request(MediaType.APPLICATION_XML_TYPE)
.post(xml(project));
} }
@Override @Override
@ -184,26 +169,17 @@ public class DaisyAPIImpl implements DaisyAPI {
@Override @Override
public Response deleteProject(Integer projectId) { public Response deleteProject(Integer projectId) {
return thesis() return thesis().path(String.valueOf(projectId)).request(MediaType.APPLICATION_XML_TYPE).delete();
.path(String.valueOf(projectId))
.request(MediaType.APPLICATION_XML_TYPE)
.delete();
} }
@Override @Override
public Response getStudent(Integer id) { public Response getStudent(Integer id) {
return student() return student().path(String.valueOf(id)).request(MediaType.APPLICATION_XML_TYPE).get();
.path(String.valueOf(id))
.request(MediaType.APPLICATION_XML_TYPE)
.get();
} }
@Override @Override
public Program getProgram(Integer id) { public Program getProgram(Integer id) {
return program() return program().path(String.valueOf(id)).request(MediaType.APPLICATION_XML_TYPE).get(Program.class);
.path(String.valueOf(id))
.request(MediaType.APPLICATION_XML_TYPE)
.get(Program.class);
} }
@Override @Override
@ -212,17 +188,12 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(projectIdentifier)) .path(String.valueOf(projectIdentifier))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(Response.class); .get(Response.class);
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.of(response.readEntity(Thesis.class)) : Optional.empty();
? Optional.of(response.readEntity(Thesis.class))
: Optional.empty();
} }
@Override @Override
public void updateThesis(final Integer id, ThesisToBeUpdated thesis) { public void updateThesis(final Integer id, ThesisToBeUpdated thesis) {
thesis() thesis().path(String.valueOf(id)).request().put(xml(thesis));
.path(String.valueOf(id))
.request()
.put(xml(thesis));
} }
@Override @Override
@ -233,9 +204,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(String.valueOf(authorId)) .path(String.valueOf(authorId))
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(); .get();
return response.getStatus() == 200 return response.getStatus() == 200 ? Optional.ofNullable(response.readEntity(String.class)) : Optional.empty();
? Optional.ofNullable(response.readEntity(String.class))
: Optional.empty();
} }
@Override @Override
@ -243,8 +212,7 @@ public class DaisyAPIImpl implements DaisyAPI {
return person() return person()
.queryParam("personnummer", personnummer) .queryParam("personnummer", personnummer)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -333,8 +301,7 @@ public class DaisyAPIImpl implements DaisyAPI {
return program() return program()
.queryParam("responsibleDepartment", responsibleDepartmentId) .queryParam("responsibleDepartment", responsibleDepartmentId)
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -344,8 +311,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path("admissions") .path("admissions")
.queryParam("admissionSemester", admissionSemester.getId()) .queryParam("admissionSemester", admissionSemester.getId())
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -357,8 +323,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.queryParam("since", sinceParameter) .queryParam("since", sinceParameter)
// must be XML due to api date-formatting in json // must be XML due to api date-formatting in json
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} }
@Override @Override
@ -368,8 +333,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(Integer.toString(studentId)) .path(Integer.toString(studentId))
.path("programAdmissions") .path("programAdmissions")
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} catch (NotFoundException ignored) { } catch (NotFoundException ignored) {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -382,8 +346,7 @@ public class DaisyAPIImpl implements DaisyAPI {
.path(Integer.toString(studentId)) .path(Integer.toString(studentId))
.path("courseRegistrations") .path("courseRegistrations")
.request(MediaType.APPLICATION_XML_TYPE) .request(MediaType.APPLICATION_XML_TYPE)
.get(new GenericType<>() { .get(new GenericType<>() {});
});
} catch (NotFoundException ignored) { } catch (NotFoundException ignored) {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -400,7 +363,8 @@ public class DaisyAPIImpl implements DaisyAPI {
@Override @Override
public OrganisationalUnit orgunit(final int unitId) { public OrganisationalUnit orgunit(final int unitId) {
return () -> target() return () ->
target()
.path("orgunit") .path("orgunit")
.path(Integer.toString(unitId)) .path(Integer.toString(unitId))
.path("researchAreas") .path("researchAreas")
@ -444,37 +408,30 @@ public class DaisyAPIImpl implements DaisyAPI {
} }
private WebTarget program() { private WebTarget program() {
return target() return target().path(PROGRAM);
.path(PROGRAM);
} }
private WebTarget student() { private WebTarget student() {
return target() return target().path(STUDENT);
.path(STUDENT);
} }
private WebTarget thesis() { private WebTarget thesis() {
return target() return target().path(THESIS);
.path(THESIS);
} }
private WebTarget units() { private WebTarget units() {
return target() return target().path(ORGUNIT);
.path(ORGUNIT);
} }
private WebTarget person() { private WebTarget person() {
return target() return target().path(PERSON);
.path(PERSON);
} }
private WebTarget course() { private WebTarget course() {
return target() return target().path(COURSE);
.path(COURSE);
} }
private WebTarget target() { private WebTarget target() {
return client return client.target(baseUrl);
.target(baseUrl);
} }
} }

View File

@ -1,8 +1,7 @@
package se.su.dsv.scipro.daisyExternal.http; package se.su.dsv.scipro.daisyExternal.http;
import se.su.dsv.scipro.io.dto.ResearchArea;
import java.util.List; import java.util.List;
import se.su.dsv.scipro.io.dto.ResearchArea;
public interface OrganisationalUnit { public interface OrganisationalUnit {
List<ResearchArea> getResearchAreas(); List<ResearchArea> getResearchAreas();

View File

@ -6,23 +6,38 @@ import java.util.function.Supplier;
public abstract class PhotoResult { public abstract class PhotoResult {
public abstract <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found); public abstract <X> X fold(
final Supplier<X> missing,
final Supplier<X> forbidden,
final Function<InputStream, X> found
);
public static class Missing extends PhotoResult { public static class Missing extends PhotoResult {
@Override @Override
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) { public <X> X fold(
final Supplier<X> missing,
final Supplier<X> forbidden,
final Function<InputStream, X> found
) {
return missing.get(); return missing.get();
} }
} }
static class Forbidden extends PhotoResult { static class Forbidden extends PhotoResult {
@Override @Override
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) { public <X> X fold(
final Supplier<X> missing,
final Supplier<X> forbidden,
final Function<InputStream, X> found
) {
return forbidden.get(); return forbidden.get();
} }
} }
static class Found extends PhotoResult { static class Found extends PhotoResult {
private final InputStream photo; private final InputStream photo;
Found(final InputStream photo) { Found(final InputStream photo) {
@ -30,9 +45,12 @@ public abstract class PhotoResult {
} }
@Override @Override
public <X> X fold(final Supplier<X> missing, final Supplier<X> forbidden, final Function<InputStream, X> found) { public <X> X fold(
final Supplier<X> missing,
final Supplier<X> forbidden,
final Function<InputStream, X> found
) {
return found.apply(photo); return found.apply(photo);
} }
} }
} }

View File

@ -1,6 +1,7 @@
package se.su.dsv.scipro.daisyExternal.http; package se.su.dsv.scipro.daisyExternal.http;
public abstract class Semester { public abstract class Semester {
public static Semester spring(int year) { public static Semester spring(int year) {
return new Spring(year); return new Spring(year);
} }
@ -17,6 +18,7 @@ public abstract class Semester {
public abstract String toString(); public abstract String toString();
private static final class Spring extends Semester { private static final class Spring extends Semester {
private final int year; private final int year;
public Spring(final int year) { public Spring(final int year) {
@ -35,6 +37,7 @@ public abstract class Semester {
} }
private static final class Autumn extends Semester { private static final class Autumn extends Semester {
private final int year; private final int year;
public Autumn(final int year) { public Autumn(final int year) {

View File

@ -1,11 +1,11 @@
package se.su.dsv.scipro.data.dataobjects; package se.su.dsv.scipro.data.dataobjects;
import se.su.dsv.scipro.system.User;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.system.User;
public class Member implements Serializable { public class Member implements Serializable {
private final User user; private final User user;
private final Type type; private final Type type;
@ -75,7 +75,7 @@ public class Member implements Serializable {
public String toString() { public String toString() {
return "Individual milestone"; return "Individual milestone";
} }
} },
} }
public Member(User user, Type type) { public Member(User user, Type type) {
@ -96,9 +96,11 @@ public class Member implements Serializable {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Member)) return false; if (!(o instanceof Member)) return false;
final Member other = (Member) o; final Member other = (Member) o;
return other.canEqual(this) return (
&& Objects.equals(this.getUser(), other.getUser()) other.canEqual(this) &&
&& Objects.equals(this.getType(), other.getType()); Objects.equals(this.getUser(), other.getUser()) &&
Objects.equals(this.getType(), other.getType())
);
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -112,6 +114,6 @@ public class Member implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "Member(user=" + this.getUser() + ", type=" + this.getType() + ")"; return ("Member(user=" + this.getUser() + ", type=" + this.getType() + ")");
} }
} }

View File

@ -1,8 +1,9 @@
package se.su.dsv.scipro.data.enums; package se.su.dsv.scipro.data.enums;
public enum DateStyle { public enum DateStyle {
DATETIME("yyyy-MM-dd HH:mm"),
DATETIME("yyyy-MM-dd HH:mm"), DATE("yyyy-MM-dd"), TIME("HH:mm"); DATE("yyyy-MM-dd"),
TIME("HH:mm");
private final String format; private final String format;

View File

@ -22,6 +22,4 @@ public enum MailChoice {
public String toString() { public String toString() {
return asString; return asString;
} }
} }

View File

@ -1,5 +1,8 @@
package se.su.dsv.scipro.data.facade; package se.su.dsv.scipro.data.facade;
import jakarta.inject.Inject;
import java.io.Serializable;
import java.util.*;
import se.su.dsv.scipro.data.enums.MailChoice; import se.su.dsv.scipro.data.enums.MailChoice;
import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettingsService; import se.su.dsv.scipro.generalsystemsettings.GeneralSystemSettingsService;
import se.su.dsv.scipro.mail.EmailRecipient; import se.su.dsv.scipro.mail.EmailRecipient;
@ -15,16 +18,14 @@ import se.su.dsv.scipro.project.ProjectStatus;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject;
import java.io.Serializable;
import java.util.*;
public class MailFacade implements Serializable { public class MailFacade implements Serializable {
@Inject @Inject
private ProjectService projectService; private ProjectService projectService;
@Inject @Inject
private IdeaService ideaService; private IdeaService ideaService;
@Inject @Inject
private GeneralSystemSettingsService generalSystemSettingsService; private GeneralSystemSettingsService generalSystemSettingsService;
@ -38,7 +39,12 @@ public class MailFacade implements Serializable {
return supervisorsFromProjects(filter); return supervisorsFromProjects(filter);
} }
private Set<Recipient> addProjectCoSupervisors(ProjectStatus ps, Set<ProjectType> pc, Date startDate, Date endDate) { private Set<Recipient> addProjectCoSupervisors(
ProjectStatus ps,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate); final ProjectService.Filter filter = setProjectParams(ps, pc, startDate, endDate);
return coSupervisorsFromProjects(filter); return coSupervisorsFromProjects(filter);
} }
@ -48,7 +54,12 @@ public class MailFacade implements Serializable {
return reviewersFromProjects(filter); return reviewersFromProjects(filter);
} }
private ProjectService.Filter setProjectParams(ProjectStatus status, Set<ProjectType> pc, Date startDate, Date endDate) { private ProjectService.Filter setProjectParams(
ProjectStatus status,
Set<ProjectType> pc,
Date startDate,
Date endDate
) {
final ProjectService.Filter projectParams = new ProjectService.Filter(); final ProjectService.Filter projectParams = new ProjectService.Filter();
if (status != null) { if (status != null) {
projectParams.setStatuses(new HashSet<>(Collections.singletonList(status))); projectParams.setStatuses(new HashSet<>(Collections.singletonList(status)));
@ -91,7 +102,7 @@ public class MailFacade implements Serializable {
List<Project> listOfProjects = projectService.findAll(filter); List<Project> listOfProjects = projectService.findAll(filter);
Set<Recipient> recipients = new HashSet<>(); Set<Recipient> recipients = new HashSet<>();
for (Project p : listOfProjects) { for (Project p : listOfProjects) {
for (User user : p.getCoSupervisors()){ for (User user : p.getCoSupervisors()) {
recipients.add(new UserRecipient(user)); recipients.add(new UserRecipient(user));
} }
} }
@ -103,7 +114,7 @@ public class MailFacade implements Serializable {
List<Project> listOProjects = projectService.findAll(filter); List<Project> listOProjects = projectService.findAll(filter);
Set<Recipient> recipients = new HashSet<>(); Set<Recipient> recipients = new HashSet<>();
for (Project p : listOProjects) { for (Project p : listOProjects) {
for (User user : p.getReviewers()){ for (User user : p.getReviewers()) {
recipients.add(new UserRecipient(user)); recipients.add(new UserRecipient(user));
} }
} }
@ -112,11 +123,12 @@ public class MailFacade implements Serializable {
} }
private Set<Recipient> addThesisSupport() { private Set<Recipient> addThesisSupport() {
String thesisSupportMail = generalSystemSettingsService.getGeneralSystemSettingsInstance().getThesisSupportMail(); String thesisSupportMail = generalSystemSettingsService
.getGeneralSystemSettingsInstance()
.getThesisSupportMail();
if (thesisSupportMail != null) { if (thesisSupportMail != null) {
return Collections.singleton(new EmailRecipient(thesisSupportMail)); return Collections.singleton(new EmailRecipient(thesisSupportMail));
} } else {
else {
return Collections.emptySet(); return Collections.emptySet();
} }
} }
@ -140,23 +152,53 @@ public class MailFacade implements Serializable {
allFollowers.addAll(addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate)); allFollowers.addAll(addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
return allFollowers; return allFollowers;
case AUTHORS_MATCHED_IDEA: case AUTHORS_MATCHED_IDEA:
IdeaService.Filter matchedFilter = setIdeaParams(Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED), pc, startDate, endDate, null); IdeaService.Filter matchedFilter = setIdeaParams(
Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED),
pc,
startDate,
endDate,
null
);
return authorsFromIdeas(matchedFilter); return authorsFromIdeas(matchedFilter);
case AUTHORS_SUBMITTED_IDEA: case AUTHORS_SUBMITTED_IDEA:
IdeaService.Filter submittedFilter = setIdeaParams(null, pc, startDate, endDate, Collections.singletonList(Type.STUDENT)); IdeaService.Filter submittedFilter = setIdeaParams(
null,
pc,
startDate,
endDate,
Collections.singletonList(Type.STUDENT)
);
return authorsFromIdeas(submittedFilter); return authorsFromIdeas(submittedFilter);
case SUPERVISORS_MATCHED_IDEA: case SUPERVISORS_MATCHED_IDEA:
IdeaService.Filter supervisorMatchedFilter = setIdeaParams(Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED), pc, startDate, endDate, null); IdeaService.Filter supervisorMatchedFilter = setIdeaParams(
Arrays.asList(Idea.Status.COMPLETED, Idea.Status.MATCHED),
pc,
startDate,
endDate,
null
);
return supervisorsFromIdeas(supervisorMatchedFilter); return supervisorsFromIdeas(supervisorMatchedFilter);
case SUPERVISORS_SUBMITTED_IDEA: case SUPERVISORS_SUBMITTED_IDEA:
IdeaService.Filter supervisorSubmittedFilter = setIdeaParams(null, pc, startDate, endDate, Collections.singletonList(Type.SUPERVISOR)); IdeaService.Filter supervisorSubmittedFilter = setIdeaParams(
null,
pc,
startDate,
endDate,
Collections.singletonList(Type.SUPERVISOR)
);
return supervisorsFromIdeas(supervisorSubmittedFilter); return supervisorsFromIdeas(supervisorSubmittedFilter);
default: default:
return new HashSet<>(); return new HashSet<>();
} }
} }
private IdeaService.Filter setIdeaParams(Collection<Idea.Status> statuses, Set<ProjectType> pc, Date startDate, Date endDate, Collection<Type> types) { private IdeaService.Filter setIdeaParams(
Collection<Idea.Status> statuses,
Set<ProjectType> pc,
Date startDate,
Date endDate,
Collection<Type> types
) {
final IdeaService.Filter ideaParams = new IdeaService.Filter(); final IdeaService.Filter ideaParams = new IdeaService.Filter();
if (statuses != null && !statuses.isEmpty()) { if (statuses != null && !statuses.isEmpty()) {
ideaParams.setStatuses(statuses); ideaParams.setStatuses(statuses);

View File

@ -1,8 +1,7 @@
package se.su.dsv.scipro.date; package se.su.dsv.scipro.date;
import se.su.dsv.scipro.data.enums.DateStyle;
import java.util.Date; import java.util.Date;
import se.su.dsv.scipro.data.enums.DateStyle;
public interface DateService { public interface DateService {
String format(Date date); String format(Date date);

View File

@ -1,15 +1,12 @@
package se.su.dsv.scipro.date; package se.su.dsv.scipro.date;
import se.su.dsv.scipro.data.enums.DateStyle;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import se.su.dsv.scipro.data.enums.DateStyle;
public class DateServiceImpl implements DateService { public class DateServiceImpl implements DateService {
private String findStyle(DateStyle style) {
private String findStyle(DateStyle style){
return style.getFormat(); return style.getFormat();
} }

View File

@ -1,10 +1,5 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -13,6 +8,10 @@ import java.nio.file.Files;
import java.nio.file.NoSuchFileException; import java.nio.file.NoSuchFileException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Objects; import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User;
/** /**
* Metadata about a specific file. To get access to the underlying data you need a * Metadata about a specific file. To get access to the underlying data you need a
@ -138,8 +137,7 @@ public class FileDescription extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FileDescription)) return false; if (!(o instanceof FileDescription)) return false;
final FileDescription other = (FileDescription) o; final FileDescription other = (FileDescription) o;
return other.canEqual(this) return (other.canEqual(this) && Objects.equals(this.getId(), other.getId()));
&& Objects.equals(this.getId(), other.getId());
} }
@Override @Override

View File

@ -4,7 +4,6 @@ import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.JpaRepository; import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor; import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
@Transactional @Transactional
public interface FileDescriptionRepo extends JpaRepository<FileDescription, Long>, QueryDslPredicateExecutor<FileDescription> { public interface FileDescriptionRepo
} extends JpaRepository<FileDescription, Long>, QueryDslPredicateExecutor<FileDescription> {}

View File

@ -1,15 +1,14 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.system.GenericRepo;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 @Inject
public FileDescriptionRepoImpl(Provider<EntityManager> em) { public FileDescriptionRepoImpl(Provider<EntityManager> em) {
super(em, FileDescription.class, QFileDescription.fileDescription); super(em, FileDescription.class, QFileDescription.fileDescription);
} }
} }

View File

@ -24,6 +24,7 @@ import java.util.Objects;
@Entity @Entity
@Table(name = "file_reference") @Table(name = "file_reference")
public class FileReference implements Serializable { public class FileReference implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@ -57,7 +58,7 @@ public class FileReference implements Serializable {
return false; return false;
} }
final FileReference that = (FileReference) o; final FileReference that = (FileReference) o;
return Objects.equals(id, that.id) && fileDescription.equals(that.fileDescription); return (Objects.equals(id, that.id) && fileDescription.equals(that.fileDescription));
} }
@Override @Override
@ -67,10 +68,7 @@ public class FileReference implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "FileReference{" + return ("FileReference{" + "id=" + id + ", fileDescription=" + fileDescription + '}');
"id=" + id +
", fileDescription=" + fileDescription +
'}';
} }
public String getName() { public String getName() {

View File

@ -1,11 +1,10 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractRepository;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; 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 {

View File

@ -1,8 +1,7 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.system.GenericService;
import java.io.InputStream; import java.io.InputStream;
import se.su.dsv.scipro.system.GenericService;
public interface FileService extends GenericService<FileDescription, Long> { public interface FileService extends GenericService<FileDescription, Long> {
FileReference storeFile(FileUpload fileUpload); FileReference storeFile(FileUpload fileUpload);

View File

@ -1,12 +1,11 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;
import java.io.InputStream; 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 {
@ -19,8 +18,8 @@ public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long>
Provider<EntityManager> em, Provider<EntityManager> em,
final FileReferenceRepository fileReferenceRepository, final FileReferenceRepository fileReferenceRepository,
final FileDescriptionRepo fileDescriptionRepository, final FileDescriptionRepo fileDescriptionRepository,
final FileStore fileStore) final FileStore fileStore
{ ) {
super(em, FileDescription.class, QFileDescription.fileDescription); super(em, FileDescription.class, QFileDescription.fileDescription);
this.fileReferenceRepository = fileReferenceRepository; this.fileReferenceRepository = fileReferenceRepository;
this.fileDescriptionRepository = fileDescriptionRepository; this.fileDescriptionRepository = fileDescriptionRepository;
@ -80,5 +79,4 @@ public class FileServiceImpl extends AbstractServiceImpl<FileDescription, Long>
fileStore.deleteData(fileDescription); fileStore.deleteData(fileDescription);
} }
} }
} }

View File

@ -7,5 +7,5 @@ public enum FileSource {
PEER_REVIEW, PEER_REVIEW,
PEER_REQUEST, PEER_REQUEST,
FINAL_SEMINAR, FINAL_SEMINAR,
ACTIVITY_PLAN ACTIVITY_PLAN,
} }

View File

@ -1,9 +1,8 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.system.User;
import java.io.InputStream; import java.io.InputStream;
import java.util.function.Function; import java.util.function.Function;
import se.su.dsv.scipro.system.User;
public interface FileUpload { public interface FileUpload {
String getFileName(); String getFileName();

View File

@ -12,11 +12,10 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
import java.util.Objects;
@Entity @Entity
@Table(name = "project_file") @Table(name = "project_file")
public class ProjectFile extends DomainObject { public class ProjectFile extends DomainObject {
@ -88,12 +87,14 @@ public class ProjectFile extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof ProjectFile)) return false; if (!(o instanceof ProjectFile)) return false;
final ProjectFile other = (ProjectFile) o; final ProjectFile other = (ProjectFile) o;
return other.canEqual(this) return (
&& super.equals(o) other.canEqual(this) &&
&& Objects.equals(this.getId(), other.getId()) super.equals(o) &&
&& Objects.equals(this.getProject(), other.getProject()) Objects.equals(this.getId(), other.getId()) &&
&& Objects.equals(this.getFileSource(), other.getFileSource()) Objects.equals(this.getProject(), other.getProject()) &&
&& Objects.equals(this.getFileDescription(), other.getFileDescription()); Objects.equals(this.getFileSource(), other.getFileSource()) &&
Objects.equals(this.getFileDescription(), other.getFileDescription())
);
} }
@Override @Override
@ -103,7 +104,17 @@ public class ProjectFile extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "ProjectFile(id=" + this.getId() + ", project=" + this.getProject() + ", fileSource=" + this.getFileSource() + ", fileDescription=" + this.getFileDescription() + ")"; return (
"ProjectFile(id=" +
this.getId() +
", project=" +
this.getProject() +
", fileSource=" +
this.getFileSource() +
", fileDescription=" +
this.getFileDescription() +
")"
);
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------

View File

@ -1,13 +1,13 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
import se.su.dsv.scipro.project.Project;
import java.util.*; import java.util.*;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
public interface ProjectFileRepository extends JpaRepository<ProjectFile, Long>, QueryDslPredicateExecutor<ProjectFile> { public interface ProjectFileRepository
extends JpaRepository<ProjectFile, Long>, QueryDslPredicateExecutor<ProjectFile> {
List<ProjectFile> latestUpload(Project project, int amount); List<ProjectFile> latestUpload(Project project, int amount);
Collection<ProjectFile> getProjectFiles(Project project, Pageable pageable); Collection<ProjectFile> getProjectFiles(Project project, Pageable pageable);

View File

@ -2,16 +2,16 @@ package se.su.dsv.scipro.file;
import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQuery;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.*; import java.util.*;
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 @Inject
public ProjectFileRepositoryImpl(final Provider<EntityManager> em) { public ProjectFileRepositoryImpl(final Provider<EntityManager> em) {
super(em, ProjectFile.class, QProjectFile.projectFile); super(em, ProjectFile.class, QProjectFile.projectFile);
@ -38,8 +38,13 @@ public class ProjectFileRepositoryImpl extends AbstractServiceImpl<ProjectFile,
@Override @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( return Optional.ofNullable(
findOne(
Expressions.allOf(
QProjectFile.projectFile.fileReference.fileDescription.eq(fileDescription), QProjectFile.projectFile.fileReference.fileDescription.eq(fileDescription),
QProjectFile.projectFile.project.eq(project)))); QProjectFile.projectFile.project.eq(project)
)
)
);
} }
} }

View File

@ -1,9 +1,8 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.project.Project;
import java.util.*; import java.util.*;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Pageable;
public interface ProjectFileService { public interface ProjectFileService {
ProjectFile store(ProjectFileUpload projectFileUpload, final FileSource fileSource); ProjectFile store(ProjectFileUpload projectFileUpload, final FileSource fileSource);

View File

@ -1,26 +1,22 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.project.Project;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import java.util.*; import java.util.*;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Pageable;
public class ProjectFileServiceImpl implements ProjectFileService { public class ProjectFileServiceImpl implements ProjectFileService {
private final FileService fileService; private final FileService fileService;
private final ProjectFileRepository projectFileRepository; private final ProjectFileRepository projectFileRepository;
@Inject @Inject
public ProjectFileServiceImpl( public ProjectFileServiceImpl(final FileService fileService, final ProjectFileRepository projectFileRepository) {
final FileService fileService,
final ProjectFileRepository projectFileRepository)
{
this.fileService = fileService; this.fileService = fileService;
this.projectFileRepository = projectFileRepository; this.projectFileRepository = projectFileRepository;
} }
@Override @Override
@Transactional @Transactional
public ProjectFile store(final ProjectFileUpload projectFileUpload, final FileSource fileSource) { public ProjectFile store(final ProjectFileUpload projectFileUpload, final FileSource fileSource) {
@ -30,7 +26,11 @@ public class ProjectFileServiceImpl implements ProjectFileService {
@Override @Override
@Transactional @Transactional
public ProjectFile promote(final FileDescription fileDescription, final Project project, final FileSource fileSource) { public ProjectFile promote(
final FileDescription fileDescription,
final Project project,
final FileSource fileSource
) {
Optional<ProjectFile> existing = projectFileRepository.findProjectFile(fileDescription, project); Optional<ProjectFile> existing = projectFileRepository.findProjectFile(fileDescription, project);
if (existing.isPresent()) { if (existing.isPresent()) {
return existing.get(); return existing.get();

View File

@ -1,6 +1,5 @@
package se.su.dsv.scipro.file; package se.su.dsv.scipro.file;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
public interface ProjectFileUpload extends FileUpload { public interface ProjectFileUpload extends FileUpload {

View File

@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
class AbstractOppositionEvent { class AbstractOppositionEvent {
private final FinalSeminarOpposition opposition; private final FinalSeminarOpposition opposition;
protected AbstractOppositionEvent(FinalSeminarOpposition opposition) { protected AbstractOppositionEvent(FinalSeminarOpposition opposition) {

View File

@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
class AbstractParticipationEvent { class AbstractParticipationEvent {
private final FinalSeminarActiveParticipation participation; private final FinalSeminarActiveParticipation participation;
protected AbstractParticipationEvent(FinalSeminarActiveParticipation participation) { protected AbstractParticipationEvent(FinalSeminarActiveParticipation participation) {

View File

@ -4,6 +4,7 @@ import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
class AbstractRespondentEvent { class AbstractRespondentEvent {
private final FinalSeminarRespondent respondent; private final FinalSeminarRespondent respondent;
protected AbstractRespondentEvent(FinalSeminarRespondent respondent) { protected AbstractRespondentEvent(FinalSeminarRespondent respondent) {

View File

@ -3,74 +3,84 @@ package se.su.dsv.scipro.finalseminar;
import java.util.function.Function; import java.util.function.Function;
public abstract class ActiveParticipationRegistrationErrorStatus { public abstract class ActiveParticipationRegistrationErrorStatus {
ActiveParticipationRegistrationErrorStatus() {
} ActiveParticipationRegistrationErrorStatus() {}
public abstract <A> A fold( public abstract <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g); Function<ParticipationFinalSeminarCancelled, A> g
);
} }
final class TooManyParticipants extends ActiveParticipationRegistrationErrorStatus { final class TooManyParticipants extends ActiveParticipationRegistrationErrorStatus {
@Override @Override
public <A> A fold( public <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g) { Function<ParticipationFinalSeminarCancelled, A> g
) {
return a.apply(this); return a.apply(this);
} }
} }
final class ManualParticipants extends ActiveParticipationRegistrationErrorStatus { final class ManualParticipants extends ActiveParticipationRegistrationErrorStatus {
@Override @Override
public <A> A fold( public <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g) { Function<ParticipationFinalSeminarCancelled, A> g
) {
return b.apply(this); return b.apply(this);
} }
} }
final class ParticipationAlreadyParticipating extends ActiveParticipationRegistrationErrorStatus { final class ParticipationAlreadyParticipating extends ActiveParticipationRegistrationErrorStatus {
@Override @Override
public <A> A fold( public <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g) { Function<ParticipationFinalSeminarCancelled, A> g
) {
return e.apply(this); return e.apply(this);
} }
} }
final class ParticipationAlreadyHappened extends ActiveParticipationRegistrationErrorStatus { final class ParticipationAlreadyHappened extends ActiveParticipationRegistrationErrorStatus {
@Override @Override
public <A> A fold( public <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g) { Function<ParticipationFinalSeminarCancelled, A> g
) {
return f.apply(this); return f.apply(this);
} }
} }
final class ParticipationFinalSeminarCancelled extends ActiveParticipationRegistrationErrorStatus { final class ParticipationFinalSeminarCancelled extends ActiveParticipationRegistrationErrorStatus {
@Override @Override
public <A> A fold( public <A> A fold(
Function<TooManyParticipants, A> a, Function<TooManyParticipants, A> a,
Function<ManualParticipants, A> b, Function<ManualParticipants, A> b,
Function<ParticipationAlreadyParticipating, A> e, Function<ParticipationAlreadyParticipating, A> e,
Function<ParticipationAlreadyHappened, A> f, Function<ParticipationAlreadyHappened, A> f,
Function<ParticipationFinalSeminarCancelled, A> g) { Function<ParticipationFinalSeminarCancelled, A> g
) {
return g.apply(this); return g.apply(this);
} }
} }

View File

@ -1,13 +1,12 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import java.util.List;
import java.util.Optional;
import se.su.dsv.scipro.project.Author; import se.su.dsv.scipro.project.Author;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.List;
import java.util.Optional;
public interface AuthorRepository { public interface AuthorRepository {
Optional<Author> findByProjectAndUser(Project project, User user); Optional<Author> findByProjectAndUser(Project project, User user);

View File

@ -1,5 +1,10 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.persistence.EntityManager;
import java.util.List;
import java.util.Optional;
import se.su.dsv.scipro.project.Author; import se.su.dsv.scipro.project.Author;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.project.ProjectStatus; import se.su.dsv.scipro.project.ProjectStatus;
@ -8,13 +13,8 @@ import se.su.dsv.scipro.system.AbstractRepository;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.persistence.EntityManager;
import java.util.List;
import java.util.Optional;
public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRepository { public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRepository {
@Inject @Inject
public AuthorRepositoryImpl(Provider<EntityManager> em) { public AuthorRepositoryImpl(Provider<EntityManager> em) {
super(em); super(em);
@ -23,11 +23,7 @@ public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRe
@Override @Override
public Optional<Author> findByProjectAndUser(Project project, User user) { public Optional<Author> findByProjectAndUser(Project project, User user) {
final QAuthor author = QAuthor.author; final QAuthor author = QAuthor.author;
final Author author1 = from(author) final Author author1 = from(author).where(author.project.eq(project), author.user.eq(user)).fetchOne();
.where(
author.project.eq(project),
author.user.eq(user))
.fetchOne();
return Optional.ofNullable(author1); return Optional.ofNullable(author1);
} }
@ -35,9 +31,11 @@ public class AuthorRepositoryImpl extends AbstractRepository implements AuthorRe
public List<Author> getSubscribersWithActiveProjectOnType(ProjectType projectType) { public List<Author> getSubscribersWithActiveProjectOnType(ProjectType projectType) {
final QAuthor author = QAuthor.author; final QAuthor author = QAuthor.author;
return from(author) return from(author)
.where(author.subscribedToFinalSeminarNotifications.isTrue(), .where(
author.subscribedToFinalSeminarNotifications.isTrue(),
author.project.projectType.eq(projectType), author.project.projectType.eq(projectType),
author.project.projectStatus.eq(ProjectStatus.ACTIVE)) author.project.projectStatus.eq(ProjectStatus.ACTIVE)
)
.fetch(); .fetch();
} }
} }

View File

@ -1,15 +1,6 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import com.querydsl.core.annotations.QueryInit; import com.querydsl.core.annotations.QueryInit;
import jakarta.persistence.GenerationType;
import se.su.dsv.scipro.data.dataobjects.Member;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Language;
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
@ -18,12 +9,12 @@ import jakarta.persistence.Entity;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated; import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -32,11 +23,19 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import se.su.dsv.scipro.data.dataobjects.Member;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.Language;
import se.su.dsv.scipro.system.LazyDeletableDomainObject;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
@Entity @Entity
@Table(name = "final_seminar") @Table(name = "final_seminar")
@Cacheable(true) @Cacheable(true)
public class FinalSeminar extends LazyDeletableDomainObject { public class FinalSeminar extends LazyDeletableDomainObject {
public static final String U_SINGULAR = "Final seminar"; public static final String U_SINGULAR = "Final seminar";
public static final int DEFAULT_MAX_OPPONENTS = 2; public static final int DEFAULT_MAX_OPPONENTS = 2;
@ -100,7 +99,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
@OneToOne(optional = false) @OneToOne(optional = false)
@JoinColumn(name = "project_id", referencedColumnName = "id") @JoinColumn(name = "project_id", referencedColumnName = "id")
@QueryInit({"projectType", "headSupervisor"}) @QueryInit({ "projectType", "headSupervisor" })
private Project project; private Project project;
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -118,8 +117,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Constructors // Constructors
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
public FinalSeminar() { public FinalSeminar() {}
}
public FinalSeminar(int maxOpponents, int maxParticipants) { public FinalSeminar(int maxOpponents, int maxParticipants) {
this.maxOpponents = maxOpponents; this.maxOpponents = maxOpponents;
@ -273,9 +271,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminar)) return false; if (!(o instanceof FinalSeminar)) return false;
final FinalSeminar other = (FinalSeminar) o; final FinalSeminar other = (FinalSeminar) o;
return other.canEqual(this) return (other.canEqual(this) && super.equals(o) && Objects.equals(this.getId(), other.getId()));
&& super.equals(o)
&& Objects.equals(this.getId(), other.getId());
} }
@Override @Override
@ -285,14 +281,35 @@ public class FinalSeminar extends LazyDeletableDomainObject {
@Override @Override
public String toString() { public String toString() {
return "FinalSeminar(id=" + this.getId() + ", project=" + this.getProject() + ", startDate=" + return (
this.getStartDate() + ", room=" + this.getRoom() + ", activeParticipations=" + "FinalSeminar(id=" +
this.getActiveParticipations() + ", oppositions=" + this.getOppositions() + this.getId() +
", respondents=" + this.getRespondents() + ", document=" + this.getDocument() + ", project=" +
", documentUploadDate=" + this.getDocumentUploadDate() + ", presentationLanguage=" + this.getProject() +
this.getPresentationLanguage() + ", maxOpponents=" + this.getMaxOpponents() + ", startDate=" +
", maxParticipants=" + this.getMaxParticipants() + ", creationReason=" + this.getStartDate() +
this.getCreationReason() + ")"; ", room=" +
this.getRoom() +
", activeParticipations=" +
this.getActiveParticipations() +
", oppositions=" +
this.getOppositions() +
", respondents=" +
this.getRespondents() +
", document=" +
this.getDocument() +
", documentUploadDate=" +
this.getDocumentUploadDate() +
", presentationLanguage=" +
this.getPresentationLanguage() +
", maxOpponents=" +
this.getMaxOpponents() +
", maxParticipants=" +
this.getMaxParticipants() +
", creationReason=" +
this.getCreationReason() +
")"
);
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -314,9 +331,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
activeParticipations.removeIf(next -> next.getUser().equals(user)); activeParticipations.removeIf(next -> next.getUser().equals(user));
} }
public Set<User> getActiveParticipants(){ public Set<User> getActiveParticipants() {
Set<User> activeParticipants = new HashSet<>(); Set<User> activeParticipants = new HashSet<>();
for (FinalSeminarActiveParticipation fsap : activeParticipations){ for (FinalSeminarActiveParticipation fsap : activeParticipations) {
activeParticipants.add(fsap.getUser()); activeParticipants.add(fsap.getUser());
} }
return activeParticipants; return activeParticipants;
@ -334,9 +351,9 @@ public class FinalSeminar extends LazyDeletableDomainObject {
this.oppositions.remove(opposition); this.oppositions.remove(opposition);
} }
public Set<User> getOpponents(){ public Set<User> getOpponents() {
Set<User> opponents = new HashSet<>(); Set<User> opponents = new HashSet<>();
for (FinalSeminarOpposition fso : oppositions){ for (FinalSeminarOpposition fso : oppositions) {
opponents.add(fso.getUser()); opponents.add(fso.getUser());
} }
return opponents; return opponents;
@ -353,7 +370,7 @@ public class FinalSeminar extends LazyDeletableDomainObject {
private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) { private Collection<User> getNotGradedParticipations(Set<? extends FinalSeminarParticipation> participations) {
List<User> result = new ArrayList<>(); List<User> result = new ArrayList<>();
for (FinalSeminarParticipation participation : participations) { for (FinalSeminarParticipation participation : participations) {
if(participation.getGrade() == null) { if (participation.getGrade() == null) {
result.add(participation.getUser()); result.add(participation.getUser());
} }
} }

View File

@ -1,18 +1,18 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.persistence.JoinColumn;
import se.su.dsv.scipro.project.Project;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.project.Project;
@Entity @Entity
@Table(name = "final_seminar_active_participation") @Table(name = "final_seminar_active_participation")
@Cacheable(true) @Cacheable(true)
public class FinalSeminarActiveParticipation extends FinalSeminarParticipation { public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (final_seminar_active_participation) // JPA-mappings of foreign keys in this table (final_seminar_active_participation)
// referencing other tables. // referencing other tables.
@ -40,9 +40,7 @@ public class FinalSeminarActiveParticipation extends FinalSeminarParticipation {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarActiveParticipation)) return false; if (!(o instanceof FinalSeminarActiveParticipation)) return false;
final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o; final FinalSeminarActiveParticipation other = (FinalSeminarActiveParticipation) o;
return other.canEqual(this) return (other.canEqual(this) && super.equals(o) && Objects.equals(this.project, other.project));
&& super.equals(o)
&& Objects.equals(this.project, other.project);
} }
@Override @Override

View File

@ -1,10 +1,9 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import java.util.*;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.*;
public interface FinalSeminarActiveParticipationRepository { public interface FinalSeminarActiveParticipationRepository {
List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType); List<FinalSeminarActiveParticipation> findByParticipatingUserAndLevel(User user, ProjectType projectType);
} }

View File

@ -1,15 +1,17 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.AbstractRepository;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.*; import java.util.*;
import se.su.dsv.scipro.system.AbstractRepository;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
public class FinalSeminarActiveParticipationRepositoryImpl
extends AbstractRepository
implements FinalSeminarActiveParticipationRepository {
public class FinalSeminarActiveParticipationRepositoryImpl extends AbstractRepository implements FinalSeminarActiveParticipationRepository {
@Inject @Inject
public FinalSeminarActiveParticipationRepositoryImpl(Provider<EntityManager> em) { public FinalSeminarActiveParticipationRepositoryImpl(Provider<EntityManager> em) {
super(em); super(em);

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.GenericService;
import se.su.dsv.scipro.system.User; 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);
FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar,User user);
} }

View File

@ -1,28 +1,31 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User;
public class FinalSeminarActiveParticipationServiceImpl extends AbstractServiceImpl<FinalSeminarActiveParticipation, Long> implements FinalSeminarActiveParticipationService { public class FinalSeminarActiveParticipationServiceImpl
extends AbstractServiceImpl<FinalSeminarActiveParticipation, Long>
implements FinalSeminarActiveParticipationService {
@Inject @Inject
public FinalSeminarActiveParticipationServiceImpl(Provider<EntityManager> em) { public FinalSeminarActiveParticipationServiceImpl(Provider<EntityManager> em) {
super(em, FinalSeminarActiveParticipation.class, QFinalSeminarActiveParticipation.finalSeminarActiveParticipation); super(
em,
FinalSeminarActiveParticipation.class,
QFinalSeminarActiveParticipation.finalSeminarActiveParticipation
);
} }
@Override @Override
public FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar,User user){ public FinalSeminarActiveParticipation findByFinalSeminarUser(FinalSeminar finalSeminar, User user) {
for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) { for (FinalSeminarActiveParticipation fsap : finalSeminar.getActiveParticipations()) {
if(fsap.getUser().equals(user)){ if (fsap.getUser().equals(user)) {
return fsap; return fsap;
} }
} }
return null; return null;
} }
} }

View File

@ -3,9 +3,10 @@ package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
public final class FinalSeminarCreatedEvent { public final class FinalSeminarCreatedEvent {
private final FinalSeminar finalSeminar; private final FinalSeminar finalSeminar;
public FinalSeminar getFinalSeminar(){ public FinalSeminar getFinalSeminar() {
return finalSeminar; return finalSeminar;
} }

View File

@ -2,6 +2,10 @@ package se.su.dsv.scipro.finalseminar;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe; import com.google.common.eventbus.Subscribe;
import jakarta.inject.Inject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import se.su.dsv.scipro.data.dataobjects.Member; import se.su.dsv.scipro.data.dataobjects.Member;
import se.su.dsv.scipro.notifications.NotificationController; import se.su.dsv.scipro.notifications.NotificationController;
import se.su.dsv.scipro.notifications.dataobject.NotificationSource; import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
@ -9,12 +13,8 @@ import se.su.dsv.scipro.notifications.dataobject.SeminarEvent;
import se.su.dsv.scipro.project.Author; import se.su.dsv.scipro.project.Author;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class FinalSeminarCreationSubscribers { public class FinalSeminarCreationSubscribers {
private final AuthorRepository authorRepository; private final AuthorRepository authorRepository;
private final FinalSeminarService finalSeminarService; private final FinalSeminarService finalSeminarService;
private final NotificationController notificationController; private final NotificationController notificationController;
@ -22,8 +22,8 @@ public class FinalSeminarCreationSubscribers {
FinalSeminarCreationSubscribers( FinalSeminarCreationSubscribers(
AuthorRepository authorRepository, AuthorRepository authorRepository,
FinalSeminarService finalSeminarService, FinalSeminarService finalSeminarService,
NotificationController notificationController) NotificationController notificationController
{ ) {
this.authorRepository = authorRepository; this.authorRepository = authorRepository;
this.finalSeminarService = finalSeminarService; this.finalSeminarService = finalSeminarService;
this.notificationController = notificationController; this.notificationController = notificationController;
@ -34,20 +34,27 @@ public class FinalSeminarCreationSubscribers {
AuthorRepository authorRepository, AuthorRepository authorRepository,
FinalSeminarService finalSeminarService, FinalSeminarService finalSeminarService,
NotificationController notificationController, NotificationController notificationController,
EventBus eventBus) EventBus eventBus
{ ) {
this(authorRepository, finalSeminarService, notificationController); this(authorRepository, finalSeminarService, notificationController);
eventBus.register(this); eventBus.register(this);
} }
@Subscribe @Subscribe
public void finalSeminarCreated(FinalSeminarCreatedEvent event) { public void finalSeminarCreated(FinalSeminarCreatedEvent event) {
List<Author> subscribers = authorRepository.getSubscribersWithActiveProjectOnType(event.getFinalSeminar().getProjectType()); List<Author> subscribers = authorRepository.getSubscribersWithActiveProjectOnType(
event.getFinalSeminar().getProjectType()
);
Set<Member> users = getSubscribersStillNeedingOppositionOrParticipation(subscribers) Set<Member> users = getSubscribersStillNeedingOppositionOrParticipation(subscribers)
.stream() .stream()
.map(user -> new Member(user, Member.Type.OPPONENT)) .map(user -> new Member(user, Member.Type.OPPONENT))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
notificationController.notifyCustomSeminar(event.getFinalSeminar(), SeminarEvent.Event.CREATED, new NotificationSource(), users); notificationController.notifyCustomSeminar(
event.getFinalSeminar(),
SeminarEvent.Event.CREATED,
new NotificationSource(),
users
);
} }
private List<User> getSubscribersStillNeedingOppositionOrParticipation(List<Author> subscribers) { private List<User> getSubscribersStillNeedingOppositionOrParticipation(List<Author> subscribers) {
@ -59,13 +66,18 @@ public class FinalSeminarCreationSubscribers {
} }
private boolean onlyFailedParticipations(Author subscriber) { private boolean onlyFailedParticipations(Author subscriber) {
return finalSeminarService.findUserParticipating(subscriber.getProject(), subscriber.getUser()) return finalSeminarService
.findUserParticipating(subscriber.getProject(), subscriber.getUser())
.stream() .stream()
.noneMatch(FinalSeminarParticipation::isApproved); .noneMatch(FinalSeminarParticipation::isApproved);
} }
private boolean onlyFailedOppositions(Author subscriber) { private boolean onlyFailedOppositions(Author subscriber) {
return finalSeminarService.findFinalSeminarOppositionsByOpponentAndProjectType(subscriber.getProject().getProjectType(), subscriber.getUser()) return finalSeminarService
.findFinalSeminarOppositionsByOpponentAndProjectType(
subscriber.getProject().getProjectType(),
subscriber.getUser()
)
.stream() .stream()
.noneMatch(FinalSeminarParticipation::isApproved); .noneMatch(FinalSeminarParticipation::isApproved);
} }

View File

@ -3,9 +3,10 @@ package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
public final class FinalSeminarDeletedEvent { public final class FinalSeminarDeletedEvent {
private final FinalSeminar finalSeminar; private final FinalSeminar finalSeminar;
public FinalSeminar getFinalSeminar(){ public FinalSeminar getFinalSeminar() {
return finalSeminar; return finalSeminar;
} }

View File

@ -9,6 +9,5 @@ public record FinalSeminarDetails(
int maxOpponents, int maxOpponents,
Language presentationLanguage, Language presentationLanguage,
Language reportLanguage, Language reportLanguage,
String extraInfo) String extraInfo
{ ) {}
}

View File

@ -1,17 +1,16 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
public enum FinalSeminarGrade { public enum FinalSeminarGrade {
APPROVED { APPROVED {
@Override @Override
public String toString() { public String toString() {
return "approved"; return "approved";
} }
}, NOT_APPROVED { },
NOT_APPROVED {
@Override @Override
public String toString() { public String toString() {
return "not approved"; return "not approved";
} }
} },
} }

View File

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

View File

@ -1,10 +1,5 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.report.OppositionReport;
import se.su.dsv.scipro.system.ProjectType;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
@ -13,12 +8,16 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.report.OppositionReport;
import se.su.dsv.scipro.system.ProjectType;
@Entity @Entity
@Table(name="final_seminar_opposition") @Table(name = "final_seminar_opposition")
public class FinalSeminarOpposition extends FinalSeminarParticipation { public class FinalSeminarOpposition extends FinalSeminarParticipation {
private static final int FEEDBACK_LENGTH = 2000; private static final int FEEDBACK_LENGTH = 2000;
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -47,8 +46,7 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// JPA-mappings of other tables referencing to this table (final_seminar_opposition) // JPA-mappings of other tables referencing to this table (final_seminar_opposition)
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL, @OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "finalSeminarOpposition")
mappedBy = "finalSeminarOpposition")
private OppositionReport oppositionReport; private OppositionReport oppositionReport;
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -102,9 +100,7 @@ public class FinalSeminarOpposition extends FinalSeminarParticipation {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarOpposition)) return false; if (!(o instanceof FinalSeminarOpposition)) return false;
final FinalSeminarOpposition other = (FinalSeminarOpposition) o; final FinalSeminarOpposition other = (FinalSeminarOpposition) o;
return other.canEqual(this) return (other.canEqual(this) && super.equals(o) && Objects.equals(this.getProject(), other.getProject()));
&& super.equals(o)
&& Objects.equals(this.getProject(), other.getProject());
} }
@Override @Override

View File

@ -1,15 +1,14 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import java.util.*;
import se.su.dsv.scipro.system.JpaRepository; import se.su.dsv.scipro.system.JpaRepository;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.QueryDslPredicateExecutor;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.*;
@Transactional @Transactional
public interface FinalSeminarOppositionRepo extends JpaRepository<FinalSeminarOpposition, Long>, QueryDslPredicateExecutor<FinalSeminarOpposition> { public interface FinalSeminarOppositionRepo
extends JpaRepository<FinalSeminarOpposition, Long>, QueryDslPredicateExecutor<FinalSeminarOpposition> {
List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType); List<FinalSeminarOpposition> findByOpposingUserAndType(User user, ProjectType projectType);
} }

View File

@ -1,15 +1,17 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.GenericRepo;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import java.util.*; import java.util.*;
import se.su.dsv.scipro.system.GenericRepo;
import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User;
public class FinalSeminarOppositionRepoImpl
extends GenericRepo<FinalSeminarOpposition, Long>
implements FinalSeminarOppositionRepo {
public class FinalSeminarOppositionRepoImpl extends GenericRepo<FinalSeminarOpposition,Long> implements FinalSeminarOppositionRepo {
@Inject @Inject
public FinalSeminarOppositionRepoImpl(Provider<EntityManager> em) { public FinalSeminarOppositionRepoImpl(Provider<EntityManager> em) {
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition); super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);

View File

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

View File

@ -1,12 +1,14 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractServiceImpl;
public class FinalSeminarOppositionServiceImpl
extends AbstractServiceImpl<FinalSeminarOpposition, Long>
implements FinalSeminarOppositionService {
public class FinalSeminarOppositionServiceImpl extends AbstractServiceImpl<FinalSeminarOpposition, Long> implements FinalSeminarOppositionService {
@Inject @Inject
public FinalSeminarOppositionServiceImpl(Provider<EntityManager> em) { public FinalSeminarOppositionServiceImpl(Provider<EntityManager> em) {
super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition); super(em, FinalSeminarOpposition.class, QFinalSeminarOpposition.finalSeminarOpposition);

View File

@ -10,13 +10,13 @@ import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;
import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject; import se.su.dsv.scipro.system.DomainObject;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import java.util.Objects;
@MappedSuperclass @MappedSuperclass
public abstract class FinalSeminarParticipation extends DomainObject { public abstract class FinalSeminarParticipation extends DomainObject {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Basic JPA-mappings // Basic JPA-mappings
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
@ -45,8 +45,7 @@ public abstract class FinalSeminarParticipation extends DomainObject {
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Constructors // Constructors
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
protected FinalSeminarParticipation() { protected FinalSeminarParticipation() {}
}
protected FinalSeminarParticipation(User user, FinalSeminar finalSeminar) { protected FinalSeminarParticipation(User user, FinalSeminar finalSeminar) {
this.user = user; this.user = user;
@ -97,9 +96,11 @@ public abstract class FinalSeminarParticipation extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarParticipation)) return false; if (!(o instanceof FinalSeminarParticipation)) return false;
final FinalSeminarParticipation other = (FinalSeminarParticipation) o; final FinalSeminarParticipation other = (FinalSeminarParticipation) o;
return other.canEqual(this) return (
&& Objects.equals(this.getUser(), other.getUser()) other.canEqual(this) &&
&& Objects.equals(this.getFinalSeminar(), other.getFinalSeminar()); Objects.equals(this.getUser(), other.getUser()) &&
Objects.equals(this.getFinalSeminar(), other.getFinalSeminar())
);
} }
@Override @Override

View File

@ -1,13 +1,13 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.transaction.Transactional;
import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.AbstractRepository;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
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 @Inject
public FinalSeminarRepositoryImpl(Provider<EntityManager> em) { public FinalSeminarRepositoryImpl(Provider<EntityManager> em) {
super(em); super(em);
@ -19,8 +19,7 @@ public class FinalSeminarRepositoryImpl extends AbstractRepository implements Fi
EntityManager entityManager = em(); EntityManager entityManager = em();
if (entityManager.contains(finalSeminar)) { if (entityManager.contains(finalSeminar)) {
return entityManager.merge(finalSeminar); return entityManager.merge(finalSeminar);
} } else {
else {
entityManager.persist(finalSeminar); entityManager.persist(finalSeminar);
return finalSeminar; return finalSeminar;
} }

View File

@ -1,19 +1,17 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.User;
import jakarta.persistence.Cacheable; import jakarta.persistence.Cacheable;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.User;
@Entity @Entity
@Table(name = "final_seminar_respondent") @Table(name = "final_seminar_respondent")
@Cacheable(true) @Cacheable(true)
public class FinalSeminarRespondent extends FinalSeminarParticipation { public class FinalSeminarRespondent extends FinalSeminarParticipation {
protected FinalSeminarRespondent() { protected FinalSeminarRespondent() {}
}
public FinalSeminarRespondent(User student, FinalSeminar finalSeminar) { public FinalSeminarRespondent(User student, FinalSeminar finalSeminar) {
super(student, finalSeminar); super(student, finalSeminar);

View File

@ -1,8 +1,7 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.GenericService;
import java.util.List; 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); List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar);

View File

@ -1,21 +1,22 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.transaction.Transactional; import static com.querydsl.core.types.dsl.Expressions.allOf;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.User;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Named; import jakarta.inject.Named;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.SortedSet; import java.util.SortedSet;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import static com.querydsl.core.types.dsl.Expressions.allOf; import se.su.dsv.scipro.system.User;
@Named @Named
public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<FinalSeminarRespondent, Long> implements FinalSeminarRespondentService { public class FinalSeminarRespondentServiceImpl
extends AbstractServiceImpl<FinalSeminarRespondent, Long>
implements FinalSeminarRespondentService {
@Inject @Inject
public FinalSeminarRespondentServiceImpl(Provider<EntityManager> em) { public FinalSeminarRespondentServiceImpl(Provider<EntityManager> em) {
@ -23,9 +24,12 @@ public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<Final
} }
private FinalSeminarRespondent findOrCreate(User student, FinalSeminar finalSeminar) { private FinalSeminarRespondent findOrCreate(User student, FinalSeminar finalSeminar) {
FinalSeminarRespondent finalSeminarRespondent = findOne(allOf( FinalSeminarRespondent finalSeminarRespondent = findOne(
allOf(
QFinalSeminarRespondent.finalSeminarRespondent.user.eq(student), QFinalSeminarRespondent.finalSeminarRespondent.user.eq(student),
QFinalSeminarRespondent.finalSeminarRespondent.finalSeminar.eq(finalSeminar))); QFinalSeminarRespondent.finalSeminarRespondent.finalSeminar.eq(finalSeminar)
)
);
if (finalSeminarRespondent == null) { if (finalSeminarRespondent == null) {
finalSeminarRespondent = new FinalSeminarRespondent(student, finalSeminar); finalSeminarRespondent = new FinalSeminarRespondent(student, finalSeminar);
return save(finalSeminarRespondent); return save(finalSeminarRespondent);
@ -36,7 +40,7 @@ public class FinalSeminarRespondentServiceImpl extends AbstractServiceImpl<Final
@Override @Override
@Transactional @Transactional
public List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar) { public List<FinalSeminarRespondent> findOrCreate(FinalSeminar finalSeminar) {
if(finalSeminar.getId() == null) { if (finalSeminar.getId() == null) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<FinalSeminarRespondent> finalSeminarRespondents = new ArrayList<>(); List<FinalSeminarRespondent> finalSeminarRespondents = new ArrayList<>();

View File

@ -1,10 +1,9 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.util.Either;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.util.Either;
public interface FinalSeminarScheduling { public interface FinalSeminarScheduling {
Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details); Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details);

View File

@ -1,28 +1,49 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.*;
import se.su.dsv.scipro.util.Either;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.system.*;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.util.Either;
public interface FinalSeminarService extends GenericService<FinalSeminar, Long>, FilteredService<FinalSeminar, Long, FinalSeminarService.Filter>, FinalSeminarScheduling { public interface FinalSeminarService
Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(User student, FinalSeminar finalSeminar, Project project); extends
GenericService<FinalSeminar, Long>,
FilteredService<FinalSeminar, Long, FinalSeminarService.Filter>,
FinalSeminarScheduling {
Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(
User student,
FinalSeminar finalSeminar,
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, FinalSeminar finalSeminar, Project project); Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(
User student,
FinalSeminar finalSeminar,
Project project
);
Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(User student, FinalSeminar finalSeminar, Project project); 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, FinalSeminar finalSeminar); Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(
User student,
FinalSeminar finalSeminar
);
Iterable<FinalSeminar> findAll(Filter params); Iterable<FinalSeminar> findAll(Filter params);
@ -51,7 +72,10 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
FinalSeminar cancel(FinalSeminar finalSeminar); FinalSeminar cancel(FinalSeminar finalSeminar);
List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(ProjectType projectType, User user); List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(
ProjectType projectType,
User user
);
List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user); List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user);
@ -60,6 +84,7 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
void toggleSubscriptionToSeminarCreationNotifications(Project project, User user); void toggleSubscriptionToSeminarCreationNotifications(Project project, User user);
class Filter implements Serializable { class Filter implements Serializable {
private Date fromDate; private Date fromDate;
private Date toDate; private Date toDate;
private Boolean lazyDeleted; private Boolean lazyDeleted;
@ -147,16 +172,18 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Filter)) return false; if (!(o instanceof Filter)) return false;
final Filter other = (Filter) o; final Filter other = (Filter) o;
return other.canEqual(this) return (
&& Objects.equals(this.getFromDate(), other.getFromDate()) other.canEqual(this) &&
&& Objects.equals(this.getToDate(), other.getToDate()) Objects.equals(this.getFromDate(), other.getFromDate()) &&
&& Objects.equals(this.getLazyDeleted(), other.getLazyDeleted()) Objects.equals(this.getToDate(), other.getToDate()) &&
&& Objects.equals(this.getExempted(), other.getExempted()) Objects.equals(this.getLazyDeleted(), other.getLazyDeleted()) &&
&& Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects()) Objects.equals(this.getExempted(), other.getExempted()) &&
&& Objects.equals(this.getOnlyActiveOrCompletedProjects(), other.getOnlyActiveOrCompletedProjects()) Objects.equals(this.getOnlyActiveProjects(), other.getOnlyActiveProjects()) &&
&& Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor()) Objects.equals(this.getOnlyActiveOrCompletedProjects(), other.getOnlyActiveOrCompletedProjects()) &&
&& Objects.equals(this.getDegreeType(), other.getDegreeType()) Objects.equals(this.getHeadSupervisor(), other.getHeadSupervisor()) &&
&& Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants); Objects.equals(this.getDegreeType(), other.getDegreeType()) &&
Objects.equals(this.onlyNonManualParticipants, other.onlyNonManualParticipants)
);
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -174,21 +201,34 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
this.getOnlyActiveOrCompletedProjects(), this.getOnlyActiveOrCompletedProjects(),
this.getHeadSupervisor(), this.getHeadSupervisor(),
this.getDegreeType(), this.getDegreeType(),
this.getOnlyNonManualParticipants()); this.getOnlyNonManualParticipants()
);
} }
@Override @Override
public String toString() { public String toString() {
return "FinalSeminarService.Filter(" + return (
"fromDate=" + this.getFromDate() "FinalSeminarService.Filter(" +
+ ", toDate=" + this.getToDate() "fromDate=" +
+ ", lazyDeleted=" + this.getLazyDeleted() this.getFromDate() +
+ ", exempted=" + this.getExempted() ", toDate=" +
+ ", onlyActiveProjects=" + this.getOnlyActiveProjects() this.getToDate() +
+ ", onlyActiveOrCompletedProjects=" + this.getOnlyActiveOrCompletedProjects() ", lazyDeleted=" +
+ ", headSupervisor=" + this.getHeadSupervisor() this.getLazyDeleted() +
+ ", degreeType=" + this.getDegreeType() ", exempted=" +
+ ", onlyNonManualParticipants=" + this.getOnlyNonManualParticipants() + ")"; this.getExempted() +
", onlyActiveProjects=" +
this.getOnlyActiveProjects() +
", onlyActiveOrCompletedProjects=" +
this.getOnlyActiveOrCompletedProjects() +
", headSupervisor=" +
this.getHeadSupervisor() +
", degreeType=" +
this.getDegreeType() +
", onlyNonManualParticipants=" +
this.getOnlyNonManualParticipants() +
")"
);
} }
} }
} }

View File

@ -1,11 +1,16 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import jakarta.transaction.Transactional;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.BooleanExpression;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import se.su.dsv.scipro.system.Pageable; import jakarta.transaction.Transactional;
import java.time.*;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import se.su.dsv.scipro.file.FileReference; import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.file.FileService; import se.su.dsv.scipro.file.FileService;
import se.su.dsv.scipro.misc.DaysService; import se.su.dsv.scipro.misc.DaysService;
@ -17,25 +22,22 @@ import se.su.dsv.scipro.report.OppositionReportService;
import se.su.dsv.scipro.reviewing.RoughDraftApproval; import se.su.dsv.scipro.reviewing.RoughDraftApproval;
import se.su.dsv.scipro.reviewing.RoughDraftApprovalService; import se.su.dsv.scipro.reviewing.RoughDraftApprovalService;
import se.su.dsv.scipro.system.AbstractServiceImpl; import se.su.dsv.scipro.system.AbstractServiceImpl;
import se.su.dsv.scipro.system.Pageable;
import se.su.dsv.scipro.system.ProjectType; import se.su.dsv.scipro.system.ProjectType;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
import se.su.dsv.scipro.util.Either; import se.su.dsv.scipro.util.Either;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import java.time.*;
import java.util.Date;
import java.util.List;
import java.util.Optional;
public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, Long> implements FinalSeminarService { public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, Long> implements FinalSeminarService {
@Inject @Inject
FinalSeminarSettingsService finalSeminarSettingsService; FinalSeminarSettingsService finalSeminarSettingsService;
@Inject @Inject
DaysService daysService; DaysService daysService;
@Inject @Inject
OppositionReportService oppositionReportService; OppositionReportService oppositionReportService;
@Inject @Inject
NonWorkDayPeriodService nonWorkDayPeriodService; NonWorkDayPeriodService nonWorkDayPeriodService;
@ -58,7 +60,8 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository, FinalSeminarActiveParticipationRepository finalSeminarActiveParticipationRepository,
FinalSeminarRepository finalSeminarRepository, FinalSeminarRepository finalSeminarRepository,
Clock clock, Clock clock,
RoughDraftApprovalService roughDraftApprovalService) { RoughDraftApprovalService roughDraftApprovalService
) {
super(em, FinalSeminar.class, QFinalSeminar.finalSeminar); super(em, FinalSeminar.class, QFinalSeminar.finalSeminar);
this.eventBus = eventBus; this.eventBus = eventBus;
this.authorRepository = authorRepository; this.authorRepository = authorRepository;
@ -72,7 +75,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
@Transactional @Transactional
public Either<SchedulingError, FinalSeminar> schedule(Project project, LocalDateTime when, FinalSeminarDetails details) { public Either<SchedulingError, FinalSeminar> schedule(
Project project,
LocalDateTime when,
FinalSeminarDetails details
) {
if (project.isFinalSeminarRuleExempted()) { if (project.isFinalSeminarRuleExempted()) {
return createSeminar(project, when, details); return createSeminar(project, when, details);
} }
@ -80,7 +87,8 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
SchedulingError violation = validateSchedulingRules(when.toLocalDate()); SchedulingError violation = validateSchedulingRules(when.toLocalDate());
if (violation != null) return Either.left(violation); if (violation != null) return Either.left(violation);
boolean roughDraftApproved = roughDraftApprovalService.findBy(project) boolean roughDraftApproved = roughDraftApprovalService
.findBy(project)
.map(RoughDraftApproval::isApproved) .map(RoughDraftApproval::isApproved)
.orElse(Boolean.FALSE); .orElse(Boolean.FALSE);
if (!roughDraftApproved) { if (!roughDraftApproved) {
@ -90,8 +98,7 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
final FinalSeminar current = findByProject(project); final FinalSeminar current = findByProject(project);
if (current == null) { if (current == null) {
return createSeminar(project, when, details); return createSeminar(project, when, details);
} } else {
else {
// Assume double click sends the same data so no need to change anything // Assume double click sends the same data so no need to change anything
return Either.right(current); return Either.right(current);
} }
@ -118,7 +125,8 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
private Either<SchedulingError, FinalSeminar> createSeminar( private Either<SchedulingError, FinalSeminar> createSeminar(
Project project, Project project,
LocalDateTime when, LocalDateTime when,
FinalSeminarDetails details) { FinalSeminarDetails details
) {
FinalSeminar finalSeminar = new FinalSeminar(project); FinalSeminar finalSeminar = new FinalSeminar(project);
FinalSeminar persisted = setDetails(finalSeminar, when, details); FinalSeminar persisted = setDetails(finalSeminar, when, details);
eventBus.post(new FinalSeminarCreatedEvent(persisted)); eventBus.post(new FinalSeminarCreatedEvent(persisted));
@ -211,7 +219,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
} }
@Override @Override
public Either<OppositionRegistrationErrorStatus, Void> canOppose(User Student, FinalSeminar finalSeminar, Project project) { public Either<OppositionRegistrationErrorStatus, Void> canOppose(
User Student,
FinalSeminar finalSeminar,
Project project
) {
if (finalSeminar.isCancelled()) { if (finalSeminar.isCancelled()) {
return Either.left(new FinalSeminarCancelled()); return Either.left(new FinalSeminarCancelled());
} }
@ -227,7 +239,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) { if (finalSeminar.getOppositions().size() >= finalSeminar.getMaxOpponents()) {
return Either.left(new TooManyOpponents()); return Either.left(new TooManyOpponents());
} }
for (FinalSeminarOpposition opposition : finalSeminarOppositionRepository.findByOpposingUserAndType(Student, project.getProjectType())) { List<FinalSeminarOpposition> oppositions = finalSeminarOppositionRepository.findByOpposingUserAndType(
Student,
project.getProjectType()
);
for (FinalSeminarOpposition opposition : oppositions) {
if (opposition.getGrade() == null) { if (opposition.getGrade() == null) {
return Either.left(new UngradedOpposition()); return Either.left(new UngradedOpposition());
} else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) { } else if (opposition.getGrade() == FinalSeminarGrade.APPROVED) {
@ -244,7 +260,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
} }
@Override @Override
public Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(User student, FinalSeminar finalSeminar) { public Either<ActiveParticipationRegistrationErrorStatus, Void> canActiveParticipate(
User student,
FinalSeminar finalSeminar
) {
if (finalSeminar.getManualParticipants()) { if (finalSeminar.getManualParticipants()) {
return Either.left(new ManualParticipants()); return Either.left(new ManualParticipants());
} }
@ -264,20 +283,32 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
} }
private boolean alreadyParticipatingInSeminar(User user, FinalSeminar finalSeminar) { private boolean alreadyParticipatingInSeminar(User user, FinalSeminar finalSeminar) {
return alreadyOpponent(user, finalSeminar) || isAuthor(user, finalSeminar) || alreadyActiveParticipant(user, finalSeminar); return (
alreadyOpponent(user, finalSeminar) ||
isAuthor(user, finalSeminar) ||
alreadyActiveParticipant(user, finalSeminar)
);
} }
@Override @Override
@Transactional @Transactional
public Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(final User student, final FinalSeminar finalSeminar, final Project project) { public Either<OppositionRegistrationErrorStatus, FinalSeminarOpposition> attemptAddOpposition(
return canOppose(student, finalSeminar, project) final User student,
.map(allowed -> createAndSaveOpposition(student, finalSeminar, project)); final FinalSeminar finalSeminar,
final Project project
) {
return canOppose(student, finalSeminar, project).map(allowed ->
createAndSaveOpposition(student, finalSeminar, project)
);
} }
@Override @Override
@Transactional @Transactional
public Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(User student, FinalSeminar finalSeminar, Project project) { public Either<OpposeError, FinalSeminarOpposition> attemptAddOppositionAsSupervisor(
User student,
FinalSeminar finalSeminar,
Project project
) {
if (alreadyActiveParticipant(student, finalSeminar)) { if (alreadyActiveParticipant(student, finalSeminar)) {
return Either.left(OpposeError.ALREADY_PARTICIPANT); return Either.left(OpposeError.ALREADY_PARTICIPANT);
} else if (alreadyOpponent(student, finalSeminar)) { } else if (alreadyOpponent(student, finalSeminar)) {
@ -301,14 +332,22 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
@Transactional @Transactional
public Either<ActiveParticipationRegistrationErrorStatus, FinalSeminarActiveParticipation> attemptAddActiveParticipation(final User student, final FinalSeminar finalSeminar, final Project project) { public Either<
return canActiveParticipate(student, finalSeminar) ActiveParticipationRegistrationErrorStatus,
.map(allowed -> createAndSaveActiveParticipation(student, finalSeminar, project)); FinalSeminarActiveParticipation
> attemptAddActiveParticipation(final User student, final FinalSeminar finalSeminar, final Project project) {
return canActiveParticipate(student, finalSeminar).map(allowed ->
createAndSaveActiveParticipation(student, finalSeminar, project)
);
} }
@Override @Override
@Transactional @Transactional
public Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(User student, FinalSeminar finalSeminar, Project project) { public Either<ParticipateError, FinalSeminarActiveParticipation> attemptAddActiveParticipationAsSupervisor(
User student,
FinalSeminar finalSeminar,
Project project
) {
if (alreadyActiveParticipant(student, finalSeminar)) { if (alreadyActiveParticipant(student, finalSeminar)) {
return Either.left(ParticipateError.ALREADY_PARTICIPANT); return Either.left(ParticipateError.ALREADY_PARTICIPANT);
} else if (alreadyOpponent(student, finalSeminar)) { } else if (alreadyOpponent(student, finalSeminar)) {
@ -320,7 +359,11 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
} }
} }
private FinalSeminarActiveParticipation createAndSaveActiveParticipation(User student, FinalSeminar finalSeminar, Project project) { private FinalSeminarActiveParticipation createAndSaveActiveParticipation(
User student,
FinalSeminar finalSeminar,
Project project
) {
FinalSeminarActiveParticipation activeParticipation = new FinalSeminarActiveParticipation(); FinalSeminarActiveParticipation activeParticipation = new FinalSeminarActiveParticipation();
activeParticipation.setUser(student); activeParticipation.setUser(student);
activeParticipation.setFinalSeminar(finalSeminar); activeParticipation.setFinalSeminar(finalSeminar);
@ -337,7 +380,10 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
public Date thesisUploadDeadline(FinalSeminar finalSeminar) { public Date thesisUploadDeadline(FinalSeminar finalSeminar) {
return daysService.workDaysAhead(finalSeminar.getStartDate(), finalSeminarSettingsService.getInstance().getDaysAheadToUploadThesis()); return daysService.workDaysAhead(
finalSeminar.getStartDate(),
finalSeminarSettingsService.getInstance().getDaysAheadToUploadThesis()
);
} }
@Override @Override
@ -348,7 +394,7 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
public boolean hasThesis(FinalSeminar finalSeminar) { public boolean hasThesis(FinalSeminar finalSeminar) {
FileReference fileDescription = finalSeminar.getDocument(); FileReference fileDescription = finalSeminar.getDocument();
return fileDescription != null && fileService.isDataAvailable(fileDescription); return (fileDescription != null && fileService.isDataAvailable(fileDescription));
} }
@Override @Override
@ -393,7 +439,6 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
return bb; return bb;
} }
private BooleanExpression hasHeadSupervisor(User headSupervisor) { private BooleanExpression hasHeadSupervisor(User headSupervisor) {
return QFinalSeminar.finalSeminar.project.headSupervisor.eq(headSupervisor); return QFinalSeminar.finalSeminar.project.headSupervisor.eq(headSupervisor);
} }
@ -430,7 +475,8 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
public List<FinalSeminarOpposition> getOppositionsByProjectAuthors(Project project) { public List<FinalSeminarOpposition> getOppositionsByProjectAuthors(Project project) {
return project.getProjectParticipants() return project
.getProjectParticipants()
.stream() .stream()
.map(author -> findFinalSeminarOppositionsByOpponentAndProjectType(project.getProjectType(), author)) .map(author -> findFinalSeminarOppositionsByOpponentAndProjectType(project.getProjectType(), author))
.flatMap(List::stream) .flatMap(List::stream)
@ -440,7 +486,7 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
@Override @Override
public boolean hasHadFinalSeminar(Project project) { public boolean hasHadFinalSeminar(Project project) {
FinalSeminar finalSeminar = findByProject(project); FinalSeminar finalSeminar = findByProject(project);
return finalSeminar != null && finalSeminar.getStartDate().toInstant().isBefore(clock.instant()); return (finalSeminar != null && finalSeminar.getStartDate().toInstant().isBefore(clock.instant()));
} }
@Override @Override
@ -463,39 +509,52 @@ public class FinalSeminarServiceImpl extends AbstractServiceImpl<FinalSeminar, L
} }
@Override @Override
public List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(ProjectType projectType, User user) { public List<FinalSeminarOpposition> findFinalSeminarOppositionsByOpponentAndProjectType(
ProjectType projectType,
User user
) {
return finalSeminarOppositionRepository.findByOpposingUserAndType(user, projectType); return finalSeminarOppositionRepository.findByOpposingUserAndType(user, projectType);
} }
@Override @Override
public List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user) { public List<FinalSeminarActiveParticipation> findUserParticipating(Project project, User user) {
return finalSeminarActiveParticipationRepository.findByParticipatingUserAndLevel(user, project.getProjectType()); return finalSeminarActiveParticipationRepository.findByParticipatingUserAndLevel(
user,
project.getProjectType()
);
} }
@Override @Override
public boolean isSubscribedToSeminarCreationNotifications(Project project, User user) { public boolean isSubscribedToSeminarCreationNotifications(Project project, User user) {
final Optional<Author> author = authorRepository.findByProjectAndUser(project, user); final Optional<Author> author = authorRepository.findByProjectAndUser(project, user);
return author.isPresent() && author.get().isSubscribedToFinalSeminarNotifications(); return (author.isPresent() && author.get().isSubscribedToFinalSeminarNotifications());
} }
@Override @Override
@Transactional @Transactional
public void toggleSubscriptionToSeminarCreationNotifications(Project project, User user) { public void toggleSubscriptionToSeminarCreationNotifications(Project project, User user) {
authorRepository.findByProjectAndUser(project, user) authorRepository
.ifPresent(author -> author.setSubscribedToFinalSeminarNotifications(!author.isSubscribedToFinalSeminarNotifications())); .findByProjectAndUser(project, user)
.ifPresent(author ->
author.setSubscribedToFinalSeminarNotifications(!author.isSubscribedToFinalSeminarNotifications())
);
} }
private BooleanExpression unfinishedSeminars(Date after, Date before) { private BooleanExpression unfinishedSeminars(Date after, Date before) {
QFinalSeminar seminar = QFinalSeminar.finalSeminar; QFinalSeminar seminar = QFinalSeminar.finalSeminar;
if (after == null && before == null) { if (after == null && before == null) {
return seminar.oppositions.any().grade.isNull().or( return seminar.oppositions
seminar.activeParticipations.any().grade.isNull().or( .any()
seminar.respondents.any().grade.isNull())); .grade.isNull()
.or(seminar.activeParticipations.any().grade.isNull().or(seminar.respondents.any().grade.isNull()));
} else { } else {
return seminar.startDate.between(after, before) return seminar.startDate
.andAnyOf(seminar.oppositions.any().grade.isNull(), .between(after, before)
.andAnyOf(
seminar.oppositions.any().grade.isNull(),
seminar.activeParticipations.any().grade.isNull(), seminar.activeParticipations.any().grade.isNull(),
seminar.respondents.any().grade.isNull()); seminar.respondents.any().grade.isNull()
);
} }
} }

View File

@ -1,14 +1,14 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.system.DomainObject;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Objects; import java.util.Objects;
import se.su.dsv.scipro.system.DomainObject;
@Entity @Entity
@Cacheable(true) @Cacheable(true)
@Table(name = "final_seminar_settings") @Table(name = "final_seminar_settings")
public class FinalSeminarSettings extends DomainObject { public class FinalSeminarSettings extends DomainObject {
public static final int DEFAULT_DAYS_AHEAD_TO_UPLOAD_THESIS = 10; public static final int DEFAULT_DAYS_AHEAD_TO_UPLOAD_THESIS = 10;
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_OPPOSITION = 3; public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_OPPOSITION = 3;
public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_PARTICIPATION = 1; public static final int DEFAULT_DAYS_AHEAD_TO_REGISTER_PARTICIPATION = 1;
@ -16,8 +16,7 @@ public class FinalSeminarSettings extends DomainObject {
@Id @Id
private Long id = null; private Long id = null;
public FinalSeminarSettings() { public FinalSeminarSettings() {}
}
public FinalSeminarSettings(final Long id) { public FinalSeminarSettings(final Long id) {
this.id = id; this.id = id;
@ -116,7 +115,25 @@ public class FinalSeminarSettings extends DomainObject {
@Override @Override
public String toString() { public String toString() {
return "FinalSeminarSettings(id=" + this.getId() + ", daysAheadToCreate=" + this.getDaysAheadToCreate() + ", daysAheadToRegisterParticipation=" + this.getDaysAheadToRegisterParticipation() + ", daysAheadToRegisterOpposition=" + this.getDaysAheadToRegisterOpposition() + ", daysAheadToUploadThesis=" + this.getDaysAheadToUploadThesis() + ", thesisMustBePDF=" + this.isThesisMustBePDF() + ", evaluationURL=" + this.getEvaluationURL() + ", oppositionPriorityDays=" + this.getOppositionPriorityDays() + ")"; return (
"FinalSeminarSettings(id=" +
this.getId() +
", daysAheadToCreate=" +
this.getDaysAheadToCreate() +
", daysAheadToRegisterParticipation=" +
this.getDaysAheadToRegisterParticipation() +
", daysAheadToRegisterOpposition=" +
this.getDaysAheadToRegisterOpposition() +
", daysAheadToUploadThesis=" +
this.getDaysAheadToUploadThesis() +
", thesisMustBePDF=" +
this.isThesisMustBePDF() +
", evaluationURL=" +
this.getEvaluationURL() +
", oppositionPriorityDays=" +
this.getOppositionPriorityDays() +
")"
);
} }
@Override @Override
@ -124,16 +141,18 @@ public class FinalSeminarSettings extends DomainObject {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof FinalSeminarSettings)) return false; if (!(o instanceof FinalSeminarSettings)) return false;
final FinalSeminarSettings other = (FinalSeminarSettings) o; final FinalSeminarSettings other = (FinalSeminarSettings) o;
return other.canEqual(this) return (
&& super.equals(o) other.canEqual(this) &&
&& Objects.equals(this.getId(), other.getId()) super.equals(o) &&
&& this.getDaysAheadToCreate() == other.getDaysAheadToCreate() Objects.equals(this.getId(), other.getId()) &&
&& this.getDaysAheadToRegisterParticipation() == other.getDaysAheadToRegisterParticipation() this.getDaysAheadToCreate() == other.getDaysAheadToCreate() &&
&& this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition() this.getDaysAheadToRegisterParticipation() == other.getDaysAheadToRegisterParticipation() &&
&& this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis() this.getDaysAheadToRegisterOpposition() == other.getDaysAheadToRegisterOpposition() &&
&& this.isThesisMustBePDF() == other.isThesisMustBePDF() this.getDaysAheadToUploadThesis() == other.getDaysAheadToUploadThesis() &&
&& Objects.equals(this.getEvaluationURL(), other.getEvaluationURL()) this.isThesisMustBePDF() == other.isThesisMustBePDF() &&
&& this.getOppositionPriorityDays() == other.getOppositionPriorityDays(); Objects.equals(this.getEvaluationURL(), other.getEvaluationURL()) &&
this.getOppositionPriorityDays() == other.getOppositionPriorityDays()
);
} }
protected boolean canEqual(final Object other) { protected boolean canEqual(final Object other) {
@ -150,6 +169,7 @@ public class FinalSeminarSettings extends DomainObject {
this.getDaysAheadToUploadThesis(), this.getDaysAheadToUploadThesis(),
this.isThesisMustBePDF(), this.isThesisMustBePDF(),
this.getEvaluationURL(), this.getEvaluationURL(),
this.getOppositionPriorityDays()); this.getOppositionPriorityDays()
);
} }
} }

View File

@ -1,13 +1,14 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Provider; import jakarta.inject.Provider;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;
import se.su.dsv.scipro.system.AbstractServiceImpl;
public class FinalSeminarSettingsServiceImpl extends AbstractServiceImpl<FinalSeminarSettings,Long> implements FinalSeminarSettingsService { public class FinalSeminarSettingsServiceImpl
extends AbstractServiceImpl<FinalSeminarSettings, Long>
implements FinalSeminarSettingsService {
private static final long INSTANCE_ID = 1L; private static final long INSTANCE_ID = 1L;
@ -20,7 +21,7 @@ public class FinalSeminarSettingsServiceImpl extends AbstractServiceImpl<FinalSe
@Transactional @Transactional
public FinalSeminarSettings getInstance() { public FinalSeminarSettings getInstance() {
FinalSeminarSettings settings = findOne(INSTANCE_ID); FinalSeminarSettings settings = findOne(INSTANCE_ID);
if(settings==null) { if (settings == null) {
settings = new FinalSeminarSettings(INSTANCE_ID); settings = new FinalSeminarSettings(INSTANCE_ID);
save(settings); save(settings);
} }

View File

@ -1,6 +1,7 @@
package se.su.dsv.scipro.finalseminar; package se.su.dsv.scipro.finalseminar;
public final class FinalSeminarThesisDeletedEvent { public final class FinalSeminarThesisDeletedEvent {
private final FinalSeminar finalSeminar; private final FinalSeminar finalSeminar;
public FinalSeminarThesisDeletedEvent(final FinalSeminar finalSeminar) { public FinalSeminarThesisDeletedEvent(final FinalSeminar finalSeminar) {

View File

@ -3,6 +3,7 @@ package se.su.dsv.scipro.finalseminar;
import se.su.dsv.scipro.project.Project; import se.su.dsv.scipro.project.Project;
public final class FinalSeminarThesisUploadedEvent { public final class FinalSeminarThesisUploadedEvent {
private final FinalSeminar seminar; private final FinalSeminar seminar;
public FinalSeminarThesisUploadedEvent(FinalSeminar seminar) { public FinalSeminarThesisUploadedEvent(FinalSeminar seminar) {

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