Skip to content

Commit

Permalink
Integer dictionary support in fragment inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkp96 committed Dec 18, 2024
1 parent f9cdc9e commit 0a2b29b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function isPermittedTypeVariant(item: FragmentInputParameter): item is Pe
resolveRefClazzName(item.typ.refClazzName) === "String",
resolveRefClazzName(item.typ.refClazzName) === "Boolean",
resolveRefClazzName(item.typ.refClazzName) === "Long",
resolveRefClazzName(item.typ.refClazzName) === "Integer",
].includes(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,20 @@ object PrettyValidationErrors {
)
case UnsupportedFixedValuesType(paramName, typ, _) =>
node(
message = s"Fixed values list can only be be provided for type String or Boolean, found: $typ",
message = s"Fixed values list can only be be provided for type String, Integer, Long or Boolean, found: $typ",
description = "Please check component definition",
paramName = Some(qualifiedParamFieldName(paramName = paramName, subFieldName = Some(TypFieldName)))
)
case UnsupportedDictParameterEditorType(paramName, typ, _) =>
node(
s"Dictionary parameter editor can only be used for parameters of type String, Long or Boolean, found: $typ",
"Please check component definition",
message =
s"Dictionary parameter editor can only be used for parameters of type String, Integer, Long or Boolean, found: $typ",
description = "Please check component definition",
paramName = Some(qualifiedParamFieldName(paramName = paramName, subFieldName = Some(TypFieldName)))
)
case EmptyFixedListForRequiredField(paramName, _) =>
node(
s"Non-empty fixed list of values have to be declared for required parameter",
message = s"Non-empty fixed list of values have to be declared for required parameter",
description = "Please add a value to the list of possible values",
paramName = Some(qualifiedParamFieldName(paramName = paramName, subFieldName = Some(InputModeFieldName)))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class DevProcessConfigCreator extends ProcessConfigCreator {
BusinessConfigDictionary.id -> BusinessConfigDictionary.definition,
BooleanDictionary.id -> BooleanDictionary.definition, // not available through global variables, but still available through DictParameterEditor
LongDictionary.id -> LongDictionary.definition, // not available through global variables, but still available through DictParameterEditor
IntegerDictionary.id -> IntegerDictionary.definition // not available through global variables, but still available through DictParameterEditor
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package pl.touk.nussknacker.engine.management.sample.dict

import pl.touk.nussknacker.engine.api.dict.embedded.EmbeddedDictDefinition
import pl.touk.nussknacker.engine.api.dict.{DictDefinition, DictInstance, ReturningKeyWithoutTransformation}
import pl.touk.nussknacker.engine.api.typed.typing
import pl.touk.nussknacker.engine.api.typed.typing.Typed

object IntegerDictionary {
val id: String = "integer_dict"

val definition: DictDefinition = new EmbeddedDictDefinition with ReturningKeyWithoutTransformation {
override def valueType(dictId: String): typing.SingleTypingResult = Typed.typedClass[java.lang.Integer]

override def labelByKey: Map[String, String] = Map(
"-2147483648" -> "large (negative) number",
"42" -> "small number",
"2147483647" -> "big number"
)

}

val instance: DictInstance = DictInstance(id, definition)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ import scala.util.Try
object FragmentParameterValidator {

val permittedTypesForEditors: List[FragmentClazzRef] = List(
FragmentClazzRef[java.lang.Boolean],
FragmentClazzRef[String],
FragmentClazzRef[java.lang.Boolean],
FragmentClazzRef[java.lang.Integer],
FragmentClazzRef[java.lang.Long],
FragmentClazzRef("String"),
FragmentClazzRef("Boolean"),
FragmentClazzRef("Long")
FragmentClazzRef("Integer"),
FragmentClazzRef("Long"),
)

}
Expand Down

0 comments on commit 0a2b29b

Please sign in to comment.