diff --git a/docker-compose.yml b/docker-compose.yml index 0f763b7d..960059c8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: libraries: image: nginx:latest diff --git a/src/main/java/com/ditrit/letomodelizerapi/controller/RoleController.java b/src/main/java/com/ditrit/letomodelizerapi/controller/RoleController.java index e075bfb2..48f099b1 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/controller/RoleController.java +++ b/src/main/java/com/ditrit/letomodelizerapi/controller/RoleController.java @@ -432,8 +432,8 @@ public Response getGroupsOfRole(final @Context HttpServletRequest request, userPermissionService.checkIsAdmin(user, null); Map filters = new HashMap<>(this.getFilters(uriInfo)); - filters.put("parentAccessControlId", id.toString()); - filters.put("parentAccessControlType", AccessControlType.ROLE.name()); + filters.put("parentId", id.toString()); + filters.put("parentType", AccessControlType.ROLE.name()); log.info( "[{}] Received GET request to get groups of role {} with the following filters: {}", @@ -658,8 +658,8 @@ public Response getScopesOfRole(final @Context HttpServletRequest request, userPermissionService.checkIsAdmin(user, null); Map filters = new HashMap<>(this.getFilters(uriInfo)); - filters.put("parentAccessControlId", id.toString()); - filters.put("parentAccessControlType", AccessControlType.ROLE.name()); + filters.put("parentId", id.toString()); + filters.put("parentType", AccessControlType.ROLE.name()); log.info( "[{}] Received GET request to get scopes of role {} with the following filters: {}", diff --git a/src/main/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunction.java b/src/main/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunction.java index 7d7c13cb..f79f06b9 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunction.java +++ b/src/main/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunction.java @@ -35,11 +35,11 @@ public AccessControlDirectDTO apply(final AccessControlTreeView accessControlTre AccessControlDirectDTO dto = new AccessControlDirectDTO(); if (this.fromParent) { - dto.setId(accessControlTreeView.getParentAccessControlId()); - dto.setName(accessControlTreeView.getParentAccessControlName()); + dto.setId(accessControlTreeView.getParentId()); + dto.setName(accessControlTreeView.getParentName()); } else { - dto.setId(accessControlTreeView.getAccessControlId()); - dto.setName(accessControlTreeView.getAccessControlName()); + dto.setId(accessControlTreeView.getId()); + dto.setName(accessControlTreeView.getName()); } dto.setIsDirect(accessControlTreeView.getIsDirect()); diff --git a/src/main/java/com/ditrit/letomodelizerapi/persistence/model/AccessControlTreeView.java b/src/main/java/com/ditrit/letomodelizerapi/persistence/model/AccessControlTreeView.java index fd7ef2e3..f785657e 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/persistence/model/AccessControlTreeView.java +++ b/src/main/java/com/ditrit/letomodelizerapi/persistence/model/AccessControlTreeView.java @@ -29,7 +29,7 @@ public class AccessControlTreeView { @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "aca_id") @FilterType(type = FilterType.Type.TEXT) - private String id; + private String internalId; /** * Identifier of the current access control. @@ -37,42 +37,42 @@ public class AccessControlTreeView { */ @Column(name = "aco_id") @FilterType(type = FilterType.Type.UUID) - private UUID accessControlId; + private UUID id; /** * Type of the current access control. */ @Column(name = "type") @FilterType(type = FilterType.Type.TEXT) - private String accessControlType; + private String type; /** * Name of the current access control. */ @Column(name = "name") @FilterType(type = FilterType.Type.TEXT) - private String accessControlName; + private String name; /** * Identifier of the parent access control in the tree structure. */ @Column(name = "parent") @FilterType(type = FilterType.Type.UUID) - private UUID parentAccessControlId; + private UUID parentId; /** * Name of the parent access control. */ @Column(name = "parent_name") @FilterType(type = FilterType.Type.TEXT) - private String parentAccessControlName; + private String parentName; /** * Type of the parent access control. */ @Column(name = "parent_type") @FilterType(type = FilterType.Type.TEXT) - private String parentAccessControlType; + private String parentType; /** * Indicates whether the access control relationship is direct. diff --git a/src/main/java/com/ditrit/letomodelizerapi/persistence/model/UserAccessControlView.java b/src/main/java/com/ditrit/letomodelizerapi/persistence/model/UserAccessControlView.java index d0156aed..c4481904 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/persistence/model/UserAccessControlView.java +++ b/src/main/java/com/ditrit/letomodelizerapi/persistence/model/UserAccessControlView.java @@ -67,7 +67,7 @@ public class UserAccessControlView { /** * The name of the access control. */ - @Column(name = "access_control_name") + @Column(name = "name") @FilterType(type = FilterType.Type.TEXT) private String name; diff --git a/src/main/java/com/ditrit/letomodelizerapi/persistence/repository/AccessControlTreeViewRepository.java b/src/main/java/com/ditrit/letomodelizerapi/persistence/repository/AccessControlTreeViewRepository.java index adbcc9aa..742aaae3 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/persistence/repository/AccessControlTreeViewRepository.java +++ b/src/main/java/com/ditrit/letomodelizerapi/persistence/repository/AccessControlTreeViewRepository.java @@ -40,5 +40,5 @@ public interface AccessControlTreeViewRepository extends JpaRepository findByAccessControlIdAndParentAccessControlId(UUID id, UUID parent); + Optional findByIdAndParentId(UUID id, UUID parent); } diff --git a/src/main/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImpl.java b/src/main/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImpl.java index eed7d300..195afc10 100644 --- a/src/main/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImpl.java +++ b/src/main/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImpl.java @@ -143,14 +143,14 @@ public Page findAllChildren(final AccessControlType type AccessControl accessControl = findById(type, id); Map filters = new HashMap<>(immutableFilters); filters.put("type", childrenType.name()); - filters.put("parentAccessControlId", accessControl.getId().toString()); + filters.put("parentId", accessControl.getId().toString()); return accessControlTreeViewRepository.findAll( new SpecificationHelper<>(AccessControlTreeView.class, filters), PageRequest.of( pageable.getPageNumber(), pageable.getPageSize(), - pageable.getSortOr(Sort.by(Sort.Direction.ASC, "parentAccessControlName")) + pageable.getSortOr(Sort.by(Sort.Direction.ASC, "parentName")) ) ).map(new AccessControlTreeViewToAccessControlDirectDTOFunction(false)); } @@ -180,14 +180,14 @@ public Page findAllAccessControls(final AccessControlTyp final Pageable pageable) { AccessControl accessControl = this.findById(type, id); Map filters = new HashMap<>(immutableFilters); - filters.put("accessControlId", accessControl.getId().toString()); - filters.put("parentAccessControlType", subType.name()); + filters.put("id", accessControl.getId().toString()); + filters.put("parentType", subType.name()); return accessControlTreeViewRepository.findAll(new SpecificationHelper<>(AccessControlTreeView.class, filters), PageRequest.of( pageable.getPageNumber(), pageable.getPageSize(), - pageable.getSortOr(Sort.by(Sort.Direction.ASC, "parentAccessControlName"))) + pageable.getSortOr(Sort.by(Sort.Direction.ASC, "parentName"))) ).map(new AccessControlTreeViewToAccessControlDirectDTOFunction()); } @@ -230,7 +230,7 @@ public void associate(final AccessControlType parentType, AccessControl parentAccessControl = findById(parentType, id); AccessControl accessControl = findById(type, roleId); Optional userAccessControlOptional = accessControlTreeViewRepository - .findByAccessControlIdAndParentAccessControlId(parentAccessControl.getId(), accessControl.getId()); + .findByIdAndParentId(parentAccessControl.getId(), accessControl.getId()); if (userAccessControlOptional.isPresent()) { return; diff --git a/src/main/resources/db/migration/R__users_access_controls_view.sql b/src/main/resources/db/migration/R__users_access_controls_view.sql index d2328ded..a6339d02 100644 --- a/src/main/resources/db/migration/R__users_access_controls_view.sql +++ b/src/main/resources/db/migration/R__users_access_controls_view.sql @@ -30,7 +30,7 @@ SELECT DISTINCT users.email, users.name as "user_name", access_controls.aco_id, - access_controls.name as "access_control_name", + access_controls.name as "name", access_controls.type::text, not all_access_controls.direct as "direct" FROM diff --git a/src/test/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunctionTest.java b/src/test/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunctionTest.java index c3abcbed..5df6084f 100644 --- a/src/test/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunctionTest.java +++ b/src/test/java/com/ditrit/letomodelizerapi/persistence/function/AccessControlTreeViewToAccessControlDirectDTOFunctionTest.java @@ -19,18 +19,18 @@ class AccessControlTreeViewToAccessControlDirectDTOFunctionTest { @DisplayName("Test apply: should transform AccessControlTreeView to AccessControlDirectDTO with parent") void testApply() { AccessControlTreeView accessControlTreeView = new AccessControlTreeView(); - accessControlTreeView.setAccessControlId(UUID.randomUUID()); - accessControlTreeView.setAccessControlName("current"); - accessControlTreeView.setAccessControlType("current_Type"); - accessControlTreeView.setParentAccessControlId(UUID.randomUUID()); - accessControlTreeView.setParentAccessControlName("parent"); - accessControlTreeView.setParentAccessControlType("parent_type"); + accessControlTreeView.setId(UUID.randomUUID()); + accessControlTreeView.setName("current"); + accessControlTreeView.setType("current_Type"); + accessControlTreeView.setParentId(UUID.randomUUID()); + accessControlTreeView.setParentName("parent"); + accessControlTreeView.setParentType("parent_type"); accessControlTreeView.setIsDirect(true); AccessControlDirectDTO accessControl = new AccessControlTreeViewToAccessControlDirectDTOFunction() .apply(accessControlTreeView); - assertEquals(accessControlTreeView.getParentAccessControlId(), accessControl.getId()); + assertEquals(accessControlTreeView.getParentId(), accessControl.getId()); assertEquals("parent", accessControl.getName()); assertTrue(accessControl.getIsDirect()); } @@ -39,18 +39,18 @@ void testApply() { @DisplayName("Test apply: should transform AccessControlTreeView to AccessControlDirectDTO with current") void testApplyNotFromParent() { AccessControlTreeView accessControlTreeView = new AccessControlTreeView(); - accessControlTreeView.setAccessControlId(UUID.randomUUID()); - accessControlTreeView.setAccessControlName("current"); - accessControlTreeView.setAccessControlType("current_Type"); - accessControlTreeView.setParentAccessControlId(UUID.randomUUID()); - accessControlTreeView.setParentAccessControlName("parent"); - accessControlTreeView.setParentAccessControlType("parent_type"); + accessControlTreeView.setId(UUID.randomUUID()); + accessControlTreeView.setName("current"); + accessControlTreeView.setType("current_Type"); + accessControlTreeView.setParentId(UUID.randomUUID()); + accessControlTreeView.setParentName("parent"); + accessControlTreeView.setParentType("parent_type"); accessControlTreeView.setIsDirect(true); AccessControlDirectDTO accessControl = new AccessControlTreeViewToAccessControlDirectDTOFunction(false) .apply(accessControlTreeView); - assertEquals(accessControlTreeView.getAccessControlId(), accessControl.getId()); + assertEquals(accessControlTreeView.getId(), accessControl.getId()); assertEquals("current", accessControl.getName()); assertTrue(accessControl.getIsDirect()); } diff --git a/src/test/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImplTest.java b/src/test/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImplTest.java index 726d7d3e..8ebb4282 100644 --- a/src/test/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImplTest.java +++ b/src/test/java/com/ditrit/letomodelizerapi/service/AccessControlServiceImplTest.java @@ -359,7 +359,7 @@ void testAssociate() { .when(accessControlRepository.findOne(Mockito.any(Specification.class))) .thenReturn(Optional.of(accessControl)); Mockito - .when(accessControlTreeViewRepository.findByAccessControlIdAndParentAccessControlId(Mockito.any(), Mockito.any())) + .when(accessControlTreeViewRepository.findByIdAndParentId(Mockito.any(), Mockito.any())) .thenReturn(Optional.empty()); service.associate(AccessControlType.ROLE, UUID.randomUUID(), AccessControlType.ROLE, UUID.randomUUID()); @@ -379,7 +379,7 @@ void testAssociateDoNothing() { .when(accessControlRepository.findOne(Mockito.any(Specification.class))) .thenReturn(Optional.of(accessControl)); Mockito - .when(accessControlTreeViewRepository.findByAccessControlIdAndParentAccessControlId(Mockito.any(), Mockito.any())) + .when(accessControlTreeViewRepository.findByIdAndParentId(Mockito.any(), Mockito.any())) .thenReturn(Optional.of(new AccessControlTreeView())); ApiException exception = null;