Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Np 32875 remove migration code #351

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

group 'com.github.bibsysdev'

version '0.19.33'
version '0.20.0'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
import no.unit.nva.model.instancetypes.book.AcademicMonograph;
import no.unit.nva.model.instancetypes.book.BookAbstracts;
import no.unit.nva.model.instancetypes.book.BookAnthology;
import no.unit.nva.model.instancetypes.book.BookMonograph;
import no.unit.nva.model.instancetypes.book.Encyclopedia;
import no.unit.nva.model.instancetypes.book.ExhibitionCatalog;
import no.unit.nva.model.instancetypes.book.NonFictionMonograph;
import no.unit.nva.model.instancetypes.book.PopularScienceMonograph;
import no.unit.nva.model.instancetypes.book.Textbook;
import no.unit.nva.model.instancetypes.chapter.AcademicChapter;
import no.unit.nva.model.instancetypes.chapter.ChapterArticle;
import no.unit.nva.model.instancetypes.chapter.ChapterConferenceAbstract;
import no.unit.nva.model.instancetypes.chapter.ChapterInReport;
import no.unit.nva.model.instancetypes.chapter.EncyclopediaChapter;
Expand All @@ -44,7 +42,6 @@
import no.unit.nva.model.instancetypes.journal.CaseReport;
import no.unit.nva.model.instancetypes.journal.ConferenceAbstract;
import no.unit.nva.model.instancetypes.journal.FeatureArticle;
import no.unit.nva.model.instancetypes.journal.JournalArticle;
import no.unit.nva.model.instancetypes.journal.JournalCorrigendum;
import no.unit.nva.model.instancetypes.journal.JournalInterview;
import no.unit.nva.model.instancetypes.journal.JournalIssue;
Expand Down Expand Up @@ -78,7 +75,6 @@
@JsonSubTypes.Type(name = "FeatureArticle", value = FeatureArticle.class),
@JsonSubTypes.Type(name = "MovingPicture", value = MovingPicture.class),
@JsonSubTypes.Type(name = "PerformingArts", value = PerformingArts.class),
@JsonSubTypes.Type(name = "JournalArticle", value = JournalArticle.class),
@JsonSubTypes.Type(name = "AcademicArticle", value = AcademicArticle.class),
@JsonSubTypes.Type(name = "AcademicLiteratureReview", value = AcademicLiteratureReview.class),
@JsonSubTypes.Type(name = "CaseReport", value = CaseReport.class),
Expand All @@ -91,7 +87,6 @@
@JsonSubTypes.Type(name = "JournalLeader", value = JournalLeader.class),
@JsonSubTypes.Type(name = "JournalReview", value = JournalReview.class),
@JsonSubTypes.Type(name = "BookAbstracts", value = BookAbstracts.class),
@JsonSubTypes.Type(name = "BookMonograph", value = BookMonograph.class),
@JsonSubTypes.Type(name = "AcademicMonograph", value = AcademicMonograph.class),
@JsonSubTypes.Type(name = "PopularScienceMonograph", value = PopularScienceMonograph.class),
@JsonSubTypes.Type(name = "Encyclopedia", value = Encyclopedia.class),
Expand All @@ -108,7 +103,6 @@
@JsonSubTypes.Type(name = "ReportResearch", value = ReportResearch.class),
@JsonSubTypes.Type(name = "ReportWorkingPaper", value = ReportWorkingPaper.class),
@JsonSubTypes.Type(name = "ReportBookOfAbstract", value = ReportBookOfAbstract.class),
@JsonSubTypes.Type(name = "ChapterArticle", value = ChapterArticle.class),
@JsonSubTypes.Type(name = "AcademicChapter", value = AcademicChapter.class),
@JsonSubTypes.Type(name = "EncyclopediaChapter", value = EncyclopediaChapter.class),
@JsonSubTypes.Type(name = "ExhibitionCatalogChapter", value = ExhibitionCatalogChapter.class),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import no.unit.nva.model.contexttypes.PublishingHouse;
import no.unit.nva.model.contexttypes.UnconfirmedPublisher;
import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator;
import no.unit.nva.model.time.Instant;
import nva.commons.core.JacocoGenerated;

