Skip to content

Commit

Permalink
fix: Fix breaking changes from last powsybl release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Apr 14, 2024
1 parent 81e10f2 commit a2e3471
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.github.statnett.loadflowservice.formItemHandlers.MultiFormItemLoaders
import com.github.statnett.loadflowservice.formItemHandlers.SecurityAnalysisParametersContainer
import com.github.statnett.loadflowservice.formItemHandlers.SensitivityAnalysisParametersContainer
import com.github.statnett.loadflowservice.formItemHandlers.SensitivityFactorContainer
import com.powsybl.security.action.Action
import com.powsybl.action.Action
import com.powsybl.security.interceptors.SecurityAnalysisInterceptor
import com.powsybl.security.monitor.StateMonitor
import com.powsybl.security.strategy.OperatorStrategy
Expand Down
21 changes: 11 additions & 10 deletions src/main/Solver.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.statnett.loadflowservice

import com.fasterxml.jackson.databind.ObjectMapper
import com.powsybl.action.Action
import com.powsybl.commons.PowsyblException
import com.powsybl.commons.reporter.Reporter
import com.powsybl.commons.reporter.ReporterModel
import com.powsybl.commons.report.ReportNode
import com.powsybl.computation.local.LocalComputationManager
import com.powsybl.contingency.ContingenciesProvider
import com.powsybl.contingency.contingency.list.ContingencyList
Expand All @@ -18,7 +18,6 @@ import com.powsybl.loadflow.json.LoadFlowParametersJsonModule
import com.powsybl.security.LimitViolationFilter
import com.powsybl.security.SecurityAnalysis
import com.powsybl.security.SecurityAnalysisParameters
import com.powsybl.security.action.Action
import com.powsybl.security.detectors.DefaultLimitViolationDetector
import com.powsybl.security.interceptors.SecurityAnalysisInterceptor
import com.powsybl.security.monitor.StateMonitor
Expand Down Expand Up @@ -61,7 +60,7 @@ fun networkFromFileContent(content: NamedNetworkSource): Network {

val importConfig = ImportConfig.CACHE.get()
val loader = ImportersServiceLoader()
val reporter = Reporter.NO_OP
val reporter = ReportNode.NO_OP
val computationManager = LocalComputationManager.getDefault()
val dataSource = content.asReadOnlyDataSource()
val importer = Importer.find(dataSource, loader, computationManager, importConfig)
Expand All @@ -84,14 +83,16 @@ fun loadFlowTaskName(): String {
return "load-flow"
}

fun loadFlowReporter(): ReporterModel {
fun loadFlowReporter(): ReportNode {
val name = loadFlowTaskName()
return ReporterModel(name, name)
return ReportNode.newRootReportNode().withMessageTemplate(name, name).build()
}

fun reporterToString(reporter: ReporterModel): String {
fun reporterToString(reporter: ReportNode): String {
val writer = StringWriter()
reporter.export(writer)

// Check if we should use reporter writeJson instead
reporter.print(writer)
return writer.toString()
}

Expand Down Expand Up @@ -122,7 +123,7 @@ fun runSensitivityAnalysis(
params: SensitivityAnalysisParameters,
contingenciesList: ContingencyList,
): LoadFlowServiceSensitivityAnalysisResult {
val reporter = ReporterModel("sensitivity", "")
val reporter = ReportNode.newRootReportNode().withMessageTemplate("sensitivity", "").build()
val variableSets: List<SensitivityVariableSet> = listOf()
val contingencies = contingenciesList.getContingencies(network)

Expand Down Expand Up @@ -152,7 +153,7 @@ fun runSecurityAnalysis(
actions: List<Action>,
monitors: List<StateMonitor>,
): LoadFlowServiceSecurityAnalysisResult {
val reporter = ReporterModel("security", "")
val reporter = ReportNode.newRootReportNode().withMessageTemplate("security", "").build()
val securityReport =
SecurityAnalysis.run(
network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ class ExternalNetworkResourceHandler(
return Json.decodeFromString<SparqlResultJson>(response.body())
}

// Used for testing
fun tripleStoreQuery(query: String): PropertyBags = tripleStore.query(query)
}

0 comments on commit a2e3471

Please sign in to comment.