From 1911406d91fd4b1b1d1a0ba32f154a73f9e11f9f Mon Sep 17 00:00:00 2001 From: Hknots Date: Fri, 13 Sep 2024 20:04:48 +0200 Subject: [PATCH] move packages & add components controller --- .../fintlabs/metamodel/ComponentController.kt | 21 +++++++++++++++++++ .../fintlabs/metamodel/ReflectionService.kt | 5 +++-- .../metamodel/{ => metadata}/MetadataCache.kt | 6 +++--- .../{ => metadata}/MetadataController.kt | 4 ++-- .../model/FintRelationMetadata.kt | 2 +- .../{ => metadata}/model/Metadata.kt | 2 +- 6 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/no/fintlabs/metamodel/ComponentController.kt rename src/main/kotlin/no/fintlabs/metamodel/{ => metadata}/MetadataCache.kt (88%) rename src/main/kotlin/no/fintlabs/metamodel/{ => metadata}/MetadataController.kt (95%) rename src/main/kotlin/no/fintlabs/metamodel/{ => metadata}/model/FintRelationMetadata.kt (79%) rename src/main/kotlin/no/fintlabs/metamodel/{ => metadata}/model/Metadata.kt (87%) diff --git a/src/main/kotlin/no/fintlabs/metamodel/ComponentController.kt b/src/main/kotlin/no/fintlabs/metamodel/ComponentController.kt new file mode 100644 index 0000000..8c9c920 --- /dev/null +++ b/src/main/kotlin/no/fintlabs/metamodel/ComponentController.kt @@ -0,0 +1,21 @@ +package no.fintlabs.metamodel + +import no.fintlabs.metamodel.metadata.MetadataCache +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/components") +class ComponentController(val metadataCache: MetadataCache) { + + @GetMapping + fun getComponents(): Set { + val uniqueDomainPackages = metadataCache.domainPackageCache.keys + .map { "${it.first}.${it.second}" } + .toSet() + + return uniqueDomainPackages + } + +} \ No newline at end of file diff --git a/src/main/kotlin/no/fintlabs/metamodel/ReflectionService.kt b/src/main/kotlin/no/fintlabs/metamodel/ReflectionService.kt index 0158eb4..dde9cbc 100644 --- a/src/main/kotlin/no/fintlabs/metamodel/ReflectionService.kt +++ b/src/main/kotlin/no/fintlabs/metamodel/ReflectionService.kt @@ -2,8 +2,9 @@ package no.fintlabs.metamodel import jakarta.annotation.PostConstruct import no.fint.model.FintModelObject -import no.fintlabs.metamodel.model.FintRelationMetadata -import no.fintlabs.metamodel.model.Metadata +import no.fintlabs.metamodel.metadata.MetadataCache +import no.fintlabs.metamodel.metadata.model.FintRelationMetadata +import no.fintlabs.metamodel.metadata.model.Metadata import org.reflections.Reflections import org.springframework.stereotype.Service import java.util.stream.Collectors diff --git a/src/main/kotlin/no/fintlabs/metamodel/MetadataCache.kt b/src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataCache.kt similarity index 88% rename from src/main/kotlin/no/fintlabs/metamodel/MetadataCache.kt rename to src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataCache.kt index dde6116..6987d6e 100644 --- a/src/main/kotlin/no/fintlabs/metamodel/MetadataCache.kt +++ b/src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataCache.kt @@ -1,13 +1,13 @@ -package no.fintlabs.metamodel +package no.fintlabs.metamodel.metadata -import no.fintlabs.metamodel.model.Metadata +import no.fintlabs.metamodel.metadata.model.Metadata import org.springframework.stereotype.Service @Service class MetadataCache { private val domainCache: MutableMap> = mutableMapOf() - private val domainPackageCache: MutableMap, List> = mutableMapOf() + val domainPackageCache: MutableMap, List> = mutableMapOf() private val resourceCache: MutableMap, Metadata> = mutableMapOf() val metamodels: MutableList = mutableListOf() diff --git a/src/main/kotlin/no/fintlabs/metamodel/MetadataController.kt b/src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataController.kt similarity index 95% rename from src/main/kotlin/no/fintlabs/metamodel/MetadataController.kt rename to src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataController.kt index 0d537d8..73d5c26 100644 --- a/src/main/kotlin/no/fintlabs/metamodel/MetadataController.kt +++ b/src/main/kotlin/no/fintlabs/metamodel/metadata/MetadataController.kt @@ -1,6 +1,6 @@ -package no.fintlabs.metamodel +package no.fintlabs.metamodel.metadata -import no.fintlabs.metamodel.model.Metadata +import no.fintlabs.metamodel.metadata.model.Metadata import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/src/main/kotlin/no/fintlabs/metamodel/model/FintRelationMetadata.kt b/src/main/kotlin/no/fintlabs/metamodel/metadata/model/FintRelationMetadata.kt similarity index 79% rename from src/main/kotlin/no/fintlabs/metamodel/model/FintRelationMetadata.kt rename to src/main/kotlin/no/fintlabs/metamodel/metadata/model/FintRelationMetadata.kt index e15d56a..fce5153 100644 --- a/src/main/kotlin/no/fintlabs/metamodel/model/FintRelationMetadata.kt +++ b/src/main/kotlin/no/fintlabs/metamodel/metadata/model/FintRelationMetadata.kt @@ -1,4 +1,4 @@ -package no.fintlabs.metamodel.model +package no.fintlabs.metamodel.metadata.model import no.fint.model.FintMultiplicity diff --git a/src/main/kotlin/no/fintlabs/metamodel/model/Metadata.kt b/src/main/kotlin/no/fintlabs/metamodel/metadata/model/Metadata.kt similarity index 87% rename from src/main/kotlin/no/fintlabs/metamodel/model/Metadata.kt rename to src/main/kotlin/no/fintlabs/metamodel/metadata/model/Metadata.kt index ca5c51a..6808511 100644 --- a/src/main/kotlin/no/fintlabs/metamodel/model/Metadata.kt +++ b/src/main/kotlin/no/fintlabs/metamodel/metadata/model/Metadata.kt @@ -1,4 +1,4 @@ -package no.fintlabs.metamodel.model +package no.fintlabs.metamodel.metadata.model import com.fasterxml.jackson.annotation.JsonInclude