Skip to content

Commit 8962997

Browse files
committed
Merge remote-tracking branch 'origin/staging' into NU.2152.loose.redundant.parameters.validation
2 parents d1a42bb + fc2a662 commit 8962997

File tree

94 files changed

+1683
-552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1683
-552
lines changed

build.sbt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ lazy val scenarioCompiler = (project in file("scenario-compiler"))
857857
"org.apache.avro" % "avro" % avroV % Test,
858858
"org.scalacheck" %% "scalacheck" % scalaCheckV % Test,
859859
"com.cronutils" % "cron-utils" % cronParserV % Test,
860-
"org.scalatestplus" %% s"scalacheck-$scalaCheckVshort" % scalaTestPlusV % Test
860+
"org.scalatestplus" %% s"scalacheck-$scalaCheckVshort" % scalaTestPlusV % Test,
861+
"org.apache.flink" % "flink-core" % flinkV % Test,
861862
)
862863
}
863864
)
@@ -1160,7 +1161,12 @@ lazy val mathUtils = (project in utils("math-utils"))
11601161
lazy val defaultHelpers = (project in utils("default-helpers"))
11611162
.settings(commonSettings)
11621163
.settings(
1163-
name := "nussknacker-default-helpers"
1164+
name := "nussknacker-default-helpers",
1165+
libraryDependencies ++= {
1166+
Seq(
1167+
"org.apache.flink" % "flink-core" % flinkV % Test,
1168+
)
1169+
}
11641170
)
11651171
.dependsOn(mathUtils, commonUtils, testUtils % Test, scenarioCompiler % "test->test;test->compile")
11661172

