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

MODBULKOPS-334 - Preventing record update with values from different tenants #278

Merged
merged 61 commits into from
Oct 17, 2024

Conversation

obozhko-folio
Copy link
Collaborator

@obozhko-folio obozhko-folio commented Oct 10, 2024

MODBULKOPS-334 - Preventing record update with values from different tenants

Purpose

Align logic before commit stage.

Approach

Use rule and action tenants from content update.

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 Oct 17, 2024
@obozhko-folio obozhko-folio requested a review from a team October 17, 2024 07:02
@@ -34,15 +46,27 @@ public List<HoldingsNote> convertToObject(String value) {

@Override
public String convertToString(List<HoldingsNote> object) {
return object.stream()
var str = object.stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to introduce local variable str here - return result.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

noteTypeName = ItemReferenceHelper.service().getNoteTypeNameById(itemNote.getItemNoteTypeId(), itemNote.getTenantId());
} catch (NotFoundException e) {
log.error("Item note type with id = {} not found : {}", itemNote.getItemNoteTypeId(), e.getMessage());
noteTypeName = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Initialise this variable before try-catch block as empty 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.

Fixed.

@@ -8,8 +8,10 @@
import lombok.NoArgsConstructor;
import lombok.With;
import org.folio.bulkops.domain.dto.IdentifierType;
import org.folio.bulkops.domain.dto.TenantNotePair;
Copy link
Contributor

Choose a reason for hiding this comment

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

TenantNotePair can be renamed to ExtendedNoteTypeName o follow general rule when including tenant information.

noteTypeName = HoldingsReferenceHelper.service().getNoteTypeNameById(note.getHoldingsNoteTypeId());
} catch (NotFoundException e) {
log.error("Holding note type with id = {} not found : {}", note.getHoldingsNoteTypeId(), e.getMessage());
noteTypeName = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

String noteType name can be initialised as empty string before try-catch block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

return (Updater<ExtendedHoldingsRecord>) electronicAccessUpdaterFactory.updater(option, action);
} else if (REPLACE_WITH == action.getType()) {
return extendedHoldingsRecord -> {
var locationId = action.getUpdated();
var tenant = getTenantFromAction(action);
Copy link
Contributor

Choose a reason for hiding this comment

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

Tenant is used only if forPreview = true. This can be moved inside if-statement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@@ -122,14 +134,16 @@ private void validateReplacement(UpdateOptionType option, Action action) throws
}

if (Set.of(PERMANENT_LOCATION, TEMPORARY_LOCATION).contains(option)) {
try {
itemReferenceService.getLocationById(newId);
var tenant = getTenantFromAction(action);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks this is duplication. var tenant = getTenantFromAction(action); can be calculated outside if (Set.of(PERMANENT_LOCATION, TEMPORARY_LOCATION).contains(option)) statement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

var ruleTenants = rule.getRuleDetails().getTenants();
var actionTenants = action.getTenants();
if (nonNull(ruleTenants) && !ruleTenants.isEmpty() && nonNull(actionTenants) && !actionTenants.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @obozhko-folio , it is better to have here separate method to understand why such checking is needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link

sonarcloud bot commented Oct 17, 2024

@obozhko-folio obozhko-folio merged commit 04d462f into master Oct 17, 2024
6 checks passed
@obozhko-folio obozhko-folio deleted the MODBULKOPS-334 branch October 17, 2024 12:56
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