Skip to content

Commit

Permalink
Finished refactor for ScenarioPropertiesConfig as domain object
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Philipiak committed Aug 13, 2024
1 parent 9ed401a commit ff3f437
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import pl.touk.nussknacker.engine.api.component.ScenarioPropertiesParameterConfi
@JsonCodec case class ScenarioPropertiesConfig(
parameterConfig: Map[String, ScenarioPropertiesParameterConfig],
docsIconConfig: Option[ScenarioPropertiesDocsUrlConfig]
)
) {

// it will overwrite docsIcon, with the approach that the latest config is the proper one.
def ++(newConfig: ScenarioPropertiesConfig): ScenarioPropertiesConfig = {
this.copy(parameterConfig = this.parameterConfig ++ newConfig.parameterConfig, newConfig.docsIconConfig)
}

}

object ScenarioPropertiesConfig {
def empty(): ScenarioPropertiesConfig = { ScenarioPropertiesConfig(Map.empty, None) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DefinitionsService(
(if (forFragment) FragmentPropertiesConfig.properties else finalizedScenarioPropertiesConfig.parameterConfig)
.mapValuesNow(createUIScenarioAdditionalFieldConfig),
docsUrlIconConfig = finalizedScenarioPropertiesConfig.docsIconConfig.map(config =>
ScenarioPropertiesDocsUrlIconConfig(config.docsUrl, config.docsIconPath)
ScenarioPropertiesDocsUrlIconConfig(config.docsUrl, config.docsUrl)
)
),
edgesForNodes = EdgeTypesPreparer.prepareEdgeTypes(components.map(_.component)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pl.touk.nussknacker.ui.process.processingtype

import com.typesafe.config.Config
import net.ceedubs.ficus.readers.ArbitraryTypeReader.arbitraryTypeValueReader
import pl.touk.nussknacker.engine._
import pl.touk.nussknacker.engine.api.component.ScenarioPropertiesParameterConfig
import pl.touk.nussknacker.engine.api.deployment.cache.ScenarioStateCachingConfig
Expand Down Expand Up @@ -98,15 +99,16 @@ object ProcessingTypeData {
deploymentConfig,
scenarioStateCacheTTL
)
val scenarioProperties = ScenarioPropertiesConfig(
deploymentManagerProvider.scenarioPropertiesConfig(deploymentConfig) ++ modelData.modelConfig
.getOrElse[Map[ProcessingType, ScenarioPropertiesConfig]]("scenarioPropertiesConfig", Map.empty),
modelData.)

val modelScenarioProps = modelData.modelConfig
.getOrElse[ScenarioPropertiesConfig]("scenarioPropertiesConfig", ScenarioPropertiesConfig.empty())

val runtimeScenarioProps =
deploymentManagerProvider.scenarioPropertiesConfig(deploymentConfig) ++ modelScenarioProps
DeploymentData(
validDeploymentManager,
metaDataInitializer,
scenarioProperties,
runtimeScenarioProps,
deploymentManagerProvider.additionalValidators(deploymentConfig),
DeploymentManagerType(deploymentManagerProvider.name),
engineSetupName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class AkkaHttpBasedRouteProvider(
val validator = new UIProcessValidator(
processingTypeData.name,
ProcessValidator.default(processingTypeData.designerModelData.modelData),
processingTypeData.deploymentData.scenarioPropertiesConfig,
processingTypeData.deploymentData.scenarioPropertiesConfig.parameterConfig,
new ScenarioPropertiesConfigFinalizer(additionalUIConfigProvider, processingTypeData.name),
processingTypeData.deploymentData.additionalValidators,
fragmentResolver
Expand Down Expand Up @@ -237,7 +237,7 @@ class AkkaHttpBasedRouteProvider(
val newProcessPreparer = processingTypeDataProvider.mapValues { processingTypeData =>
new NewProcessPreparer(
processingTypeData.deploymentData.metaDataInitializer,
processingTypeData.deploymentData.scenarioPropertiesConfig,
processingTypeData.deploymentData.scenarioPropertiesConfig.parameterConfig,
new ScenarioPropertiesConfigFinalizer(additionalUIConfigProvider, processingTypeData.name),
)
}
Expand Down Expand Up @@ -336,10 +336,16 @@ class AkkaHttpBasedRouteProvider(
new NodeValidator(v.designerModelData.modelData, fragmentRepository)
),
processingTypeToExpressionSuggester = processingTypeDataProvider.mapValues(v =>
ExpressionSuggester(v.designerModelData.modelData, v.deploymentData.scenarioPropertiesConfig.keys)
ExpressionSuggester(
v.designerModelData.modelData,
v.deploymentData.scenarioPropertiesConfig.parameterConfig.keys
)
),
processingTypeToParametersValidator = processingTypeDataProvider.mapValues(v =>
new ParametersValidator(v.designerModelData.modelData, v.deploymentData.scenarioPropertiesConfig.keys)
new ParametersValidator(
v.designerModelData.modelData,
v.deploymentData.scenarioPropertiesConfig.parameterConfig.keys
)
),
scenarioService = processService
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import pl.touk.nussknacker.engine.api.definition._
import pl.touk.nussknacker.engine.api.editor._
import pl.touk.nussknacker.engine.api.parameter.ParameterName
import pl.touk.nussknacker.engine.api.process.{EmptyProcessConfigCreator, ProcessObjectDependencies, WithCategories}
import pl.touk.nussknacker.engine.api.properties.ScenarioPropertiesConfig
import pl.touk.nussknacker.engine.canonicalgraph.CanonicalProcess
import pl.touk.nussknacker.engine.definition.component.bultin.BuiltInComponentsDefinitionsPreparer
import pl.touk.nussknacker.engine.definition.fragment.FragmentComponentDefinitionExtractor
Expand Down Expand Up @@ -280,7 +281,7 @@ class DefinitionsServiceSpec extends AnyFunSuite with Matchers with PatientScala
new DefinitionsService(
modelData = model,
staticDefinitionForDynamicComponents = Map.empty,
scenarioPropertiesConfig = Map.empty,
scenarioPropertiesConfig = ScenarioPropertiesConfig.empty(),
deploymentManager = new MockDeploymentManager,
alignedComponentsDefinitionProvider = alignedComponentsDefinitionProvider,
scenarioPropertiesConfigFinalizer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import pl.touk.nussknacker.engine._
import pl.touk.nussknacker.engine.api.StreamMetaData
import pl.touk.nussknacker.engine.api.component.ProcessingMode
import pl.touk.nussknacker.engine.api.process.ProcessingType
import pl.touk.nussknacker.engine.api.properties.ScenarioPropertiesConfig
import pl.touk.nussknacker.engine.deployment.EngineSetupName
import pl.touk.nussknacker.engine.testing.LocalModelData
import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap
Expand Down Expand Up @@ -118,7 +119,7 @@ class ProcessingTypeDataReaderSpec extends AnyFunSuite with Matchers {
DeploymentData(
valid(new MockDeploymentManager),
MetaDataInitializer(StreamMetaData.typeName),
Map.empty,
ScenarioPropertiesConfig.empty(),
List.empty,
DeploymentManagerType(deploymentManagerProvider.name),
engineSetupName
Expand Down

0 comments on commit ff3f437

Please sign in to comment.