Skip to content

MODBULKOPS-337 - Stage 3b - FQM Performance (FQL): switching matched records flow to use mod-bulk-operations capabilities #423

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

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

Conversation

obozhko-folio
Copy link
Collaborator

@obozhko-folio obozhko-folio commented May 29, 2025

MODBULKOPS-337 - Stage 3b - FQM Performance (FQL): switching matched records flow to use mod-bulk-operations capabilities

Purpose

Fix bug with JSON from FQM.

Approach

Use getters/setters for json properties, JsonIgnore for objects which are absent in FQM response.

TODOS and Open Questions

Learning

Pre-Merge Checklist:

Before merging this PR, please go through the following list and take appropriate actions.

  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • Were any API paths or methods changed, added or removed?
    • Were there any schema changes?
    • Did any of the interface versions change?
    • Were permissions changed, added, or removed?
    • Are there new interface dependencies?
    • There are no breaking changes in this PR.

If there are breaking changes, please STOP and consider the following:

  • What other modules will these changes impact?
  • Do JIRAs exist to update the impacted modules?
    • If not, please create them
    • Do they contain the appropriate level of detail? Which endpoints/schemas changed, etc.
    • Do they have all they appropriate links to blocked/related issues?
  • Are the JIRAs under active development?
    • If not, contact the project's PO and make sure they're aware of the urgency.
  • Do PRs exist for these changes?
    • If so, have they been approved?

Ideally all of the PRs involved in breaking changes would be merged in the same day to avoid breaking the folio-testing environment. Communication is paramount if that is to be achieved, especially as the number of intermodule and inter-team dependencies increase.

While it's helpful for reviewers to help identify potential problems, ensuring that it's safe to merge is ultimately the responsibility of the PR assignee.

@obozhko-folio obozhko-folio self-assigned this May 30, 2025
@obozhko-folio obozhko-folio requested a review from a team May 30, 2025 20:07
var jsonb = json.get(getContentJsonKey(entityType));
try {
ObjectNode extendedRecordWrapper = objectMapper.createObjectNode();
extendedRecordWrapper.set("entity", objectMapper.readTree(jsonb.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Strings can be used as constants.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

log.error("Error processing JSON content for entity type {}: {}", entityType, e.getMessage());
throw new FqmFetcherException("Error processing JSON content", e);
}
}).collect(Collectors.joining("\n"))
Copy link
Contributor

Choose a reason for hiding this comment

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

'\n' new line separator is already introduced as constant (or it makes sense to introduce such constant).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


private String getContentTenantKey(EntityType entityType) {
return switch(entityType) {
case USER -> null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe empty string will be safer then null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added.

import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "material-types", configuration = FeignClientConfiguration.class)
public interface MaterialTypeClient {

@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
MaterialTypeCollection getByQuery(@RequestParam String query);

@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
MaterialType getById(@PathVariable String id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use here UUID type instead of String?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably yes, but in all other clients related to reference data we use String.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's stay as is.


@Override
public LoanType convertToObject(String value) {
return ItemReferenceHelper.service().getLoanTypeByName(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

TBC - Looks, there is no flow to restore LoanType from csv representation to object. Why do we need this method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed.

public class LoanTypeDeserializer extends JsonDeserializer<LoanType> {
@Override
public LoanType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
System.out.println("Deserializing LoanType from JSON");
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging should be used here instead of sout (if applicable).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LoanTypeDeserializer is not needed, removed.

import com.fasterxml.jackson.databind.JsonDeserializer;
import org.folio.bulkops.domain.bean.LoanType;

public class LoanTypeDeserializer extends JsonDeserializer<LoanType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Renaming for code readability: JsonParser p -> JsonParser parser.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LoanTypeDeserializer is not needed, removed.

@@ -26,6 +26,7 @@ public class ItemUpdateProcessor extends FolioAbstractUpdateProcessor<ExtendedIt
private final FolioExecutionContext folioExecutionContext;
private final ConsortiaService consortiaService;
private final PermissionsValidator permissionsValidator;
private final ObjectMapper objectMapper;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed.

@@ -40,7 +41,7 @@ public void updateRecord(ExtendedItem extendedItem) {
} else {
permissionsValidator.checkIfBulkEditWritePermissionExists(folioExecutionContext.getTenantId(), EntityType.ITEM,
NO_ITEM_WRITE_PERMISSIONS_TEMPLATE + folioExecutionContext.getTenantId());
itemClient.updateItem(item.withHoldingsData(null), item.getId());
itemClient.updateItem(item.withHoldingsData(null), item.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline: roll-back format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -142,7 +142,7 @@ void testClearItemLocationAndLoanType() {
.withHoldingsRecordId(holdingsId)
.withPermanentLocation(new ItemLocation().withId(UUID.randomUUID().toString()).withName("Permanent location"))
.withTemporaryLocation(new ItemLocation().withId(UUID.randomUUID().toString()).withName("Temporary location"))
.withPermanentLoanType(new LoanType().withId(UUID.randomUUID().toString()).withName("Permanent loan type"));
.withPermanentLoanType(new LoanType().withId(UUID.randomUUID().toString()).withName("Permanent loan type"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline: roll-back format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -174,7 +174,7 @@ void testUpdateItemAndLoanTypeLocation() {
var item = new Item()
.withPermanentLocation(new ItemLocation().withId(UUID.randomUUID().toString()).withName("Permanent location"))
.withTemporaryLocation(new ItemLocation().withId(UUID.randomUUID().toString()).withName("Temporary location"))
.withPermanentLoanType(new LoanType().withId(UUID.randomUUID().toString()).withName("Permanent loan type"))
.withPermanentLoanType(new LoanType().withId(UUID.randomUUID().toString()).withName("Permanent loan type"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline: roll-back format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link

sonarqubecloud bot commented Jun 3, 2025

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.

2 participants