diff --git a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt index 05336fa470a90d5d1fa204dab936b1c8859b504b..b62b6c0a500946bf308f88328a8a4296272830d5 100644 --- a/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt +++ b/app/backend/src/main/kotlin/de/fraunhofer/iem/app/toolRun/service/ToolRunService.kt @@ -81,14 +81,11 @@ class ToolRunService( val repoDetailsDto = repositoryDetailsService.getRepositoryDetails(projectId) val rawValueRepoKpis = VcsAdapter.transformDataToKpi(repoDetailsDto) + .filterIsInstance<AdapterResult.Success>() + .map { it.rawValueKpi } - val result = if (rawValueRepoKpis is AdapterResult.Success) { - listOf(rawValueRepoKpis.rawValueKpi) - } else { - listOf() - } - Pair(repositoryDetailsService.getToolDto(), result) + Pair(repositoryDetailsService.getToolDto(), rawValueRepoKpis) }, async { diff --git a/kpi-calculator/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/KpiAdapter.kt b/kpi-calculator/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/KpiAdapter.kt index ab93079a772342ea01d4fdee6923686cb7cbd843..2ae04b8d4ec83105309dd292d5275342bcd2bd08 100644 --- a/kpi-calculator/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/KpiAdapter.kt +++ b/kpi-calculator/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/KpiAdapter.kt @@ -5,5 +5,5 @@ import de.fraunhofer.iem.kpiCalculator.model.adapter.AdapterResult interface KpiAdapter<T> { fun transformDataToKpi(data: List<T>): List<AdapterResult> - fun transformDataToKpi(data: T): AdapterResult = transformDataToKpi(listOf(data)).first() + fun transformDataToKpi(data: T): List<AdapterResult> = transformDataToKpi(listOf(data)) } diff --git a/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/KpiCalculator.kt b/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/KpiCalculator.kt index 8ae82a12fcb80cbdfe37bd96f1f8187b28060a78..7d34a34a0f390067c0456678b75e38a7454c5a68 100644 --- a/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/KpiCalculator.kt +++ b/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/KpiCalculator.kt @@ -61,7 +61,7 @@ object KpiCalculator { depthFirstTraversal( node = calculationRoot ) { currentNode -> - val correspondingRawValue = kindToValues[currentNode.kind] + val correspondingRawValue = kindToValues[currentNode.kpiId] val parent = currentNode.parent if (!correspondingRawValue.isNullOrEmpty() && parent != null) { @@ -77,7 +77,7 @@ object KpiCalculator { val rawValueNodes = correspondingRawValue.map { rawValue -> val newNode = KpiCalculationNode( - kind = rawValue.kind, + kpiId = rawValue.kind, calculationStrategy = KpiStrategyId.RAW_VALUE_STRATEGY, parent = parent ) diff --git a/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/hierarchy/KpiCalculationNode.kt b/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/hierarchy/KpiCalculationNode.kt index 252bfbfe6c9c9e272f89f6030e7234ea66e2b11a..f4d3a8c8fa3ed66b998053bc7b81a999dd9d0102 100644 --- a/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/hierarchy/KpiCalculationNode.kt +++ b/kpi-calculator/core/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/core/hierarchy/KpiCalculationNode.kt @@ -12,7 +12,7 @@ import de.fraunhofer.iem.kpiCalculator.model.kpi.hierarchy.KpiResultNode internal class KpiCalculationNode( - val kind: KpiId, + val kpiId: KpiId, val calculationStrategy: KpiStrategyId, val parent: KpiCalculationNode? ) { @@ -96,7 +96,7 @@ internal class KpiCalculationNode( companion object { fun to(node: KpiCalculationNode): KpiResultNode { return KpiResultNode( - kpiId = node.kind, + kpiId = node.kpiId, strategyType = node.calculationStrategy, kpiResult = node.result, children = node.hierarchyEdges.map { @@ -116,7 +116,7 @@ internal class KpiCalculationNode( private fun from(node: KpiNode, parent: KpiCalculationNode? = null): KpiCalculationNode { val calcNode = - KpiCalculationNode(kind = node.kpiId, parent = parent, calculationStrategy = node.strategyType) + KpiCalculationNode(kpiId = node.kpiId, parent = parent, calculationStrategy = node.strategyType) val children = node.children.map { child -> KpiHierarchyEdge( to = from(child.target, calcNode), diff --git a/kpi-calculator/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/kpi/hierarchy/KpiHierarchy.kt b/kpi-calculator/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/kpi/hierarchy/KpiHierarchy.kt index 0505b5f1ff3c0cd4f591f43e924a110e24819f34..efc9d7dd862847137e4203d071be9d40ec8a3697 100644 --- a/kpi-calculator/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/kpi/hierarchy/KpiHierarchy.kt +++ b/kpi-calculator/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/kpi/hierarchy/KpiHierarchy.kt @@ -8,7 +8,7 @@ val SCHEMA_VERSIONS: Array<String> = arrayOf( "1.0.0" ).sortedArray() -//TODO: add Hierarchy Validator +//XXX: add Hierarchy Validator @Serializable data class KpiHierarchy private constructor(val rootNode: KpiNode, val schemaVersion: String) { companion object { @@ -22,6 +22,7 @@ data class KpiNode(val kpiId: KpiId, val strategyType: KpiStrategyId, val childr @Serializable data class KpiEdge(val target: KpiNode, val weight: Double) +//TODO: extract this in a separate file @Serializable data class KpiResultHierarchy private constructor(val rootNode: KpiResultNode, val schemaVersion: String) { companion object {