-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: refactor the crud method to custom repo class #38138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,19 @@ | |
| import reactor.core.publisher.Flux; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface CustomDatasourceRepositoryCE extends AppsmithRepository<Datasource> { | ||
|
|
||
| Flux<Datasource> findAllByWorkspaceId(String workspaceId, AclPermission permission); | ||
|
|
||
| Mono<Datasource> findByNameAndWorkspaceId(String name, String workspaceId, AclPermission aclPermission); | ||
|
|
||
| Flux<Datasource> findByWorkspaceId(String workspaceId, AclPermission aclPermission); | ||
|
|
||
| Flux<Datasource> findAllByWorkspaceIdWithoutPermissions(String workspaceId); | ||
|
|
||
| Flux<Datasource> findByIdIn(List<String> ids); | ||
|
|
||
| Mono<Long> countByDeletedAtNull(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we not adding
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not used anywhere in the code base. Hence removing this. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,14 @@ | |
| import com.appsmith.external.models.Datasource; | ||
| import com.appsmith.server.acl.AclPermission; | ||
| import com.appsmith.server.helpers.ce.bridge.Bridge; | ||
| import com.appsmith.server.helpers.ce.bridge.BridgeQuery; | ||
| import com.appsmith.server.repositories.BaseAppsmithRepositoryImpl; | ||
| import org.springframework.data.domain.Sort; | ||
| import reactor.core.publisher.Flux; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class CustomDatasourceRepositoryCEImpl extends BaseAppsmithRepositoryImpl<Datasource> | ||
| implements CustomDatasourceRepositoryCE { | ||
|
|
||
|
|
@@ -28,4 +31,28 @@ public Mono<Datasource> findByNameAndWorkspaceId(String name, String workspaceId | |
| .permission(aclPermission) | ||
| .one(); | ||
| } | ||
|
|
||
| @Override | ||
| public Flux<Datasource> findByWorkspaceId(String workspaceId, AclPermission aclPermission) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not present in DatasourceRepoisitoryCE, are we adding this as a new methods?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a duplicate since the method already exists in custom implementation. |
||
| final BridgeQuery<Datasource> q = Bridge.equal(Datasource.Fields.workspaceId, workspaceId); | ||
| return queryBuilder().criteria(q).permission(aclPermission).all(); | ||
| } | ||
|
|
||
| @Override | ||
| public Flux<Datasource> findAllByWorkspaceIdWithoutPermissions(String workspaceId) { | ||
|
AnaghHegde marked this conversation as resolved.
Outdated
|
||
| final BridgeQuery<Datasource> q = Bridge.equal(Datasource.Fields.workspaceId, workspaceId); | ||
| return queryBuilder().criteria(q).all(); | ||
| } | ||
|
|
||
| @Override | ||
| public Flux<Datasource> findByIdIn(List<String> ids) { | ||
| final BridgeQuery<Datasource> q = Bridge.in(Datasource.Fields.id, ids); | ||
| return queryBuilder().criteria(q).all(); | ||
| } | ||
|
|
||
| @Override | ||
| public Mono<Long> countByDeletedAtNull() { | ||
| final BridgeQuery<Datasource> q = Bridge.isNull(Datasource.Fields.deletedAt); | ||
| return queryBuilder().criteria(q).count(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.