In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

Commit be35681d authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add exception handle for CSV errors.

parent f5b97f8b
......@@ -16,13 +16,19 @@
package ch.memobase.model
import ch.memobase.helpers.LoadFile
import ch.memobase.helpers.ValidationError
import ch.memobase.transform.CarrierTypeNormalizer
import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException
data class NormalizeCarrierType(
val facets: String,
val labels: String
) {
fun generate(): CarrierTypeNormalizer {
return CarrierTypeNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
try {
return CarrierTypeNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
} catch (ex: CSVParseFormatException) {
throw ValidationError("[Genre] CSV Exception: ${ex.localizedMessage}.")
}
}
}
......@@ -16,13 +16,19 @@
package ch.memobase.model
import ch.memobase.helpers.LoadFile
import ch.memobase.helpers.ValidationError
import ch.memobase.transform.GenreNormalizer
import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException
data class NormalizeGenre(
val facets: String,
val labels: String
) {
fun generate(): GenreNormalizer {
return GenreNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
try {
return GenreNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
} catch (ex: CSVParseFormatException) {
throw ValidationError("[Genre] CSV Exception: ${ex.localizedMessage}.")
}
}
}
\ No newline at end of file
......@@ -16,13 +16,19 @@
package ch.memobase.model
import ch.memobase.helpers.LoadFile
import ch.memobase.helpers.ValidationError
import ch.memobase.transform.LanguagesNormalizer
import com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException
data class NormalizeLanguages(
val facets: String,
val labels: String
) {
fun generate(): LanguagesNormalizer {
return LanguagesNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
try {
return LanguagesNormalizer(LoadFile.readFacetList(facets), LoadFile.readLabelFile(labels))
} catch (ex: CSVParseFormatException) {
throw ValidationError("[Language] CSV Exception: ${ex.localizedMessage}.")
}
}
}
......@@ -73,4 +73,13 @@ class TestGlobalTransformLoader {
global.parse()
}
}
@Test
fun `test 5 - valid genre transform`() {
val file = "$basePath/5/transforms.yml"
val global = GlobalTransformsLoader(file)
assertThrows<GlobalTransformException> {
global.parse()
}
}
}
\ No newline at end of file
id,de,fr,it
facetten-wert-1,Facette 1 (DE),Facette 1 (FR),Facette 1 (IT)
\ No newline at end of file
wert,wikidata1,wikidata2,wikidata3,wikidata4,wikidata5,wikidata6,facette1,facette2,facette3,facette4,facette5,facette6
test",,,,,,,facetten-wert-1,,,,,
\ No newline at end of file
normalizeGenre:
facets: src/test/resources/global/tests/5/genres.csv
labels: src/test/resources/global/tests/5/genre_labels.csv
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment