Skip to content

Commit

Permalink
fix!: [#132] remove deprecated RIS fields number and typeOfWork
Browse files Browse the repository at this point in the history
  • Loading branch information
ursjoss committed Oct 7, 2023
1 parent 2916237 commit 37ae737
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 222 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog].

.Removed
- Java 11 compatibility (now requiring java platform 17 as minimum)
- {url-issues}132[#132] Remove deprecated RIS fields number and typeOfWork


[[v0.4.9]]
Expand Down
18 changes: 5 additions & 13 deletions subprojects/kris-core/api/kris-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ public data class RisRecord(
/** M1. Often used for Number. This is an alphanumeric field, thus suporting e.g. ranges or chars */
public var miscellaneous1: String? = null,

// TODO remove in #132
/** M1 - deprecated */
@Deprecated("Use miscellaneous1 (returning a nullable String) instead", ReplaceWith("miscellaneous1"))
public var number: Long? = null,

/**
* M2. This is an alphanumeric field and there is no practical limit to the length of this field.
*/
Expand All @@ -186,11 +181,6 @@ public data class RisRecord(
*/
public var miscellaneous3: String? = null,

// TODO remove in #132
/** M3 - deprecated */
@Deprecated("Use miscellaneous3 instead", ReplaceWith("miscellaneous3"))
public var typeOfWork: String? = null,

/** N1 */
public var notes: String? = null,

Expand Down Expand Up @@ -348,12 +338,8 @@ public data class RisRecord(
private var label: String? = null
private var websiteLink: String? = null
private var miscellaneous1: String? = null
// TODO remove in #132
private var number: Long? = null
private var miscellaneous2: String? = null
private var miscellaneous3: String? = null
// TODO remove in #132
private var typeOfWork: String? = null
private var notes: String? = null
private var abstr2: String? = null
private var numberOfVolumes: String? = null
Expand Down Expand Up @@ -473,14 +459,8 @@ public data class RisRecord(
public fun label(label: String?): Builder = apply { this.label = label }
public fun websiteLink(websiteLink: String?): Builder = apply { this.websiteLink = websiteLink }
public fun miscellaneous1(miscellaneous1: String?): Builder = apply { this.miscellaneous1 = miscellaneous1 }

@Deprecated("use miscellaneous1(number.toString()) instead", ReplaceWith("miscellaneous1(number.toString())"))
public fun number(number: Long?): Builder = apply { this.number = number }
public fun miscellaneous2(miscellaneous2: String?): Builder = apply { this.miscellaneous2 = miscellaneous2 }
public fun miscellaneous3(miscellaneous3: String?): Builder = apply { this.miscellaneous3 = miscellaneous3 }

@Deprecated("use miscellaneous3(String) instead", ReplaceWith("miscellaneous3(typeOfWork)"))
public fun typeOfWork(typeOfWork: String?): Builder = apply { this.typeOfWork = typeOfWork }
public fun notes(notes: String?): Builder = apply { this.notes = notes }
public fun abstr2(abstr2: String?): Builder = apply { this.abstr2 = abstr2 }
public fun numberOfVolumes(numberOfVolumes: String?): Builder = apply { this.numberOfVolumes = numberOfVolumes }
Expand Down Expand Up @@ -568,10 +548,8 @@ public data class RisRecord(
label,
websiteLink,
miscellaneous1,
number,
miscellaneous2,
miscellaneous3,
typeOfWork,
notes,
abstr2,
numberOfVolumes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import kotlin.reflect.KClass
* The class was composed from information available on
* [Wikipedia](https://en.wikipedia.org/wiki/RIS_(file_format)).
*/
@Suppress("SpellCheckingInspection")
public enum class RisTag(
internal val description: String,
internal val maxLength: Int? = null,
Expand Down Expand Up @@ -382,17 +381,10 @@ public enum class RisTag(
),

/** Miscellaneous 1. Often used for Number or Range of Numbers */
@Suppress("Deprecation")
M1(
description = "Miscellaneous 1 (often Number)",
setInto = { r, v ->
r.miscellaneous1 = v as String?
r.number = v?.toLongOrNull()
},
getFrom = { r: RisRecord ->
r.miscellaneous1.takeUnless { it.isNullOrBlank() }
?: r.number
},
setInto = { r, v -> r.miscellaneous1 = v as String? },
getFrom = { r: RisRecord -> r.miscellaneous1 },
kClass = String::class
),

Expand All @@ -404,17 +396,10 @@ public enum class RisTag(
),

/** Miscellaneous 3. Often used for Type of Work */
@Suppress("Deprecation")
M3(
description = "Miscellaneous 3 (often Type of Work)",
setInto = { r, v ->
r.miscellaneous3 = v as String?
r.typeOfWork = v
},
getFrom = { r: RisRecord ->
r.miscellaneous3.takeUnless { it.isNullOrBlank() }
?: r.typeOfWork
}
setInto = { r, v -> r.miscellaneous3 = v as String? },
getFrom = { r: RisRecord -> r.miscellaneous3 }
),

/** Notes */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,44 +256,4 @@ void emptyRecord() {
assertThat(risRecord.getPrimaryDate()).isNull();
assertThat(risRecord.getAccessDate()).isNull();
}

@SuppressWarnings("deprecation")
@Test
public void givenRisRecordWithMisc1_providesMisc1ButNotNumber() {
RisRecord risRecord = new RisRecord.Builder()
.miscellaneous1("4es")
.build();
assertThat(risRecord.getMiscellaneous1()).isEqualTo("4es");
assertThat(risRecord.getNumber()).isNull();
}

@SuppressWarnings("deprecation")
@Test
public void givenRisRecordWithNumber_providesNumberButNotMisc1() {
RisRecord risRecord = new RisRecord.Builder()
.number(1234L)
.build();
assertThat(risRecord.getMiscellaneous1()).isNull();
assertThat(risRecord.getNumber()).isEqualTo(1234L);
}

@SuppressWarnings("deprecation")
@Test
public void givenRisRecordWithMisc3_providesMisc3ButNotTypeOfWork() {
RisRecord risRecord = new RisRecord.Builder()
.miscellaneous3("misc3")
.build();
assertThat(risRecord.getMiscellaneous3()).isEqualTo("misc3");
assertThat(risRecord.getTypeOfWork()).isNull();
}

@SuppressWarnings("deprecation")
@Test
public void givenRisRecordWithTypeOfWork_providesTypeOfWorkButNotMisc3() {
RisRecord risRecord = new RisRecord.Builder()
.typeOfWork("misc3")
.build();
assertThat(risRecord.getMiscellaneous3()).isNull();
assertThat(risRecord.getTypeOfWork()).isEqualTo("misc3");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class KRisUsageTest {

//@formatter:off
@SuppressWarnings("SpellCheckingInspection") private final List<String> risLines = List.of(
private final List<String> risLines = List.of(
"TY - JOUR",
"AU - Shannon, Claude E.",
"PY - 1948/07//",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldHaveSize
import org.amshove.kluent.shouldThrow

@Suppress("unused", "SpellCheckingInspection", "S1192")
@Suppress("SpellCheckingInspection", "S1192")
object KRisProcessingSpec : DescribeSpec({

describe("with RIS file as list of strings") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeNull
import org.amshove.kluent.shouldContainAll

@Suppress("unused")
object RisRecordSpec : DescribeSpec({

describe("no values specified") {
Expand Down Expand Up @@ -281,40 +280,6 @@ object RisRecordSpec : DescribeSpec({
assertSpecifiedValues(record)
}
}

@Suppress("DEPRECATION")
describe("Deprecated fields") {
describe("with RisRecord constructed with new properties") {
val record = RisRecord(miscellaneous1 = "1234", miscellaneous3 = "foo")
it("should return null as Number") {
record.number.shouldBeNull()
}
it("should return null as typeOfWork") {
record.typeOfWork.shouldBeNull()
}
it("should return '1234' as miscellaneous1") {
record.miscellaneous1 shouldBeEqualTo "1234"
}
it("should return 'foo'' as miscellaneous3") {
record.miscellaneous3 shouldBeEqualTo "foo"
}
}
describe("with RisRecord constructed with deprecated properties") {
val record = RisRecord(number = 1234L, typeOfWork = "foo")
it("should return 1234 as Number") {
record.number shouldBeEqualTo 1234L
}
it("should return 'foo' as typeOfWork") {
record.typeOfWork shouldBeEqualTo "foo"
}
it("should return null as miscellaneous1") {
record.miscellaneous1.shouldBeNull()
}
it("should return null as miscellaneous3") {
record.miscellaneous3.shouldBeNull()
}
}
}
})

@Suppress("LongMethod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.difty.kris.domain
import org.amshove.kluent.shouldContainAll
import org.junit.jupiter.api.Test

@Suppress("SpellCheckingInspection")
internal class RisTagTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeNull
import org.amshove.kluent.shouldHaveSize

/**
* Specification how to use KRis from kotlin
*/
@Suppress("SpellCheckingInspection", "unused")
/** Specification how to use KRis from kotlin */
object KRisUsageSpec : DescribeSpec({

describe("with list of strings representing two RIS records") {
Expand Down Expand Up @@ -159,86 +155,4 @@ object KRisUsageSpec : DescribeSpec({
KRis.risTagNames() shouldBeEqualTo risTagNames
}
}

@Suppress("DEPRECATION")
describe("deprecated RisRecord Properties") {
describe("importing from RIS") {
describe("given M1 with numeric value") {
val risLines: List<String> = listOf(
"M1 - 1234",
"ER - "
)
it("can be processed") {
val risRecords = risLines.toRisRecords()
risRecords.shouldHaveSize(1)
}
it("can retrieve it with new property miscellaneous1") {
val risRecords = risLines.toRisRecords()
risRecords.first().miscellaneous1 shouldBeEqualTo "1234"
}
it("can retrieve it with deprecated property number") {
val risRecords = risLines.toRisRecords()
risRecords.first().number shouldBeEqualTo 1234L
}
}
describe("given M1 with non-numeric value") {
val risLines: List<String> = listOf(
"M1 - 1234-5678",
"ER - "
)
it("can be processed") {
val risRecords = risLines.toRisRecords()
risRecords.shouldHaveSize(1)
}
it("can retrieve it with new property miscellaneous1") {
val risRecords = risLines.toRisRecords()
risRecords.first().miscellaneous1 shouldBeEqualTo "1234-5678"
}
it("can retrieve null with deprecated property number") {
val risRecords = risLines.toRisRecords()
risRecords.first().number.shouldBeNull()
}
}
describe("given M3") {
val risLines: List<String> = listOf(
"M3 - typeOfWork",
"ER - "
)
it("can be processed") {
val risRecords = risLines.toRisRecords()
risRecords.shouldHaveSize(1)
}
it("can retrieve it with new property miscellaneous3") {
val risRecords = risLines.toRisRecords()
risRecords.first().miscellaneous3 shouldBeEqualTo "typeOfWork"
}
it("can retrieve it with deprecated property typeOfWork") {
val risRecords = risLines.toRisRecords()
risRecords.first().typeOfWork shouldBeEqualTo "typeOfWork"
}
}
}
describe("exporting to RIS") {
describe("using new properties miscellaneous1 and miscellaneous 3") {
val risRecord1 = RisRecord(
miscellaneous1 = "1234-5678",
miscellaneous3 = "typeOfWork",
)
val risRecord2 = RisRecord(
number = 4567L,
typeOfWork = "tow",
)
it("should export both to M1 and M3") {
listOf(risRecord1, risRecord2).toRisLines().joinToString(separator = "") shouldBeEqualTo """M1 - 1234-5678
|M3 - typeOfWork
|ER -
|
|M1 - 4567
|M3 - tow
|ER -
|""".trimMargin()
}
}
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.withContext
import org.amshove.kluent.shouldHaveSize
import java.io.File

@Suppress("unused")
object KRisIoUsageExportSpec : DescribeSpec({

describe("exporting into file") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.amshove.kluent.shouldHaveSize
import java.io.File
import kotlin.streams.toList

@Suppress("unused")
object KRisIoUsageImportSpec : DescribeSpec({

describe("importing from file") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldHaveSize
import java.io.File

@Suppress("unused")
object KRisIoUsageSpec : DescribeSpec({

describe("importing from file") {
Expand Down

0 comments on commit 37ae737

Please sign in to comment.