diff --git a/NEWS.md b/NEWS.md index a2b99f5c6..0135a8851 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## 20.3.0-SNAPSHOT 2024-xx-xx +## 21.0.0-SNAPSHOT 2024-xx-xx * Existing "035" field is not retained the original position in imported record [MODINV-1049](https://folio-org.atlassian.net/browse/MODINV-1049) * Update Data Import logic to normalize OCLC 035 values [MODINV-949](https://folio-org.atlassian.net/browse/MODINV-949) * The sorting for Items on Instance details page is not worked [MODINV-1001](https://folio-org.atlassian.net/browse/MODINV-1001) @@ -23,6 +23,7 @@ * Apply new date type fields to instance schema [MODINV-1067](https://folio-org.atlassian.net/browse/MODINV-1067) * Extend Authority with Additional fields [MODINV-1071](https://folio-org.atlassian.net/browse/MODINV-1071) * Keep original UUIDs when updating ownership of Holdings/Items [MODINV-1074](https://folio-org.atlassian.net/browse/MODINV-1074) +* API version update [MODINV-1080](https://folio-org.atlassian.net/browse/MODINV-1080) * Fix inconsistencies in permission namings [MODINV-1072](https://folio-org.atlassian.net/browse/MODINV-1072) ## 20.2.0 2023-03-20 diff --git a/README.MD b/README.MD index ca9d74c41..759c4bed7 100644 --- a/README.MD +++ b/README.MD @@ -127,6 +127,8 @@ After setup, it is good to check logs in all related modules for errors. * DI_INVENTORY_AUTHORITY_CREATED_READY_FOR_POST_PROCESSING_PARTITIONS * DI_INVENTORY_AUTHORITY_UPDATED_READY_FOR_POST_PROCESSING_PARTITIONS * DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS + * INVENTORY_INSTANCE_INGRESS_PARTITIONS + Default value for all partitions is 1 ## Properties diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 62ae2ea7d..56096ae01 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -4,7 +4,7 @@ "provides": [ { "id": "inventory", - "version": "13.3", + "version": "14.0", "handlers": [ { "methods": ["GET"], @@ -451,7 +451,7 @@ }, { "id": "inventory-batch", - "version": "2.0", + "version": "3.0", "handlers": [ { "methods": ["POST"], @@ -604,11 +604,11 @@ }, { "id": "instance-storage", - "version": "10.3" + "version": "11.0" }, { "id": "instance-storage-batch", - "version": "2.0" + "version": "3.0" }, { "id": "holdings-storage", diff --git a/pom.xml b/pom.xml index badc2cff0..41df6736d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-inventory org.folio - 20.3.0-SNAPSHOT + 21.0.0-SNAPSHOT Apache License 2.0 diff --git a/ramls/instance.json b/ramls/instance.json index ee7703fee..24edaa73a 100644 --- a/ramls/instance.json +++ b/ramls/instance.json @@ -287,21 +287,6 @@ }, "uniqueItems": true }, - "publicationPeriod": { - "type": "object", - "description": "Publication period", - "properties": { - "start": { - "type": "integer", - "description": "Publication start year" - }, - "end": { - "type": "integer", - "description": "Publication end year" - } - }, - "additionalProperties": false - }, "electronicAccess": { "type": "array", "description": "List of electronic access items", diff --git a/ramls/inventory.raml b/ramls/inventory.raml index 0b780b512..90d735e09 100644 --- a/ramls/inventory.raml +++ b/ramls/inventory.raml @@ -1,6 +1,6 @@ #%RAML 1.0 title: Inventory API -version: v13.0 +version: v14.0 protocols: [ HTTP, HTTPS ] baseUri: http://localhost diff --git a/src/main/java/org/folio/inventory/InstanceIngressConsumerVerticle.java b/src/main/java/org/folio/inventory/InstanceIngressConsumerVerticle.java index 410218aaf..37937d82b 100644 --- a/src/main/java/org/folio/inventory/InstanceIngressConsumerVerticle.java +++ b/src/main/java/org/folio/inventory/InstanceIngressConsumerVerticle.java @@ -10,8 +10,9 @@ public class InstanceIngressConsumerVerticle extends KafkaConsumerVerticle { + public static final String INSTANCE_INGRESS_TOPIC = "inventory.instance_ingress"; + private static final Logger LOGGER = LogManager.getLogger(InstanceIngressConsumerVerticle.class); - private static final String INSTANCE_INGRESS_TOPIC = "linked-data.instance-ingress"; private static final String BASE_PROPERTY = "InstanceIngressConsumerVerticle"; @Override diff --git a/src/main/java/org/folio/inventory/domain/instances/Instance.java b/src/main/java/org/folio/inventory/domain/instances/Instance.java index 3efeba9df..5154c30e8 100644 --- a/src/main/java/org/folio/inventory/domain/instances/Instance.java +++ b/src/main/java/org/folio/inventory/domain/instances/Instance.java @@ -2,8 +2,6 @@ import static org.folio.inventory.domain.instances.Dates.datesFromJson; import static org.folio.inventory.domain.instances.Dates.datesToJson; -import static org.folio.inventory.domain.instances.PublicationPeriod.publicationPeriodFromJson; -import static org.folio.inventory.domain.instances.PublicationPeriod.publicationPeriodToJson; import static org.folio.inventory.support.JsonArrayHelper.toListOfStrings; import java.lang.invoke.MethodHandles; @@ -74,7 +72,6 @@ public class Instance { public static final String TAGS_KEY = "tags"; public static final String TAG_LIST_KEY = "tagList"; public static final String NATURE_OF_CONTENT_TERM_IDS_KEY = "natureOfContentTermIds"; - public static final String PUBLICATION_PERIOD_KEY = "publicationPeriod"; public static final String DATES_KEY = "dates"; private final String id; @@ -119,7 +116,6 @@ public class Instance { private Metadata metadata = null; private List tags; private List natureOfContentTermIds = new ArrayList<>(); - private PublicationPeriod publicationPeriod; private Dates dates; protected static final String INVENTORY_PATH = "/inventory"; @@ -192,7 +188,6 @@ public static Instance fromJson(JsonObject instanceJson) { .setStatusUpdatedDate(instanceJson.getString(STATUS_UPDATED_DATE_KEY)) .setTags(getTags(instanceJson)) .setNatureOfContentTermIds(toListOfStrings(instanceJson.getJsonArray(NATURE_OF_CONTENT_TERM_IDS_KEY))) - .setPublicationPeriod(publicationPeriodFromJson(instanceJson.getJsonObject(PUBLICATION_PERIOD_KEY))) .setDates(datesFromJson(instanceJson.getJsonObject(DATES_KEY))); } @@ -241,7 +236,6 @@ public JsonObject getJsonForStorage() { json.put(STATUS_UPDATED_DATE_KEY, statusUpdatedDate); json.put(TAGS_KEY, new JsonObject().put(TAG_LIST_KEY, new JsonArray(getTags() == null ? Collections.emptyList() : getTags()))); json.put(NATURE_OF_CONTENT_TERM_IDS_KEY, natureOfContentTermIds); - putIfNotNull(json, PUBLICATION_PERIOD_KEY, publicationPeriodToJson(publicationPeriod)); putIfNotNull(json, DATES_KEY, datesToJson(dates)); return json; @@ -295,7 +289,6 @@ public JsonObject getJsonForResponse(WebContext context) { putIfNotNull(json, METADATA_KEY, getMetadata()); putIfNotNull(json, TAGS_KEY, new JsonObject().put(TAG_LIST_KEY, new JsonArray(getTags()))); putIfNotNull(json, NATURE_OF_CONTENT_TERM_IDS_KEY, getNatureOfContentTermIds()); - putIfNotNull(json, PUBLICATION_PERIOD_KEY, publicationPeriodToJson(publicationPeriod)); putIfNotNull(json, DATES_KEY, datesToJson(dates)); if (precedingTitles != null) { @@ -759,7 +752,6 @@ public Instance copyWithNewId(String newId) { .setMetadata(metadata) .setTags(tags) .setNatureOfContentTermIds(natureOfContentTermIds) - .setPublicationPeriod(publicationPeriod) .setDates(dates); } @@ -794,7 +786,6 @@ public Instance copyInstance() { .setMetadata(metadata) .setTags(tags) .setNatureOfContentTermIds(natureOfContentTermIds) - .setPublicationPeriod(publicationPeriod) .setDates(dates); } @@ -831,11 +822,6 @@ public Instance removeIdentifier(final String identifierTypeId, final String val return copyInstance().setIdentifiers(newIdentifiers); } - public Instance setPublicationPeriod(PublicationPeriod period) { - this.publicationPeriod = period; - return this; - } - @Override public String toString() { return String.format("Instance ID: %s, HRID: %s, Title: %s", id, hrid, title); diff --git a/src/main/java/org/folio/inventory/domain/instances/PublicationPeriod.java b/src/main/java/org/folio/inventory/domain/instances/PublicationPeriod.java deleted file mode 100644 index f09044917..000000000 --- a/src/main/java/org/folio/inventory/domain/instances/PublicationPeriod.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.folio.inventory.domain.instances; - -import static org.apache.commons.lang3.ObjectUtils.anyNotNull; -import static org.folio.inventory.support.JsonHelper.includeIfPresent; - -import io.vertx.core.json.JsonObject; - -public class PublicationPeriod { - private final Integer start; - private final Integer end; - - public PublicationPeriod(Integer start, Integer end) { - this.start = start; - this.end = end; - } - - public Integer getStart() { - return start; - } - - public Integer getEnd() { - return end; - } - - public static JsonObject publicationPeriodToJson(PublicationPeriod period) { - if (period == null || (period.getStart() == null && period.getEnd() == null)) { - return null; - } - - var json = new JsonObject(); - includeIfPresent(json, "start", period.getStart()); - includeIfPresent(json, "end", period.getEnd()); - - return json; - } - - public static PublicationPeriod publicationPeriodFromJson(JsonObject pubPeriodJson) { - if (pubPeriodJson == null) { - return null; - } - - var start = pubPeriodJson.getInteger("start"); - var end = pubPeriodJson.getInteger("end"); - - return anyNotNull(start, end) ? new PublicationPeriod(start, end) : null; - } -} diff --git a/src/main/java/org/folio/inventory/services/InventoryKafkaTopicService.java b/src/main/java/org/folio/inventory/services/InventoryKafkaTopicService.java index 60458fb2e..4afbd8e0c 100644 --- a/src/main/java/org/folio/inventory/services/InventoryKafkaTopicService.java +++ b/src/main/java/org/folio/inventory/services/InventoryKafkaTopicService.java @@ -20,6 +20,7 @@ import static org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MATCHED; import static org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_MODIFIED; import static org.folio.DataImportEventTypes.DI_SRS_MARC_BIB_RECORD_NOT_MATCHED; +import static org.folio.inventory.InstanceIngressConsumerVerticle.INSTANCE_INGRESS_TOPIC; import org.folio.kafka.services.KafkaTopic; @@ -45,7 +46,8 @@ public KafkaTopic[] createTopicObjects() { new InventoryKafkaTopic(DI_INVENTORY_HOLDINGS_CREATED_READY_FOR_POST_PROCESSING.value(), holdingCreatedReadyForPostProcessingPartitions()), new InventoryKafkaTopic(DI_INVENTORY_AUTHORITY_CREATED_READY_FOR_POST_PROCESSING.value(), authorityCreatedReadyForPostProcessingPartitions()), new InventoryKafkaTopic(DI_INVENTORY_AUTHORITY_UPDATED_READY_FOR_POST_PROCESSING.value(), authorityUpdatedReadyForPostProcessingPartitions()), - new InventoryKafkaTopic(DI_SRS_MARC_BIB_RECORD_MODIFIED.value(), marcBibRecordModifiedPartitions()) + new InventoryKafkaTopic(DI_SRS_MARC_BIB_RECORD_MODIFIED.value(), marcBibRecordModifiedPartitions()), + new InventoryKafkaTopic(INSTANCE_INGRESS_TOPIC, instanceIngressPartitions()) }; } @@ -128,4 +130,8 @@ private Integer marcBibRecordModifiedPartitions() { return Integer.valueOf(firstNonBlank(System.getenv( "DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS"), "1")); } + + private Integer instanceIngressPartitions() { + return Integer.valueOf(firstNonBlank(System.getenv("INVENTORY_INSTANCE_INGRESS_PARTITIONS"), "1")); + } } diff --git a/src/test/java/api/InstancesApiExamples.java b/src/test/java/api/InstancesApiExamples.java index fd41b36ea..457ab9894 100644 --- a/src/test/java/api/InstancesApiExamples.java +++ b/src/test/java/api/InstancesApiExamples.java @@ -18,10 +18,8 @@ import static org.folio.inventory.domain.instances.Dates.datesToJson; import static org.folio.inventory.domain.instances.Instance.DATES_KEY; import static org.folio.inventory.domain.instances.Instance.PRECEDING_TITLES_KEY; -import static org.folio.inventory.domain.instances.Instance.PUBLICATION_PERIOD_KEY; import static org.folio.inventory.domain.instances.Instance.TAGS_KEY; import static org.folio.inventory.domain.instances.Instance.TAG_LIST_KEY; -import static org.folio.inventory.domain.instances.PublicationPeriod.publicationPeriodToJson; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; @@ -46,7 +44,6 @@ import org.folio.inventory.config.InventoryConfiguration; import org.folio.inventory.config.InventoryConfigurationImpl; import org.folio.inventory.domain.instances.Dates; -import org.folio.inventory.domain.instances.PublicationPeriod; import org.folio.inventory.domain.instances.Subject; import org.folio.inventory.domain.instances.titles.PrecedingSucceedingTitle; import org.folio.inventory.support.JsonArrayHelper; @@ -102,7 +99,6 @@ public void canCreateInstanceWithoutAnIDAndHRID() .put("administrativeNotes", adminNote) .put("instanceTypeId", ApiTestSuite.getTextInstanceType()) .put(TAGS_KEY, new JsonObject().put(TAG_LIST_KEY, new JsonArray().add(tagNameOne))) - .put(PUBLICATION_PERIOD_KEY, publicationPeriodToJson(new PublicationPeriod(1000, 2000))) .put(DATES_KEY, datesToJson(new Dates(dateTypeId, date1, date2))) .put("natureOfContentTermIds", new JsonArray(asList( @@ -169,10 +165,6 @@ public void canCreateInstanceWithoutAnIDAndHRID() assertThat(createdInstance.getString("hrid"), notNullValue()); - var publicationPeriod = createdInstance.getJsonObject(PUBLICATION_PERIOD_KEY); - assertThat(publicationPeriod.getInteger("start"), is(1000)); - assertThat(publicationPeriod.getInteger("end"), is(2000)); - var dates = createdInstance.getJsonObject(DATES_KEY); assertThat(dates.getString(DATE_TYPE_ID_KEY), is(dateTypeId)); assertThat(dates.getString(DATE1_KEY), is(date1)); @@ -409,7 +401,7 @@ public void canUpdateAnExistingInstance() JsonObject smallAngryPlanet = smallAngryPlanet(id); smallAngryPlanet.put("natureOfContentTermIds", new JsonArray().add(ApiTestSuite.getBibliographyNatureOfContentTermId())); - smallAngryPlanet.put(PUBLICATION_PERIOD_KEY, publicationPeriodToJson(new PublicationPeriod(1000, 2000))); + smallAngryPlanet.put(DATES_KEY, datesToJson(new Dates(null, date1, date2))); JsonObject newInstance = createInstance(smallAngryPlanet); @@ -417,7 +409,6 @@ public void canUpdateAnExistingInstance() JsonObject updateInstanceRequest = newInstance.copy() .put("title", "The Long Way to a Small, Angry Planet") .put(TAGS_KEY, new JsonObject().put(TAG_LIST_KEY, new JsonArray().add(tagNameTwo))) - .put(PUBLICATION_PERIOD_KEY, publicationPeriodToJson(new PublicationPeriod(2000, 2012))) .put(DATES_KEY, datesToJson(new Dates(dateTypeId, date1, date2))) .put("natureOfContentTermIds", new JsonArray().add(ApiTestSuite.getAudiobookNatureOfContentTermId())) @@ -454,10 +445,6 @@ public void canUpdateAnExistingInstance() assertThat(natureOfContentTermIds.size(), is(1)); assertThat(natureOfContentTermIds.getString(0), is(ApiTestSuite.getAudiobookNatureOfContentTermId())); - var publicationPeriod = updatedInstance.getJsonObject(PUBLICATION_PERIOD_KEY); - assertThat(publicationPeriod.getInteger("start"), is(2000)); - assertThat(publicationPeriod.getInteger("end"), is(2012)); - var dates = updatedInstance.getJsonObject(DATES_KEY); assertThat(dates.getString(DATE_TYPE_ID_KEY), is(dateTypeId)); assertThat(dates.getString(DATE1_KEY), is(date1)); @@ -477,7 +464,6 @@ public void canUpdateAnExistingInstanceWithPrecedingSucceedingTitlesMarcSource() JsonObject smallAngryPlanet = smallAngryPlanet(id); smallAngryPlanet.put("natureOfContentTermIds", new JsonArray().add(ApiTestSuite.getBibliographyNatureOfContentTermId())); - smallAngryPlanet.put(PUBLICATION_PERIOD_KEY, publicationPeriodToJson(new PublicationPeriod(1000, 2000))); JsonArray precedingTitles = new JsonArray(); precedingTitles.add( @@ -506,7 +492,6 @@ public void canUpdateAnExistingInstanceWithPrecedingSucceedingTitlesMarcSource() JsonObject updateInstanceRequest = newInstance.copy() .put(TAGS_KEY, new JsonObject().put(TAG_LIST_KEY, new JsonArray().add(tagNameTwo))) - .put(PUBLICATION_PERIOD_KEY, publicationPeriodToJson(new PublicationPeriod(2000, 2012))) .put(PRECEDING_TITLES_KEY, precedingTitles) .put("natureOfContentTermIds", new JsonArray().add(ApiTestSuite.getAudiobookNatureOfContentTermId())); diff --git a/src/test/java/org/folio/inventory/domain/instances/PublicationPeriodTest.java b/src/test/java/org/folio/inventory/domain/instances/PublicationPeriodTest.java deleted file mode 100644 index 65c0a29aa..000000000 --- a/src/test/java/org/folio/inventory/domain/instances/PublicationPeriodTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.folio.inventory.domain.instances; - -import static org.folio.inventory.domain.instances.PublicationPeriod.publicationPeriodFromJson; -import static org.folio.inventory.domain.instances.PublicationPeriod.publicationPeriodToJson; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -import io.vertx.core.json.JsonObject; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import junitparams.converters.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(JUnitParamsRunner.class) -public class PublicationPeriodTest { - - @Parameters({ - "1, 2", - "null, 2", - "1, null", - }) - @Test - public void shouldCreatePublicationPeriodFromJson(@Nullable Integer start, @Nullable Integer end) { - var publicationPeriod = publicationPeriodFromJson(publicationPeriodJson(start, end)); - - assertThat(publicationPeriod.getStart(), is(start)); - assertThat(publicationPeriod.getEnd(), is(end)); - } - - @Test - public void shouldNotCreatePublicationPeriodFromJsonWhenJsonIsNull() { - assertThat(publicationPeriodFromJson(null), nullValue()); - } - - @Test - public void shouldNotCreatePublicationPeriodFromJsonWhenStartAndEndAreNull() { - assertThat(publicationPeriodFromJson(publicationPeriodJson(null, null)), nullValue()); - } - - @Parameters({ - "1, 2", - "null, 2", - "1, null", - }) - @Test - public void shouldConvertPublicationPeriodToJson(@Nullable Integer start, @Nullable Integer end) { - var json = publicationPeriodToJson(new PublicationPeriod(start, end)); - - assertThat(json.getInteger("start"), is(start)); - assertThat(json.getInteger("end"), is(end)); - } - - @Test - public void shouldNotConvertPublicationPeriodToJsonWhenItIsNull() { - assertThat(publicationPeriodToJson(null), nullValue()); - } - - @Test - public void shouldNotConvertPublicationPeriodToJsonWhenStartAndEndAreNull() { - assertThat(publicationPeriodToJson(new PublicationPeriod(null, null)), nullValue()); - } - - private JsonObject publicationPeriodJson(Integer start, Integer end) { - return new JsonObject().put("start", start).put("end", end); - } -} diff --git a/src/test/java/org/folio/inventory/service/KafkaAdminClientServiceTest.java b/src/test/java/org/folio/inventory/service/KafkaAdminClientServiceTest.java index 1df518f0c..2ffe14f64 100644 --- a/src/test/java/org/folio/inventory/service/KafkaAdminClientServiceTest.java +++ b/src/test/java/org/folio/inventory/service/KafkaAdminClientServiceTest.java @@ -68,7 +68,8 @@ public void setUp() { new InventoryKafkaTopic("DI_INVENTORY_HOLDINGS_CREATED_READY_FOR_POST_PROCESSING", 1), new InventoryKafkaTopic("DI_INVENTORY_AUTHORITY_CREATED_READY_FOR_POST_PROCESSING", 1), new InventoryKafkaTopic("DI_INVENTORY_AUTHORITY_UPDATED_READY_FOR_POST_PROCESSING", 1), - new InventoryKafkaTopic("DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS", 1) + new InventoryKafkaTopic("DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS", 1), + new InventoryKafkaTopic("inventory.instance_ingress", 1) }; @@ -174,6 +175,7 @@ private Future createKafkaTopicsAsync(KafkaAdminClient client) { "folio.Default.foo-tenant.DI_INVENTORY_HOLDINGS_CREATED_READY_FOR_POST_PROCESSING", "folio.Default.foo-tenant.DI_INVENTORY_AUTHORITY_CREATED_READY_FOR_POST_PROCESSING", "folio.Default.foo-tenant.DI_INVENTORY_AUTHORITY_UPDATED_READY_FOR_POST_PROCESSING", - "folio.Default.foo-tenant.DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS" + "folio.Default.foo-tenant.DI_SRS_MARC_BIB_RECORD_MODIFIED_PARTITIONS", + "folio.Default.foo-tenant.inventory.instance_ingress" ); }