Skip to content

Commit a662377

Browse files
authored
feat(search-authorities): use authority-specific identifier types for LCCN lookups (#924)
Closes: MSEARCH-1193
1 parent 9845124 commit a662377

File tree

11 files changed

+78
-23
lines changed

11 files changed

+78
-23
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* **Authority Search**
2626
* Implement two-stage Kafka processing with event aggregation for instance indexing ([MSEARCH-1157](https://folio-org.atlassian.net/browse/MSEARCH-1157))
2727
* Separate LCCN and Canceled LCCN identifiers search to lccn and canceledLccn options ([MSEARCH-1066](https://folio-org.atlassian.net/browse/MSEARCH-1066))
28+
* Use Authority-Specific Identifier Types for LCCN Lookups ([MSEARCH-1193](https://folio-org.atlassian.net/browse/MSEARCH-1193))
2829
* **Classification Browse**
2930
* Add title and contributors to classification browse response ([MSEARCH-1045](https://folio-org.atlassian.net/browse/MSEARCH-1045))
3031
* Add id to classification browse response ([MSEARCH-1093](https://folio-org.atlassian.net/browse/MSEARCH-1093))

descriptors/ModuleDescriptor-template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,10 @@
652652
"id": "item-storage",
653653
"version": "11.0"
654654
},
655+
{
656+
"id": "authority-identifier-types",
657+
"version": "1.0"
658+
},
655659
{
656660
"id": "authority-reindex",
657661
"version": "0.1"
@@ -932,6 +936,7 @@
932936
"perms.users.item.post",
933937
"perms.users.assign.immutable",
934938
"perms.users.assign.mutable",
939+
"authority-identifier-types.collection.get",
935940
"inventory-storage.instance.reindex.post",
936941
"authority-storage.authority.reindex.post",
937942
"inventory-storage.inventory-view.instances.collection.get",

src/main/java/org/folio/search/client/InventoryReferenceDataClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public interface InventoryReferenceDataClient {
2727
@Getter
2828
enum ReferenceDataType {
2929

30+
AUTHORITY_IDENTIFIER_TYPES("authority-identifier-types"),
3031
IDENTIFIER_TYPES("identifier-types"),
3132
ALTERNATIVE_TITLE_TYPES("alternative-title-types"),
3233
CALL_NUMBER_TYPES("call-number-types"),

src/main/java/org/folio/search/model/client/CqlQueryParam.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
public enum CqlQueryParam {
88

99
ID("id"),
10+
CODE("code"),
1011
NAME("name"),
1112
SOURCE("source"),
1213
HOLDINGS_ID("holdings.id");

src/main/java/org/folio/search/service/setter/AbstractIdentifierProcessor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ protected Set<String> filterIdentifiersValue(List<Identifier> identifiers) {
5656
* @return {@link List} of {@link String} identifier ids that matches names.
5757
*/
5858
private Set<String> fetchIdentifierIdsFromCache() {
59-
var identifierTypeIds = referenceDataService.fetchReferenceData(IDENTIFIER_TYPES, CqlQueryParam.NAME,
60-
getIdentifierNames());
59+
var identifierTypeIds = getIdentifierTypeIds();
6160
if (identifierTypeIds.isEmpty()) {
6261
log.warn("Failed to provide identifiers for [processor: {}]", this.getClass().getSimpleName());
6362
}
6463
return identifierTypeIds;
6564
}
65+
66+
protected Set<String> getIdentifierTypeIds() {
67+
return referenceDataService.fetchReferenceData(IDENTIFIER_TYPES, CqlQueryParam.NAME, getIdentifierNames());
68+
}
6669
}

src/main/java/org/folio/search/service/setter/authority/AbstractAuthorityIdentifierProcessor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
package org.folio.search.service.setter.authority;
22

3+
import static org.folio.search.client.InventoryReferenceDataClient.ReferenceDataType.AUTHORITY_IDENTIFIER_TYPES;
4+
35
import java.util.Collections;
46
import java.util.List;
57
import java.util.Optional;
8+
import java.util.Set;
69
import org.folio.search.domain.dto.Authority;
710
import org.folio.search.domain.dto.Identifier;
811
import org.folio.search.integration.folio.ReferenceDataService;
12+
import org.folio.search.model.client.CqlQueryParam;
913
import org.folio.search.service.setter.AbstractIdentifierProcessor;
1014

1115
public abstract class AbstractAuthorityIdentifierProcessor extends AbstractIdentifierProcessor<Authority> {
1216

17+
private final ReferenceDataService referenceDataService;
18+
1319
protected AbstractAuthorityIdentifierProcessor(ReferenceDataService referenceDataService) {
1420
super(referenceDataService);
21+
this.referenceDataService = referenceDataService;
1522
}
1623

1724
@Override
@@ -20,4 +27,12 @@ protected List<Identifier> getIdentifiers(Authority entity) {
2027
.map(Authority::getIdentifiers)
2128
.orElse(Collections.emptyList());
2229
}
30+
31+
@Override
32+
protected Set<String> getIdentifierTypeIds() {
33+
return referenceDataService.fetchReferenceData(
34+
AUTHORITY_IDENTIFIER_TYPES,
35+
CqlQueryParam.CODE,
36+
getIdentifierNames());
37+
}
2338
}

src/main/java/org/folio/search/service/setter/authority/CanceledLccnAuthorityProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Component
99
public class CanceledLccnAuthorityProcessor extends AbstractAuthorityLccnProcessor {
1010

11-
private static final List<String> IDENTIFIER_NAMES = List.of("Canceled LCCN");
11+
private static final List<String> IDENTIFIER_NAMES = List.of("canceled-lccn");
1212

1313
/**
1414
* Used by dependency injection.

src/main/java/org/folio/search/service/setter/authority/LccnAuthorityProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Component
99
public class LccnAuthorityProcessor extends AbstractAuthorityLccnProcessor {
1010

11-
private static final List<String> IDENTIFIER_NAMES = List.of("LCCN");
11+
private static final List<String> IDENTIFIER_NAMES = List.of("lccn");
1212

1313
/**
1414
* Used by dependency injection.

src/test/java/org/folio/search/service/setter/authority/LccnAuthorityProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static java.util.Collections.emptySet;
44
import static org.assertj.core.api.Assertions.assertThat;
5-
import static org.folio.search.client.InventoryReferenceDataClient.ReferenceDataType.IDENTIFIER_TYPES;
5+
import static org.folio.search.client.InventoryReferenceDataClient.ReferenceDataType.AUTHORITY_IDENTIFIER_TYPES;
66
import static org.folio.support.TestConstants.LCCN_IDENTIFIER_TYPE_ID;
77
import static org.folio.support.utils.TestUtils.authorityWithIdentifiers;
88
import static org.folio.support.utils.TestUtils.identifier;
@@ -82,7 +82,7 @@ private static Identifier lccn(String value) {
8282
}
8383

8484
private void mockFetchReferenceData(Set<String> referenceData) {
85-
when(referenceDataService.fetchReferenceData(IDENTIFIER_TYPES, CqlQueryParam.NAME,
85+
when(referenceDataService.fetchReferenceData(AUTHORITY_IDENTIFIER_TYPES, CqlQueryParam.CODE,
8686
lccnProcessor.getIdentifierNames()))
8787
.thenReturn(referenceData);
8888
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"mappings": [
3+
{
4+
"request": {
5+
"method": "GET",
6+
"url": "/authority-identifier-types?query=code%3D%3D(%22lccn%22)&limit=100"
7+
},
8+
"response": {
9+
"status": 200,
10+
"jsonBody": {
11+
"identifierTypes": [
12+
{
13+
"id": "c858e4f2-2b6b-4385-842b-60732ee14abb",
14+
"code": "lccn",
15+
"name": "LCCN"
16+
}
17+
]
18+
},
19+
"headers": {
20+
"Content-Type": "application/json"
21+
}
22+
}
23+
},
24+
{
25+
"request": {
26+
"method": "GET",
27+
"url": "/authority-identifier-types?query=code%3D%3D(%22canceled-lccn%22)&limit=100"
28+
},
29+
"response": {
30+
"status": 200,
31+
"jsonBody": {
32+
"identifierTypes": [
33+
{
34+
"id": "3fb87c8e-d0d2-4c3a-821a-b481f32f48a9",
35+
"code": "canceled-lccn",
36+
"name": "Canceled LCCN"
37+
}
38+
]
39+
},
40+
"headers": {
41+
"Content-Type": "application/json"
42+
}
43+
}
44+
}
45+
]
46+
}

0 commit comments

Comments
 (0)