common-api/src/main/scala/pl/touk/nussknacker/engine/graph/expression/Expression.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import pl.touk.nussknacker.engine.graph.expression.Expression.Language
77
import pl.touk.nussknacker.engine.graph.expression.Expression.Language.{
88
DictKeyWithLabel,
99
Json,
10+
JsonTemplate,
1011
Spel,
1112
SpelTemplate,
1213
TabularDataDefinition
@@ -25,6 +26,7 @@ object Expression {
2526
case DictKeyWithLabel => "dictKeyWithLabel"
2627
case TabularDataDefinition => "tabularDataDefinition"
2728
case Json => "json"
29+
case JsonTemplate => "jsonTemplate"
2830
}
2931

3032
}
@@ -35,6 +37,7 @@ object Expression {
3537
object DictKeyWithLabel extends Language
3638
object TabularDataDefinition extends Language
3739
object Json extends Language
40+
object JsonTemplate extends Language
3841

3942
implicit val encoder: Encoder[Language] = Encoder.encodeString.contramap(_.toString)
4043

@@ -44,6 +47,7 @@ object Expression {
4447
case "dictKeyWithLabel" => Right(DictKeyWithLabel)
4548
case "tabularDataDefinition" => Right(TabularDataDefinition)
4649
case "json" => Right(Json)
50+
case "jsonTemplate" => Right(JsonTemplate)
4751
case unknown => Left(s"Unknown language [$unknown]")
4852
}
4953

@@ -61,4 +65,6 @@ object Expression {
6165
def tabularDataDefinition(definition: String): Expression = Expression(Language.TabularDataDefinition, definition)
6266

6367
def json(jsonString: String): Expression = Expression(Language.Json, jsonString)
68+
69+
def jsonTemplate(jsonTemplateString: String): Expression = Expression(Language.JsonTemplate, jsonTemplateString)
6470
}

components-api/src/main/java/pl/touk/nussknacker/engine/api/DefaultValue.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
@Retention(RetentionPolicy.RUNTIME)
1010
public @interface DefaultValue {
1111
String value();
12-
}
12+
ExpressionLanguage language() default ExpressionLanguage.SPEL;
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package pl.touk.nussknacker.engine.api;
2+
3+
public enum ExpressionLanguage {
4+
SPEL,
5+
SPEL_TEMPLATE,
6+
DICT_KEY_WITH_LABEL,
7+
TABULAR_DATA_DEFINITION,
8+
JSON,
9+
JSON_TEMPLATE,
10+
}

components-api/src/main/java/pl/touk/nussknacker/engine/api/editor/EditorType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public enum EditorType {
1616
DICT_EDITOR,
1717
TYPED_TABULAR_DATA_EDITOR,
1818
SPEL_EDITOR,
19+
JSON_TEMPLATE_EDITOR,
1920
}

components-api/src/main/scala/pl/touk/nussknacker/engine/api/definition/ParameterEditor.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ case object TextareaParameterEditor extends ParameterEditor with StaticParameter
2929

3030
case object JsonParameterEditor extends ParameterEditor with StaticParameterEditor
3131

32+
case object JsonTemplateParameterEditor extends ParameterEditor with StaticParameterEditor
33+
3234
case object SqlParameterEditor extends ParameterEditor
3335

3436
case object SpelTemplateParameterEditor extends ParameterEditor

components-api/src/main/scala/pl/touk/nussknacker/engine/api/typed/TypeConversionHandler.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import scala.util.Try
2222
*/
2323
private[engine] object TypeConversionHandler {
2424

25-
private val javaListClass = classOf[java.util.List[_]]
26-
private val javaCollectionClass = classOf[java.util.Collection[_]]
27-
private val javaMapClass = classOf[java.util.Map[_, _]]
28-
private val arrayOfAnyRefClass = classOf[Array[AnyRef]]
29-
private val avroIndexedRecordClassName = "org.apache.avro.generic.IndexedRecord"
25+
private val javaListClass = classOf[java.util.List[_]]
26+
private val javaCollectionClass = classOf[java.util.Collection[_]]
27+
private val javaMapClass = classOf[java.util.Map[_, _]]
28+
private val arrayOfAnyRefClass = classOf[Array[AnyRef]]
29+
private val mapConvertableClassNames = List("org.apache.avro.generic.IndexedRecord", "org.apache.flink.types.Row")
3030

3131
/**
3232
* java.math.BigDecimal is quite often returned as a wrapper for all kind of numbers (floating and without floating point).
@@ -93,7 +93,7 @@ private[engine] object TypeConversionHandler {
9393
case Loose =>
9494
Option.when(handleStringToValueClassConversions(from, to))(to) orElse
9595
handleArrayToListConversions(from.runtimeObjType, to) orElse
96-
handleIndexedRecordToMapConversion(from, to)
96+
handleMapConversions(from, to)
9797
}
9898
}
9999

@@ -153,7 +153,7 @@ private[engine] object TypeConversionHandler {
153153
}
154154
}
155155

156-
private def handleIndexedRecordToMapConversion(
156+
private def handleMapConversions(
157157
from: SingleTypingResult,
158158
to: TypedClass
159159
)(
@@ -167,7 +167,9 @@ private[engine] object TypeConversionHandler {
167167
lazy val indexedRecordValueType = superTypeOfTypes(fromFields.values)
168168

169169
Option.when(
170-
AssignabilityUtil.isAssignableToLoadableClass(fromRuntimeObjClass, avroIndexedRecordClassName) &&
170+
mapConvertableClassNames.exists(className =>
171+
AssignabilityUtil.isAssignableToLoadableClass(fromRuntimeObjClass, className)
172+
) &&
171173
AssignabilityDeterminer.isAssignable(Typed[String], mapKeyParam).isValid &&
172174
AssignabilityDeterminer.isAssignable(indexedRecordValueType, mapValueParam).isValid
173175
)(

defaultModel/src/main/scala/pl/touk/nussknacker/defaultmodel/migrations/SpelToSpelTemplateNodeMigration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import pl.touk.nussknacker.engine.graph.evaluatedparam.Parameter
55
import pl.touk.nussknacker.engine.graph.expression.Expression
66
import pl.touk.nussknacker.engine.graph.expression.Expression.Language
77
import pl.touk.nussknacker.engine.graph.node
8-
import pl.touk.nussknacker.engine.migration.NodeMigration
8+
import pl.touk.nussknacker.engine.migration.{NodeMigration, ParametersMigration}
99

1010
object SpelToSpelTemplateNodeMigration extends NodeMigration {
1111
private lazy val spelStringPattern = "^'(.*)'$".r

designer/client/src/actions/actionTypes.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export type ActionTypes =
44
| "LOGGED_USER"
55
| "UI_SETTINGS"
66
| "AVAILABLE_QUERY_STATES"
7-
| "SWITCH_TOOL_TIPS_HIGHLIGHT"
87
| "ZOOM_IN"
98
| "ZOOM_OUT"
109
| "DELETE_NODES"
@@ -21,14 +20,11 @@ export type ActionTypes =
2120
| "EDIT_LABELS"
2221
| "SHOW_METRICS"
2322
| "UPDATE_TEST_CAPABILITIES"
24-
| "UPDATE_TEST_TYPE"
2523
| "DISPLAY_PROCESS"
2624
| "GET_SCENARIO_ACTIVITIES"
2725
| "UPDATE_SCENARIO_ACTIVITIES"
2826
| "PROCESS_FETCH"
2927
| "PROCESS_LOADING"
30-
| "TEST_RESULTS_LOADING"
31-
| "TEST_RESULTS_FAILED"
3228
| "LOADING_FAILED"
3329
| "CLEAR_PROCESS"
3430
| "TOGGLE_PROCESS_ACTION_MODAL"

designer/client/src/actions/nk/displayTestResults.ts

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,87 @@ import type { ProcessName } from "src/components/Process/types";
33
import type { TestResults } from "../../common/TestResultUtils";
44
import type { SourceWithParametersTest, TestProcessResponse } from "../../http/HttpService";
55
import HttpService from "../../http/HttpService";
6+
import { getProcessName, getScenarioGraph } from "../../reducers/selectors/graph";
67
import type { ScenarioGraph } from "../../types";
7-
import type { ThunkAction } from "../reduxTypes";
8+
import type { Action, ThunkAction } from "../reduxTypes";
89
import { displayProcessCounts } from "./displayProcessCounts";
910

10-
export function testProcessFromFile(processName: ProcessName, testDataFile: File, scenarioGraph: ScenarioGraph): ThunkAction {
11-
return (dispatch) => {
12-
dispatch({
13-
type: "PROCESS_LOADING",
14-
});
11+
export function testProcessFromFile(testDataFile: File): ThunkAction {
12+
return wrapWithTestAction((processName, scenarioGraph) =>
13+
HttpService.testProcess(processName, testDataFile, scenarioGraph).then(({ data }) => ({
14+
testResults: data,
15+
})),
16+
);
17+
}
1518

16-
HttpService.testProcess(processName, testDataFile, scenarioGraph)
17-
.then((response) => dispatch(displayTestResults(response.data)))
18-
.catch(() => dispatch({ type: "LOADING_FAILED" }));
19-
};
19+
export function testProcessWithParameters(testData: SourceWithParametersTest): ThunkAction {
20+
return wrapWithTestAction((processName, scenarioGraph) =>
21+
HttpService.testProcessWithParameters(processName, testData, scenarioGraph).then(({ data }) => ({
22+
testResults: data,
23+
testData,
24+
})),
25+
);
26+
}
27+
28+
export function testScenarioWithGeneratedData(testSampleSize: string): ThunkAction {
29+
return wrapWithTestAction((processName, scenarioGraph) =>
30+
HttpService.testScenarioWithGeneratedData(processName, parseInt(testSampleSize), scenarioGraph).then(({ data }) => ({
31+
testResults: data,
32+
})),
33+
);
2034
}
2135

22-
export function testProcessWithParameters(
23-
processName: ProcessName,
24-
testData: SourceWithParametersTest,
25-
scenarioGraph: ScenarioGraph,
36+
export type TestsActions =
37+
| { type: "TEST_RESULTS_LOADING" }
38+
| { type: "TEST_RESULTS_FAILED" }
39+
| {
40+
type: "DISPLAY_TEST_RESULTS_DETAILS";
41+
testResults: TestResults;
42+
testData?: SourceWithParametersTest;
43+
}
44+
| {
45+
type: "UPDATE_TEST_TYPE";
46+
testType: string;
47+
};
48+
49+
function wrapWithTestAction(
50+
fn: (
51+
processName: ProcessName,
52+
scenarioGraph: ScenarioGraph,
53+
) => Promise<{
54+
testResults: TestProcessResponse;
55+
testData?: SourceWithParametersTest;
56+
}>,
2657
): ThunkAction {
27-
return (dispatch) => {
58+
return (dispatch, getState) => {
2859
dispatch({ type: "TEST_RESULTS_LOADING" });
29-
30-
HttpService.testProcessWithParameters(processName, testData, scenarioGraph)
31-
.then((response) => {
32-
dispatch(displayTestResults(response.data, testData));
33-
})
60+
const state = getState();
61+
const scenarioGraph = getScenarioGraph(state);
62+
const processName = getProcessName(state);
63+
fn(processName, scenarioGraph)
64+
.then(({ testResults, testData }) => dispatch(displayTestResults(testResults, testData)))
3465
.catch(() => dispatch({ type: "TEST_RESULTS_FAILED" }));
3566
};
3667
}
3768

38-
export function testScenarioWithGeneratedData(testSampleSize: string, processName: ProcessName, scenarioGraph: ScenarioGraph): ThunkAction {
39-
return (dispatch) => {
40-
dispatch({
41-
type: "PROCESS_LOADING",
42-
});
43-
dispatch({ type: "TEST_RESULTS_LOADING" });
44-
45-
HttpService.testScenarioWithGeneratedData(processName, +testSampleSize, scenarioGraph)
46-
.then((response) => dispatch(displayTestResults(response.data)))
47-
.catch(() => {
48-
dispatch({ type: "LOADING_FAILED" });
49-
dispatch({ type: "TEST_RESULTS_FAILED" });
50-
});
69+
function displayTestResultsDetails(testResults: TestResults, testData?: SourceWithParametersTest): Action {
70+
return {
71+
type: "DISPLAY_TEST_RESULTS_DETAILS",
72+
testResults,
73+
testData,
5174
};
5275
}
5376

54-
export interface DisplayTestResultsDetailsAction {
55-
type: "DISPLAY_TEST_RESULTS_DETAILS";
56-
testResults: TestResults;
57-
testData?: SourceWithParametersTest;
58-
}
59-
60-
function displayTestResultsDetails(testResults: TestProcessResponse, testData?: SourceWithParametersTest): DisplayTestResultsDetailsAction {
77+
export function updateTestType(testType: string): Action {
6178
return {
62-
type: "DISPLAY_TEST_RESULTS_DETAILS",
63-
testResults: testResults.results,
64-
testData,
79+
type: "UPDATE_TEST_TYPE",
80+
testType,
6581
};
6682
}
6783

68-
function displayTestResults(testResults: TestProcessResponse, testData?: SourceWithParametersTest) {
84+
function displayTestResults({ counts, results }: TestProcessResponse, testData?: SourceWithParametersTest): ThunkAction {
6985
return (dispatch) => {
70-
dispatch(displayTestResultsDetails(testResults, testData));
71-
dispatch(displayProcessCounts(testResults.counts));
86+
dispatch(displayTestResultsDetails(results, testData));
87+
dispatch(displayProcessCounts(counts));
7288
};
7389
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { SwitchToolTipsHighlightAction } from "../tooltips";
2-
import { LayoutChangedAction, PanelActions } from "./layout";
1+
import type { EditState } from "../../../components/graph/node-modal/node/useNodeState";
2+
import type { SwitchToolTipsHighlightAction } from "../tooltips";
3+
import type { LayoutChangedAction, PanelActions } from "./layout";
34

4-
export type UiActions = SwitchToolTipsHighlightAction | PanelActions | LayoutChangedAction;
5+
export type UiActions =
6+
| SwitchToolTipsHighlightAction
7+
| PanelActions
8+
| LayoutChangedAction
9+
| {
10+
type: "SET_PENDING_CHANGES";
11+
id: string;
12+
pendingChanges?: EditState;
13+
};

designer/client/src/actions/reduxTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { SquashHistoryActions } from "../reducers/graph/historySquash";
77
import type { ScenariosActions } from "../reducers/scenarios";
88
import type { ActionTypes } from "./actionTypes";
99
import type { CountsActions, NodeActions, NodeDetailsActions, PropertiesActions, ScenarioActions, SelectionActions } from "./nk";
10-
import type { DisplayTestResultsDetailsAction } from "./nk/displayTestResults";
10+
import type { TestsActions } from "./nk/displayTestResults";
1111
import type { NotificationActions } from "./nk/notifications";
1212
import type { GetScenarioActivitiesAction, UpdateScenarioActivitiesAction } from "./nk/scenarioActivities";
1313
import type { ToolbarActions } from "./nk/toolbars";
@@ -18,7 +18,6 @@ import type { SettingsActions } from "./settingsActions";
1818
type TypedAction =
1919
| CloudDataActions
2020
| CountsActions
21-
| DisplayTestResultsDetailsAction
2221
| GetScenarioActivitiesAction
2322
| NodeActions
2423
| NodeDetailsActions
@@ -29,6 +28,7 @@ type TypedAction =
2928
| SelectionActions
3029
| SettingsActions
3130
| SquashHistoryActions
31+
| TestsActions
3232
| ToolbarActions
3333
| UiActions
3434
| UpdateScenarioActivitiesAction

0 commit comments

Comments
 (0)