-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sharing of role capability sets
- Loading branch information
Showing
14 changed files
with
436 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@startuml | ||
title sd book room | ||
|
||
actor Guest | ||
participant Catalog | ||
participant System | ||
participant Booking | ||
participant Room | ||
participant Payment | ||
|
||
activate Guest | ||
Guest -> Catalog : searchRoom(price, style) | ||
activate Catalog | ||
Catalog --> Guest : return roomList | ||
deactivate Catalog | ||
|
||
Guest -> System : selectRoom() | ||
activate System | ||
|
||
alt roomStatus = available | ||
System --> Guest : ready to book | ||
Guest -> System : createBooking(room) | ||
System -> Booking : create | ||
activate Booking | ||
Booking -> Room : getBookingPrice() | ||
activate Room | ||
Room --> Booking : return bookingPrice | ||
deactivate Room | ||
Booking --> Guest : ready for payment | ||
deactivate Booking | ||
Guest -> Payment : initiatePayment(bookingPrice) | ||
activate Payment | ||
Payment -> Payment : process payment | ||
|
||
alt payment successful | ||
Payment --> Guest : payment succeeded | ||
Payment -> System : payment fulfilled | ||
deactivate Payment | ||
System -> Room : setRoomStatus(reserved) | ||
activate Room | ||
Room --> System : roomStatus updated | ||
deactivate Room | ||
else payment unsuccessful | ||
Payment --> Guest : payment failed | ||
deactivate Payment | ||
end | ||
|
||
else roomStatus = unavailable | ||
System --> Guest : room unavailable | ||
end | ||
|
||
deactivate System | ||
deactivate Guest | ||
|
||
@enduml |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/folio/consortia/client/CapabilitySetsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.folio.consortia.client; | ||
|
||
import org.folio.consortia.domain.dto.CapabilitySets; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@FeignClient(name = "capability-sets") | ||
public interface CapabilitySetsClient { | ||
|
||
@GetMapping | ||
CapabilitySets queryCapabilitySets(@RequestParam String query, @RequestParam Integer limit, @RequestParam Integer offset); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/folio/consortia/controller/SharingRoleCapabilitySetController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.folio.consortia.controller; | ||
|
||
import static org.springframework.http.HttpStatus.CREATED; | ||
import static org.springframework.http.HttpStatus.OK; | ||
|
||
import java.util.UUID; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilitySetDeleteResponse; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilitySetRequest; | ||
import org.folio.consortia.domain.dto.SharingRoleCapabilitySetResponse; | ||
import org.folio.consortia.rest.resource.RolesApi; | ||
import org.folio.consortia.service.impl.SharingRoleCapabilitySetService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/consortia/{consortiumId}/sharing") | ||
@RequiredArgsConstructor | ||
public class SharingRoleCapabilitySetController implements RolesApi { | ||
|
||
private final SharingRoleCapabilitySetService sharingRoleCapabilitySetService; | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleCapabilitySetResponse> startSharingRoleCapabilitySet(UUID consortiumId, | ||
SharingRoleCapabilitySetRequest sharingRoleCapabilitySetRequest) { | ||
return ResponseEntity | ||
.status(CREATED) | ||
.body(sharingRoleCapabilitySetService.start(consortiumId, sharingRoleCapabilitySetRequest)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleCapabilitySetDeleteResponse> deleteSharingRoleCapabilitySet(UUID consortiumId, UUID roleId, | ||
SharingRoleCapabilitySetRequest sharingRoleCapabilitySetRequest) { | ||
return ResponseEntity | ||
.status(OK) | ||
.body(sharingRoleCapabilitySetService.delete(consortiumId, roleId, sharingRoleCapabilitySetRequest)); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/folio/consortia/domain/entity/SharingRoleCapabilitySetEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.folio.consortia.domain.entity; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.folio.consortia.domain.entity.base.AuditableEntity; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@Entity | ||
@Table(name = "sharing_role") | ||
public class SharingRoleCapabilitySetEntity extends AuditableEntity { | ||
|
||
@Id | ||
private UUID id; | ||
private UUID roleId; | ||
private List<UUID> capabilitySetIds; | ||
private String tenantId; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/folio/consortia/repository/SharingRoleCapabilitySetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.folio.consortia.repository; | ||
|
||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
import org.folio.consortia.domain.entity.SharingRoleCapabilitySetEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface SharingRoleCapabilitySetRepository extends JpaRepository<SharingRoleCapabilitySetEntity, UUID> { | ||
|
||
@Query("SELECT sr.tenantId FROM SharingRoleCapabilitySetEntity sr WHERE sr.roleId = ?1") | ||
Set<String> findTenantsByRoleId(UUID roleId); | ||
|
||
boolean existsByRoleId(UUID roleId); | ||
|
||
@Modifying | ||
@Query("DELETE FROM SharingRoleEntity sr WHERE sr.roleId = ?1") | ||
void deleteByRoleId(UUID roleId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.