import java.util.Objects;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public class Broadcast implements MovingPictureOutput, UnconfirmedPublisherMigrator {
public class Broadcast implements MovingPictureOutput {

public static final String PUBLISHER_FIELD = "publisher";
public static final String DATE_FIELD = "date";
Expand All @@ -24,17 +22,7 @@ public class Broadcast implements MovingPictureOutput, UnconfirmedPublisherMigra
@JsonProperty(SEQUENCE_FIELD)
private final int sequence;

@Deprecated
@JsonCreator
public static Broadcast fromJson(@JsonProperty(PUBLISHER_FIELD) Object publisher,
@JsonProperty(DATE_FIELD) Instant date,
@JsonProperty(SEQUENCE_FIELD) int sequence) {
if (publisher instanceof String) {
return new Broadcast(new UnconfirmedPublisher((String) publisher), date, sequence);
}
return new Broadcast(UnconfirmedPublisherMigrator.toPublisher(publisher), date, sequence);
}

public Broadcast(@JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher,
@JsonProperty(DATE_FIELD) Instant date,
@JsonProperty(SEQUENCE_FIELD) int sequence) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Objects;
import no.unit.nva.model.contexttypes.PublishingHouse;
import no.unit.nva.model.contexttypes.UnconfirmedPublisher;
import no.unit.nva.model.contexttypes.place.UnconfirmedPlace;
import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator;
import no.unit.nva.model.time.Instant;
import nva.commons.core.JacocoGenerated;

import java.util.Objects;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public class OtherRelease implements MovingPictureOutput, UnconfirmedPublisherMigrator {
public class OtherRelease implements MovingPictureOutput {
public static final String DESCRIPTION_FIELD = "description";
public static final String PLACE_FIELD = "place";
public static final String PUBLISHER_FIELD = "publisher";
Expand All @@ -29,19 +28,7 @@ public class OtherRelease implements MovingPictureOutput, UnconfirmedPublisherMi
@JsonProperty(SEQUENCE_FIELD)
private final int sequence;

@Deprecated
@JsonCreator
public static OtherRelease fromJson(@JsonProperty(DESCRIPTION_FIELD) String description,
@JsonProperty(PLACE_FIELD) UnconfirmedPlace place,
@JsonProperty(PUBLISHER_FIELD) Object publisher,
@JsonProperty(DATE_FIELD) Instant date,
@JsonProperty(SEQUENCE_FIELD) int sequence) {
var publishingHouse = publisher instanceof String
? new UnconfirmedPublisher((String) publisher)
: UnconfirmedPublisherMigrator.toPublisher(publisher);
return new OtherRelease(description, place, publishingHouse, date, sequence);
}

public OtherRelease(@JsonProperty(DESCRIPTION_FIELD) String description,
@JsonProperty(PLACE_FIELD) UnconfirmedPlace place,
@JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package no.unit.nva.model.instancetypes.artistic.music;

import static no.unit.nva.model.util.SerializationUtils.nullListAsEmpty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.List;
import java.util.Objects;
import no.unit.nva.model.contexttypes.PublishingHouse;
import no.unit.nva.model.contexttypes.UnconfirmedPublisher;
import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator;
import nva.commons.core.JacocoGenerated;

import java.util.List;
import java.util.Objects;

import static no.unit.nva.model.util.SerializationUtils.nullListAsEmpty;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public class AudioVisualPublication implements MusicPerformanceManifestation, UnconfirmedPublisherMigrator {
public class AudioVisualPublication implements MusicPerformanceManifestation {

public static final String MEDIA_TYPE_FIELD = "mediaType";
public static final String PUBLISHER_FIELD = "publisher";
Expand All @@ -28,18 +28,7 @@ public class AudioVisualPublication implements MusicPerformanceManifestation, Un
@JsonProperty(TRACK_LIST_FIELD)
private final List<MusicTrack> trackList;

@Deprecated
@JsonCreator
public static AudioVisualPublication fromJson(@JsonProperty(MEDIA_TYPE_FIELD) MusicMediaType mediaType,
@JsonProperty(PUBLISHER_FIELD) Object publisher,
@JsonProperty(CATALOGUE_NUMBER_FIELD) String catalogueNumber,
@JsonProperty(TRACK_LIST_FIELD) List<MusicTrack> trackList) {
var publishingHouse = publisher instanceof String
? new UnconfirmedPublisher((String) publisher)
: UnconfirmedPublisherMigrator.toPublisher(publisher);
return new AudioVisualPublication(mediaType, publishingHouse, catalogueNumber, trackList);
}

public AudioVisualPublication(@JsonProperty(MEDIA_TYPE_FIELD) MusicMediaType mediaType,
@JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher,
@JsonProperty(CATALOGUE_NUMBER_FIELD) String catalogueNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import java.util.Objects;
import no.unit.nva.model.contexttypes.PublishingHouse;
import no.unit.nva.model.contexttypes.UnconfirmedPublisher;
import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator;
import nva.commons.core.JacocoGenerated;

import java.util.Objects;

@JsonTypeInfo(use = Id.NAME, property = "type")
public class MusicScore implements MusicPerformanceManifestation, UnconfirmedPublisherMigrator {
public class MusicScore implements MusicPerformanceManifestation {

public static final String ENSEMBLE_FIELD = "ensemble";
public static final String MOVEMENTS_FIELD = "movements";
Expand All @@ -34,25 +33,12 @@ public class MusicScore implements MusicPerformanceManifestation, UnconfirmedPub
private final Isrc isrc;

@JsonCreator
public static MusicScore fromJson(@JsonProperty(ENSEMBLE_FIELD) String ensemble,
@JsonProperty(MOVEMENTS_FIELD) String movements,
@JsonProperty(EXTENT_FIELD) String extent,
@JsonProperty(PUBLISHER_FIELD) Object publisher,
@JsonProperty(ISMN_FIELD) Ismn ismn,
@JsonProperty(ISRC_FIELD) Isrc isrc) {
var publishingHouse = publisher instanceof String
? new UnconfirmedPublisher((String) publisher)
: UnconfirmedPublisherMigrator.toPublisher(publisher);
return new MusicScore(ensemble, movements, extent, publishingHouse, ismn, isrc);
}

public MusicScore(@JsonProperty(ENSEMBLE_FIELD) String ensemble,
@JsonProperty(MOVEMENTS_FIELD) String movements,
@JsonProperty(EXTENT_FIELD) String extent,
@JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher,
@JsonProperty(ISMN_FIELD) Ismn ismn,
@JsonProperty(ISRC_FIELD) Isrc isrc) {

this.ensemble = ensemble;
this.movements = movements;
this.extent = extent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,20 @@
package no.unit.nva.model.instancetypes.book;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import no.unit.nva.model.instancetypes.PublicationInstance;
import no.unit.nva.model.pages.MonographPages;
import no.unit.nva.model.instancetypes.PublicationInstance;
import nva.commons.core.JacocoGenerated;

import java.util.Objects;

import static java.util.Objects.isNull;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public class BookMonograph implements PublicationInstance<MonographPages> {

public static final String PAGES_FIELD = "pages";
private static final String CONTENT_TYPE_FIELD = "contentType";
private final MonographPages pages;

public BookMonograph(@JsonProperty(PAGES_FIELD) MonographPages pages) {
public BookMonograph(MonographPages pages) {
this.pages = pages;
}

@JsonCreator
public static BookMonograph fromJson(@JsonProperty(PAGES_FIELD) MonographPages pages,
@JsonProperty(CONTENT_TYPE_FIELD) BookMonographContentType contentType) {
if (BookMonographContentType.ACADEMIC_MONOGRAPH.equals(contentType)) {
return new AcademicMonograph(pages);
} else if (BookMonographContentType.ENCYCLOPEDIA.equals(contentType)) {
return new Encyclopedia(pages);
} else if (BookMonographContentType.EXHIBITION_CATALOG.equals(contentType)) {
return new ExhibitionCatalog(pages);
} else if (BookMonographContentType.NON_FICTION_MONOGRAPH.equals(contentType)) {
return new NonFictionMonograph(pages);
} else if (BookMonographContentType.POPULAR_SCIENCE_MONOGRAPH.equals(contentType)) {
return new PopularScienceMonograph(pages);
} else if (BookMonographContentType.TEXTBOOK.equals(contentType)) {
return new Textbook(pages);
} else if (isNull(contentType)) {
return new AcademicMonograph(pages);
} else {
throw new UnsupportedOperationException("The Book Monograph subtype is unknown");
}
}

@Override
public MonographPages getPages() {
return pages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +0,0 @@
package no.unit.nva.model.instancetypes.book;

import static java.lang.String.format;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
* Content Type options for "Monograph" subtype when the creator chooses the Resource type as "Book" while doing the
* registration.
*/
@Deprecated
public enum BookMonographContentType {
ACADEMIC_MONOGRAPH("AcademicMonograph", "Academic Monograph"),
NON_FICTION_MONOGRAPH("NonFictionMonograph", "Non-fiction Monograph"),
POPULAR_SCIENCE_MONOGRAPH("PopularScienceMonograph", "Popular Science Monograph"),
TEXTBOOK("Textbook", "Textbook"),
ENCYCLOPEDIA("Encyclopedia", "Encyclopedia"),
/**
* Enum Type Exhibition catalogue represents: A book published for a specific art or museum exhibition. Contains a
* list of exhibits at the exhibition.
*/
EXHIBITION_CATALOG("ExhibitionCatalog", "Exhibition catalog");

public static final String ERROR_MESSAGE_TEMPLATE = "%s not a valid BookMonographContentType, expected one of: %s";
public static final String DELIMITER = ", ";

private final String value;
private final String deprecatedValue;

BookMonographContentType(String value, String deprecatedValue) {
this.value = value;
this.deprecatedValue = deprecatedValue;
}

@JsonCreator
public static BookMonographContentType lookup(String value) {
return stream(values())
.filter(nameType -> equalsCurrentOrDeprecatedValue(value, nameType))
.findAny()
.orElseThrow(() -> new IllegalArgumentException(createErrorMessage(value)));
}

@JsonValue
public String getValue() {
return value;
}

private String getDeprecatedValue() {
return deprecatedValue;
}

private static boolean equalsCurrentOrDeprecatedValue(String value, BookMonographContentType nameType) {
return nameType.getValue().equalsIgnoreCase(value)
|| nameType.getDeprecatedValue().equalsIgnoreCase(value);
}

private static String createErrorMessage(String value) {
return format(ERROR_MESSAGE_TEMPLATE, value, stream(BookMonographContentType.values())
.map(BookMonographContentType::toString).collect(joining(DELIMITER)));
}
}
Loading