-
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.
Merge branch 'master' into tmp-release-1.4.2
- Loading branch information
Showing
25 changed files
with
1,279 additions
and
34 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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/folio/consortia/controller/SharingRoleController.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,39 @@ | ||
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.SharingRoleDeleteResponse; | ||
import org.folio.consortia.domain.dto.SharingRoleRequest; | ||
import org.folio.consortia.domain.dto.SharingRoleResponse; | ||
import org.folio.consortia.rest.resource.RolesApi; | ||
import org.folio.consortia.service.impl.SharingRoleService; | ||
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 SharingRoleController implements RolesApi { | ||
|
||
private final SharingRoleService sharingRoleService; | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleResponse> startSharingRole(UUID consortiumId, SharingRoleRequest sharingRoleRequest) { | ||
return ResponseEntity | ||
.status(CREATED) | ||
.body(sharingRoleService.start(consortiumId, sharingRoleRequest)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<SharingRoleDeleteResponse> deleteSharingRole(UUID consortiumId, UUID roleId, | ||
SharingRoleRequest sharingRoleRequest) { | ||
return ResponseEntity | ||
.status(OK) | ||
.body(sharingRoleService.delete(consortiumId, roleId, sharingRoleRequest)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/folio/consortia/domain/entity/SharingRoleEntity.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,41 @@ | ||
package org.folio.consortia.domain.entity; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import org.folio.consortia.domain.entity.base.AuditableEntity; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
@RequiredArgsConstructor | ||
@Entity | ||
@Table(name = "sharing_role") | ||
public class SharingRoleEntity extends AuditableEntity { | ||
@Id | ||
private UUID id; | ||
private UUID roleId; | ||
private String tenantId; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
SharingRoleEntity that = (SharingRoleEntity) o; | ||
return Objects.equals(id, that.id) | ||
&& Objects.equals(roleId, that.roleId) | ||
&& Objects.equals(tenantId, that.tenantId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, roleId, tenantId); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/folio/consortia/repository/SharingRoleRepository.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.SharingRoleEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface SharingRoleRepository extends JpaRepository<SharingRoleEntity, UUID> { | ||
|
||
@Query("SELECT sr.tenantId FROM SharingRoleEntity 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
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.