Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: other changes that was not included in Bikube (TT-1691) #89

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class ItemDto (
@SerialName("object_number")
val objectNumber: String,

@SerialName("title")
val title: String? = null,

@SerialName("format")
val format: String,

Expand Down Expand Up @@ -76,11 +73,10 @@ fun createNewspaperItemDto(
return ItemDto(
priRef = id,
objectNumber = "TE-$id",
title = item.name,
format = if (item.digital == true) CollectionsFormat.DIGITAL.value else CollectionsFormat.PHYSICAL.value,
recordType = CollectionsRecordType.ITEM.value,
inputName = item.username,
inputNotes = "Registrert i Bikube",
inputNotes = "Registrert i Bikube API",
inputSource = "texts",
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun createContainerDto(
inputName = username,
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
inputNotes = "Registrert i Bikube",
inputNotes = "Registrert i Bikube API",
description = null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun createManifestationDto(
recordType = CollectionsRecordType.MANIFESTATION.value,
date = date.toString(),
inputName = username,
inputNotes = "Registrert i Bikube",
inputNotes = "Registrert i Bikube API",
inputSource = "texts",
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ fun createNameRecordDtoFromString(
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
inputName = username,
inputNotes = "Registrert i Bikube"
inputNotes = "Registrert i Bikube API"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ fun createTermRecordDtoFromString(
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
inputName = username,
inputNotes = "Registrert i Bikube"
inputNotes = "Registrert i Bikube API"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class TitleDto(
@SerialName("object_number")
val objectNumber: String,

val title: String,
@SerialName("Title")
val titles: List<CollectionsTitleDto>?,

@SerialName("record_type")
val recordType: String?,
Expand All @@ -36,7 +37,7 @@ class TitleDto(
@SerialName("publisher")
val publisher: String? = null,

@SerialName("place_of_publication")
@SerialName("association.geographical_keyword")
val placeOfPublication: String? = null,

@SerialName("language")
Expand All @@ -61,11 +62,22 @@ class TitleDto(
val dataset: String? = null
)

@Serializable
class CollectionsTitleDto(
val title: String?,

@SerialName("title.type")
val titleType: String? = null,

@SerialName("title.notes")
val titleNotes: String? = null
)

fun createNewspaperTitleDto(id: String, title: TitleInputDto): TitleDto {
return TitleDto(
priRef = id,
objectNumber = "TE-$id",
title = title.name,
titles = listOf(CollectionsTitleDto(title.name, "Originaltittel")),
dateStart = title.startDate?.toString(),
dateEnd = title.endDate?.toString(),
publisher = title.publisher,
Expand All @@ -75,7 +87,7 @@ fun createNewspaperTitleDto(id: String, title: TitleInputDto): TitleDto {
medium = "Tekst",
subMedium = "Aviser",
inputName = title.username,
inputNotes = "Registrert i Bikube",
inputNotes = "Registrert i Bikube API",
inputSource = "texts",
inputDate = LocalDate.now().toString(),
inputTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ data class ItemInputDto(
val username: String,
val digital: Boolean? = false,
val urn: String? = null,
val name: String? = null,
val containerId: String? = null,
val notes: String? = null,
val number: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.util.function.Tuple2
import java.time.LocalDate
import java.time.format.DateTimeFormatter

@Service
class NewspaperService (
Expand Down Expand Up @@ -234,14 +233,6 @@ class NewspaperService (
}
}

fun createTitleString(item: ItemInputDto, title: String): String? {
return if (item.name.isNullOrEmpty() && item.digital == true) {
"$title ${item.date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd"))}"
} else {
item.name
}
}

fun createMissingItem(item: MissingPeriodicalItemDto): Mono<Item> {
return collectionsRepository.getSingleCollectionsModelWithoutChildren(item.titleCatalogueId)
.flatMap { title ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import no.nb.bikube.core.enum.MaterialType
class CollectionsModelMockData {
companion object {
const val TEST_USERNAME = "bikube-test"
const val INPUT_NOTES = "Registrert i Bikube"
const val INPUT_NOTES = "Registrert i Bikube API"
const val TEST_NOTES = "Tester notat og greier"
const val TEST_NUMBER = "123B"

Expand Down
2 changes: 0 additions & 2 deletions src/test/kotlin/no/nb/bikube/newspaper/NewspaperMockData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class NewspaperMockData {
username = TEST_USERNAME,
digital = true,
urn = "avisa_null_null_20200105_1_1_1",
name = "Avis A 2020.01.05",
containerId = null
)

Expand All @@ -103,7 +102,6 @@ class NewspaperMockData {
username = TEST_USERNAME,
digital = true,
urn = "avisa_null_null_20200101_1_1_1",
name = "Avis A 2020.01.01",
containerId = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import no.nb.bikube.catalogue.collections.CollectionsModelMockData.Companion.col
import no.nb.bikube.catalogue.collections.enum.CollectionsFormat
import no.nb.bikube.catalogue.collections.enum.CollectionsRecordType
import no.nb.bikube.catalogue.collections.exception.CollectionsException
import no.nb.bikube.catalogue.collections.exception.CollectionsItemNotFound
import no.nb.bikube.catalogue.collections.exception.CollectionsManifestationNotFound
import no.nb.bikube.catalogue.collections.exception.CollectionsTitleNotFound
import no.nb.bikube.catalogue.collections.model.*
Expand Down Expand Up @@ -118,7 +117,6 @@ class NewspaperServiceTest {
inputTime = mockedTime.format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
dataset = "texts",
partOfReference = newspaperItemMockB.catalogueId,
title = "Avis A 2020.01.05",
urn = urnMock.name
))

Expand All @@ -134,14 +132,13 @@ class NewspaperServiceTest {
inputDate = LocalDate.now().toString(),
inputTime = mockedTime.format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(),
dataset = "texts",
partOfReference = newspaperItemMockB.catalogueId,
title = "Avis A 2020.01.05"
partOfReference = newspaperItemMockB.catalogueId
))

private val titleEncodedDto = Json.encodeToString(TitleDto(
priRef = "1600000000",
objectNumber = "TE-1600000000",
title = newspaperTitleMockB.name!!,
titles = listOf(CollectionsTitleDto(newspaperTitleMockB.name!!, "Originaltittel")),
dateStart = newspaperTitleMockB.startDate.toString(),
dateEnd = newspaperTitleMockB.endDate.toString(),
publisher = newspaperTitleMockB.publisher,
Expand Down Expand Up @@ -711,29 +708,6 @@ class NewspaperServiceTest {
.verifyComplete()
}

@Test
fun `createTitleString should create a title with date if the title field on the item is null`() {
val item = newspaperInputDtoItemMockB.copy(name = null, date = LocalDate.parse("2024-02-28"))
val title = "Aftenposten"
val result = newspaperService.createTitleString(item, title)
Assertions.assertEquals("$title 2024.02.28", result)
}

@Test
fun `createTitleString should create a title with date if the title field on the item is empty`() {
val item = newspaperInputDtoItemMockB.copy(name = "", date = LocalDate.parse("2024-02-28"))
val title = "Aftenposten"
val result = newspaperService.createTitleString(item, title)
Assertions.assertEquals("$title 2024.02.28", result)
}

@Test
fun `createTitleString should return the title field of the item if it is not null or empty`() {
val item = newspaperInputDtoItemMockB.copy(name = "Some fancy title")
val result = newspaperService.createTitleString(item, "")
Assertions.assertEquals("Some fancy title", result)
}

@Test
fun `createMissingItem should return correctly mapped item`() {
every { collectionsRepository.getSingleCollectionsModelWithoutChildren(any()) } returns Mono.just(collectionsModelMockItemB)
Expand Down