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

UIQM-709 Duplicate LCCN checking query > Do not return instance/bib record that is set for deletion #741

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* [UIQM-706](https://issues.folio.org/browse/UIQM-706) *BREAKING* Upgrade `marc-records-editor` to `6.0`.
* [UIQM-698](https://issues.folio.org/browse/UIQM-698) Validate 006/007 field lengths.
* [UIQM-704](https://issues.folio.org/browse/UIQM-704) Linked fields - combine split fields before sending for validation.
* [UIQM-709](https://issues.folio.org/browse/UIQM-709) Duplicate LCCN checking query > Do not return instance/bib record that is set for deletion.

## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18)

Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useValidation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const BASE_BIB_VALIDATORS = [
{
tag: '010',
validator: RULES.DUPLICATE_LCCN,
ignore: ({ duplicateLccnCheckingEnabled }) => !duplicateLccnCheckingEnabled,
message: () => ({ id: 'ui-quick-marc.record.error.010.lccnDuplicated' }),
},
];
Expand Down Expand Up @@ -273,6 +274,7 @@ const BASE_AUTHORITY_VALIDATORS = [
{
tag: '010',
validator: RULES.DUPLICATE_LCCN,
ignore: ({ duplicateLccnCheckingEnabled }) => !duplicateLccnCheckingEnabled,
message: () => ({ id: 'ui-quick-marc.record.error.010.lccnDuplicated' }),
},
{
Expand Down
25 changes: 13 additions & 12 deletions src/hooks/useValidation/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,19 @@ export const validateFixedFieldLength = ({ marcRecords, fixedFieldSpec, marcType

return undefined;
};
export const validateLccnDuplication = async ({
ky,
marcRecords,
duplicateLccnCheckingEnabled,
instanceId,
action,
marcType,
}, rule) => {
if (!duplicateLccnCheckingEnabled) {
export const validateLccnDuplication = async (context, rule) => {
if (rule.ignore?.(context)) {
return undefined;
}

const {
ky,
marcRecords,
instanceId,
action,
marcType,
} = context;

const fields = marcRecords.filter(record => record.tag.match(rule.tag));

const validateField = async (field) => {
Expand All @@ -479,7 +480,7 @@ export const validateLccnDuplication = async ({

const searchParams = {
limit: 1,
query: `(${lccnQuery})${idQuery}`,
query: `(${lccnQuery})${idQuery} and (staffSuppress=="false" or discoverySuppress=="false")`,
Copy link
Contributor

Choose a reason for hiding this comment

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

These fields are not present in authorities.

};

const requests = {
Expand All @@ -488,9 +489,9 @@ export const validateLccnDuplication = async ({
};

try {
const records = await requests[marcType]().json();
const response = await requests[marcType]().json();

const isLccnDuplicated = records?.authorities?.[0] || records?.instances?.[0];
const isLccnDuplicated = response?.authorities?.[0] || response?.instances?.[0];

if (isLccnDuplicated) {
return rule.message();
Expand Down
Loading