diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d7a583e7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,69 @@ +# Root EditorConfig file +root = true + +# ------------------------------------------------------- +# Global defaults +# ------------------------------------------------------- +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 +max_line_length = 160 + +# ------------------------------------------------------- +# Java files +# ------------------------------------------------------- +[*.java] +tab_width = 4 +ij_java_line_comment_add_space = true + +# Ensure imports are ordered consistently +ij_java_imports_layout = java.**,javax.**,org.springframework.**,*, @*,|,at.shiftcontrol.**,|,$* +ij_java_class_count_to_use_import_on_demand = 9999 +ij_java_names_count_to_use_import_on_demand = 9999 + +# Make sure there is no newline at end/start of class +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_before_class_end = 0 +ij_java_keep_blank_lines_in_declarations = 1 +ij_java_keep_blank_lines_in_code = 0 +ij_java_keep_blank_lines_before_right_brace = 0 +ij_java_if_brace_force = always +ij_java_binary_operation_wrap = normal +ij_java_binary_operation_sign_on_next_line = true + +# ------------------------------------------------------- +# YAML / properties (Spring configs) +# ------------------------------------------------------- +[*.yml] +indent_size = 2 + +[*.yaml] +indent_size = 2 + +# ------------------------------------------------------- +# JSON files +# ------------------------------------------------------- +[*.json] +indent_size = 2 + +# ------------------------------------------------------- +# Markdown docs +# ------------------------------------------------------- +[*.md] +trim_trailing_whitespace = false # keep Markdown formatting intact + +# ------------------------------------------------------- +# XML files (config, pom.xml, applicationContext, ...) +# ------------------------------------------------------- +[*.xml] +indent_size = 2 + +# ------------------------------------------------------- +# Git ignore files +# ------------------------------------------------------- +[.gitignore] +trim_trailing_whitespace = false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55127e92..de745ff0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: env: POSTGRES_USER: shiftcontrol POSTGRES_PASSWORD: password - POSTGRES_DB: shiftservice + POSTGRES_DB: shiftcontrol options: >- --health-cmd="pg_isready -U shiftcontrol" --health-interval=5s @@ -51,7 +51,7 @@ jobs: --health-retries=5 env: - SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/shiftservice + SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/shiftcontrol SPRING_DATASOURCE_USERNAME: shiftcontrol SPRING_DATASOURCE_PASSWORD: password diff --git a/checkstyle.xml b/checkstyle.xml index 5528785e..e3af8d10 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -262,14 +262,6 @@ - - - - - - - - - - - - - - - - - - - - - + { Optional findBySlotAndUser(long positionSlotId, String assignedUser); @@ -28,7 +30,7 @@ public interface AssignmentDao extends BasicDao { Collection getConflictingAssignmentsExcludingSlot(String volunteerId, PositionSlot slot); - Assignment getAssignmentForPositionSlotAndUser(long positionSlotId, String userId); + @NonNull Assignment getAssignmentForPositionSlotAndUser(long positionSlotId, String userId); Optional findAssignmentForPositionSlotAndUser(long positionSlotId, String userId); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dao/impl/AssignmentDaoImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dao/impl/AssignmentDaoImpl.java index 4e195c23..ee8f9ef9 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dao/impl/AssignmentDaoImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dao/impl/AssignmentDaoImpl.java @@ -96,7 +96,7 @@ public Collection getConflictingAssignmentsExcludingSlot(String volu } @Override - public Assignment getAssignmentForPositionSlotAndUser(long positionSlotId, String userId) { + public @org.jspecify.annotations.NonNull Assignment getAssignmentForPositionSlotAndUser(long positionSlotId, String userId) { return assignmentRepository.findAssignmentForPositionSlotAndUser(positionSlotId, userId) .orElseThrow(() -> new NotFoundException("Not assigned to position slot.")); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dto/invite/ShiftPlanJoinRequestDto.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dto/invite/ShiftPlanJoinRequestDto.java index cfc7e1ab..a0daa58e 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dto/invite/ShiftPlanJoinRequestDto.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/dto/invite/ShiftPlanJoinRequestDto.java @@ -1,5 +1,6 @@ package at.shiftcontrol.shiftservice.dto.invite; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Builder; import lombok.Data; @@ -7,6 +8,6 @@ @Data @Builder public class ShiftPlanJoinRequestDto { - @NotNull + @NotBlank private String inviteCode; } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleCollectionEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleCollectionEndpoint.java index a9d9e94f..87ceaefd 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleCollectionEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleCollectionEndpoint.java @@ -21,7 +21,7 @@ import at.shiftcontrol.lib.util.ConvertUtil; import at.shiftcontrol.shiftservice.dto.role.RoleDto; import at.shiftcontrol.shiftservice.dto.role.RoleModificationDto; -import at.shiftcontrol.shiftservice.service.role.RoleService; +import at.shiftcontrol.shiftservice.service.RoleService; @Tag( diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleItemEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleItemEndpoint.java index 2f83bd10..4f9ebb84 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleItemEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleItemEndpoint.java @@ -19,7 +19,7 @@ import at.shiftcontrol.lib.util.ConvertUtil; import at.shiftcontrol.shiftservice.dto.role.RoleDto; import at.shiftcontrol.shiftservice.dto.role.RoleModificationDto; -import at.shiftcontrol.shiftservice.service.role.RoleService; +import at.shiftcontrol.shiftservice.service.RoleService; @Tag( name = "role-endpoint" diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleUserAssignmentEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleUserAssignmentEndpoint.java index a7275f0d..67791766 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleUserAssignmentEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/role/RoleUserAssignmentEndpoint.java @@ -18,7 +18,7 @@ import at.shiftcontrol.lib.util.ConvertUtil; import at.shiftcontrol.shiftservice.dto.role.UserRoleAssignmentAssignDto; import at.shiftcontrol.shiftservice.dto.userprofile.VolunteerDto; -import at.shiftcontrol.shiftservice.service.role.RoleService; +import at.shiftcontrol.shiftservice.service.RoleService; @Slf4j @RestController diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationCollectionEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationCollectionEndpoint.java index 359a3f4f..54b20579 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationCollectionEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationCollectionEndpoint.java @@ -20,7 +20,7 @@ import at.shiftcontrol.shiftservice.dto.user.UserEventBulkDto; import at.shiftcontrol.shiftservice.dto.user.UserEventDto; import at.shiftcontrol.shiftservice.dto.user.UserSearchDto; -import at.shiftcontrol.shiftservice.service.user.UserAdministrationService; +import at.shiftcontrol.shiftservice.service.UserAdministrationService; @Tag( name = "user-event-endpoint" diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationItemEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationItemEndpoint.java index 884e1a22..0ee5931e 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationItemEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/AdminUserAdministrationItemEndpoint.java @@ -19,7 +19,7 @@ import at.shiftcontrol.shiftservice.dto.user.LockResetUserDto; import at.shiftcontrol.shiftservice.dto.user.UserEventDto; import at.shiftcontrol.shiftservice.dto.user.UserEventUpdateDto; -import at.shiftcontrol.shiftservice.service.user.UserAdministrationService; +import at.shiftcontrol.shiftservice.service.UserAdministrationService; @Tag( name = "user-event-endpoint" diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationCollectionEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationCollectionEndpoint.java index 07907b81..87c81ab6 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationCollectionEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationCollectionEndpoint.java @@ -22,7 +22,7 @@ import at.shiftcontrol.shiftservice.dto.user.UserPlanBulkDto; import at.shiftcontrol.shiftservice.dto.user.UserPlanDto; import at.shiftcontrol.shiftservice.dto.user.UserSearchDto; -import at.shiftcontrol.shiftservice.service.user.UserAdministrationService; +import at.shiftcontrol.shiftservice.service.UserAdministrationService; @Tag( name = "user-plan-endpoint" diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationItemEndpoint.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationItemEndpoint.java index e2583fb7..ee92b3cb 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationItemEndpoint.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/endpoint/user/UserAdministrationItemEndpoint.java @@ -17,7 +17,7 @@ import at.shiftcontrol.lib.util.ConvertUtil; import at.shiftcontrol.shiftservice.dto.user.UserPlanDto; import at.shiftcontrol.shiftservice.dto.user.UserPlanUpdateDto; -import at.shiftcontrol.shiftservice.service.user.UserAdministrationService; +import at.shiftcontrol.shiftservice.service.UserAdministrationService; @Tag( name = "user-plan-endpoint" diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ActivityService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ActivityService.java index b96f6d6c..ae80d742 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ActivityService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ActivityService.java @@ -6,16 +6,64 @@ import at.shiftcontrol.shiftservice.dto.activity.ActivityModificationDto; import at.shiftcontrol.shiftservice.dto.activity.ActivitySuggestionDto; +import lombok.NonNull; +import org.jspecify.annotations.Nullable; + public interface ActivityService { - ActivityDto getActivity(long activityId); + /** + * Get activity by id + * @param activityId the id of the activity + * @return the activity dto + * @throws at.shiftcontrol.lib.exception.NotFoundException if the activity does not exist + */ + @NonNull ActivityDto getActivity(long activityId); - Collection getActivitiesForEvent(long eventId); + /** + * Get all activities for an event + * @param eventId the id of the event + * @return collection of activity dtos + * @throws at.shiftcontrol.lib.exception.NotFoundException if the event does not exist + * @throws at.shiftcontrol.lib.exception.ForbiddenException if the user is not a planner in any plan of the event + */ + @NonNull Collection getActivitiesForEvent(long eventId); - ActivityDto createActivity(long eventId, ActivityModificationDto modificationDto); + /** + * Create a new activity for an event + * @param eventId the id of the event + * @param modificationDto the modification dto + * @return the created activity dto + * @throws at.shiftcontrol.lib.exception.NotFoundException if the event does not exist + * @throws at.shiftcontrol.lib.exception.ForbiddenException if the user is not an admin of the event + * @throws at.shiftcontrol.lib.exception.BadRequestException if the activity name is not unique within the event + */ + @NonNull ActivityDto createActivity(long eventId, @NonNull ActivityModificationDto modificationDto); - ActivityDto updateActivity(long activityId, ActivityModificationDto modificationDto); + /** + * Update an existing activity + * @param activityId the id of the activity + * @param modificationDto the modification dto + * @return the updated activity dto + * @throws at.shiftcontrol.lib.exception.NotFoundException if the activity does not exist + * @throws at.shiftcontrol.lib.exception.ForbiddenException if the user is not an admin of the event + * @throws at.shiftcontrol.lib.exception.BadRequestException if the activity name is not unique within the event + */ + @NonNull ActivityDto updateActivity(long activityId, @NonNull ActivityModificationDto modificationDto); + /** + * Delete an activity + * @param activityId the id of the activity + * @throws at.shiftcontrol.lib.exception.NotFoundException if the activity does not exist + * @throws at.shiftcontrol.lib.exception.ForbiddenException if the user is not an admin of the event + */ void deleteActivity(long activityId); - Collection suggestActivitiesForShift(long eventId, ActivitySuggestionDto suggestionDto); + /** + * Suggest activities for a shift based on the given criteria + * @param eventId the id of the event + * @param suggestionDto the suggestion criteria + * @return collection of suggested activity dtos + * @throws at.shiftcontrol.lib.exception.NotFoundException if the event does not exist + * @throws at.shiftcontrol.lib.exception.ForbiddenException if the user is not a planner in any plan of the event + */ + @NonNull Collection suggestActivitiesForShift(long eventId, @Nullable ActivitySuggestionDto suggestionDto); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentService.java index 17fd3563..4b9562aa 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentService.java @@ -9,6 +9,8 @@ import at.shiftcontrol.lib.entity.Volunteer; import at.shiftcontrol.shiftservice.dto.positionslot.PositionSlotRequestDto; +import lombok.NonNull; + public interface AssignmentService { /** * reassigns the auction to the given volunteer. @@ -19,7 +21,7 @@ public interface AssignmentService { * @param requestDto contains reward points hash * @return reassigned and accepted auction */ - Assignment claimAuction(Assignment auction, Volunteer newVolunteer, PositionSlotRequestDto requestDto); + @NonNull Assignment claimAuction(@NonNull Assignment auction, @NonNull Volunteer newVolunteer, @NonNull PositionSlotRequestDto requestDto); /** * swapps the volunteers of the given switch request. @@ -30,9 +32,9 @@ public interface AssignmentService { * @param oldTrade trade to execute * @return executed trade, where volunteers are swapped */ - AssignmentSwitchRequest executeTrade(AssignmentSwitchRequest oldTrade); + @NonNull AssignmentSwitchRequest executeTrade(@NonNull AssignmentSwitchRequest oldTrade); - void cancelOtherTrades(AssignmentSwitchRequest trade); + void cancelOtherTrades(@NonNull AssignmentSwitchRequest trade); /** * accepts an already existing assignment. @@ -42,7 +44,7 @@ public interface AssignmentService { * @param assignment to accept * @return the accepted assignment */ - Assignment accept(Assignment assignment); + @NonNull Assignment accept(@NonNull Assignment assignment); /** * assigns the volunteer to the position slot. @@ -54,7 +56,7 @@ public interface AssignmentService { * @param volunteer to assign to the position slot * @return the newly created assignment */ - Assignment assign(PositionSlot positionSlot, Volunteer volunteer, PositionSlotRequestDto requestDto); + @NonNull Assignment assign(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlotRequestDto requestDto); /** * NO VALIDATION!
@@ -64,7 +66,7 @@ public interface AssignmentService { * * @param assignment to dissolve */ - void unassignInternal(Assignment assignment); + void unassignInternal(@NonNull Assignment assignment); /** * unassign all volunteers from auctions and declines join requests for a given shift plan. @@ -73,21 +75,21 @@ public interface AssignmentService { * * @param shiftPlan to unassign all auctions */ - void unassignAllAuctions(ShiftPlan shiftPlan); + void unassignAllAuctions(@NonNull ShiftPlan shiftPlan); /** * declines all signuprequests for a given shiftplan. * * @param shiftPlan to decline all signup requests */ - void declineAllSignupRequests(ShiftPlan shiftPlan); + void declineAllSignupRequests(@NonNull ShiftPlan shiftPlan); /** * get all assignments for a user * * @param plan to fetch the assignments from * @param volunteer to assignments belong to - * @return + * @return all assignments of the user in the given shift plan */ - Collection getAllAssignmentsForUser(ShiftPlan plan, Volunteer volunteer); + @NonNull Collection getAllAssignmentsForUser(@NonNull ShiftPlan plan, @NonNull Volunteer volunteer); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentSwitchRequestService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentSwitchRequestService.java index f2445d84..e881109f 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentSwitchRequestService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/AssignmentSwitchRequestService.java @@ -6,16 +6,18 @@ import at.shiftcontrol.shiftservice.dto.trade.TradeCreateDto; import at.shiftcontrol.shiftservice.dto.trade.TradeDto; +import lombok.NonNull; + public interface AssignmentSwitchRequestService { - TradeDto getTradeById(long id); + @NonNull TradeDto getTradeById(long id); - Collection getPositionSlotsToOffer(long requestedPositionSlotId, String currentUserId); + @NonNull Collection getPositionSlotsToOffer(long requestedPositionSlotId, @NonNull String currentUserId); - Collection createTrade(TradeCreateDto tradeCreateDto, String currentUserId); + @NonNull Collection createTrade(@NonNull TradeCreateDto tradeCreateDto, @NonNull String currentUserId); - TradeDto acceptTrade(long id, String currentUserId); + @NonNull TradeDto acceptTrade(long id, @NonNull String currentUserId); - TradeDto declineTrade(long id, String currentUserId); + @NonNull TradeDto declineTrade(long id, @NonNull String currentUserId); - TradeDto cancelTrade(long id, String currentUserId); + @NonNull TradeDto cancelTrade(long id, @NonNull String currentUserId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/DashboardService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/DashboardService.java index 91c341fb..7c2e0ee3 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/DashboardService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/DashboardService.java @@ -2,6 +2,8 @@ import at.shiftcontrol.shiftservice.dto.event.EventsDashboardOverviewDto; +import lombok.NonNull; + public interface DashboardService { - EventsDashboardOverviewDto getDashboardOverviewsOfAllShiftPlans(String eventId, String userId); + @NonNull EventsDashboardOverviewDto getDashboardOverviewsOfAllShiftPlans(@NonNull String eventId, @NonNull String userId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/EligibilityService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/EligibilityService.java index b49a0bda..c344f0b2 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/EligibilityService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/EligibilityService.java @@ -10,6 +10,9 @@ import at.shiftcontrol.lib.exception.NotFoundException; import at.shiftcontrol.lib.type.PositionSignupState; +import lombok.NonNull; +import org.jspecify.annotations.Nullable; + public interface EligibilityService { /** * Determines the signup state of a volunteer for a given position slot. @@ -21,7 +24,7 @@ public interface EligibilityService { * @param volunteer The volunteer to check * @return The signup state of the volunteer for the position slot */ - PositionSignupState getSignupStateForPositionSlot(PositionSlot positionSlot, Volunteer volunteer); + @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer); /** * Determines the signup state of a volunteer for a given position slot. @@ -35,7 +38,8 @@ public interface EligibilityService { * @param slotToExclude The position slot to exclude when checking for conflicts * @return The signup state of the volunteer for the position slot */ - PositionSignupState getSignupStateForPositionSlotExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude); + @NonNull PositionSignupState getSignupStateForPositionSlotExcludingSlot(@NonNull PositionSlot positionSlot, + @NonNull Volunteer volunteer, @Nullable PositionSlot slotToExclude); /** * Determines the signup state of a volunteer for a given position slot. @@ -48,7 +52,7 @@ public interface EligibilityService { * @return The signup state of the volunteer for the position slot * @throws NotFoundException if the position slot or volunteer could not be found */ - PositionSignupState getSignupStateForPositionSlot(Long positionSlotId, String userId); + @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull Long positionSlotId, @NonNull String userId); /** * Determines the signup state of a volunteer for a given position slot. @@ -60,7 +64,7 @@ public interface EligibilityService { * @param userId The volunteer to check * @return The signup state of the volunteer for the position slot */ - PositionSignupState getSignupStateForPositionSlot(PositionSlot positionSlot, String userId); + @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull PositionSlot positionSlot, @NonNull String userId); /** * Checks if the volunteer can join the position slot based on PositionSignUpState. @@ -69,7 +73,7 @@ public interface EligibilityService { * @param volunteer The volunteer to check * @throws ConflictException if it is not possible for the volunteer to sign up for this position slot */ - void validateSignUpStateForJoin(PositionSlot positionSlot, Volunteer volunteer); + void validateSignUpStateForJoin(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer); /** * Checks if the volunteer can claim an auction for the position slot based on PositionSignUpState. @@ -78,7 +82,7 @@ public interface EligibilityService { * @param volunteer The volunteer to check * @throws ConflictException if it is not possible for the volunteer to claim an auction for this position slot */ - void validateSignUpStateForAuction(PositionSlot positionSlot, Volunteer volunteer); + void validateSignUpStateForAuction(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer); /** * Checks if the volunteer is eligible and not signed up to the given position slot. @@ -87,7 +91,7 @@ public interface EligibilityService { * @param volunteer to assign * @return true if the user is not signed up and eligible */ - boolean isEligibleAndNotSignedUp(PositionSlot positionSlot, Volunteer volunteer); + boolean isEligibleAndNotSignedUp(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer); /** * Checks if the volunteer is eligible and not signed up to the given position slot. @@ -98,7 +102,7 @@ public interface EligibilityService { * @param slotToExclude The position slot to exclude when checking for conflicts * @return true if the user is not signed up and eligible */ - boolean isEligibleAndNotSignedUpExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude); + boolean isEligibleAndNotSignedUpExcludingSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlot slotToExclude); /** * Checks if the volunteer is eligible and not signed up to the given position slot. @@ -107,7 +111,7 @@ public interface EligibilityService { * @param volunteer to assign * @throws ConflictException if the user is not assignable to the slot */ - void validateIsEligibleAndNotSignedUp(PositionSlot positionSlot, Volunteer volunteer); + void validateIsEligibleAndNotSignedUp(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer); /** * Checks if the volunteer is eligible and not signed up to the given position slot. @@ -118,7 +122,7 @@ public interface EligibilityService { * @param slotToExclude The position slot to exclude when checking for conflicts * @throws ConflictException if the user is not assignable to the slot */ - void validateIsEligibleAndNotSignedUpExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude); + void validateIsEligibleAndNotSignedUpExcludingSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlot slotToExclude); /** * returns all conflicting assignments within a given time for a specific user. @@ -128,7 +132,7 @@ public interface EligibilityService { * @param endTime end of the timespan to check * @return the overlapping assignments */ - Collection getConflictingAssignments(String volunteerId, Instant startTime, Instant endTime); + @NonNull Collection getConflictingAssignments(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime); /** * returns all conflicting assignments within a given time for a specific user. @@ -137,7 +141,7 @@ public interface EligibilityService { * @param positionSlot slot of which the time is to check * @return the overlapping assignments */ - Collection getConflictingAssignments(String volunteerId, PositionSlot positionSlot); + @NonNull Collection getConflictingAssignments(@NonNull String volunteerId, @NonNull PositionSlot positionSlot); /** * returns all conflicting assignments within a given time for a specific user, ignoring the provided position slot. @@ -148,7 +152,7 @@ public interface EligibilityService { * @param shiftIdToExclude shift that is ignored for the check * @return the overlapping assignments */ - Collection getConflictingAssignmentsExcludingShift(String volunteerId, Instant startTime, Instant endTime, long shiftIdToExclude); + @NonNull Collection getConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime, long shiftIdToExclude); /** * returns all conflicting assignments with a given position slot for a specific user, ignoring another position slot. @@ -158,7 +162,7 @@ public interface EligibilityService { * @param shiftIdToExclude shift that is ignored for the check * @return the overlapping assignments */ - Collection getConflictingAssignmentsExcludingShift(String volunteerId, PositionSlot positionSlot, long shiftIdToExclude); + @NonNull Collection getConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull PositionSlot positionSlot, long shiftIdToExclude); /** * checks if the user has any conflicting assignments within a given time, ignoring the given position slot. @@ -169,7 +173,7 @@ public interface EligibilityService { * @param positionSlot position slot that is ignored for the check * @throws ConflictException if overlapping assignments exist */ - void validateHasConflictingAssignmentsExcludingShift(String volunteerId, Instant startTime, Instant endTime, long positionSlot); + void validateHasConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime, long positionSlot); /** * checks if the user has any conflicting assignments with a given position slot, ignoring another position slot. @@ -179,7 +183,7 @@ public interface EligibilityService { * @param shiftToExclude shift that is ignored for the check * @throws ConflictException if overlapping assignments exist */ - void validateHasConflictingAssignmentsExcludingShift(String volunteerId, PositionSlot positionSlot, long shiftToExclude); + void validateHasConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull PositionSlot positionSlot, long shiftToExclude); /** * checks if a position slot is full. @@ -188,5 +192,5 @@ public interface EligibilityService { * @param positionSlot to check * @return true if slot has capacity left */ - boolean hasCapacity(PositionSlot positionSlot); + boolean hasCapacity(@NonNull PositionSlot positionSlot); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LeaderboardService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LeaderboardService.java index 69505e9d..2088f62c 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LeaderboardService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LeaderboardService.java @@ -7,6 +7,8 @@ import at.shiftcontrol.lib.exception.ForbiddenException; import at.shiftcontrol.shiftservice.dto.leaderboard.LeaderBoardDto; +import lombok.NonNull; + public interface LeaderboardService { - LeaderBoardDto getLeaderBoard(long eventId, String currentUserId) throws NotFoundException, ForbiddenException; + @NonNull LeaderBoardDto getLeaderBoard(long eventId, @NonNull String currentUserId) throws NotFoundException, ForbiddenException; } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LocationService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LocationService.java index 21958ca2..12edfc3e 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LocationService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/LocationService.java @@ -5,14 +5,16 @@ import at.shiftcontrol.shiftservice.dto.location.LocationDto; import at.shiftcontrol.shiftservice.dto.location.LocationModificationDto; +import lombok.NonNull; + public interface LocationService { - Collection getAllLocationsForEvent(long eventId); + @NonNull Collection getAllLocationsForEvent(long eventId); - LocationDto createLocation(long eventId, LocationModificationDto modificationDto); + @NonNull LocationDto createLocation(long eventId, @NonNull LocationModificationDto modificationDto); - LocationDto getLocation(long locationId); + @NonNull LocationDto getLocation(long locationId); - LocationDto updateLocation(long locationId, LocationModificationDto modificationDto); + @NonNull LocationDto updateLocation(long locationId, @NonNull LocationModificationDto modificationDto); void deleteLocation(long locationId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/NotificationRecipientService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/NotificationRecipientService.java index d7f49e9a..66486d45 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/NotificationRecipientService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/NotificationRecipientService.java @@ -5,9 +5,12 @@ import at.shiftcontrol.shiftservice.dto.notifications.RecipientsFilterDto; import at.shiftcontrol.shiftservice.dto.userprofile.AccountInfoDto; +import lombok.NonNull; + public interface NotificationRecipientService { @AdminOnly - AccountInfoDto getRecipientInformation(String recipientid); + @NonNull + AccountInfoDto getRecipientInformation(@NonNull String recipientid); - RecipientsDto getRecipientsForNotification(RecipientsFilterDto filter); + @NonNull RecipientsDto getRecipientsForNotification(@NonNull RecipientsFilterDto filter); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/RoleService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/RoleService.java new file mode 100644 index 00000000..b421859d --- /dev/null +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/RoleService.java @@ -0,0 +1,26 @@ +package at.shiftcontrol.shiftservice.service; + +import java.util.Collection; + +import at.shiftcontrol.shiftservice.dto.role.RoleDto; +import at.shiftcontrol.shiftservice.dto.role.RoleModificationDto; +import at.shiftcontrol.shiftservice.dto.role.UserRoleAssignmentAssignDto; +import at.shiftcontrol.shiftservice.dto.userprofile.VolunteerDto; + +import lombok.NonNull; + +public interface RoleService { + @NonNull Collection getRoles(long shiftPlanId); + + @NonNull RoleDto getRole(long roleId); + + @NonNull RoleDto createRole(long shiftPlanId, @NonNull RoleModificationDto roleDto); + + @NonNull RoleDto updateRole(long roleId, @NonNull RoleModificationDto roleDto); + + void deleteRole(long roleId); + + @NonNull VolunteerDto createUserRoleAssignment(String userId, @NonNull UserRoleAssignmentAssignDto assignDto); + + void deleteUserRoleAssignment(String userId, long roleId); +} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftPlanService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftPlanService.java index 3c0e2e92..3dd5591c 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftPlanService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftPlanService.java @@ -12,33 +12,34 @@ import at.shiftcontrol.shiftservice.dto.shiftplan.ShiftPlanDto; import at.shiftcontrol.shiftservice.dto.shiftplan.ShiftPlanModificationDto; +import lombok.NonNull; + public interface ShiftPlanService { - Collection getAllOfEvent(long eventId); + @NonNull Collection getAllOfEvent(long eventId); - Collection getAll(); + @NonNull Collection getAll(); - ShiftPlanDto get(long shiftPlanId); + @NonNull ShiftPlanDto get(long shiftPlanId); - ShiftPlanCreateDto createShiftPlan(long eventId, ShiftPlanModificationDto modificationDto); + @NonNull ShiftPlanCreateDto createShiftPlan(long eventId, @NonNull ShiftPlanModificationDto modificationDto); - ShiftPlanDto update(long shiftPlanId, ShiftPlanModificationDto modificationDto); + @NonNull ShiftPlanDto update(long shiftPlanId, @NonNull ShiftPlanModificationDto modificationDto); void delete(long shiftPlanId); - ShiftPlanInviteCreateResponseDto createShiftPlanInviteCode(long shiftPlanId, ShiftPlanInviteCreateRequestDto requestDto) - ; + @NonNull ShiftPlanInviteCreateResponseDto createShiftPlanInviteCode(long shiftPlanId, @NonNull ShiftPlanInviteCreateRequestDto requestDto); void revokeShiftPlanInvite(long inviteId); void deleteShiftPlanInvite(long inviteId); - ShiftPlanInviteDetailsDto getShiftPlanInviteDetails(String inviteCode); + @NonNull ShiftPlanInviteDetailsDto getShiftPlanInviteDetails(@NonNull String inviteCode); - Collection getAllShiftPlanInvites(long shiftPlanId); + @NonNull Collection getAllShiftPlanInvites(long shiftPlanId); - void joinShiftPlan(ShiftPlanJoinRequestDto requestDto); + void joinShiftPlan(@NonNull ShiftPlanJoinRequestDto requestDto); - void updateLockStatus(long shiftPlanId, LockStatus lockStatus); + void updateLockStatus(long shiftPlanId, @NonNull LockStatus lockStatus); void leavePlan(long shiftPlanId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftService.java index 571637ef..bdcc18af 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/ShiftService.java @@ -5,14 +5,16 @@ import at.shiftcontrol.shiftservice.dto.shift.ShiftDto; import at.shiftcontrol.shiftservice.dto.shift.ShiftModificationDto; +import lombok.NonNull; + public interface ShiftService { - ShiftDetailsDto getShiftDetails(long shiftId, String userId); + @NonNull ShiftDetailsDto getShiftDetails(long shiftId, @NonNull String userId); - PaginationDto getAllOpenShiftsOfPlanPaginated(long planId, int page, int size); + @NonNull PaginationDto getAllOpenShiftsOfPlanPaginated(long planId, int page, int size); - ShiftDto createShift(long shiftPlanId, ShiftModificationDto modificationDto); + @NonNull ShiftDto createShift(long shiftPlanId, @NonNull ShiftModificationDto modificationDto); - ShiftDto updateShift(long shiftId, ShiftModificationDto modificationDto); + @NonNull ShiftDto updateShift(long shiftId, @NonNull ShiftModificationDto modificationDto); void deleteShift(long shiftId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/StatisticService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/StatisticService.java index 92317cc0..61c4400b 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/StatisticService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/StatisticService.java @@ -10,14 +10,16 @@ import at.shiftcontrol.shiftservice.dto.OwnStatisticsDto; import at.shiftcontrol.shiftservice.dto.event.schedule.ScheduleStatisticsDto; +import lombok.NonNull; + public interface StatisticService { - OwnStatisticsDto getOwnStatisticsOfShifts(List userShifts); + @NonNull OwnStatisticsDto getOwnStatisticsOfShifts(@NonNull List userShifts); - OverallStatisticsDto getOverallShiftPlanStatistics(ShiftPlan shiftPlan); + @NonNull OverallStatisticsDto getOverallShiftPlanStatistics(@NonNull ShiftPlan shiftPlan); - OverallStatisticsDto getOverallEventStatistics(Event event); + @NonNull OverallStatisticsDto getOverallEventStatistics(@NonNull Event event); - OwnStatisticsDto getOwnStatisticsOfShiftPlans(List shiftPlans, String userId); + @NonNull OwnStatisticsDto getOwnStatisticsOfShiftPlans(@NonNull List shiftPlans, @NonNull String userId); - ScheduleStatisticsDto getShiftPlanScheduleStatistics(List shifts, Volunteer volunteer); + @NonNull ScheduleStatisticsDto getShiftPlanScheduleStatistics(@NonNull List shifts, @NonNull Volunteer volunteer); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TimeConstraintService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TimeConstraintService.java index 4de65409..d9aa2e64 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TimeConstraintService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TimeConstraintService.java @@ -8,9 +8,9 @@ import at.shiftcontrol.shiftservice.dto.TimeConstraintDto; public interface TimeConstraintService { - Collection getTimeConstraints(@NonNull String userId, long eventId); + @NonNull Collection getTimeConstraints(@NonNull String userId, long eventId); - TimeConstraintDto createTimeConstraint(@NonNull TimeConstraintCreateDto createDto, @NonNull String userId, long eventId); + @NonNull TimeConstraintDto createTimeConstraint(@NonNull TimeConstraintCreateDto createDto, @NonNull String userId, long eventId); void delete(long timeConstraintId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TrustAlertService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TrustAlertService.java index ae09136a..85539781 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TrustAlertService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/TrustAlertService.java @@ -4,10 +4,12 @@ import at.shiftcontrol.lib.dto.TrustAlertDto; import at.shiftcontrol.shiftservice.dto.TrustAlertDisplayDto; +import lombok.NonNull; + public interface TrustAlertService { - PaginationDto getAllPaginated(int page, int size); + @NonNull PaginationDto getAllPaginated(int page, int size); - TrustAlertDisplayDto save(TrustAlertDto alert); + @NonNull TrustAlertDisplayDto save(@NonNull TrustAlertDto alert); void delete(long id); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserAdministrationService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserAdministrationService.java new file mode 100644 index 00000000..4dc16803 --- /dev/null +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserAdministrationService.java @@ -0,0 +1,46 @@ +package at.shiftcontrol.shiftservice.service; + +import java.util.Collection; + +import jakarta.validation.Valid; + +import at.shiftcontrol.lib.dto.PaginationDto; +import at.shiftcontrol.shiftservice.dto.user.UserEventBulkDto; +import at.shiftcontrol.shiftservice.dto.user.UserEventDto; +import at.shiftcontrol.shiftservice.dto.user.UserEventUpdateDto; +import at.shiftcontrol.shiftservice.dto.user.UserPlanBulkDto; +import at.shiftcontrol.shiftservice.dto.user.UserPlanDto; +import at.shiftcontrol.shiftservice.dto.user.UserPlanUpdateDto; +import at.shiftcontrol.shiftservice.dto.user.UserSearchDto; + +import lombok.NonNull; + +public interface UserAdministrationService { + @NonNull PaginationDto getAllUsers(int page, int size, @NonNull UserSearchDto searchDt); + + @NonNull PaginationDto getAllPlanUsers(@NonNull Long shiftPlanId, int page, int size, @NonNull UserSearchDto searchDto); + + @NonNull UserEventDto getUser(@NonNull String userId); + + @NonNull UserEventDto createVolunteer(@NonNull String userId); + + @NonNull UserPlanDto getPlanUser(@NonNull Long shiftPlanId, @NonNull String userId); + + @NonNull UserEventDto updateEventUser(@NonNull String userId, @NonNull UserEventUpdateDto updateDto); + + @NonNull UserPlanDto updatePlanUser(@NonNull Long shiftPlanId, @NonNull String userId, @NonNull UserPlanUpdateDto updateDto); + + @NonNull UserEventDto lockUser(@NonNull String userId, @NonNull Collection shiftPlanId); + + @NonNull UserEventDto unLockUser(@NonNull String userId, @NonNull Collection shiftPlanId); + + @NonNull UserEventDto resetUser(@NonNull String userId, @NonNull Collection shiftPlanId); + + @NonNull Collection bulkAddRoles(long shiftPlanId, @Valid UserPlanBulkDto updateDto); + + @NonNull Collection bulkRemoveRoles(long shiftPlanId, @Valid UserPlanBulkDto updateDto); + + @NonNull Collection bulkAddVolunteeringPlans(@Valid UserEventBulkDto updateDto); + + @NonNull Collection bulkRemoveVolunteeringPlans(@Valid UserEventBulkDto updateDto); +} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserPreferenceService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserPreferenceService.java index e72c43a1..7c66f58e 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserPreferenceService.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/UserPreferenceService.java @@ -2,6 +2,9 @@ import at.shiftcontrol.shiftservice.dto.positionslot.PositionSlotPreferenceDto; +import lombok.NonNull; + public interface UserPreferenceService { - PositionSlotPreferenceDto getUserPreference(String userId, long shiftId); + @NonNull + PositionSlotPreferenceDto getUserPreference(@NonNull String userId, long shiftId); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/VolunteerService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/VolunteerService.java new file mode 100644 index 00000000..86b1a609 --- /dev/null +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/VolunteerService.java @@ -0,0 +1,13 @@ +package at.shiftcontrol.shiftservice.service; + +import at.shiftcontrol.lib.entity.Volunteer; + +import lombok.NonNull; + +public interface VolunteerService { + + @NonNull + Volunteer createVolunteer(@NonNull String userId); + + @NonNull Volunteer getOrCreate(@NonNull String userId); +} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventCloneServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventCloneServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventCloneServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventCloneServiceImpl.java index ad03a31d..a7b15e9f 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventCloneServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventCloneServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.event; +package at.shiftcontrol.shiftservice.service.event.impl; import java.util.ArrayList; import java.util.Collection; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventExportServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventExportServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventExportServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventExportServiceImpl.java index 9ba95e1d..0a7c309b 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventExportServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventExportServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.event; +package at.shiftcontrol.shiftservice.service.event.impl; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventImportServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventImportServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventImportServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventImportServiceImpl.java index 8b192266..2c6dff4b 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventImportServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventImportServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.event; +package at.shiftcontrol.shiftservice.service.event.impl; import java.io.FileNotFoundException; import java.io.IOException; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventScheduleServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventScheduleServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventScheduleServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventScheduleServiceImpl.java index 6257b06f..b87031a2 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventScheduleServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventScheduleServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.event; +package at.shiftcontrol.shiftservice.service.event.impl; import java.time.Instant; import java.util.ArrayList; @@ -18,7 +18,6 @@ import at.shiftcontrol.lib.entity.Volunteer; import at.shiftcontrol.lib.type.PositionSignupState; import at.shiftcontrol.lib.type.ShiftRelevance; -import at.shiftcontrol.lib.util.TimeUtil; import at.shiftcontrol.shiftservice.auth.ApplicationUserProvider; import at.shiftcontrol.shiftservice.dao.ActivityDao; import at.shiftcontrol.shiftservice.dao.EventDao; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventServiceImpl.java index a435190d..c2e1f42a 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/event/EventServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/event/impl/EventServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.event; +package at.shiftcontrol.shiftservice.service.event.impl; import java.net.MalformedURLException; import java.net.URL; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ActivityServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ActivityServiceImpl.java index 3728b931..c09d76b5 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ActivityServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ActivityServiceImpl.java @@ -23,6 +23,7 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.jspecify.annotations.Nullable; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; @@ -36,14 +37,14 @@ public class ActivityServiceImpl implements ActivityService { private final SecurityHelper securityHelper; @Override - public ActivityDto getActivity(long activityId) { + public @org.jspecify.annotations.NonNull ActivityDto getActivity(long activityId) { var activity = activityDao.getById(activityId); return ActivityMapper.toActivityDto(activity); } @Override - public Collection getActivitiesForEvent(long eventId) { + public @org.jspecify.annotations.NonNull Collection getActivitiesForEvent(long eventId) { var event = eventDao.getById(eventId); securityHelper.assertUserIsPlannerInAnyPlanOfEvent(event); @@ -56,7 +57,7 @@ public Collection getActivitiesForEvent(long eventId) { @Override @AdminOnly - public ActivityDto createActivity(long eventId, @NonNull ActivityModificationDto modificationDto) { + public @org.jspecify.annotations.NonNull ActivityDto createActivity(long eventId, @NonNull ActivityModificationDto modificationDto) { var event = eventDao.getById(eventId); var newActivity = Activity.builder() @@ -77,7 +78,7 @@ public ActivityDto createActivity(long eventId, @NonNull ActivityModificationDto @Override @AdminOnly - public ActivityDto updateActivity(long activityId, @NonNull ActivityModificationDto modificationDto) { + public @org.jspecify.annotations.NonNull ActivityDto updateActivity(long activityId, @NonNull ActivityModificationDto modificationDto) { var activity = activityDao.getById(activityId); //VALIDATION @@ -141,7 +142,7 @@ public void deleteActivity(long activityId) { } @Override - public Collection suggestActivitiesForShift(long eventId, ActivitySuggestionDto suggestionDto) { + public @NonNull Collection suggestActivitiesForShift(long eventId, @Nullable ActivitySuggestionDto suggestionDto) { var event = eventDao.getById(eventId); securityHelper.assertUserIsPlannerInAnyPlanOfEvent(event); @@ -153,9 +154,7 @@ public Collection suggestActivitiesForShift(long eventId, ActivityS .toList(); } - var filteredStream = getActivityStream(suggestionDto, activitiesOfEvent); - - return filteredStream + return getActivityStream(suggestionDto, activitiesOfEvent) .map(ActivityMapper::toActivityDto) .toList(); } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentServiceImpl.java index 40629b27..a8d0d219 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentServiceImpl.java @@ -39,7 +39,7 @@ public class AssignmentServiceImpl implements AssignmentService { private final ApplicationEventPublisher publisher; @Override - public Assignment claimAuction(Assignment auction, Volunteer newVolunteer, PositionSlotRequestDto requestDto) { + public @NonNull Assignment claimAuction(@NonNull Assignment auction, @NonNull Volunteer newVolunteer, @NonNull PositionSlotRequestDto requestDto) { String oldVolunteerId = auction.getAssignedVolunteer().getId(); Assignment oldAuction = AssignmentAssemblingMapper.shallowCopy(auction); // execute auction @@ -53,7 +53,7 @@ public Assignment claimAuction(Assignment auction, Volunteer newVolunteer, Posit } @Override - public AssignmentSwitchRequest executeTrade(AssignmentSwitchRequest trade) { + public @NonNull AssignmentSwitchRequest executeTrade(@NonNull AssignmentSwitchRequest trade) { // delete inverse trade if exists List inverse = assignmentSwitchRequestDao.findInverseTrade(trade) .stream() @@ -84,7 +84,7 @@ public AssignmentSwitchRequest executeTrade(AssignmentSwitchRequest trade) { } @Override - public void cancelOtherTrades(AssignmentSwitchRequest trade) { + public void cancelOtherTrades(@NonNull AssignmentSwitchRequest trade) { // this trade does not need to be excluded because it will be set to ACCEPTED in the next step assignmentSwitchRequestDao.cancelTradesForAssignment(trade.getRequestedAssignment()); assignmentSwitchRequestDao.cancelTradesForAssignment(trade.getOfferingAssignment()); @@ -107,7 +107,7 @@ private Assignment reassign(Assignment oldAssignment, Volunteer newVolunteer) { } @Override - public Assignment accept(Assignment assignment) { + public @NonNull Assignment accept(@NonNull Assignment assignment) { if (assignment.getStatus() != AssignmentStatus.REQUEST_FOR_ASSIGNMENT) { throw new IllegalArgumentException("Assignment must be an assignment request"); } @@ -123,7 +123,7 @@ public Assignment accept(Assignment assignment) { } @Override - public Assignment assign(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlotRequestDto requestDto) { + public @NonNull Assignment assign(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlotRequestDto requestDto) { // create assignment Assignment assignment = Assignment.of(positionSlot, volunteer, AssignmentStatus.ACCEPTED); @@ -143,7 +143,7 @@ public Assignment assign(@NonNull PositionSlot positionSlot, @NonNull Volunteer @Override @Transactional - public void unassignInternal(Assignment assignment) { + public void unassignInternal(@NonNull Assignment assignment) { //ACT: update reward points rewardPointsService.onAssignmentRemoved( assignment @@ -159,7 +159,7 @@ public void unassignInternal(Assignment assignment) { @Override @Transactional - public void unassignAllAuctions(ShiftPlan shiftPlan) { + public void unassignAllAuctions(@NonNull ShiftPlan shiftPlan) { Collection auctions = assignmentDao.findAuctionsByShiftPlanId(shiftPlan.getId()); auctions.forEach(auction -> { @@ -177,7 +177,7 @@ public void unassignAllAuctions(ShiftPlan shiftPlan) { @Override @Transactional - public void declineAllSignupRequests(ShiftPlan shiftPlan) { + public void declineAllSignupRequests(@NonNull ShiftPlan shiftPlan) { Collection requests = assignmentDao.findSignupRequestsByShiftPlanId(shiftPlan.getId()); // publish events @@ -188,7 +188,7 @@ public void declineAllSignupRequests(ShiftPlan shiftPlan) { } @Override - public Collection getAllAssignmentsForUser(ShiftPlan plan, Volunteer volunteer) { + public @NonNull Collection getAllAssignmentsForUser(@NonNull ShiftPlan plan, @NonNull Volunteer volunteer) { return assignmentDao.findAssignmentsForShiftPlanAndUser(plan.getId(), volunteer.getId()); } } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentSwitchRequestServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentSwitchRequestServiceImpl.java index 5cf129dd..40ffe263 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentSwitchRequestServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/AssignmentSwitchRequestServiceImpl.java @@ -8,7 +8,10 @@ import java.util.Set; import java.util.stream.Collectors; +import org.jspecify.annotations.NonNull; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -50,6 +53,9 @@ @Service @RequiredArgsConstructor public class AssignmentSwitchRequestServiceImpl implements AssignmentSwitchRequestService { + @Lazy + @Autowired(required = false) + private AssignmentSwitchRequestService self; private final AssignmentSwitchRequestDao assignmentSwitchRequestDao; private final AssignmentDao assignmentDao; private final PositionSlotDao positionSlotDao; @@ -64,13 +70,13 @@ public class AssignmentSwitchRequestServiceImpl implements AssignmentSwitchReque private final ShiftDao shiftDao; @Override - public TradeDto getTradeById(long id) { + public @NonNull TradeDto getTradeById(long id) { AssignmentSwitchRequest trade = assignmentSwitchRequestDao.getById(id); return tradeMapper.toDto(trade); } @Override - public Collection getPositionSlotsToOffer(long requestedPositionSlotId, String currentUserId) { + public @NonNull Collection getPositionSlotsToOffer(long requestedPositionSlotId, @NonNull String currentUserId) { // get requested PositionSlot PositionSlot requestedPositionSlot = positionSlotDao.getById(requestedPositionSlotId); @@ -200,7 +206,7 @@ private Collection removeExistingTrades(Collection createTrade(TradeCreateDto tradeCreateDto, String currentUserId) { + public @NonNull Collection createTrade(@NonNull TradeCreateDto tradeCreateDto, @NonNull String currentUserId) { // get current user (volunteer) Volunteer currentUser = volunteerDao.getById(currentUserId); @@ -281,7 +287,7 @@ public Collection createTrade(TradeCreateDto tradeCreateDto, String cu throw new IllegalStateException("more than one inverse trade is open" + inverse); } if (!inverse.isEmpty()) { - return List.of(acceptTrade(inverse.get(0).getId(), currentUserId)); + return List.of(self.acceptTrade(inverse.get(0).getId(), currentUserId)); } } @@ -306,7 +312,7 @@ private Collection getVolunteersToTradeWith(PositionSlot positionSlot @Override @Transactional @IsNotAdmin - public TradeDto acceptTrade(long id, String currentUserId) { + public @NonNull TradeDto acceptTrade(long id, @NonNull String currentUserId) { // get trade AssignmentSwitchRequest trade = assignmentSwitchRequestDao.getById(id); @@ -348,7 +354,7 @@ public TradeDto acceptTrade(long id, String currentUserId) { @Override @IsNotAdmin - public TradeDto declineTrade(long id, String currentUserId) { + public @NonNull TradeDto declineTrade(long id, @NonNull String currentUserId) { // get trade AssignmentSwitchRequest trade = assignmentSwitchRequestDao.getById(id); securityHelper.assertVolunteerIsNotLockedInPlan(trade.getOfferingAssignment()); @@ -371,7 +377,7 @@ public TradeDto declineTrade(long id, String currentUserId) { @Override @IsNotAdmin - public TradeDto cancelTrade(long id, String currentUserId) { + public @NonNull TradeDto cancelTrade(long id, @NonNull String currentUserId) { // get trade AssignmentSwitchRequest trade = assignmentSwitchRequestDao.getById(id); securityHelper.assertVolunteerIsNotLockedInPlan(trade.getOfferingAssignment()); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/DashboardServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/DashboardServiceImpl.java index e7356c34..007484a3 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/DashboardServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/DashboardServiceImpl.java @@ -26,6 +26,7 @@ import at.shiftcontrol.shiftservice.service.StatisticService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jspecify.annotations.NonNull; import org.springframework.stereotype.Service; @Service @@ -47,7 +48,7 @@ public class DashboardServiceImpl implements DashboardService { private final AssignmentAssemblingMapper assignmentAssemblingMapper; @Override - public EventsDashboardOverviewDto getDashboardOverviewsOfAllShiftPlans(String eventId, String userId) { + public @NonNull EventsDashboardOverviewDto getDashboardOverviewsOfAllShiftPlans(@NonNull String eventId, @NonNull String userId) { var userShiftPlans = shiftPlanDao.findAllUserRelatedShiftPlansInEvent(userId, eventId); var shiftPlanDashboards = userShiftPlans.stream().map(shiftPlan -> { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/EligibilityServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/EligibilityServiceImpl.java index 641931a4..4179ff8b 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/EligibilityServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/EligibilityServiceImpl.java @@ -3,6 +3,8 @@ import java.time.Instant; import java.util.Collection; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -35,7 +37,7 @@ public class EligibilityServiceImpl implements EligibilityService { private final ApplicationUserProvider userProvider; @Override - public PositionSignupState getSignupStateForPositionSlot(Long positionSlotId, String userId) { + public @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull Long positionSlotId, @NonNull String userId) { return getSignupStateForPositionSlot( positionSlotDao.getById(positionSlotId), volunteerDao.getById(userId) @@ -43,7 +45,7 @@ public PositionSignupState getSignupStateForPositionSlot(Long positionSlotId, St } @Override - public PositionSignupState getSignupStateForPositionSlot(PositionSlot positionSlot, String userId) { + public @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull PositionSlot positionSlot, @NonNull String userId) { return getSignupStateForPositionSlot( positionSlot, volunteerDao.getById(userId) @@ -51,12 +53,12 @@ public PositionSignupState getSignupStateForPositionSlot(PositionSlot positionSl } @Override - public PositionSignupState getSignupStateForPositionSlot(PositionSlot positionSlot, Volunteer volunteer) { // todo fix testdata + public @NonNull PositionSignupState getSignupStateForPositionSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer) { return getSignupStateForPositionSlotExcludingSlot(positionSlot, volunteer, null); } @Override - public PositionSignupState getSignupStateForPositionSlotExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude) { + public @NonNull PositionSignupState getSignupStateForPositionSlotExcludingSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @Nullable PositionSlot slotToExclude) { if (isSignedUp(positionSlot, volunteer)) { return PositionSignupState.SIGNED_UP; } @@ -110,7 +112,7 @@ public PositionSignupState getSignupStateForPositionSlotExcludingSlot(PositionSl } @Override - public void validateSignUpStateForJoin(PositionSlot positionSlot, Volunteer volunteer) { + public void validateSignUpStateForJoin(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer) { PositionSignupState signupState = this.getSignupStateForPositionSlot(positionSlot, volunteer); switch (signupState) { case SIGNED_UP, FULL, SIGNUP_VIA_TRADE, SIGNUP_VIA_AUCTION, TIME_CONFLICT_ASSIGNMENT, TIME_CONFLICT_TIME_CONSTRAINT: @@ -129,7 +131,7 @@ public void validateSignUpStateForJoin(PositionSlot positionSlot, Volunteer volu } @Override - public void validateSignUpStateForAuction(PositionSlot positionSlot, Volunteer volunteer) { + public void validateSignUpStateForAuction(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer) { PositionSignupState signupState = this.getSignupStateForPositionSlot(positionSlot, volunteer); switch (signupState) { case SIGNED_UP, FULL, SIGNUP_VIA_TRADE, SIGNUP_POSSIBLE, SIGNUP_OR_TRADE, TIME_CONFLICT_ASSIGNMENT, TIME_CONFLICT_TIME_CONSTRAINT: @@ -148,56 +150,56 @@ public void validateSignUpStateForAuction(PositionSlot positionSlot, Volunteer v } @Override - public boolean isEligibleAndNotSignedUp(PositionSlot positionSlot, Volunteer volunteer) { + public boolean isEligibleAndNotSignedUp(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer) { PositionSignupState signupState = this.getSignupStateForPositionSlot(positionSlot, volunteer); return !PositionSignupState.SIGNED_UP.equals(signupState) && !PositionSignupState.isConflicts(signupState); } @Override - public boolean isEligibleAndNotSignedUpExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude) { + public boolean isEligibleAndNotSignedUpExcludingSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlot slotToExclude) { PositionSignupState signupState = this.getSignupStateForPositionSlotExcludingSlot(positionSlot, volunteer, slotToExclude); return !PositionSignupState.SIGNED_UP.equals(signupState) && !PositionSignupState.isConflicts(signupState); } @Override - public void validateIsEligibleAndNotSignedUp(PositionSlot positionSlot, Volunteer volunteer) { + public void validateIsEligibleAndNotSignedUp(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer) { if (!isEligibleAndNotSignedUp(positionSlot, volunteer)) { throw new ConflictException("position slot can not be assigned to volunteer"); } } @Override - public void validateIsEligibleAndNotSignedUpExcludingSlot(PositionSlot positionSlot, Volunteer volunteer, PositionSlot slotToExclude) { + public void validateIsEligibleAndNotSignedUpExcludingSlot(@NonNull PositionSlot positionSlot, @NonNull Volunteer volunteer, @NonNull PositionSlot slotToExclude) { if (!isEligibleAndNotSignedUpExcludingSlot(positionSlot, volunteer, slotToExclude)) { throw new ConflictException("position slot can not be assigned to volunteer"); } } @Override - public Collection getConflictingAssignments(String volunteerId, Instant startTime, Instant endTime) { + public @NonNull Collection getConflictingAssignments(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime) { return assignmentDao.getConflictingAssignments(volunteerId, startTime, endTime); } @Override - public Collection getConflictingAssignments(String volunteerId, PositionSlot positionSlot) { + public @NonNull Collection getConflictingAssignments(@NonNull String volunteerId, @NonNull PositionSlot positionSlot) { return getConflictingAssignments(volunteerId, positionSlot.getShift().getStartTime(), positionSlot.getShift().getEndTime()); } @Override - public Collection getConflictingAssignmentsExcludingShift(String volunteerId, Instant startTime, Instant endTime, long shiftIdToExclude) { + public @NonNull Collection getConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime, long shiftIdToExclude) { return assignmentDao.getConflictingAssignmentsExcludingShift(volunteerId, startTime, endTime, shiftIdToExclude); } @Override - public Collection getConflictingAssignmentsExcludingShift(String volunteerId, PositionSlot positionSlot, long shiftIdToExclude) { + public @NonNull Collection getConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull PositionSlot positionSlot, long shiftIdToExclude) { return getConflictingAssignmentsExcludingShift( volunteerId, positionSlot.getShift().getStartTime(), positionSlot.getShift().getEndTime(), shiftIdToExclude); } @Override - public void validateHasConflictingAssignmentsExcludingShift(String volunteerId, Instant startTime, Instant endTime, long shiftId) { + public void validateHasConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull Instant startTime, @NonNull Instant endTime, long shiftId) { var a = assignmentDao.getConflictingAssignmentsExcludingShift(volunteerId, startTime, endTime, shiftId); if (a.isEmpty()) { return; @@ -206,13 +208,13 @@ public void validateHasConflictingAssignmentsExcludingShift(String volunteerId, } @Override - public void validateHasConflictingAssignmentsExcludingShift(String volunteerId, PositionSlot positionSlot, long shiftToExclude) { + public void validateHasConflictingAssignmentsExcludingShift(@NonNull String volunteerId, @NonNull PositionSlot positionSlot, long shiftToExclude) { validateHasConflictingAssignmentsExcludingShift( volunteerId, positionSlot.getShift().getStartTime(), positionSlot.getShift().getEndTime(), shiftToExclude); } @Override - public boolean hasCapacity(PositionSlot positionSlot) { + public boolean hasCapacity(@NonNull PositionSlot positionSlot) { if (positionSlot.getAssignments() != null) { return positionSlot.getAssignments().stream() .filter(a -> a.getStatus() != AssignmentStatus.REQUEST_FOR_ASSIGNMENT).toList() diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LeaderboardServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LeaderboardServiceImpl.java index dea1db64..9ff28163 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LeaderboardServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LeaderboardServiceImpl.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; +import org.jspecify.annotations.NonNull; import org.springframework.stereotype.Service; import jakarta.ws.rs.NotFoundException; @@ -32,7 +33,7 @@ public class LeaderboardServiceImpl implements LeaderboardService { private final KeycloakUserService keycloakService; @Override - public LeaderBoardDto getLeaderBoard(long eventId, String currentUserId) throws NotFoundException, ForbiddenException { + public @NonNull LeaderBoardDto getLeaderBoard(long eventId, @NonNull String currentUserId) throws NotFoundException, ForbiddenException { var event = eventDao.findById(eventId).orElseThrow(NotFoundException::new); securityHelper.assertUserIsAllowedToAccessEvent(event); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LocationServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LocationServiceImpl.java index 005cf351..740981db 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LocationServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/LocationServiceImpl.java @@ -29,7 +29,7 @@ public class LocationServiceImpl implements LocationService { private final ApplicationEventPublisher publisher; @Override - public LocationDto getLocation(long locationId) { + public @NonNull LocationDto getLocation(long locationId) { var location = locationDao.getById(locationId); securityHelper.assertUserIsAllowedToAccessEvent(location.getEvent()); @@ -37,7 +37,7 @@ public LocationDto getLocation(long locationId) { } @Override - public Collection getAllLocationsForEvent(long eventId) { + public @NonNull Collection getAllLocationsForEvent(long eventId) { securityHelper.assertUserIsAllowedToAccessEvent(eventDao.getById(eventId)); var locations = locationDao.findAllByEventId(eventId); @@ -46,7 +46,7 @@ public Collection getAllLocationsForEvent(long eventId) { @Override @AdminOnly - public LocationDto createLocation(long eventId, @NonNull LocationModificationDto modificationDto) { + public @NonNull LocationDto createLocation(long eventId, @NonNull LocationModificationDto modificationDto) { var event = eventDao.getById(eventId); validateNameUniquenessInEvent(eventId, modificationDto.getName(), null); @@ -68,7 +68,7 @@ public LocationDto createLocation(long eventId, @NonNull LocationModificationDto @Override @AdminOnly - public LocationDto updateLocation(long locationId, @NonNull LocationModificationDto modificationDto) { + public @NonNull LocationDto updateLocation(long locationId, @NonNull LocationModificationDto modificationDto) { var location = locationDao.getById(locationId); if (location.isReadOnly()) { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/NotificationRecipientServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/NotificationRecipientServiceImpl.java index cee5afe7..2bbe31c1 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/NotificationRecipientServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/NotificationRecipientServiceImpl.java @@ -4,6 +4,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.jspecify.annotations.NonNull; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -34,14 +35,14 @@ public class NotificationRecipientServiceImpl implements NotificationRecipientSe @AdminOnly @Override - public AccountInfoDto getRecipientInformation(String recipientid) { + public @NonNull AccountInfoDto getRecipientInformation(@NonNull String recipientid) { var user = keycloakUserService.getUserById(recipientid); return AccountInfoMapper.toDto(user); } @Override @AdminOnly - public RecipientsDto getRecipientsForNotification(RecipientsFilterDto filter) { + public @NonNull RecipientsDto getRecipientsForNotification(@NonNull RecipientsFilterDto filter) { validateFilter(filter); // filter from cheapest and most narrowing query first Collection recipientIds = null; @@ -57,7 +58,7 @@ public RecipientsDto getRecipientsForNotification(RecipientsFilterDto filter) { /* if target level is admin or planner (admin equals a planner matching all filters), append all admins to recipients */ if (filter.getReceiverAccessLevel() == ReceiverAccessLevel.ADMIN || filter.getReceiverAccessLevel() == ReceiverAccessLevel.PLANNER) { - var adminIds = filterAdminsById(filter, null); + var adminIds = filterAdminsById(filter); if (recipientIds != null) { recipientIds.addAll(adminIds); } else { @@ -177,19 +178,18 @@ private Collection filterByVolunteerIds(RecipientsFilterDto filter, Coll } } - private Collection filterAdminsById(RecipientsFilterDto filter, Collection recipientIds) { + private Collection filterAdminsById(RecipientsFilterDto filter) { var admins = keycloakUserService.getAllAdmins(); if (filter.getRelatedVolunteerIds() != null) { - recipientIds = admins.stream() + return admins.stream() .map(AbstractUserRepresentation::getId) .filter(id -> filter.getRelatedVolunteerIds().contains(id)) .collect(Collectors.toSet()); } else { - recipientIds = admins.stream() + return admins.stream() .map(AbstractUserRepresentation::getId) .collect(Collectors.toSet()); } - return recipientIds; } private void validateFilter(RecipientsFilterDto filter) { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/impl/RoleServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/RoleServiceImpl.java similarity index 86% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/impl/RoleServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/RoleServiceImpl.java index 9995fc23..9e4cca9a 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/impl/RoleServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/RoleServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.role.impl; +package at.shiftcontrol.shiftservice.service.impl; import java.util.Collection; import java.util.HashSet; @@ -25,7 +25,7 @@ import at.shiftcontrol.shiftservice.dto.userprofile.VolunteerDto; import at.shiftcontrol.shiftservice.mapper.RoleMapper; import at.shiftcontrol.shiftservice.mapper.VolunteerAssemblingMapper; -import at.shiftcontrol.shiftservice.service.role.RoleService; +import at.shiftcontrol.shiftservice.service.RoleService; import at.shiftcontrol.shiftservice.util.SecurityHelper; @Service @@ -39,19 +39,19 @@ public class RoleServiceImpl implements RoleService { private final VolunteerAssemblingMapper volunteerAssemblingMapper; @Override - public Collection getRoles(Long shiftPlanId) { + public @org.jspecify.annotations.NonNull Collection getRoles(long shiftPlanId) { return RoleMapper.toRoleDto(roleDao.findAllByShiftPlanId(shiftPlanId)); } @Override - public RoleDto getRole(Long roleId) { + public @org.jspecify.annotations.NonNull RoleDto getRole(long roleId) { Role role = roleDao.getById(roleId); securityHelper.assertUserIsPlanner(role.getShiftPlan().getId()); return RoleMapper.toRoleDto(role); } @Override - public RoleDto createRole(Long shiftPlanId, @NonNull RoleModificationDto roleDto) { + public @org.jspecify.annotations.NonNull RoleDto createRole(long shiftPlanId, @NonNull RoleModificationDto roleDto) { securityHelper.assertUserIsPlanner(shiftPlanId); var shiftPlan = shiftPlanDao.getById(shiftPlanId); validateUniqueNameInShiftPlan(roleDto.getName(), shiftPlanId, null); @@ -64,7 +64,7 @@ public RoleDto createRole(Long shiftPlanId, @NonNull RoleModificationDto roleDto } @Override - public RoleDto updateRole(Long roleId, @NonNull RoleModificationDto roleDto) { + public @org.jspecify.annotations.NonNull RoleDto updateRole(long roleId, @NonNull RoleModificationDto roleDto) { var role = roleDao.getById(roleId); securityHelper.assertUserIsPlanner(role.getShiftPlan().getId()); validateUniqueNameInShiftPlan(roleDto.getName(), role.getShiftPlan().getId(), roleId); @@ -91,7 +91,7 @@ private void updateRole(@NonNull RoleModificationDto roleDto, Role role) { } @Override - public void deleteRole(Long roleId) { + public void deleteRole(long roleId) { Role role = roleDao.getById(roleId); securityHelper.assertUserIsPlanner(role.getShiftPlan().getId()); @@ -101,7 +101,7 @@ public void deleteRole(Long roleId) { } @Override - public VolunteerDto createUserRoleAssignment(String userId, UserRoleAssignmentAssignDto assignDto) { + public @org.jspecify.annotations.NonNull VolunteerDto createUserRoleAssignment(String userId, @org.jspecify.annotations.NonNull UserRoleAssignmentAssignDto assignDto) { Role role = roleDao.getById(Long.valueOf(assignDto.getRoleId())); Volunteer volunteer = volunteerDao.getById(userId); if (!role.isSelfAssignable()) { @@ -121,7 +121,7 @@ public VolunteerDto createUserRoleAssignment(String userId, UserRoleAssignmentAs } @Override - public void deleteUserRoleAssignment(String userId, Long roleId) { + public void deleteUserRoleAssignment(String userId, long roleId) { Role role = roleDao.getById(roleId); Volunteer volunteer = volunteerDao.getById(userId); if (!role.isSelfAssignable()) { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftPlanServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftPlanServiceImpl.java index 0b8ffb04..45306fdd 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftPlanServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftPlanServiceImpl.java @@ -4,6 +4,8 @@ import java.util.Collection; import java.util.List; +import jakarta.validation.Valid; +import org.jspecify.annotations.NonNull; import org.springframework.context.ApplicationEventPublisher; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; @@ -50,7 +52,7 @@ import at.shiftcontrol.shiftservice.mapper.ShiftPlanMapper; import at.shiftcontrol.shiftservice.service.AssignmentService; import at.shiftcontrol.shiftservice.service.ShiftPlanService; -import at.shiftcontrol.shiftservice.service.user.VolunteerService; +import at.shiftcontrol.shiftservice.service.VolunteerService; import at.shiftcontrol.shiftservice.util.SecurityHelper; import static at.shiftcontrol.lib.type.LockStatus.SELF_SIGNUP; @@ -80,25 +82,25 @@ public class ShiftPlanServiceImpl implements ShiftPlanService { private final VolunteerService volunteerService; @Override - public Collection getAllOfEvent(long eventId) { + public @NonNull Collection getAllOfEvent(long eventId) { eventDao.getById(eventId); return ShiftPlanMapper.toShiftPlanDto(shiftPlanDao.findByEventId(eventId)); } @Override @AdminOnly - public Collection getAll() { + public @NonNull Collection getAll() { return ShiftPlanMapper.toShiftPlanDto(shiftPlanDao.findAll()); } @Override - public ShiftPlanDto get(long shiftPlanId) { + public @NonNull ShiftPlanDto get(long shiftPlanId) { return ShiftPlanMapper.toShiftPlanDto(shiftPlanDao.getById(shiftPlanId)); } @Override @AdminOnly - public ShiftPlanCreateDto createShiftPlan(long eventId, ShiftPlanModificationDto modificationDto) { + public @NonNull ShiftPlanCreateDto createShiftPlan(long eventId, @NonNull ShiftPlanModificationDto modificationDto) { var event = eventDao.getById(eventId); validateUniqueNameInEvent(eventId, modificationDto.getName(), null); @@ -140,7 +142,7 @@ public ShiftPlanCreateDto createShiftPlan(long eventId, ShiftPlanModificationDto @Override @AdminOnly - public ShiftPlanDto update(long shiftPlanId, ShiftPlanModificationDto modificationDto) { + public @NonNull ShiftPlanDto update(long shiftPlanId, @NonNull ShiftPlanModificationDto modificationDto) { var plan = shiftPlanDao.getById(shiftPlanId); validateUniqueNameInEvent(plan.getEvent().getId(), modificationDto.getName(), shiftPlanId); @@ -179,7 +181,7 @@ public void delete(long shiftPlanId) { } @Override - public ShiftPlanInviteCreateResponseDto createShiftPlanInviteCode(long shiftPlanId, ShiftPlanInviteCreateRequestDto requestDto) { + public @NonNull ShiftPlanInviteCreateResponseDto createShiftPlanInviteCode(long shiftPlanId, @NonNull ShiftPlanInviteCreateRequestDto requestDto) { var currentUser = userProvider.getCurrentUser(); validatePermission(shiftPlanId, requestDto.getType(), currentUser); final var shiftPlan = shiftPlanDao.getById(shiftPlanId); @@ -271,7 +273,7 @@ private void validatePermission(long shiftPlanId, ShiftPlanInviteType type, Shif } @Override - public ShiftPlanInviteDetailsDto getShiftPlanInviteDetails(String inviteCode) { + public @NonNull ShiftPlanInviteDetailsDto getShiftPlanInviteDetails(@NonNull String inviteCode) { String userId; try { userId = userProvider.getCurrentUser().getUserId(); @@ -321,7 +323,7 @@ private boolean isUserAlreadyInShiftPlan(ShiftPlanInviteType type, ShiftPlan shi } @Override - public Collection getAllShiftPlanInvites(long shiftPlanId) { + public @NonNull Collection getAllShiftPlanInvites(long shiftPlanId) { // both planners and admins can list invites securityHelper.assertUserIsPlanner(shiftPlanId); var shiftPlan = shiftPlanDao.getById(shiftPlanId); @@ -333,11 +335,8 @@ public Collection getAllShiftPlanInvites(long shiftPlanId) { @Override @Transactional - public void joinShiftPlan(ShiftPlanJoinRequestDto requestDto) { + public void joinShiftPlan(@NonNull @Valid ShiftPlanJoinRequestDto requestDto) { String userId = userProvider.getCurrentUser().getUserId(); - if (requestDto == null || requestDto.getInviteCode() == null || requestDto.getInviteCode().isBlank()) { - throw new BadRequestException("Invite code is null or empty"); - } String inviteCode = requestDto.getInviteCode().trim(); ShiftPlanInvite invite = shiftPlanInviteDao.getByCode(inviteCode); validateInvite(invite); @@ -423,7 +422,7 @@ private void addRolesToUser(Collection rolesToAssign, Volunteer volunteer) } @Override - public void updateLockStatus(long shiftPlanId, LockStatus lockStatus) { + public void updateLockStatus(long shiftPlanId, @NonNull LockStatus lockStatus) { var shiftPlan = shiftPlanDao.getById(shiftPlanId); securityHelper.assertUserIsPlanner(shiftPlan); if (shiftPlan.getLockStatus().equals(lockStatus)) { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftServiceImpl.java index 262771b0..3e625f98 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/ShiftServiceImpl.java @@ -31,7 +31,6 @@ import at.shiftcontrol.shiftservice.util.SecurityHelper; import java.util.Comparator; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -46,7 +45,7 @@ public class ShiftServiceImpl implements ShiftService { private final ApplicationEventPublisher publisher; @Override - public ShiftDetailsDto getShiftDetails(long shiftId, String userId) { + public @org.jspecify.annotations.NonNull ShiftDetailsDto getShiftDetails(long shiftId, @org.jspecify.annotations.NonNull String userId) { var shift = shiftDao.getById(shiftId); var plan = shift.getShiftPlan(); var event = plan.getEvent(); @@ -62,7 +61,7 @@ public ShiftDetailsDto getShiftDetails(long shiftId, String userId) { } @Override - public PaginationDto getAllOpenShiftsOfPlanPaginated(long shiftPlanId, int page, int size) { + public @org.jspecify.annotations.NonNull PaginationDto getAllOpenShiftsOfPlanPaginated(long shiftPlanId, int page, int size) { securityHelper.assertUserIsPlanner(shiftPlanId); var shifts = shiftDao.findAllInShiftPlan(shiftPlanId) @@ -92,7 +91,7 @@ public PaginationDto getAllOpenShiftsOfPlanPaginated(long shiftPlanId, } @Override - public ShiftDto createShift(long shiftPlanId, @NonNull ShiftModificationDto modificationDto) { + public @org.jspecify.annotations.NonNull ShiftDto createShift(long shiftPlanId, @NonNull ShiftModificationDto modificationDto) { securityHelper.assertUserIsPlanner(shiftPlanId); var shiftPlan = shiftPlanDao.getById(shiftPlanId); @@ -108,7 +107,7 @@ public ShiftDto createShift(long shiftPlanId, @NonNull ShiftModificationDto modi } @Override - public ShiftDto updateShift(long shiftId, @NonNull ShiftModificationDto modificationDto) { + public @org.jspecify.annotations.NonNull ShiftDto updateShift(long shiftId, @NonNull ShiftModificationDto modificationDto) { var shift = shiftDao.getById(shiftId); securityHelper.assertUserIsPlanner(shift); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/StatisticServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/StatisticServiceImpl.java index 9a0cc758..e5131b01 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/StatisticServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/StatisticServiceImpl.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.List; +import org.jspecify.annotations.NonNull; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -29,7 +30,7 @@ public class StatisticServiceImpl implements StatisticService { private final EligibilityService eligibilityService; @Override - public OwnStatisticsDto getOwnStatisticsOfShifts(List userShifts) { + public @NonNull OwnStatisticsDto getOwnStatisticsOfShifts(@NonNull List userShifts) { var busyDays = calculateBusyDaysInShifts(userShifts); var totalShifts = calculateTotalShiftCountInShifts(userShifts); var totalHours = calculateTotalHoursInShifts(userShifts); @@ -43,7 +44,7 @@ public OwnStatisticsDto getOwnStatisticsOfShifts(List userShifts) { @Override - public OverallStatisticsDto getOverallShiftPlanStatistics(ShiftPlan shiftPlan) { + public @NonNull OverallStatisticsDto getOverallShiftPlanStatistics(@NonNull ShiftPlan shiftPlan) { var totalShifts = shiftPlan.getShifts().size(); var totalHours = calculateTotalHoursInShifts(shiftPlan.getShifts().stream().toList()); var volunteerCount = calculateVolunteerCountInShiftPlan(shiftPlan); @@ -56,7 +57,7 @@ public OverallStatisticsDto getOverallShiftPlanStatistics(ShiftPlan shiftPlan) { } @Override - public OverallStatisticsDto getOverallEventStatistics(Event event) { + public @NonNull OverallStatisticsDto getOverallEventStatistics(@NonNull Event event) { var totalHours = event.getShiftPlans().stream() .mapToDouble(shiftPlan -> calculateTotalHoursInShifts(shiftPlan.getShifts().stream().toList())) @@ -77,7 +78,7 @@ public OverallStatisticsDto getOverallEventStatistics(Event event) { } @Override - public OwnStatisticsDto getOwnStatisticsOfShiftPlans(List shiftPlans, String userId) { + public @NonNull OwnStatisticsDto getOwnStatisticsOfShiftPlans(@NonNull List shiftPlans, @NonNull String userId) { var userShiftsSet = new HashSet(); for (var shiftPlan : shiftPlans) { var relevantShiftsOfPlan = shiftDao.searchUserRelatedShiftsInShiftPlan(shiftPlan.getId(), userId); @@ -88,7 +89,7 @@ public OwnStatisticsDto getOwnStatisticsOfShiftPlans(List shiftPlans, } @Override - public ScheduleStatisticsDto getShiftPlanScheduleStatistics(List shifts, Volunteer volunteer) { + public @NonNull ScheduleStatisticsDto getShiftPlanScheduleStatistics(@NonNull List shifts, @NonNull Volunteer volunteer) { double totalHours = shifts.stream() .mapToDouble(s -> TimeUtil.calculateDurationInMinutes(s.getStartTime(), s.getEndTime())) .sum() / 60.0; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TimeConstraintServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TimeConstraintServiceImpl.java index 0ec8e6cb..c2b68100 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TimeConstraintServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TimeConstraintServiceImpl.java @@ -47,14 +47,14 @@ public class TimeConstraintServiceImpl implements TimeConstraintService { private static final long SECONDS_PER_DAY = Duration.ofDays(1).getSeconds(); @Override - public Collection getTimeConstraints(@NonNull String userId, long eventId) { + public @org.jspecify.annotations.NonNull Collection getTimeConstraints(@NonNull String userId, long eventId) { return TimeConstraintMapper.toDto(timeConstraintDao.searchByVolunteerAndEvent(userId, eventId)); } @Override @IsNotAdmin @Transactional - public TimeConstraintDto createTimeConstraint(@NonNull TimeConstraintCreateDto createDto, @NonNull String userId, long eventId) { + public @org.jspecify.annotations.NonNull TimeConstraintDto createTimeConstraint(@NonNull TimeConstraintCreateDto createDto, @NonNull String userId, long eventId) { //VALIDATION: Validate date range Instant from = createDto.getFrom(); Instant to = createDto.getTo(); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TrustAlertServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TrustAlertServiceImpl.java index b12e51aa..c43d9268 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TrustAlertServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/TrustAlertServiceImpl.java @@ -1,5 +1,6 @@ package at.shiftcontrol.shiftservice.service.impl; +import org.jspecify.annotations.NonNull; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; @@ -25,7 +26,7 @@ public class TrustAlertServiceImpl implements TrustAlertService { @Override @AdminOnly - public PaginationDto getAllPaginated(int page, int size) { + public @NonNull PaginationDto getAllPaginated(int page, int size) { var items = trustAlertAssemblingMapper.toDto(trustAlertDao.getAllPaginated(page, size)); long totalItems = trustAlertDao.findAllSize(); return PaginationMapper.toPaginationDto(size, page, totalItems, items); @@ -33,7 +34,7 @@ public PaginationDto getAllPaginated(int page, int size) { @Override @AdminOnly - public TrustAlertDisplayDto save(TrustAlertDto alert) { + public @NonNull TrustAlertDisplayDto save(@NonNull TrustAlertDto alert) { TrustAlert entity = trustAlertAssemblingMapper.toEntity(alert); entity = trustAlertDao.save(entity); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/UserAdministrationServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserAdministrationServiceImpl.java similarity index 91% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/UserAdministrationServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserAdministrationServiceImpl.java index 99226eac..a05005b1 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/UserAdministrationServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserAdministrationServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.user.impl; +package at.shiftcontrol.shiftservice.service.impl; import java.util.Collection; import java.util.Collections; @@ -45,8 +45,8 @@ import at.shiftcontrol.shiftservice.mapper.UserAssemblingMapper; import at.shiftcontrol.shiftservice.repo.AssignmentRepository; import at.shiftcontrol.shiftservice.service.AssignmentService; -import at.shiftcontrol.shiftservice.service.user.UserAdministrationService; -import at.shiftcontrol.shiftservice.service.user.VolunteerService; +import at.shiftcontrol.shiftservice.service.UserAdministrationService; +import at.shiftcontrol.shiftservice.service.VolunteerService; import at.shiftcontrol.shiftservice.util.SecurityHelper; @Service @@ -67,7 +67,7 @@ public class UserAdministrationServiceImpl implements UserAdministrationService @Override @AdminOnly - public PaginationDto getAllUsers(int page, int size, UserSearchDto searchDto) { + public @NonNull PaginationDto getAllUsers(int page, int size, @NonNull UserSearchDto searchDto) { var allUsers = keycloakUserService.getAllUsers(); var users = filterUsers(searchDto, allUsers); var paginatedUsers = paginateUsers(users, page, size); @@ -79,7 +79,7 @@ public PaginationDto getAllUsers(int page, int size, UserSearchDto } @Override - public PaginationDto getAllPlanUsers(Long shiftPlanId, int page, int size, UserSearchDto searchDto) { + public @NonNull PaginationDto getAllPlanUsers(@NonNull Long shiftPlanId, int page, int size, @NonNull UserSearchDto searchDto) { securityHelper.assertUserIsPlanner(shiftPlanId); var allUsers = keycloakUserService.getAllUsers(); var volunteersInPlanId = volunteerDao.findAllIdsByShiftPlan(shiftPlanId); @@ -121,18 +121,18 @@ private static List filterUsers(UserSearchDto searchDto, Lis @Override @AdminOnly - public UserEventDto getUser(String userId) { + public @NonNull UserEventDto getUser(@NonNull String userId) { var volunteer = volunteerService.getOrCreate(userId); return userAssemblingMapper.toUserEventDto(volunteer); } @Override - public UserEventDto createVolunteer(String userId) { + public @NonNull UserEventDto createVolunteer(@NonNull String userId) { return userAssemblingMapper.toUserEventDto(volunteerService.createVolunteer(userId)); } @Override - public UserPlanDto getPlanUser(Long shiftPlanId, String userId) { + public @NonNull UserPlanDto getPlanUser(@NonNull Long shiftPlanId, @NonNull String userId) { var volunteer = volunteerDao.getById(userId); securityHelper.assertUserIsPlanner(shiftPlanId); securityHelper.assertVolunteerIsVolunteer(shiftPlanDao.getById(shiftPlanId), volunteer, false); @@ -142,7 +142,7 @@ public UserPlanDto getPlanUser(Long shiftPlanId, String userId) { @Override @Transactional @AdminOnly - public UserEventDto updateEventUser(String userId, UserEventUpdateDto updateDto) { + public @NonNull UserEventDto updateEventUser(@NonNull String userId, @NonNull UserEventUpdateDto updateDto) { var volunteer = volunteerDao.getById(userId); assertPlansChanged(volunteer, updateDto); @@ -166,7 +166,7 @@ public UserEventDto updateEventUser(String userId, UserEventUpdateDto updateDto) @Override @Transactional - public UserPlanDto updatePlanUser(Long shiftPlanId, String userId, UserPlanUpdateDto updateDto) { + public @NonNull UserPlanDto updatePlanUser(@NonNull Long shiftPlanId, @NonNull String userId, @NonNull UserPlanUpdateDto updateDto) { var volunteer = volunteerDao.getById(userId); securityHelper.assertUserIsPlanner(shiftPlanId); securityHelper.assertVolunteerIsVolunteer(shiftPlanDao.getById(shiftPlanId), volunteer, false); @@ -197,7 +197,7 @@ public UserPlanDto updatePlanUser(Long shiftPlanId, String userId, UserPlanUpdat @Override @Transactional - public UserEventDto lockUser(String userId, Collection shiftPlanIds) { + public @NonNull UserEventDto lockUser(@NonNull String userId, @NonNull Collection shiftPlanIds) { shiftPlanIds.forEach(securityHelper::assertUserIsPlanner); var volunteer = volunteerDao.getById(userId); var plans = shiftPlanDao.getByIds(new HashSet<>(shiftPlanIds)); @@ -216,7 +216,7 @@ public UserEventDto lockUser(String userId, Collection shiftPlanIds) { @Override @Transactional - public UserEventDto unLockUser(String userId, Collection shiftPlanIds) { + public @NonNull UserEventDto unLockUser(@NonNull String userId, @NonNull Collection shiftPlanIds) { shiftPlanIds.forEach(securityHelper::assertUserIsPlanner); var volunteer = volunteerDao.getById(userId); var plans = shiftPlanDao.getByIds(new HashSet<>(shiftPlanIds)); @@ -232,7 +232,7 @@ public UserEventDto unLockUser(String userId, Collection shiftPlanIds) { @Override @Transactional - public UserEventDto resetUser(String userId, Collection shiftPlanId) { + public @NonNull UserEventDto resetUser(@NonNull String userId, @NonNull Collection shiftPlanId) { var volunteer = volunteerDao.getById(userId); var plans = shiftPlanDao.getByIds(new HashSet<>(shiftPlanId)); for (ShiftPlan plan : plans) { @@ -250,7 +250,7 @@ public UserEventDto resetUser(String userId, Collection shiftPlanId) { } @Override - public Collection bulkAddRoles(long shiftPlanId, UserPlanBulkDto updateDto) { + public @NonNull Collection bulkAddRoles(long shiftPlanId, UserPlanBulkDto updateDto) { securityHelper.assertUserIsPlanner(shiftPlanId); var volunteers = volunteerDao.findAllByVolunteerIds(updateDto.getVolunteers()); var roles = roleDao.findAllById(updateDto.getRoles().stream().map(ConvertUtil::idToLong).toList()); @@ -267,7 +267,7 @@ public Collection bulkAddRoles(long shiftPlanId, UserPlanBulkDto up } @Override - public Collection bulkRemoveRoles(long shiftPlanId, UserPlanBulkDto updateDto) { + public @NonNull Collection bulkRemoveRoles(long shiftPlanId, UserPlanBulkDto updateDto) { securityHelper.assertUserIsPlanner(shiftPlanId); var volunteers = volunteerDao.findAllByVolunteerIds(updateDto.getVolunteers()); var roles = roleDao.findAllById(updateDto.getRoles().stream().map(ConvertUtil::idToLong).toList()); @@ -282,7 +282,7 @@ public Collection bulkRemoveRoles(long shiftPlanId, UserPlanBulkDto @Override @AdminOnly @Transactional - public Collection bulkAddVolunteeringPlans(UserEventBulkDto updateDto) { + public @NonNull Collection bulkAddVolunteeringPlans(UserEventBulkDto updateDto) { var volunteers = volunteerDao.findAllByVolunteerIds(updateDto.getVolunteers()); var plans = shiftPlanDao.getByIds(updateDto.getPlans().stream().map(ConvertUtil::idToLong).collect(Collectors.toSet())); for (Volunteer v : volunteers) { @@ -299,7 +299,7 @@ public Collection bulkAddVolunteeringPlans(UserEventBulkDto update @Override @AdminOnly @Transactional - public Collection bulkRemoveVolunteeringPlans(UserEventBulkDto updateDto) { + public @NonNull Collection bulkRemoveVolunteeringPlans(UserEventBulkDto updateDto) { var volunteers = volunteerDao.findAllByVolunteerIds(updateDto.getVolunteers()); var plans = shiftPlanDao.getByIds(updateDto.getPlans().stream().map(ConvertUtil::idToLong).collect(Collectors.toSet())); for (Volunteer v : volunteers) { diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserPreferenceServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserPreferenceServiceImpl.java index 43d01819..a78cb9a0 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserPreferenceServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/UserPreferenceServiceImpl.java @@ -3,13 +3,14 @@ import at.shiftcontrol.shiftservice.dto.positionslot.PositionSlotPreferenceDto; import at.shiftcontrol.shiftservice.service.UserPreferenceService; import lombok.RequiredArgsConstructor; +import org.jspecify.annotations.NonNull; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class UserPreferenceServiceImpl implements UserPreferenceService { @Override - public PositionSlotPreferenceDto getUserPreference(String userId, long shiftId) { + public @NonNull PositionSlotPreferenceDto getUserPreference(@NonNull String userId, long shiftId) { //TODO implement method return null; } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/VolunteerServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/VolunteerServiceImpl.java similarity index 80% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/VolunteerServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/VolunteerServiceImpl.java index f29e70d8..3d86f4cb 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/impl/VolunteerServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/VolunteerServiceImpl.java @@ -1,7 +1,8 @@ -package at.shiftcontrol.shiftservice.service.user.impl; +package at.shiftcontrol.shiftservice.service.impl; import java.util.Collections; +import org.jspecify.annotations.NonNull; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; @@ -9,7 +10,7 @@ import at.shiftcontrol.lib.entity.Volunteer; import at.shiftcontrol.shiftservice.dao.userprofile.VolunteerDao; -import at.shiftcontrol.shiftservice.service.user.VolunteerService; +import at.shiftcontrol.shiftservice.service.VolunteerService; @Service @RequiredArgsConstructor @@ -17,7 +18,7 @@ public class VolunteerServiceImpl implements VolunteerService { private final VolunteerDao volunteerDao; @Override - public Volunteer createVolunteer(String userId) { + public @NonNull Volunteer createVolunteer(@NonNull String userId) { var newVolunteer = Volunteer.builder() .id(userId) .planningPlans(Collections.emptySet()) @@ -35,7 +36,7 @@ public Volunteer createVolunteer(String userId) { } @Override - public Volunteer getOrCreate(String userId) { + public @NonNull Volunteer getOrCreate(@NonNull String userId) { return volunteerDao.findById(userId).orElseGet(() -> createVolunteer(userId)); } } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/positionslot/impl/PositionSlotServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/positionslot/impl/PositionSlotServiceImpl.java index 7e2d1900..52090036 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/positionslot/impl/PositionSlotServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/positionslot/impl/PositionSlotServiceImpl.java @@ -219,7 +219,7 @@ public AssignmentDto createAuction(@NonNull Long positionSlotId, @NonNull String securityHelper.assertVolunteerIsNotLockedInPlan(assignment); // no security check necessary, because user is already assigned to position, // if not, assignment would not be found - if (assignment == null || assignment.getStatus() == AssignmentStatus.REQUEST_FOR_ASSIGNMENT) { + if (assignment.getStatus() == AssignmentStatus.REQUEST_FOR_ASSIGNMENT) { throw new IllegalStateException("auction not possible, not assigned to slot"); } if (AssignmentStatus.ACTIVE_AUCTION_STATES.contains(assignment.getStatus())) { @@ -244,7 +244,7 @@ public AssignmentDto claimAuction(@NonNull Long positionSlotId, @NonNull String @NonNull PositionSlotRequestDto requestDto) { // get auction-assignment Assignment auction = assignmentDao.getAssignmentForPositionSlotAndUser(positionSlotId, offeringUserId); - if (auction == null || !AssignmentStatus.ACTIVE_AUCTION_STATES.contains(auction.getStatus())) { + if (!AssignmentStatus.ACTIVE_AUCTION_STATES.contains(auction.getStatus())) { throw new BadRequestException("Assignment is not up for auction"); } securityHelper.assertVolunteerIsNotLockedInPlan(auction); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsCalculatorImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsCalculatorImpl.java similarity index 96% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsCalculatorImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsCalculatorImpl.java index 55e23354..07c11726 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsCalculatorImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsCalculatorImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.rewardpoints; +package at.shiftcontrol.shiftservice.service.rewardpoints.impl; import java.util.HashMap; import java.util.Map; @@ -21,9 +21,6 @@ @Service @RequiredArgsConstructor public class RewardPointsCalculatorImpl implements RewardPointsCalculator { - - private final ObjectMapper objectMapper = new ObjectMapper(); - @Override public RewardPointsSnapshotDto calculateForAssignment(@NonNull PositionSlot slot) { var shift = slot.getShift(); diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsExportServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsExportServiceImpl.java similarity index 97% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsExportServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsExportServiceImpl.java index 0d7a211e..e0243461 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsExportServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsExportServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.rewardpoints; +package at.shiftcontrol.shiftservice.service.rewardpoints.impl; import java.io.*; import java.time.Instant; @@ -10,6 +10,7 @@ import java.util.Map; import at.shiftcontrol.lib.common.UniqueCodeGenerator; +import at.shiftcontrol.lib.exception.FileExportException; import at.shiftcontrol.shiftservice.annotation.AdminOnly; import at.shiftcontrol.shiftservice.auth.KeycloakUserService; import at.shiftcontrol.shiftservice.dao.EventDao; @@ -41,7 +42,6 @@ @Service public class RewardPointsExportServiceImpl extends RewardPointsServiceImpl implements RewardPointsExportService { - public RewardPointsExportServiceImpl(RewardPointsCalculator calculator, RewardPointsLedgerService ledgerService, RewardPointsShareTokenDao rewardPointsShareTokenDao, @@ -86,7 +86,7 @@ public EventExportDto exportRewardPoints() { .build(); } catch (IOException e) { - throw new RuntimeException("Failed to export reward points", e); + throw new FileExportException("Failed to export reward points", e); } } @@ -136,7 +136,7 @@ private void buildDetailsSheet( createTextCell(row, c++, vp.getLastName(), textStyle); createTextCell(row, c++, vp.getEmail(), textStyle); - Cell pointsCell = row.createCell(c++); + Cell pointsCell = row.createCell(c); pointsCell.setCellValue(vp.getRewardPoints()); pointsCell.setCellStyle(intStyle); } @@ -166,7 +166,7 @@ private void buildSummarySheet( class VolRow { String volunteerId, firstName, lastName, email; - Map pointsByEventId = new HashMap<>(); + final Map pointsByEventId = new HashMap<>(); int totalFinished = 0; int totalAll = 0; } diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsLedgerServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsLedgerServiceImpl.java similarity index 98% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsLedgerServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsLedgerServiceImpl.java index 7bb54804..403352f0 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsLedgerServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsLedgerServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.rewardpoints; +package at.shiftcontrol.shiftservice.service.rewardpoints.impl; import java.time.Instant; import java.util.Collection; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsServiceImpl.java similarity index 99% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsServiceImpl.java index f0419f79..4679dda0 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/impl/rewardpoints/RewardPointsServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/rewardpoints/impl/RewardPointsServiceImpl.java @@ -1,4 +1,4 @@ -package at.shiftcontrol.shiftservice.service.impl.rewardpoints; +package at.shiftcontrol.shiftservice.service.rewardpoints.impl; import java.time.Instant; import java.util.ArrayList; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/RoleService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/RoleService.java deleted file mode 100644 index 1fab2dcf..00000000 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/role/RoleService.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.shiftcontrol.shiftservice.service.role; - -import java.util.Collection; - -import at.shiftcontrol.shiftservice.dto.role.RoleDto; -import at.shiftcontrol.shiftservice.dto.role.RoleModificationDto; -import at.shiftcontrol.shiftservice.dto.role.UserRoleAssignmentAssignDto; -import at.shiftcontrol.shiftservice.dto.userprofile.VolunteerDto; - -public interface RoleService { - Collection getRoles(Long shiftPlanId); - - RoleDto getRole(Long roleId); - - RoleDto createRole(Long shiftPlanId, RoleModificationDto roleDto); - - RoleDto updateRole(Long roleId, RoleModificationDto roleDto); - - void deleteRole(Long roleId); - - VolunteerDto createUserRoleAssignment(String userId, UserRoleAssignmentAssignDto assignDto); - - void deleteUserRoleAssignment(String userId, Long roleId); -} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/UserAdministrationService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/UserAdministrationService.java deleted file mode 100644 index 09363202..00000000 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/UserAdministrationService.java +++ /dev/null @@ -1,44 +0,0 @@ -package at.shiftcontrol.shiftservice.service.user; - -import java.util.Collection; - -import jakarta.validation.Valid; - -import at.shiftcontrol.lib.dto.PaginationDto; -import at.shiftcontrol.shiftservice.dto.user.UserEventBulkDto; -import at.shiftcontrol.shiftservice.dto.user.UserEventDto; -import at.shiftcontrol.shiftservice.dto.user.UserEventUpdateDto; -import at.shiftcontrol.shiftservice.dto.user.UserPlanBulkDto; -import at.shiftcontrol.shiftservice.dto.user.UserPlanDto; -import at.shiftcontrol.shiftservice.dto.user.UserPlanUpdateDto; -import at.shiftcontrol.shiftservice.dto.user.UserSearchDto; - -public interface UserAdministrationService { - PaginationDto getAllUsers(int page, int size, UserSearchDto searchDt); - - PaginationDto getAllPlanUsers(Long shiftPlanId, int page, int size, UserSearchDto searchDto); - - UserEventDto getUser(String userId); - - UserEventDto createVolunteer(String userId); - - UserPlanDto getPlanUser(Long shiftPlanId, String userId); - - UserEventDto updateEventUser(String userId, UserEventUpdateDto updateDto); - - UserPlanDto updatePlanUser(Long shiftPlanId, String userId, UserPlanUpdateDto updateDto); - - UserEventDto lockUser(String userId, Collection shiftPlanId); - - UserEventDto unLockUser(String userId, Collection shiftPlanId); - - UserEventDto resetUser(String userId, Collection shiftPlanId); - - Collection bulkAddRoles(long shiftPlanId, @Valid UserPlanBulkDto updateDto); - - Collection bulkRemoveRoles(long shiftPlanId, @Valid UserPlanBulkDto updateDto); - - Collection bulkAddVolunteeringPlans(@Valid UserEventBulkDto updateDto); - - Collection bulkRemoveVolunteeringPlans(@Valid UserEventBulkDto updateDto); -} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/VolunteerService.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/VolunteerService.java deleted file mode 100644 index 96902dd5..00000000 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/user/VolunteerService.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.shiftcontrol.shiftservice.service.user; - -import at.shiftcontrol.lib.entity.Volunteer; - -public interface VolunteerService { - - Volunteer createVolunteer(String userId); - - Volunteer getOrCreate(String userId); -} diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/UserProfileServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/KeycloakUserProfileService.java similarity index 94% rename from shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/UserProfileServiceImpl.java rename to shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/KeycloakUserProfileService.java index 13b78c51..938b4a5d 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/UserProfileServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/KeycloakUserProfileService.java @@ -14,14 +14,14 @@ import at.shiftcontrol.shiftservice.dto.userprofile.NotificationSettingsDto; import at.shiftcontrol.shiftservice.dto.userprofile.UserProfileDto; import at.shiftcontrol.shiftservice.mapper.UserProfileMapper; -import at.shiftcontrol.shiftservice.service.user.VolunteerService; +import at.shiftcontrol.shiftservice.service.VolunteerService; import at.shiftcontrol.shiftservice.service.userprofile.NotificationService; import at.shiftcontrol.shiftservice.service.userprofile.UserProfileService; import at.shiftcontrol.shiftservice.util.SecurityHelper; @Service @RequiredArgsConstructor -public class UserProfileServiceImpl implements UserProfileService { +public class KeycloakUserProfileService implements UserProfileService { private final KeycloakUserService kcService; private final NotificationService notificationService; private final ApplicationUserProvider userProvider; diff --git a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/NotificationServiceImpl.java b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/NotificationServiceImpl.java index b698e748..236d4acb 100644 --- a/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/NotificationServiceImpl.java +++ b/shiftservice/src/main/java/at/shiftcontrol/shiftservice/service/userprofile/impl/NotificationServiceImpl.java @@ -6,6 +6,8 @@ import java.util.Map; import java.util.stream.Collectors; +import at.shiftcontrol.lib.exception.IllegalStateException; + import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; @@ -38,9 +40,10 @@ public Collection getNotificationsForUser(String userId public NotificationSettingsDto updateNotificationSetting(@NonNull String userId, @NonNull NotificationSettingsDto settingsDto) { Collection existingOrDefault = getSettingsOrDefault(userId); // find setting for type - NotificationSettings toUpdate = existingOrDefault.stream() + var toUpdate = existingOrDefault.stream() .filter(ns -> ns.getType() == settingsDto.getType()) - .findFirst().get(); + .findFirst().orElseThrow(() -> new IllegalStateException("Could not find notification setting for type " + settingsDto.getType())); + // update setting toUpdate.setChannels( settingsDto.getChannels().isEmpty() diff --git a/shiftservice/src/test/java/at/shiftcontrol/shiftservice/service/impl/EventServiceTest.java b/shiftservice/src/test/java/at/shiftcontrol/shiftservice/service/impl/EventServiceTest.java index f087efa8..42c18295 100644 --- a/shiftservice/src/test/java/at/shiftcontrol/shiftservice/service/impl/EventServiceTest.java +++ b/shiftservice/src/test/java/at/shiftcontrol/shiftservice/service/impl/EventServiceTest.java @@ -18,7 +18,7 @@ import at.shiftcontrol.shiftservice.mapper.EventMapper; import at.shiftcontrol.shiftservice.mapper.ShiftPlanMapper; import at.shiftcontrol.shiftservice.service.StatisticService; -import at.shiftcontrol.shiftservice.service.impl.event.EventServiceImpl; +import at.shiftcontrol.shiftservice.service.event.impl.EventServiceImpl; import at.shiftcontrol.shiftservice.util.SecurityHelper; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/shiftservice/src/test/java/config/TestConfig.java b/shiftservice/src/test/java/config/TestConfig.java index 0eb51868..cc5b78db 100644 --- a/shiftservice/src/test/java/config/TestConfig.java +++ b/shiftservice/src/test/java/config/TestConfig.java @@ -6,7 +6,7 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import at.shiftcontrol.shiftservice.service.impl.rewardpoints.RewardPointsCalculatorImpl; +import at.shiftcontrol.shiftservice.service.rewardpoints.impl.RewardPointsCalculatorImpl; import at.shiftcontrol.shiftservice.service.rewardpoints.RewardPointsCalculator; import at.shiftcontrol.shiftservice.util.TestEntityFactory;