Skip to content

Commit

Permalink
Remove manipulations with PublicationPeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanChernetskyi committed Oct 9, 2024
1 parent adcb9bc commit dcc29fd
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 145 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 20.2.0 2023-03-20
* Inventory cannot process Holdings with virtual fields ([MODINV-941](https://issues.folio.org/browse/MODINV-941))
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/org/folio/inventory/domain/instances/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -119,7 +116,6 @@ public class Instance {
private Metadata metadata = null;
private List<String> tags;
private List<String> natureOfContentTermIds = new ArrayList<>();
private PublicationPeriod publicationPeriod;
private Dates dates;

protected static final String INVENTORY_PATH = "/inventory";
Expand Down Expand Up @@ -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)));
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -759,7 +752,6 @@ public Instance copyWithNewId(String newId) {
.setMetadata(metadata)
.setTags(tags)
.setNatureOfContentTermIds(natureOfContentTermIds)
.setPublicationPeriod(publicationPeriod)
.setDates(dates);
}

Expand Down Expand Up @@ -794,7 +786,6 @@ public Instance copyInstance() {
.setMetadata(metadata)
.setTags(tags)
.setNatureOfContentTermIds(natureOfContentTermIds)
.setPublicationPeriod(publicationPeriod)
.setDates(dates);
}

Expand Down Expand Up @@ -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);
Expand Down

This file was deleted.

17 changes: 1 addition & 16 deletions src/test/java/api/InstancesApiExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -409,15 +401,14 @@ 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);

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()))
Expand Down Expand Up @@ -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));
Expand All @@ -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(
Expand Down Expand Up @@ -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()));
Expand Down

This file was deleted.

0 comments on commit dcc29fd

Please sign in to comment.