Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/main/java/org/folio/circulation/domain/Loan.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
@ToString(onlyExplicitlyIncluded = true)
public class Loan implements ItemRelatedRecord, UserRelatedRecord {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());
@ToString.Include
private final JsonObject representation;
@Getter
private final Item item;
Expand Down Expand Up @@ -256,7 +255,6 @@ public Loan changeItemEffectiveLocationIdAtCheckOut(String locationId) {
}

public void changeActionComment(String comment) {
log.debug("changeActionComment:: parameters comment: {}", comment);
representation.put(ACTION_COMMENT, comment);
}

Expand Down Expand Up @@ -330,6 +328,7 @@ private String getStatusName() {
return getNestedStringProperty(representation, STATUS, "name");
}

@ToString.Include(name = "id")
public String getId() {
return getProperty(representation, "id");
}
Expand Down Expand Up @@ -585,7 +584,7 @@ Loan resolveClaimedReturned(LoanAction resolveAction,


public Loan declareItemLost(String comment, ZonedDateTime dateTime) {
log.debug("declareItemLost:: parameters comment: {}, dateTime: {}", () -> comment, () -> dateTime);
log.debug("declareItemLost:: parameters dateTime: {}", dateTime);
changeAction(DECLARED_LOST);
changeActionComment(comment);
changeItemStatusForItemAndLoan(ItemStatus.DECLARED_LOST);
Expand Down Expand Up @@ -737,8 +736,7 @@ public RemindersPolicy.ReminderConfig getNextReminder() {
}

public Loan claimItemReturned(String comment, ZonedDateTime claimedReturnedDate) {
log.debug("claimItemReturned:: parameters comment: {}, claimedReturnedDate: {}",
() -> comment, () -> claimedReturnedDate);
log.debug("claimItemReturned:: parameters claimedReturnedDate: {}", claimedReturnedDate);
changeAction(CLAIMED_RETURNED);
if (StringUtils.isNotBlank(comment)) {
changeActionComment(comment);
Expand All @@ -764,7 +762,7 @@ public Loan closeLoan(LoanAction action) {
}

public Loan closeLoan(LoanAction action, String comment) {
log.debug("closeLoan:: parameters action: {}, comment: {}", action, comment);
log.debug("closeLoan:: parameters action: {}", action);
changeStatus(LoanStatus.CLOSED);

changeAction(action);
Expand All @@ -774,7 +772,6 @@ public Loan closeLoan(LoanAction action, String comment) {
}

public Loan markItemMissing(String comment) {
log.debug("markItemMissing:: parameters comment: {}", comment);
changeItemStatusForItemAndLoan(ItemStatus.MISSING);

return closeLoan(MISSING, comment);
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/org/folio/circulation/domain/PrintEventRequest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.folio.circulation.domain;

import io.vertx.core.json.JsonObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import static lombok.AccessLevel.PRIVATE;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getArrayProperty;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty;

import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.Set;

import static lombok.AccessLevel.PRIVATE;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getArrayProperty;
import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import io.vertx.core.json.JsonObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

@AllArgsConstructor(access = PRIVATE)
@ToString(onlyExplicitlyIncluded = true)
Expand All @@ -24,16 +25,17 @@ public class PrintEventRequest {
public static final String REQUESTER_NAME_FIELD = "requesterName";
public static final String PRINT_DATE_FIELD = "printEventDate";

@ToString.Include
@Getter
private final JsonObject representation;

@ToString.Include
@Getter
private final List<String> requestIds;
@Getter
private final String requesterId;
@Getter
private final String requesterName;
@ToString.Include
@Getter
private final String printEventDate;

Expand All @@ -46,7 +48,7 @@ public static PrintEventRequest from(JsonObject representation) {
final var printEventDate = getProperty(representation, PRINT_DATE_FIELD);

if (requestIds.isEmpty() || null == requesterId || null == requesterName || null == printEventDate || !containsOnlyKnownFields(representation)) {
log.info("from:: Print Event Request JSON is invalid: {},{},{},{},{}", representation, requestIds, requesterName, requesterId, printEventDate);
log.info("from:: Print Event Request JSON is invalid: requestIds={}, requesterId={}, printEventDate={}", requestIds, requesterId, printEventDate);
return null;
}
return new PrintEventRequest(representation, requestIds, requesterId, requesterName, printEventDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.vertx.core.json.JsonObject;

public class ProxyRelationship {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());

Check warning on line 19 in src/main/java/org/folio/circulation/domain/ProxyRelationship.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "log" private field.

See more on https://sonarcloud.io/project/issues?id=org.folio%3Amod-circulation&issues=AZ2_QIhfPYrtt2fos2kb&open=AZ2_QIhfPYrtt2fos2kb&pullRequest=1674

private static final String NOTIFICATIONS_SENT_TO_PROPERTY_NAME = "notificationsTo";
private static final String EXPIRATION_DATE_PROPERTY_NAME = "expirationDate";
Expand Down Expand Up @@ -48,8 +48,6 @@
}

private boolean getActive(JsonObject representation) {
log.debug("getActive:: parameters representation: {}", () -> representation);

if(representation.containsKey(STATUS_PROPERTY_NAME)) {
return convertStatusToActive(
representation.getString(STATUS_PROPERTY_NAME));
Expand All @@ -61,8 +59,6 @@
}

private ZonedDateTime getExpirationDate(JsonObject representation) {
log.debug("getExpirationDate:: parameters representation: {}", () -> representation);

if(representation.containsKey(EXPIRATION_DATE_PROPERTY_NAME) ) {
return getDateTimeProperty(representation,
EXPIRATION_DATE_PROPERTY_NAME);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/circulation/domain/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import static org.folio.circulation.domain.representations.RequestProperties.CANCELLATION_REASON_ID;
import static org.folio.circulation.domain.representations.RequestProperties.CANCELLATION_REASON_NAME;
import static org.folio.circulation.domain.representations.RequestProperties.CANCELLATION_REASON_PUBLIC_DESCRIPTION;
import static org.folio.circulation.domain.representations.RequestProperties.ITEM_LOCATION_CODE;
import static org.folio.circulation.domain.representations.RequestProperties.ECS_REQUEST_PHASE;
import static org.folio.circulation.domain.representations.RequestProperties.HOLDINGS_RECORD_ID;
import static org.folio.circulation.domain.representations.RequestProperties.HOLD_SHELF_EXPIRATION_DATE;
import static org.folio.circulation.domain.representations.RequestProperties.INSTANCE_ID;
import static org.folio.circulation.domain.representations.RequestProperties.ITEM_ID;
import static org.folio.circulation.domain.representations.RequestProperties.ITEM_LOCATION_CODE;
import static org.folio.circulation.domain.representations.RequestProperties.POSITION;
import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_DATE;
import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_EXPIRATION_DATE;
Expand Down Expand Up @@ -65,7 +65,6 @@ public class Request implements ItemRelatedRecord, UserRelatedRecord {
@With
private final Operation operation;

@ToString.Include
@With
private final JsonObject requestRepresentation;

Expand Down Expand Up @@ -259,6 +258,7 @@ public RequestFulfillmentPreference getfulfillmentPreference() {
return RequestFulfillmentPreference.from(getfulfillmentPreferenceName());
}

@ToString.Include(name = "id")
public String getId() {
return requestRepresentation.getString("id");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/circulation/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.util.Objects;
import java.util.stream.Collectors;

import io.vertx.core.json.JsonArray;
import org.folio.circulation.support.utils.ClockUtil;

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import lombok.ToString;
import lombok.val;
Expand All @@ -33,7 +33,6 @@ public class User {
private final PatronGroup patronGroup;
private final Collection<Department> departments;

@ToString.Include
private final JsonObject representation;

public User(JsonObject representation) {
Expand Down Expand Up @@ -87,6 +86,7 @@ public String getBarcode() {
return getProperty(representation, "barcode");
}

@ToString.Include(name = "id")
public String getId() {
return getProperty(representation, "id");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@

write(logEventPayload, REQUESTS.value(), getUpdatedRequests(checkInContext));

String result = logEventPayload.encode();

Check warning on line 61 in src/main/java/org/folio/circulation/domain/representations/logs/CirculationCheckInCheckOutLogEventMapper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Immediately return this expression instead of assigning it to the temporary variable "result".

See more on https://sonarcloud.io/project/issues?id=org.folio%3Amod-circulation&issues=AZ2_QIdVPYrtt2fos2kZ&open=AZ2_QIdVPYrtt2fos2kZ&pullRequest=1674
log.info("mapToCheckInLogEventContent:: result {}", result);
return result;
}

Expand Down Expand Up @@ -90,8 +89,7 @@
write(logEventPayload, REQUESTS.value(), getUpdatedRequests(loanAndRelatedRecords));
logEventPayload.put(PAYLOAD,payload);

String result = logEventPayload.encode();

Check warning on line 92 in src/main/java/org/folio/circulation/domain/representations/logs/CirculationCheckInCheckOutLogEventMapper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Immediately return this expression instead of assigning it to the temporary variable "result".

See more on https://sonarcloud.io/project/issues?id=org.folio%3Amod-circulation&issues=AZ2_QIdVPYrtt2fos2ka&open=AZ2_QIdVPYrtt2fos2ka&pullRequest=1674
log.info("mapToCheckOutLogEventContent:: result {}", result);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static JsonObject mapToRequestLogEventJson(Request request) {
populateItemData(request, logEventPayload);
write(logEventPayload, REQUESTS.value(), mapCreatedRequestToJson(request));

log.info("mapToRequestLogEventJson:: result {}", logEventPayload::encode);
return logEventPayload;
}

Expand All @@ -51,7 +50,6 @@ public static JsonObject mapToRequestLogEventJson(Request original, Request upda
write(logEventPayload, REQUESTS.value(), mapUpdatedRequestPairToJson(
new UpdatedRequestPair(original, updated)));

log.info("mapToRequestLogEventJson:: result {}", logEventPayload::encode);
return logEventPayload;
}

Expand All @@ -65,7 +63,6 @@ public static JsonObject mapToRequestLogEventJson(List<Request> requests) {
populateItemData(requests.get(0), logEventPayload);
write(logEventPayload, REQUESTS.value(), mapReorderedRequestsToJsonArray(requests));

log.info("mapToRequestLogEventJson:: result {}", logEventPayload::encode);
return logEventPayload;
}

Expand All @@ -90,7 +87,6 @@ private static JsonObject mapUpdatedRequestPairToJson(UpdatedRequestPair updated
ofNullable(updatedRequestPair.getOriginal()).ifPresent(original -> requestPayload.put("original", original.asJson()));
ofNullable(updatedRequestPair.getUpdated()).ifPresent(updated -> requestPayload.put("updated", updated.asJson()));

log.info("mapUpdatedRequestPairToJson:: result {}", requestPayload::encode);
return requestPayload;
}

Expand All @@ -100,7 +96,6 @@ private static JsonObject mapCreatedRequestToJson(Request request) {
JsonObject requestPayload = new JsonObject();
requestPayload.put("created", request.asJson());

log.info("mapCreatedRequestToJson:: result {}", requestPayload::encode);
return requestPayload;
}

Expand All @@ -113,7 +108,6 @@ private static JsonObject mapReorderedRequestsToJsonArray(List<Request> requests
.map(r -> r.asJson().put("previousPosition", r.getPreviousPosition()))
.collect(Collectors.toList())));

log.info("mapReorderedRequestsToJsonArray:: result {}", requestPayload::encode);
return requestPayload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public class InactiveUserValidator {
}

public static InactiveUserValidator forProxy(String proxyUserBarcode) {
log.debug("forProxy:: parameters proxyUserBarcode: {}", proxyUserBarcode);

return new InactiveUserValidator(LoanAndRelatedRecords::getProxy,
"Cannot check out via inactive proxying user",
"Cannot determine if proxying user is active or not",
Expand All @@ -46,8 +44,6 @@ public static InactiveUserValidator forProxy(String proxyUserBarcode) {
}

public static InactiveUserValidator forUser(String userBarcode) {
log.debug("forUser:: parameters userBarcode: {}", userBarcode);

return new InactiveUserValidator(records -> records.getLoan().getUser(),
"Cannot check out to inactive user",
"Cannot determine if user is active or not",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ public CompletableFuture<Result<LoanAndRelatedRecords>> createLoan(
public CompletableFuture<Result<LoanAndRelatedRecords>> updateLoan(
LoanAndRelatedRecords loanAndRelatedRecords) {

log.debug("updateLoan:: parameters loanAndRelatedRecords: {}", loanAndRelatedRecords);
Loan loan = loanAndRelatedRecords.getLoan();
log.info("Loan " + loan.getId() + " prior to update: " + loan.asJson().toString());
log.debug("updateLoan:: loan id: {}", loan.getId());
return updateLoan(loanAndRelatedRecords.getLoan())
.thenApply(mapResult(loanAndRelatedRecords::withLoan));
}
Expand Down Expand Up @@ -229,7 +228,6 @@ private String mapToLatestPatronInfoAddedComment(MultipleRecords<LoanHistory> lo
String latestPatronInfoAddedComment = null;
if (loanHistory != null) {
latestPatronInfoAddedComment = loanHistory.getLoan().getActionComment();
log.debug("mapToLatestPatronInfoAddedComment:: loan history contains patron info: {}", latestPatronInfoAddedComment);
}
return latestPatronInfoAddedComment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ private Result<LoanAndRelatedRecords> addPatronOrStaffInfo(
private LoanAndRelatedRecords addPatronOrStaffInfo(LoanAndRelatedRecords loanAndRelatedRecords,
String action, String actionComment) {

log.debug("addPatronOrStaffInfo:: parameters loanAndRelatedRecords: {}, action: {}, " +
"actionComment: {}", () -> loanAndRelatedRecords, () -> action, () -> actionComment);
log.debug("addPatronOrStaffInfo:: parameters action: {}", action);
loanAndRelatedRecords.getLoan().changeAction(action);
loanAndRelatedRecords.getLoan().changeActionComment(actionComment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private LoanAndRelatedRecords unsetDueDateChangedByRecallIfNoOpenRecallsInQueue(
() -> loanAndRelatedRecords);
RequestQueue queue = loanAndRelatedRecords.getRequestQueue();
Loan loan = loanAndRelatedRecords.getLoan();
log.info("Loan {} prior to flag check: {}", loan.getId(), loan.asJson().toString());
log.debug("unsetDueDateChangedByRecallIfNoOpenRecallsInQueue:: checking loan: {}", loan.getId());
if (loan.wasDueDateChangedByRecall() && !queue.hasOpenRecalls()) {
log.info("Loan {} registers as having due date change flag set to true and no open recalls in queue.", loan.getId());
return loanAndRelatedRecords.withLoan(loan.unsetDueDateChangedByRecall());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ private CompletableFuture<Result<LoanAndRelatedRecords>> lookupUser(String barco
UserRepository userRepository, Result<LoanAndRelatedRecords> loanResult,
CirculationErrorHandler errorHandler) {

log.debug("lookupUser:: parameters barcode: {}", barcode);

return userRepository.getUserByBarcode(barcode)
.thenApply(userResult -> loanResult.combine(userResult, LoanAndRelatedRecords::withRequestingUser))
.thenApply(r -> errorHandler.handleValidationResult(r, FAILED_TO_FETCH_USER, loanResult));
Expand All @@ -356,8 +354,6 @@ private CompletableFuture<Result<LoanAndRelatedRecords>> lookupProxyUser(String
UserRepository userRepository, Result<LoanAndRelatedRecords> loanResult,
CirculationErrorHandler errorHandler) {

log.debug("lookupProxyUser:: parameters barcode: {}", barcode);

return userRepository.getProxyUserByBarcode(barcode)
.thenApply(userResult -> loanResult.combine(userResult, LoanAndRelatedRecords::withProxyingUser))
.thenApply(r -> errorHandler.handleValidationResult(r, FAILED_TO_FETCH_PROXY_USER, loanResult));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private LoanAndRelatedRecords unsetDueDateChangedByRecallIfNoOpenRecallsInQueue(

RequestQueue queue = loanAndRelatedRecords.getRequestQueue();
Loan loan = loanAndRelatedRecords.getLoan();
log.info("Loan {} prior to flag check: {}", loan.getId(), loan.asJson());
log.debug("unsetDueDateChangedByRecallIfNoOpenRecallsInQueue:: checking loan: {}", loan.getId());
if (loan.wasDueDateChangedByRecall() && !queue.hasOpenRecalls()) {
log.info("Loan {} registers as having due date change flag set to true and no open recalls in queue.", loan.getId());
return loanAndRelatedRecords.withLoan(loan.unsetDueDateChangedByRecall());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import io.vertx.ext.web.RoutingContext;

public class RequestCollectionResource extends CollectionResource {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());

Check warning on line 64 in src/main/java/org/folio/circulation/resources/RequestCollectionResource.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused "log" private field.

See more on https://sonarcloud.io/project/issues?id=org.folio%3Amod-circulation&issues=AZ2_QIjsPYrtt2fos2kc&open=AZ2_QIjsPYrtt2fos2kc&pullRequest=1674

public RequestCollectionResource(HttpClient client) {
super(client, "/circulation/requests");
Expand All @@ -80,8 +80,6 @@

final var representation = routingContext.body().asJsonObject();

log.debug("create:: {}", representation);

final var eventPublisher = new EventPublisher(context, clients);

RequestRelatedRepositories repositories = new RequestRelatedRepositories(clients);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package org.folio.circulation.resources.foruseatlocation;

import io.vertx.core.http.HttpClient;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import static org.folio.circulation.domain.policy.library.ClosedLibraryStrategyUtils.determineClosedLibraryStrategyForHoldShelfExpirationDate;
import static org.folio.circulation.domain.representations.LoanProperties.USAGE_STATUS_HELD;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.forUseAtLocationIsNotEnabledFailure;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.loanIsNotForUseAtLocationFailure;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.noOpenLoanFailure;
import static org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_FIND_SINGLE_OPEN_LOAN;

import java.lang.invoke.MethodHandles;
import java.time.ZonedDateTime;
import java.util.concurrent.CompletableFuture;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.circulation.domain.Loan;
Expand Down Expand Up @@ -35,16 +42,10 @@
import org.folio.circulation.support.results.Result;
import org.folio.circulation.support.utils.ClockUtil;

import java.lang.invoke.MethodHandles;
import java.time.ZonedDateTime;
import java.util.concurrent.CompletableFuture;

import static org.folio.circulation.domain.policy.library.ClosedLibraryStrategyUtils.determineClosedLibraryStrategyForHoldShelfExpirationDate;
import static org.folio.circulation.domain.representations.LoanProperties.*;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.forUseAtLocationIsNotEnabledFailure;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.loanIsNotForUseAtLocationFailure;
import static org.folio.circulation.resources.foruseatlocation.HoldByBarcodeRequest.noOpenLoanFailure;
import static org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_FIND_SINGLE_OPEN_LOAN;
import io.vertx.core.http.HttpClient;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;

public class HoldByBarcodeResource extends Resource {
private static final String rootPath = "/circulation/hold-by-barcode-for-use-at-location";
Expand Down Expand Up @@ -161,7 +162,7 @@ private Result<HoldByBarcodeRequest> setActionToHeld(Result<HoldByBarcodeRequest
}

private CompletableFuture<Result<HoldByBarcodeRequest>> updateLoan(HoldByBarcodeRequest request, LoanRepository loanRepository) {
log.debug("updateLoan:: loan parameter: {}", request.getLoan().asJson());
log.debug("updateLoan:: loan id: {}", request.getLoan().getId());
return loanRepository.updateLoan(request.getLoan())
.thenApply(loanResult -> loanResult.map(request::withLoan));
}
Expand Down
Loading
Loading