From 3e9162dd0be2f317f4d7570e1e98c1c24c103646 Mon Sep 17 00:00:00 2001 From: askhat-abishev <150008941+askhat-abishev@users.noreply.github.com> Date: Fri, 31 May 2024 14:02:35 +0500 Subject: [PATCH] =?UTF-8?q?MODLD-308:=20Enhance=20GET,=20PUT=20and=20POST?= =?UTF-8?q?=20APIs=20to=20support=20Dewey=20Decimal=20Cl=E2=80=A6=20(#261)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/sub/AssigningSourceMapperUnit.java | 31 ++++++++ .../DeweyDecimalClassificationMapperUnit.java | 24 ++++-- .../schema/resource/Classification.json | 56 ++++++++++++++ .../resource/DeweyDecimalClassification.json | 28 ------- .../swagger.api/schema/resource/Work.json | 2 +- .../linked/data/e2e/ResourceControllerIT.java | 73 +++++++++++++++---- .../linked/data/test/MonographTestUtil.java | 36 ++++++--- .../samples/work_and_instance_ref.json | 14 ++++ 8 files changed, 202 insertions(+), 62 deletions(-) create mode 100644 src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/AssigningSourceMapperUnit.java create mode 100644 src/main/resources/swagger.api/schema/resource/Classification.json delete mode 100644 src/main/resources/swagger.api/schema/resource/DeweyDecimalClassification.json diff --git a/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/AssigningSourceMapperUnit.java b/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/AssigningSourceMapperUnit.java new file mode 100644 index 00000000..2bdb6566 --- /dev/null +++ b/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/AssigningSourceMapperUnit.java @@ -0,0 +1,31 @@ +package org.folio.linked.data.mapper.dto.monograph.work.sub; + +import static org.folio.ld.dictionary.PredicateDictionary.ASSIGNING_SOURCE; +import static org.folio.ld.dictionary.ResourceTypeDictionary.ORGANIZATION; + +import java.util.Set; +import org.folio.linked.data.domain.dto.Classification; +import org.folio.linked.data.domain.dto.Reference; +import org.folio.linked.data.mapper.dto.common.MapperUnit; +import org.folio.linked.data.repo.ResourceRepository; +import org.springframework.stereotype.Component; + +@Component +@MapperUnit(type = ORGANIZATION, predicate = ASSIGNING_SOURCE, dtoClass = Reference.class) +public class AssigningSourceMapperUnit extends ReferenceMapperUnit { + + private static final Set> SUPPORTED_PARENTS = Set.of(Classification.class); + + public AssigningSourceMapperUnit(ResourceRepository resourceRepository) { + super((assigningSource, destination) -> { + if (destination instanceof Classification deweyDecimalClassification) { + deweyDecimalClassification.addAssigningSourceReferenceItem(assigningSource); + } + }, resourceRepository); + } + + @Override + public Set> supportedParents() { + return SUPPORTED_PARENTS; + } +} diff --git a/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/DeweyDecimalClassificationMapperUnit.java b/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/DeweyDecimalClassificationMapperUnit.java index 870f51c8..f7bc0451 100644 --- a/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/DeweyDecimalClassificationMapperUnit.java +++ b/src/main/java/org/folio/linked/data/mapper/dto/monograph/work/sub/DeweyDecimalClassificationMapperUnit.java @@ -1,16 +1,20 @@ package org.folio.linked.data.mapper.dto.monograph.work.sub; +import static org.folio.ld.dictionary.PredicateDictionary.ASSIGNING_SOURCE; import static org.folio.ld.dictionary.PredicateDictionary.CLASSIFICATION; import static org.folio.ld.dictionary.PropertyDictionary.CODE; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION_NUMBER; +import static org.folio.ld.dictionary.PropertyDictionary.ITEM_NUMBER; import static org.folio.ld.dictionary.PropertyDictionary.SOURCE; -import static org.folio.ld.dictionary.ResourceTypeDictionary.CATEGORY; import static org.folio.linked.data.util.BibframeUtils.putProperty; import com.fasterxml.jackson.databind.JsonNode; import java.util.HashMap; import java.util.List; import lombok.RequiredArgsConstructor; -import org.folio.linked.data.domain.dto.DeweyDecimalClassification; +import org.folio.ld.dictionary.ResourceTypeDictionary; +import org.folio.linked.data.domain.dto.Classification; import org.folio.linked.data.domain.dto.Work; import org.folio.linked.data.mapper.dto.common.CoreMapper; import org.folio.linked.data.mapper.dto.common.MapperUnit; @@ -20,7 +24,8 @@ @Component @RequiredArgsConstructor -@MapperUnit(type = CATEGORY, predicate = CLASSIFICATION, dtoClass = DeweyDecimalClassification.class) +@MapperUnit(type = ResourceTypeDictionary.CLASSIFICATION, predicate = CLASSIFICATION, + dtoClass = Classification.class) public class DeweyDecimalClassificationMapperUnit implements WorkSubResourceMapperUnit { private final CoreMapper coreMapper; @@ -28,7 +33,7 @@ public class DeweyDecimalClassificationMapperUnit implements WorkSubResourceMapp @Override public

P toDto(Resource source, P parentDto, Resource parentResource) { - var deweyDecimalClassification = coreMapper.toDtoWithEdges(source, DeweyDecimalClassification.class, false); + var deweyDecimalClassification = coreMapper.toDtoWithEdges(source, Classification.class, false); deweyDecimalClassification.setId(String.valueOf(source.getId())); if (parentDto instanceof Work work) { work.addClassificationItem(deweyDecimalClassification); @@ -38,18 +43,23 @@ public

P toDto(Resource source, P parentDto, Resource parentResource) { @Override public Resource toEntity(Object dto, Resource parentEntity) { - var deweyDecimalClassification = (DeweyDecimalClassification) dto; + var deweyDecimalClassification = (Classification) dto; var resource = new Resource(); - resource.addTypes(CATEGORY); + resource.addTypes(ResourceTypeDictionary.CLASSIFICATION); resource.setDoc(getDoc(deweyDecimalClassification)); + coreMapper.addOutgoingEdges(resource, Classification.class, + deweyDecimalClassification.getAssigningSourceReference(), ASSIGNING_SOURCE); resource.setId(hashService.hash(resource)); return resource; } - private JsonNode getDoc(DeweyDecimalClassification dto) { + private JsonNode getDoc(Classification dto) { var map = new HashMap>(); putProperty(map, CODE, dto.getCode()); putProperty(map, SOURCE, dto.getSource()); + putProperty(map, ITEM_NUMBER, dto.getItemNumber()); + putProperty(map, EDITION_NUMBER, dto.getEditionNumber()); + putProperty(map, EDITION, dto.getEdition()); return map.isEmpty() ? null : coreMapper.toJson(map); } diff --git a/src/main/resources/swagger.api/schema/resource/Classification.json b/src/main/resources/swagger.api/schema/resource/Classification.json new file mode 100644 index 00000000..eb6adbd4 --- /dev/null +++ b/src/main/resources/swagger.api/schema/resource/Classification.json @@ -0,0 +1,56 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Dewey decimal classification object", + "allOf": [ + { + "$ref": "Topper.json" + }, + { + "type": "object", + "properties": { + "code": { + "type": "array", + "items": { + "type": "string" + }, + "x-json-property": "http://bibfra.me/vocab/marc/code" + }, + "source": { + "type": "array", + "items": { + "type": "string" + }, + "x-json-property": "http://bibfra.me/vocab/marc/source" + }, + "itemNumber": { + "type": "array", + "items": { + "type": "string" + }, + "x-json-property": "http://bibfra.me/vocab/marc/itemNumber" + }, + "editionNumber": { + "type": "array", + "items": { + "type": "string" + }, + "x-json-property": "http://bibfra.me/vocab/marc/editionNumber" + }, + "edition": { + "type": "array", + "items": { + "type": "string" + }, + "x-json-property": "http://bibfra.me/vocab/marc/edition" + }, + "_assigningSourceReference": { + "type": "array", + "items": { + "type": "object", + "$ref": "Reference.json" + } + } + } + } + ] +} diff --git a/src/main/resources/swagger.api/schema/resource/DeweyDecimalClassification.json b/src/main/resources/swagger.api/schema/resource/DeweyDecimalClassification.json deleted file mode 100644 index 76fa2198..00000000 --- a/src/main/resources/swagger.api/schema/resource/DeweyDecimalClassification.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "description": "Dewey decimal classification object", - "allOf": [ - { - "$ref": "Topper.json" - }, - { - "type": "object", - "properties": { - "code": { - "type": "array", - "items": { - "type": "string" - }, - "x-json-property": "http://bibfra.me/vocab/marc/code" - }, - "source": { - "type": "array", - "items": { - "type": "string" - }, - "x-json-property": "http://bibfra.me/vocab/marc/source" - } - } - } - ] -} diff --git a/src/main/resources/swagger.api/schema/resource/Work.json b/src/main/resources/swagger.api/schema/resource/Work.json index bc80de45..b2aab2d4 100644 --- a/src/main/resources/swagger.api/schema/resource/Work.json +++ b/src/main/resources/swagger.api/schema/resource/Work.json @@ -60,7 +60,7 @@ "type": "array", "items": { "type": "object", - "$ref": "DeweyDecimalClassification.json" + "$ref": "Classification.json" }, "x-json-property": "http://bibfra.me/vocab/lite/classification" }, diff --git a/src/test/java/org/folio/linked/data/e2e/ResourceControllerIT.java b/src/test/java/org/folio/linked/data/e2e/ResourceControllerIT.java index 7bc43355..ee10737e 100644 --- a/src/test/java/org/folio/linked/data/e2e/ResourceControllerIT.java +++ b/src/test/java/org/folio/linked/data/e2e/ResourceControllerIT.java @@ -45,6 +45,8 @@ import static org.folio.ld.dictionary.PropertyDictionary.DESCRIPTION_SOURCE_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.DIMENSIONS; import static org.folio.ld.dictionary.PropertyDictionary.EAN_VALUE; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION_NUMBER; import static org.folio.ld.dictionary.PropertyDictionary.EDITION_STATEMENT; import static org.folio.ld.dictionary.PropertyDictionary.EXHIBITIONS_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.EXTENT; @@ -52,6 +54,7 @@ import static org.folio.ld.dictionary.PropertyDictionary.ISSUANCE; import static org.folio.ld.dictionary.PropertyDictionary.ISSUANCE_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.ISSUING_BODY; +import static org.folio.ld.dictionary.PropertyDictionary.ITEM_NUMBER; import static org.folio.ld.dictionary.PropertyDictionary.LABEL; import static org.folio.ld.dictionary.PropertyDictionary.LANGUAGE; import static org.folio.ld.dictionary.PropertyDictionary.LANGUAGE_NOTE; @@ -185,6 +188,7 @@ class ResourceControllerIT { private static final String CONTRIBUTOR_REF = "_contributorReference"; private static final String GEOGRAPHIC_COVERAGE_REF = "_geographicCoverageReference"; private static final String GENRE_REF = "_genreReference"; + private static final String ASSIGNING_SOURCE_REF = "_assigningSourceReference"; private static final String WORK_ID_PLACEHOLDER = "%WORK_ID%"; private static final String INSTANCE_ID_PLACEHOLDER = "%INSTANCE_ID%"; @Autowired @@ -445,8 +449,8 @@ void deleteResourceById_shouldDeleteRootInstanceAndRootEdges_reindexWork() throw var work = getSampleWork(null); var instance = resourceTestService.saveGraph(getSampleInstanceResource(null, work)); assertThat(resourceTestService.findById(instance.getId())).isPresent(); - assertThat(resourceTestService.countResources()).isEqualTo(49); - assertThat(resourceTestService.countEdges()).isEqualTo(51); + assertThat(resourceTestService.countResources()).isEqualTo(50); + assertThat(resourceTestService.countEdges()).isEqualTo(52); var requestBuilder = delete(RESOURCE_URL + "/" + instance.getId()) .contentType(APPLICATION_JSON) .headers(defaultHeaders(env)); @@ -457,9 +461,9 @@ void deleteResourceById_shouldDeleteRootInstanceAndRootEdges_reindexWork() throw // then resultActions.andExpect(status().isNoContent()); assertThat(resourceTestService.existsById(instance.getId())).isFalse(); - assertThat(resourceTestService.countResources()).isEqualTo(48); + assertThat(resourceTestService.countResources()).isEqualTo(49); assertThat(resourceTestService.findEdgeById(instance.getOutgoingEdges().iterator().next().getId())).isNotPresent(); - assertThat(resourceTestService.countEdges()).isEqualTo(33); + assertThat(resourceTestService.countEdges()).isEqualTo(34); checkKafkaMessage(work.getId(), UPDATE); } @@ -468,8 +472,8 @@ void deleteResourceById_shouldDeleteRootWorkAndRootEdges() throws Exception { // given var existed = resourceTestService.saveGraph(getSampleWork(getSampleInstanceResource(null, null))); assertThat(resourceTestService.findById(existed.getId())).isPresent(); - assertThat(resourceTestService.countResources()).isEqualTo(49); - assertThat(resourceTestService.countEdges()).isEqualTo(51); + assertThat(resourceTestService.countResources()).isEqualTo(50); + assertThat(resourceTestService.countEdges()).isEqualTo(52); var requestBuilder = delete(RESOURCE_URL + "/" + existed.getId()) .contentType(APPLICATION_JSON) .headers(defaultHeaders(env)); @@ -480,9 +484,9 @@ void deleteResourceById_shouldDeleteRootWorkAndRootEdges() throws Exception { // then resultActions.andExpect(status().isNoContent()); assertThat(resourceTestService.existsById(existed.getId())).isFalse(); - assertThat(resourceTestService.countResources()).isEqualTo(48); + assertThat(resourceTestService.countResources()).isEqualTo(49); assertThat(resourceTestService.findEdgeById(existed.getOutgoingEdges().iterator().next().getId())).isNotPresent(); - assertThat(resourceTestService.countEdges()).isEqualTo(25); + assertThat(resourceTestService.countEdges()).isEqualTo(26); checkKafkaMessage(existed.getId(), DELETE); } @@ -647,6 +651,11 @@ private void validateWorkResponse(ResultActions resultActions, String workBase) .andExpect(jsonPath(toWorkLanguage(workBase), equalTo("eng"))) .andExpect(jsonPath(toWorkDeweyCode(workBase), equalTo("709.83"))) .andExpect(jsonPath(toWorkDeweySource(workBase), equalTo("ddc"))) + .andExpect(jsonPath(toWorkDeweyItemNumber(workBase), equalTo("item number"))) + .andExpect(jsonPath(toWorkDeweyEditionNumber(workBase), equalTo("edition number"))) + .andExpect(jsonPath(toWorkDeweyEdition(workBase), equalTo("edition"))) + .andExpect(jsonPath(toDeweyAssigningSourceId(workBase), containsInAnyOrder("11"))) + .andExpect(jsonPath(toDeweyAssigningSourceLabel(workBase), containsInAnyOrder("assigning agency"))) .andExpect(jsonPath(toWorkCreatorId(workBase), containsInAnyOrder("1001", "1002", "1003", "1004"))) .andExpect(jsonPath(toWorkCreatorLabel(workBase), containsInAnyOrder("name-MEETING", "name-PERSON", "name-ORGANIZATION", "name-FAMILY"))) @@ -1041,7 +1050,6 @@ private void validateWork(Resource work, boolean validateFullInstance) { validateParallelTitle(outgoingEdgeIterator.next(), work); validateWorkContentType(outgoingEdgeIterator.next(), work); validateWorkTargetAudience(outgoingEdgeIterator.next(), work); - validateWorkClassification(outgoingEdgeIterator.next(), work); validateWorkGovernmentPublication(outgoingEdgeIterator.next(), work); validateWorkContributor(outgoingEdgeIterator.next(), work, ORGANIZATION, CREATOR.getUri()); validateWorkContributor(outgoingEdgeIterator.next(), work, ORGANIZATION, EDITOR.getUri()); @@ -1049,6 +1057,7 @@ private void validateWork(Resource work, boolean validateFullInstance) { validateWorkContributor(outgoingEdgeIterator.next(), work, ORGANIZATION, ASSIGNEE.getUri()); validateWorkContributor(outgoingEdgeIterator.next(), work, FAMILY, CREATOR.getUri()); validateWorkContributor(outgoingEdgeIterator.next(), work, FAMILY, CONTRIBUTOR.getUri()); + validateWorkClassification(outgoingEdgeIterator.next(), work); validateBasicTitle(outgoingEdgeIterator.next(), work); validateWorkContributor(outgoingEdgeIterator.next(), work, PERSON, AUTHOR.getUri()); validateWorkContributor(outgoingEdgeIterator.next(), work, PERSON, CREATOR.getUri()); @@ -1082,11 +1091,19 @@ private void validateWorkClassification(ResourceEdge edge, Resource source) { assertThat(edge.getSource()).isEqualTo(source); assertThat(edge.getPredicate().getUri()).isEqualTo(CLASSIFICATION.getUri()); var classification = edge.getTarget(); - assertThat(classification.getDoc().size()).isEqualTo(2); - assertThat(classification.getDoc().get(CODE.getValue()).size()).isEqualTo(1); - assertThat(classification.getDoc().get(CODE.getValue()).get(0).asText()).isEqualTo("709.83"); - assertThat(classification.getDoc().get(SOURCE.getValue()).size()).isEqualTo(1); - assertThat(classification.getDoc().get(SOURCE.getValue()).get(0).asText()).isEqualTo("ddc"); + var types = classification.getTypes().stream().map(ResourceTypeEntity::getUri).toList(); + assertThat(types).contains(ResourceTypeDictionary.CLASSIFICATION.getUri()); + assertThat(classification.getDoc().size()).isEqualTo(5); + validateLiteral(classification, CODE.getValue(), "709.83"); + validateLiteral(classification, SOURCE.getValue(), "ddc"); + validateLiteral(classification, ITEM_NUMBER.getValue(), "item number"); + validateLiteral(classification, EDITION_NUMBER.getValue(), "edition number"); + validateLiteral(classification, EDITION.getValue(), "edition"); + var resourceEdge = classification.getOutgoingEdges().iterator().next(); + var assigningSource = resourceEdge.getTarget(); + validateResourceEdge(resourceEdge, classification, assigningSource, PredicateDictionary.ASSIGNING_SOURCE.getUri()); + assertThat(assigningSource.getDoc().size()).isZero(); + assertThat(assigningSource.getLabel()).isEqualTo("assigning agency"); } private void validateWorkContentType(ResourceEdge edge, Resource source) { @@ -1219,7 +1236,8 @@ private LookupResources saveLookupResources() { List.of(unitedStates, europe), List.of(genre1, genre2), List.of(creatorMeeting, creatorPerson, creatorOrganization, creatorFamily, - contributorPerson, contributorMeeting, contributorOrganization, contributorFamily) + contributorPerson, contributorMeeting, contributorOrganization, contributorFamily), + List.of(saveResource(11L, "assigning agency", ORGANIZATION, "{}")) ); } @@ -1545,6 +1563,28 @@ private String toWorkDeweyCode(String workBase) { return join(".", workBase, arrayPath(CLASSIFICATION.getUri()), arrayPath(CODE.getValue())); } + private String toWorkDeweyItemNumber(String workBase) { + return join(".", workBase, arrayPath(CLASSIFICATION.getUri()), arrayPath(ITEM_NUMBER.getValue())); + } + + private String toWorkDeweyEditionNumber(String workBase) { + return join(".", workBase, arrayPath(CLASSIFICATION.getUri()), arrayPath(EDITION_NUMBER.getValue())); + } + + private String toWorkDeweyEdition(String workBase) { + return join(".", workBase, arrayPath(CLASSIFICATION.getUri()), arrayPath(EDITION.getValue())); + } + + private String toDeweyAssigningSourceId(String workBase) { + return join(".", join(".", workBase, arrayPath(CLASSIFICATION.getUri())), + dynamicArrayPath(ASSIGNING_SOURCE_REF), path(ID_PROPERTY)); + } + + private String toDeweyAssigningSourceLabel(String workBase) { + return join(".", join(".", workBase, arrayPath(CLASSIFICATION.getUri())), + dynamicArrayPath(ASSIGNING_SOURCE_REF), path(LABEL_PROPERTY)); + } + private String toWorkCreatorId(String workBase) { return join(".", workBase, dynamicArrayPath(CREATOR_REF), path(ID_PROPERTY)); } @@ -1665,7 +1705,8 @@ private record LookupResources( List subjects, List geographicCoverages, List genres, - List creators + List creators, + List assigningSources ) { } } diff --git a/src/test/java/org/folio/linked/data/test/MonographTestUtil.java b/src/test/java/org/folio/linked/data/test/MonographTestUtil.java index 3cc5421b..5cee78b5 100644 --- a/src/test/java/org/folio/linked/data/test/MonographTestUtil.java +++ b/src/test/java/org/folio/linked/data/test/MonographTestUtil.java @@ -41,6 +41,8 @@ import static org.folio.ld.dictionary.PropertyDictionary.DESCRIPTION_SOURCE_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.DIMENSIONS; import static org.folio.ld.dictionary.PropertyDictionary.EAN_VALUE; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION; +import static org.folio.ld.dictionary.PropertyDictionary.EDITION_NUMBER; import static org.folio.ld.dictionary.PropertyDictionary.EDITION_STATEMENT; import static org.folio.ld.dictionary.PropertyDictionary.EXHIBITIONS_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.EXTENT; @@ -50,6 +52,7 @@ import static org.folio.ld.dictionary.PropertyDictionary.ISSUANCE; import static org.folio.ld.dictionary.PropertyDictionary.ISSUANCE_NOTE; import static org.folio.ld.dictionary.PropertyDictionary.ISSUING_BODY; +import static org.folio.ld.dictionary.PropertyDictionary.ITEM_NUMBER; import static org.folio.ld.dictionary.PropertyDictionary.LABEL; import static org.folio.ld.dictionary.PropertyDictionary.LANGUAGE; import static org.folio.ld.dictionary.PropertyDictionary.LANGUAGE_NOTE; @@ -329,15 +332,6 @@ private static Resource createVariantTitle() { public static Resource getSampleWork(Resource linkedInstance) { var basicTitle = createBasicTitle(null); - var deweyClassification = createResource( - Map.of( - CODE, List.of("709.83"), - SOURCE, List.of("ddc") - ), - Set.of(CATEGORY), - emptyMap() - ).setLabel("709.83"); - var creatorMeeting = createResource( Map.of( NAME, List.of("name-MEETING"), @@ -498,7 +492,7 @@ public static Resource getSampleWork(Resource linkedInstance) { var pred2OutgoingResources = new LinkedHashMap>(); pred2OutgoingResources.put(TITLE, List.of(basicTitle, createParallelTitle(), createVariantTitle())); - pred2OutgoingResources.put(CLASSIFICATION, List.of(deweyClassification)); + pred2OutgoingResources.put(CLASSIFICATION, List.of(createDeweyClassification())); pred2OutgoingResources.put(CREATOR, List.of(creatorPerson, creatorMeeting, creatorOrganization, creatorFamily)); pred2OutgoingResources.put(AUTHOR, List.of(creatorPerson)); pred2OutgoingResources.put(CONTRIBUTOR, List.of(contributorPerson, contributorMeeting, contributorOrganization, @@ -536,6 +530,28 @@ public static Resource getSampleWork(Resource linkedInstance) { return work; } + private static Resource createDeweyClassification() { + var assigningSource = createResource( + emptyMap(), + Set.of(ORGANIZATION), + emptyMap() + ).setLabel("assigning agency") + .setId(11L); + var pred2OutgoingResources = new LinkedHashMap>(); + pred2OutgoingResources.put(PredicateDictionary.ASSIGNING_SOURCE, List.of(assigningSource)); + return createResource( + Map.of( + CODE, List.of("709.83"), + SOURCE, List.of("ddc"), + ITEM_NUMBER, List.of("item number"), + EDITION_NUMBER, List.of("edition number"), + EDITION, List.of("edition") + ), + Set.of(ResourceTypeDictionary.CLASSIFICATION), + pred2OutgoingResources + ); + } + private static Resource createContent() { var categorySet = createResource( Map.of( diff --git a/src/test/resources/samples/work_and_instance_ref.json b/src/test/resources/samples/work_and_instance_ref.json index 5c9966b9..ff045c3c 100644 --- a/src/test/resources/samples/work_and_instance_ref.json +++ b/src/test/resources/samples/work_and_instance_ref.json @@ -157,6 +157,20 @@ ], "http://bibfra.me/vocab/marc/source": [ "ddc" + ], + "http://bibfra.me/vocab/marc/itemNumber": [ + "item number" + ], + "http://bibfra.me/vocab/marc/editionNumber": [ + "edition number" + ], + "http://bibfra.me/vocab/marc/edition": [ + "edition" + ], + "_assigningSourceReference": [ + { + "id": "11" + } ] } ],