Skip to content
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

Circ 1886 add dropdown for item service point #1335

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

rgupta-nla
Copy link
Contributor

Purpose

https://issues.folio.org/browse/CIRC-1886
To populate the drop down the (ServicePoint) code will need to be used, this allows the already existing service point code to be leveraged.

User must have the view request permission. Users: View requests, this should also limit them to their assigned service point/s. (This may need to be updated to suit general open source) This does match the generic permission in snapshot.

Approach

The request list is filtered in the backend based on the item selected in Primary Service Point name dropdown.

TODOS and Open Questions

  • Check logging

Learning

image

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.4% 90.4% Coverage
0.0% 0.0% Duplication

@@ -148,6 +148,9 @@ private static JsonObject locationSummary(Location location) {
write(locationSummary, "name", location.getName());
write(locationSummary, "libraryName", location.getLibraryName());
write(locationSummary, "code", location.getCode());
if(location.getPrimaryServicePoint() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(location.getPrimaryServicePoint() != null) {
if (location.getPrimaryServicePoint() != null) {

break;
}
}
if(!foundSP) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!foundSP) {
if (!foundSP) {

boolean foundSP = false;

for(ServicePoint servicePoint : spCollection) {
if(request.getItem() != null && request.getItem().getLocation() != null && request.getItem().getLocation().getPrimaryServicePointId() != null &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(request.getItem() != null && request.getItem().getLocation() != null && request.getItem().getLocation().getPrimaryServicePointId() != null &&
if (request.getItem() != null && request.getItem().getLocation() != null && request.getItem().getLocation().getPrimaryServicePointId() != null &&

List<Request> newRequestList = new ArrayList<>();
Collection<ServicePoint> spCollection = multipleServicePoints.getRecords();

for(Request request : requests) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(Request request : requests) {
for (Request request : requests) {

Request newRequest = null;
boolean foundSP = false;

for(ServicePoint servicePoint : spCollection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(ServicePoint servicePoint : spCollection) {
for (ServicePoint servicePoint : spCollection) {

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import org.apache.commons.lang.StringUtils;
import org.folio.circulation.domain.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't import all package

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as above

}

@Test
void parseQueryWithThreePSPIds() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to do the same as previous tests do? Maybe it makes sense to consider including inclusion within a single test?

Comment on lines +204 to +210
final List<String> servicePointsToFetch = requests.stream()
.filter(Objects::nonNull)
.map(r -> r.getItem() != null ? r.getItem().getLocation().getPrimaryServicePointId() : null)
.filter(Objects::nonNull)
.map(Object::toString)
.distinct()
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final List<String> servicePointsToFetch = requests.stream()
.filter(Objects::nonNull)
.map(r -> r.getItem() != null ? r.getItem().getLocation().getPrimaryServicePointId() : null)
.filter(Objects::nonNull)
.map(Object::toString)
.distinct()
.toList();
List<String> servicePointsToFetch = requests.stream()
.map(Request::getItem)
.filter(Objects::nonNull)
.map(Item::getLocation)
.map(Location::getPrimaryServicePointId)
.filter(Objects::nonNull)
.map(Object::toString)
.distinct()
.toList();

Comment on lines +219 to +221
multipleServicePoints -> {
List<Request> newRequestList = new ArrayList<>();
Collection<ServicePoint> spCollection = multipleServicePoints.getRecords();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving this lambda into separate method

Copy link
Contributor

@alexanderkurash alexanderkurash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes required

Copy link

sonarqubecloud bot commented Nov 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.4% 90.4% Coverage
0.0% 0.0% Duplication

Copy link

1 similar comment
Copy link

sonarqubecloud bot commented May 1, 2024

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants