-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Move all form item handlers into its own package
- Loading branch information
1 parent
cf3356f
commit 9fe6251
Showing
13 changed files
with
51 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/AutoVersionableJsonParser.kt → ...ItemHandlers/AutoVersionableJsonParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/ContingencyListContainer.kt → ...mItemHandlers/ContingencyListContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.statnett.loadflowservice.formItemHandlers | ||
|
||
import io.ktor.http.content.* | ||
|
||
interface FormItemLoadable { | ||
fun formItemHandler(part: PartData.FormItem) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.statnett.loadflowservice.formItemHandlers | ||
|
||
import com.powsybl.loadflow.LoadFlowParameters | ||
import com.powsybl.loadflow.json.JsonLoadFlowParameters | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import io.ktor.http.content.* | ||
|
||
private val logger = KotlinLogging.logger {} | ||
|
||
/** | ||
* Convenience class used to deserialize and update a load parameter instance | ||
*/ | ||
class LoadParameterContainer : AutoVersionableJsonParser(), FormItemLoadable { | ||
var parameters = LoadFlowParameters() | ||
private var parametersModified = false | ||
|
||
override fun currentVersion(): String { | ||
return LoadFlowParameters.VERSION | ||
} | ||
|
||
private fun update(jsonString: String) { | ||
val withVersion = jsonStringWithVersion(jsonString) | ||
this.parameters = JsonLoadFlowParameters.update(this.parameters, withVersion.byteInputStream()) | ||
this.parametersModified = true | ||
} | ||
|
||
override fun formItemHandler(part: PartData.FormItem) { | ||
val name = part.name ?: "" | ||
if (name == "load-flow-parameters") { | ||
this.update(part.value) | ||
logger.info { "Received load flow parameters: ${part.value}" } | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/MultiFormItemLoaders.kt → .../formItemHandlers/MultiFormItemLoaders.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...SensitivityAnalysisParametersContainer.kt → ...SensitivityAnalysisParametersContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/SensitivityFactorContainer.kt → ...temHandlers/SensitivityFactorContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters