Skip to content

Commit

Permalink
Fix pbl's remarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jedesroches committed Jul 26, 2023
1 parent a018c02 commit 8edf62d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ch.kleis.lcaplugin.core.lang.value.*
class SankeyGraphBuilder(
private val allocatedSystem: SystemValue,
private val inventory: Inventory,
private val progressionOrder: Comparator<MatrixColumnIndex>,
private val observableOrder: Comparator<MatrixColumnIndex>,
) {
fun buildContributionGraph(sankeyIndicator: MatrixColumnIndex): Graph {
val portsWithObservedImpact = inventory.getObservablePorts().getElements().toSet()
Expand All @@ -22,7 +22,7 @@ class SankeyGraphBuilder(
is SubstanceValue -> {
graph.addNode(GraphNode(port.getUID(), port.getShortName()))
.addLinkIfNoCycle(
progressionOrder,
observableOrder,
port,
sankeyIndicator,
impactAmountForSubstance(sankeyIndicator, inventory, port)
Expand All @@ -38,7 +38,7 @@ class SankeyGraphBuilder(

linksWithObservedImpact.fold(graph.addNode(GraphNode(port.getUID(), port.getShortName()))) { accumulatorGraph, exchange ->
accumulatorGraph.addLinkIfNoCycle(
progressionOrder,
observableOrder,
port,
exchange.port(),
impactAmountForExchange(sankeyIndicator, inventory, port, exchange))
Expand All @@ -53,15 +53,15 @@ class SankeyGraphBuilder(
}

private fun Graph.addLinkIfNoCycle(
comparator: Comparator<MatrixColumnIndex>,
observableOrder: Comparator<MatrixColumnIndex>,
source: MatrixColumnIndex,
target: MatrixColumnIndex,
value: Double,
): Graph {
// The observable wrt which we are computing is not in the matrix: it will raise a not found exception.
// It is always the target, and always "deeper" in the graph than everything else.
val compareResult = try {
comparator.compare(source, target)
observableOrder.compare(source, target)
} catch (e: EvaluatorException) {
-1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ch.kleis.lcaplugin.imports.model.ImportedProductExchange
import ch.kleis.lcaplugin.imports.simapro.sanitizeSymbol
import ch.kleis.lcaplugin.imports.util.ImportException

open class EcoSpoldProcessMapper(val process: ActivityDataset) {
class EcoSpoldProcessMapper(val process: ActivityDataset) {
private val pUid = uid(process)
val result = ImportedProcess(pUid)

Expand All @@ -36,15 +36,14 @@ open class EcoSpoldProcessMapper(val process: ActivityDataset) {

mapMetas()
mapProducts()
mapInputs()
mapLandUse()
mapResources()
mapEmissions()

return result
}

open fun mapProducts() {
private fun mapProducts() {
val geo = if (process.description.geography?.shortName == "GLO") ""
else process.description.geography?.shortName ?: ""
val products = process.flowData.intermediateExchanges.map { mapProduct(it, geo) }.toMutableList()
Expand Down Expand Up @@ -90,9 +89,7 @@ open class EcoSpoldProcessMapper(val process: ActivityDataset) {
subCompartment = elementaryExchange.subCompartment,
)

open fun mapInputs() {}

open fun mapMetas() {
private fun mapMetas() {
val metas = result.meta
process.description.let { description ->
description.activity.let { activity ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.kleis.lcaplugin.imports.ecospold

import ch.kleis.lcaplugin.imports.ModelWriter
import ch.kleis.lcaplugin.imports.ecospold.EcospoldImporter.ProcessDictRecord
import ch.kleis.lcaplugin.imports.ecospold.lcia.EcoSpoldSubstanceMapper
import ch.kleis.lcaplugin.imports.ecospold.model.ActivityDataset
import ch.kleis.lcaplugin.imports.shared.serializer.ProcessSerializer
import ch.kleis.lcaplugin.imports.shared.serializer.SubstanceSerializer
Expand Down

0 comments on commit 8edf62d

Please sign in to comment.