diff --git a/src/main/kotlin/no/digdir/catalog_admin_service/model/Code.kt b/src/main/kotlin/no/digdir/catalog_admin_service/model/Code.kt index 8c5a8e8..2c64149 100644 --- a/src/main/kotlin/no/digdir/catalog_admin_service/model/Code.kt +++ b/src/main/kotlin/no/digdir/catalog_admin_service/model/Code.kt @@ -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? ) diff --git a/src/main/kotlin/no/digdir/catalog_admin_service/service/CodeListService.kt b/src/main/kotlin/no/digdir/catalog_admin_service/service/CodeListService.kt index 278ef4c..24d57c0 100644 --- a/src/main/kotlin/no/digdir/catalog_admin_service/service/CodeListService.kt +++ b/src/main/kotlin/no/digdir/catalog_admin_service/service/CodeListService.kt @@ -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 = @@ -151,7 +151,7 @@ class CodeListService( return this } - private fun Resource.createCodeResource(code: Code, childrenIds: List): Resource { + private fun Resource.createCodeResource(code: Code, childrenIds: List): Resource { val codeURI = createCodeURI(uri, code.id) return model.createResource(codeURI, SKOS.Concept) .addProperty(DCTerms.identifier, model.createTypedLiteral(codeURI, XSDDateType.XSDanyURI)) @@ -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): Resource { + private fun Resource.addNarrower(codeListUri: String, childrenIds: List): Resource { childrenIds.forEach { addProperty(SKOS.narrower, model.getResource(createCodeURI(codeListUri, it))) } return this } diff --git a/src/test/kotlin/no/digdir/catalog_admin_service/utils/TestData.kt b/src/test/kotlin/no/digdir/catalog_admin_service/utils/TestData.kt index 7f9acc9..4ff2568 100644 --- a/src/test/kotlin/no/digdir/catalog_admin_service/utils/TestData.kt +++ b/src/test/kotlin/no/digdir/catalog_admin_service/utils/TestData.kt @@ -33,14 +33,14 @@ val MONGO_ENV_VALUES: Map = 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 = 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")