Skip to content

Commit

Permalink
fix: change code id from int to string
Browse files Browse the repository at this point in the history
  • Loading branch information
hegeaal authored and jeffreiffers committed Feb 5, 2024
1 parent 7f0af21 commit 28b6c30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/no/digdir/catalog_admin_service/model/Code.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.digdir.catalog_admin_service.model

data class Code(
val id: Int,
val id: String,
val name: MultiLanguageTexts,
val parentID: Int?
val parentID: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CodeListService(
private val internalFieldsRepository: InternalFieldsRepository,
) {
private fun CodeList.subjectsURI() = "${applicationProperties.adminServiceUri}/$catalogId/concepts/subjects"
private fun createCodeURI(codeListUri: String, codeId: Int) = "$codeListUri#$codeId"
private fun createCodeURI(codeListUri: String, codeId: String) = "$codeListUri#$codeId"
private fun publisherURI(publisherId: String) = "https://data.brreg.no/enhetsregisteret/api/enheter/$publisherId"

fun getCodeLists(catalogId: String): CodeLists =
Expand Down Expand Up @@ -151,7 +151,7 @@ class CodeListService(
return this
}

private fun Resource.createCodeResource(code: Code, childrenIds: List<Int>): Resource {
private fun Resource.createCodeResource(code: Code, childrenIds: List<String>): Resource {
val codeURI = createCodeURI(uri, code.id)
return model.createResource(codeURI, SKOS.Concept)
.addProperty(DCTerms.identifier, model.createTypedLiteral(codeURI, XSDDateType.XSDanyURI))
Expand All @@ -168,12 +168,12 @@ class CodeListService(
return this
}

private fun Resource.addBroader(codeListUri: String, parentId: Int?): Resource {
private fun Resource.addBroader(codeListUri: String, parentId: String?): Resource {
if (parentId != null) addProperty(SKOS.broader, model.getResource(createCodeURI(codeListUri, parentId)))
return this
}

private fun Resource.addNarrower(codeListUri: String, childrenIds: List<Int>): Resource {
private fun Resource.addNarrower(codeListUri: String, childrenIds: List<String>): Resource {
childrenIds.forEach { addProperty(SKOS.narrower, model.getResource(createCodeURI(codeListUri, it))) }
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ val MONGO_ENV_VALUES: Map<String, String> = ImmutableMap.of(
)

val NAME: MultiLanguageTexts = MultiLanguageTexts(en = "codeName", nb = null, nn = null)
val CODE: Code = Code(id = 555, name = NAME, parentID = null)
val CODE: Code = Code(id = "555", name = NAME, parentID = null)
val CODES: List<Code> = listOf(CODE)
val CODE_LIST_0 =
CodeList(id = "123", name = "name", description = "description", codes = CODES, catalogId = "910244132")
val CODES_1 = listOf(
Code(1, MultiLanguageTexts("nb 1", "nn 1", "en 1"), null),
Code(2, MultiLanguageTexts("nb 2", "nn 2", "en 2"), 1),
Code(3, MultiLanguageTexts("nb 3", "nn 3", null), 1)
Code("1", MultiLanguageTexts("nb 1", "nn 1", "en 1"), null),
Code("2", MultiLanguageTexts("nb 2", "nn 2", "en 2"), "1"),
Code("3", MultiLanguageTexts("nb 3", "nn 3", null), "1")
)
val CODE_LIST_1 = CodeList(id = "321", name = "code list 1", description = "description of code list 1", codes = CODES_1, catalogId = "123456789")
val CODE_LIST_2 = CodeList(id = "456", name = "code list 2", description = "description of code list 2", codes = CODES_1, catalogId = "910244132")
Expand Down

0 comments on commit 28b6c30

Please sign in to comment.