-
Notifications
You must be signed in to change notification settings - Fork 11
feat: default access form selection implementation #1127
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
cc90a03
1076f82
d298190
0392c4a
377a5db
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 |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ public class ResourceServiceImpl implements ResourceService { | |
| private final OrganizationRepository organizationRepository; | ||
| private final NegotiationAccessManager negotiationAccessManager; | ||
|
|
||
| private static final long DEFAULT_ACCESS_FORM_ID = 1L; | ||
|
|
||
| public ResourceServiceImpl( | ||
| NetworkRepository networkRepository, | ||
| ResourceRepository repository, | ||
|
|
@@ -216,10 +218,22 @@ public List<ResourceResponseModel> addResources(List<ResourceCreateDTO> resource | |
| .findById(resDTO.getDiscoveryServiceId()) | ||
| .orElseThrow( | ||
| () -> new DiscoveryServiceNotFoundException(resDTO.getDiscoveryServiceId())); | ||
| AccessForm accessForm = | ||
| accessFormRepository | ||
| .findById(resDTO.getAccessFormId()) | ||
| .orElseThrow(() -> new AccessFormNotFoundException(resDTO.getAccessFormId())); | ||
| AccessForm accessForm; | ||
| if (resDTO.getAccessFormId() == null) { | ||
| accessForm = | ||
| accessFormRepository | ||
| .findFirstMostCommonAccessFormByOrganization(resDTO.getOrganizationId()) | ||
| .orElse( | ||
|
stetsche marked this conversation as resolved.
Outdated
|
||
| accessFormRepository | ||
| .findById(DEFAULT_ACCESS_FORM_ID) | ||
| .orElseThrow( | ||
| () -> new AccessFormNotFoundException(DEFAULT_ACCESS_FORM_ID))); | ||
| } else { | ||
| accessForm = | ||
|
Collaborator
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. If we could try to reduce the queries to the database that would be great as well. This logic could be in a loop of lots of resources with a relatively small amount of access forms and organizations, but they are queried all the time. I see that this behavior was preexisting and we could address it in a separate issue as well. |
||
| accessFormRepository | ||
| .findById(resDTO.getAccessFormId()) | ||
| .orElseThrow(() -> new AccessFormNotFoundException(resDTO.getAccessFormId())); | ||
| } | ||
| Organization organization = | ||
| organizationRepository | ||
| .findById(resDTO.getOrganizationId()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some unit tests for the repository to test more cases then covered in the integration test would be great, but not a blocker.