chore: Move to interface based projection as for columns with jsonb type record based projections does not work in PG (#32909)

## Description
- Move away from record based projections to interface classes as record
based projections does not work for jsonb column in PG branch.
- Remove ID generation within testclass and let DB handle the generation
to fix failing tests on the PG branch.

## Automation

/ok-to-test tags="@tag.Sanity, @tag.GenerateCRUD, "@tag.Fork""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8919248892>
> Commit: f43425a9c1e29a35dcaba3abf47f8e63cf607def
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8919248892&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->






## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Updated the method for generating workspace names to enhance
uniqueness and reliability.
- **Bug Fixes**
- Improved the `updateCurrentUser` method to update the current user
based on their ID for accuracy.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Abhijeet 2024-05-03 16:56:02 +05:30 committed by GitHub
parent 894be58813
commit bea3cc1598
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 17 deletions

View File

@ -595,8 +595,8 @@ public class ApplicationForkingServiceCEImpl implements ApplicationForkingServic
.findIdsAndPoliciesByApplicationIdIn(List.of(application.getId()))
.map(idPoliciesOnly -> {
NewPage newPage = new NewPage();
newPage.setId(idPoliciesOnly.id());
newPage.setPolicies(idPoliciesOnly.policies());
newPage.setId(idPoliciesOnly.getId());
newPage.setPolicies(idPoliciesOnly.getPolicies());
return newPage;
})
.flatMap(newPageRepository::setUserPermissionsInObject));
@ -605,8 +605,8 @@ public class ApplicationForkingServiceCEImpl implements ApplicationForkingServic
.findIdsAndPoliciesByApplicationIdIn(List.of(application.getId()))
.map(idPoliciesOnly -> {
NewAction newAction = new NewAction();
newAction.setId(idPoliciesOnly.id());
newAction.setPolicies(idPoliciesOnly.policies());
newAction.setId(idPoliciesOnly.getId());
newAction.setPolicies(idPoliciesOnly.getPolicies());
return newAction;
})
.flatMap(newActionRepository::setUserPermissionsInObject));

View File

@ -1,8 +1,11 @@
package com.appsmith.server.projections;
import com.appsmith.external.models.Policy;
import lombok.NonNull;
import java.util.Set;
public record IdPoliciesOnly(@NonNull String id, Set<Policy> policies) {}
public interface IdPoliciesOnly {
String getId();
Set<Policy> getPolicies();
}

View File

@ -1470,8 +1470,8 @@ public class ApplicationPageServiceCEImpl implements ApplicationPageServiceCE {
.findIdsAndPoliciesByApplicationIdIn(List.of(application.getId()))
.map(idPoliciesOnly -> {
NewPage newPage = new NewPage();
newPage.setId(idPoliciesOnly.id());
newPage.setPolicies(idPoliciesOnly.policies());
newPage.setId(idPoliciesOnly.getId());
newPage.setPolicies(idPoliciesOnly.getPolicies());
return newPage;
})
.flatMap(newPageRepository::setUserPermissionsInObject));
@ -1479,8 +1479,8 @@ public class ApplicationPageServiceCEImpl implements ApplicationPageServiceCE {
.findIdsAndPoliciesByApplicationIdIn(List.of(application.getId()))
.map(idPoliciesOnly -> {
NewAction newAction = new NewAction();
newAction.setId(idPoliciesOnly.id());
newAction.setPolicies(idPoliciesOnly.policies());
newAction.setId(idPoliciesOnly.getId());
newAction.setPolicies(idPoliciesOnly.getPolicies());
return newAction;
})
.flatMap(newActionRepository::setUserPermissionsInObject));
@ -1488,8 +1488,8 @@ public class ApplicationPageServiceCEImpl implements ApplicationPageServiceCE {
.findIdsAndPoliciesByApplicationIdIn(List.of(application.getId()))
.map(idPoliciesOnly -> {
ActionCollection actionCollection = new ActionCollection();
actionCollection.setId(idPoliciesOnly.id());
actionCollection.setPolicies(idPoliciesOnly.policies());
actionCollection.setId(idPoliciesOnly.getId());
actionCollection.setPolicies(idPoliciesOnly.getPolicies());
return actionCollection;
})
.flatMap(actionCollectionRepository::setUserPermissionsInObject));
@ -1538,8 +1538,8 @@ public class ApplicationPageServiceCEImpl implements ApplicationPageServiceCE {
.findIdsAndPoliciesByIdIn(datasourceIds)
.flatMap(idPolicy -> {
Datasource datasource = new Datasource();
datasource.setId(idPolicy.id());
datasource.setPolicies(idPolicy.policies());
datasource.setId(idPolicy.getId());
datasource.setPolicies(idPolicy.getPolicies());
return datasourceRepository.setUserPermissionsInObject(datasource);
}));

View File

@ -608,7 +608,7 @@ public class UserServiceCEImpl extends BaseService<UserRepository, User, String>
updates.setName(inputName);
updatedUserMono = sessionUserService
.getCurrentUser()
.flatMap(user -> update(user.getEmail(), updates, User.Fields.email)
.flatMap(user -> update(user.getId(), updates, User.Fields.id)
.then(
exchange == null
? repository.findByEmail(user.getEmail())

View File

@ -103,8 +103,7 @@ public class UserWorkspaceServiceUnitTest {
List<Workspace> workspaceList = new ArrayList<>(4);
for (int i = 1; i <= 4; i++) {
Workspace workspace = new Workspace();
workspace.setId("org-" + i);
workspace.setName(workspace.getId());
workspace.setName(UUID.randomUUID().toString());
workspaceList.add(workspace);
}
return Flux.fromIterable(workspaceList)