Mapped Mime type names

This commit is contained in:
dankito 2024-12-04 22:06:58 +01:00
parent d4cfd38ae1
commit 0fee651114
2 changed files with 15 additions and 6 deletions

View File

@ -1,10 +1,10 @@
package net.codinux.invoicing.model.codes
enum class Mime(val code: String) {
application_pdf("application/pdf"),
image_png("image/png"),
image_jpeg("image/jpeg"),
text_csv("text/csv"),
application_vnd_openxmlformats_officedocument_spreadsheetml_sheet("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
application_vnd_oasis_opendocument_spreadsheet("application/vnd.oasis.opendocument.spreadsheet"),
PDF("application/pdf"),
PNG("image/png"),
JPEG("image/jpeg"),
CSV("text/csv"),
ExcelSpreadsheet("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
OpenDocumentSpreadsheet("application/vnd.oasis.opendocument.spreadsheet"),
}

View File

@ -137,6 +137,15 @@ class CodeGenerator {
}
private fun getEnumName(columns: List<Column>, row: List<Any?>): String {
// Mime types
val firstColumn = row[0]
if (firstColumn == "application/pdf") return "PDF"
else if (firstColumn == "image/png") return "PNG"
else if (firstColumn == "image/jpeg") return "JPEG"
else if (firstColumn == "text/csv") return "CSV"
else if (firstColumn == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") return "ExcelSpreadsheet"
else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet"
val column = if (columns.first().name == "Scheme ID") row[1] // ISO 6523 Scheme Identifier codes
else if (columns.first().name == "English Name") row[1] // Country codes
else if (columns.first().name == "Country") row[2] // Currency codes, but does not work yet due to duplicate Keys / Alpha3-Codes