@finos/legend-extension-dsl-data-quality 1.0.61 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/lib/components/{DSL_DataQuality_ClassElementDriver.d.ts → DSL_DataQuality_ElementDriver.d.ts} +17 -7
  2. package/lib/components/DSL_DataQuality_ElementDriver.d.ts.map +1 -0
  3. package/lib/components/{DSL_DataQuality_ClassElementDriver.js → DSL_DataQuality_ElementDriver.js} +70 -23
  4. package/lib/components/DSL_DataQuality_ElementDriver.js.map +1 -0
  5. package/lib/components/DSL_DataQuality_LegendStudioApplicationPlugin.d.ts.map +1 -1
  6. package/lib/components/DSL_DataQuality_LegendStudioApplicationPlugin.js +20 -39
  7. package/lib/components/DSL_DataQuality_LegendStudioApplicationPlugin.js.map +1 -1
  8. package/lib/components/{DSL_NewDataQualityClassValidationElement.d.ts → DSL_NewDataQualityValidationElement.d.ts} +2 -2
  9. package/lib/components/DSL_NewDataQualityValidationElement.d.ts.map +1 -0
  10. package/lib/components/DSL_NewDataQualityValidationElement.js +80 -0
  11. package/lib/components/DSL_NewDataQualityValidationElement.js.map +1 -0
  12. package/lib/components/DataQualityRelationTrialRuns.d.ts +22 -0
  13. package/lib/components/DataQualityRelationTrialRuns.d.ts.map +1 -0
  14. package/lib/components/DataQualityRelationTrialRuns.js +87 -0
  15. package/lib/components/DataQualityRelationTrialRuns.js.map +1 -0
  16. package/lib/components/{DSL_NewDataQualityServiceValidationElement.d.ts → DataQualityRelationValidationConfigurationEditor.d.ts} +2 -2
  17. package/lib/components/DataQualityRelationValidationConfigurationEditor.d.ts.map +1 -0
  18. package/lib/components/DataQualityRelationValidationConfigurationEditor.js +99 -0
  19. package/lib/components/DataQualityRelationValidationConfigurationEditor.js.map +1 -0
  20. package/lib/components/DataQualityRelationValidationEditor.d.ts +30 -0
  21. package/lib/components/DataQualityRelationValidationEditor.d.ts.map +1 -0
  22. package/lib/components/DataQualityRelationValidationEditor.js +89 -0
  23. package/lib/components/DataQualityRelationValidationEditor.js.map +1 -0
  24. package/lib/components/DataQualityResultPanel.d.ts.map +1 -1
  25. package/lib/components/DataQualityResultPanel.js +1 -1
  26. package/lib/components/DataQualityResultPanel.js.map +1 -1
  27. package/lib/components/DataQualityResultValues.d.ts +0 -2
  28. package/lib/components/DataQualityResultValues.d.ts.map +1 -1
  29. package/lib/components/DataQualityResultValues.js.map +1 -1
  30. package/lib/components/DataQualitySideBar.js +2 -2
  31. package/lib/components/DataQualitySideBar.js.map +1 -1
  32. package/lib/components/DataQualityValidationDetailPanel.d.ts +36 -0
  33. package/lib/components/DataQualityValidationDetailPanel.d.ts.map +1 -0
  34. package/lib/components/DataQualityValidationDetailPanel.js +39 -0
  35. package/lib/components/DataQualityValidationDetailPanel.js.map +1 -0
  36. package/lib/components/DataQualityValidationParametersEditor.d.ts +15 -0
  37. package/lib/components/DataQualityValidationParametersEditor.d.ts.map +1 -0
  38. package/lib/components/DataQualityValidationParametersEditor.js +129 -0
  39. package/lib/components/DataQualityValidationParametersEditor.js.map +1 -0
  40. package/lib/components/states/ConstraintState.d.ts +2 -0
  41. package/lib/components/states/ConstraintState.d.ts.map +1 -1
  42. package/lib/components/states/ConstraintState.js +2 -0
  43. package/lib/components/states/ConstraintState.js.map +1 -1
  44. package/lib/components/states/DataQualityClassValidationState.d.ts +2 -2
  45. package/lib/components/states/DataQualityClassValidationState.d.ts.map +1 -1
  46. package/lib/components/states/DataQualityClassValidationState.js +4 -4
  47. package/lib/components/states/DataQualityClassValidationState.js.map +1 -1
  48. package/lib/components/states/DataQualityRelationResultState.d.ts +46 -0
  49. package/lib/components/states/DataQualityRelationResultState.d.ts.map +1 -0
  50. package/lib/components/states/DataQualityRelationResultState.js +194 -0
  51. package/lib/components/states/DataQualityRelationResultState.js.map +1 -0
  52. package/lib/components/states/DataQualityRelationValidationConfigurationState.d.ts +73 -0
  53. package/lib/components/states/DataQualityRelationValidationConfigurationState.d.ts.map +1 -0
  54. package/lib/components/states/DataQualityRelationValidationConfigurationState.js +255 -0
  55. package/lib/components/states/DataQualityRelationValidationConfigurationState.js.map +1 -0
  56. package/lib/components/states/DataQualityRelationValidationLambdaEditorState.d.ts +32 -0
  57. package/lib/components/states/DataQualityRelationValidationLambdaEditorState.d.ts.map +1 -0
  58. package/lib/components/states/DataQualityRelationValidationLambdaEditorState.js +79 -0
  59. package/lib/components/states/DataQualityRelationValidationLambdaEditorState.js.map +1 -0
  60. package/lib/components/states/DataQualityRelationValidationState.d.ts +38 -0
  61. package/lib/components/states/DataQualityRelationValidationState.d.ts.map +1 -0
  62. package/lib/components/states/DataQualityRelationValidationState.js +119 -0
  63. package/lib/components/states/DataQualityRelationValidationState.js.map +1 -0
  64. package/lib/components/states/DataQualityResultState.d.ts.map +1 -1
  65. package/lib/components/states/DataQualityResultState.js +6 -3
  66. package/lib/components/states/DataQualityResultState.js.map +1 -1
  67. package/lib/components/states/DataQualityState.js +1 -1
  68. package/lib/components/states/DataQualityState.js.map +1 -1
  69. package/lib/graph/metamodel/DSL_DataQuality_HashUtils.d.ts +5 -1
  70. package/lib/graph/metamodel/DSL_DataQuality_HashUtils.d.ts.map +1 -1
  71. package/lib/graph/metamodel/DSL_DataQuality_HashUtils.js +4 -0
  72. package/lib/graph/metamodel/DSL_DataQuality_HashUtils.js.map +1 -1
  73. package/lib/graph/metamodel/DSL_DataQuality_PureGraphPlugin.d.ts.map +1 -1
  74. package/lib/graph/metamodel/DSL_DataQuality_PureGraphPlugin.js +2 -1
  75. package/lib/graph/metamodel/DSL_DataQuality_PureGraphPlugin.js.map +1 -1
  76. package/lib/graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.d.ts +36 -3
  77. package/lib/graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.d.ts.map +1 -1
  78. package/lib/graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.js +58 -4
  79. package/lib/graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.js.map +1 -1
  80. package/lib/graph-manager/DSL_DataQuality_GraphManagerHelper.d.ts +2 -1
  81. package/lib/graph-manager/DSL_DataQuality_GraphManagerHelper.d.ts.map +1 -1
  82. package/lib/graph-manager/DSL_DataQuality_GraphManagerHelper.js +2 -1
  83. package/lib/graph-manager/DSL_DataQuality_GraphManagerHelper.js.map +1 -1
  84. package/lib/graph-manager/DSL_DataQuality_GraphModifierHelper.d.ts +13 -2
  85. package/lib/graph-manager/DSL_DataQuality_GraphModifierHelper.d.ts.map +1 -1
  86. package/lib/graph-manager/DSL_DataQuality_GraphModifierHelper.js +36 -2
  87. package/lib/graph-manager/DSL_DataQuality_GraphModifierHelper.js.map +1 -1
  88. package/lib/graph-manager/DSL_DataQuality_PureGraphManagerPlugin.d.ts.map +1 -1
  89. package/lib/graph-manager/DSL_DataQuality_PureGraphManagerPlugin.js +5 -2
  90. package/lib/graph-manager/DSL_DataQuality_PureGraphManagerPlugin.js.map +1 -1
  91. package/lib/graph-manager/action/changeDetection/DSL_DataQuality_ObserverHelper.d.ts +5 -1
  92. package/lib/graph-manager/action/changeDetection/DSL_DataQuality_ObserverHelper.d.ts.map +1 -1
  93. package/lib/graph-manager/action/changeDetection/DSL_DataQuality_ObserverHelper.js +29 -2
  94. package/lib/graph-manager/action/changeDetection/DSL_DataQuality_ObserverHelper.js.map +1 -1
  95. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureGraphManagerExtension.d.ts +6 -5
  96. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureGraphManagerExtension.d.ts.map +1 -1
  97. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureGraphManagerExtension.js.map +1 -1
  98. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureProtocolProcessorPlugin.d.ts +1 -1
  99. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureProtocolProcessorPlugin.d.ts.map +1 -1
  100. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureProtocolProcessorPlugin.js +34 -40
  101. package/lib/graph-manager/protocol/pure/DSL_DataQuality_PureProtocolProcessorPlugin.js.map +1 -1
  102. package/lib/graph-manager/protocol/pure/v1/V1_DSL_Data_Quality_PureGraphManagerExtension.d.ts +8 -6
  103. package/lib/graph-manager/protocol/pure/v1/V1_DSL_Data_Quality_PureGraphManagerExtension.d.ts.map +1 -1
  104. package/lib/graph-manager/protocol/pure/v1/V1_DSL_Data_Quality_PureGraphManagerExtension.js +19 -12
  105. package/lib/graph-manager/protocol/pure/v1/V1_DSL_Data_Quality_PureGraphManagerExtension.js.map +1 -1
  106. package/lib/graph-manager/protocol/pure/v1/{V1_DataQualityConstraintsConfiguration.d.ts → V1_DataQualityValidationConfiguration.d.ts} +26 -4
  107. package/lib/graph-manager/protocol/pure/v1/V1_DataQualityValidationConfiguration.d.ts.map +1 -0
  108. package/lib/graph-manager/protocol/pure/v1/{V1_DataQualityConstraintsConfiguration.js → V1_DataQualityValidationConfiguration.js} +49 -4
  109. package/lib/graph-manager/protocol/pure/v1/V1_DataQualityValidationConfiguration.js.map +1 -0
  110. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationBuilderHelper.d.ts +7 -3
  111. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationBuilderHelper.d.ts.map +1 -1
  112. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationBuilderHelper.js +43 -3
  113. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationBuilderHelper.js.map +1 -1
  114. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationTransformer.d.ts +6 -3
  115. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationTransformer.d.ts.map +1 -1
  116. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationTransformer.js +39 -2
  117. package/lib/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationTransformer.js.map +1 -1
  118. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataQuality_ProtocolHelper.d.ts +5 -2
  119. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataQuality_ProtocolHelper.d.ts.map +1 -1
  120. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataQuality_ProtocolHelper.js +27 -9
  121. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataQuality_ProtocolHelper.js.map +1 -1
  122. package/lib/index.css +2 -2
  123. package/lib/index.css.map +1 -1
  124. package/lib/package.json +1 -1
  125. package/package.json +7 -7
  126. package/src/components/{DSL_DataQuality_ClassElementDriver.tsx → DSL_DataQuality_ElementDriver.tsx} +87 -18
  127. package/src/components/DSL_DataQuality_LegendStudioApplicationPlugin.tsx +33 -48
  128. package/src/components/DSL_NewDataQualityValidationElement.tsx +208 -0
  129. package/src/components/DataQualityRelationTrialRuns.tsx +288 -0
  130. package/src/components/DataQualityRelationValidationConfigurationEditor.tsx +364 -0
  131. package/src/components/DataQualityRelationValidationEditor.tsx +290 -0
  132. package/src/components/DataQualityResultPanel.tsx +1 -4
  133. package/src/components/DataQualityResultValues.tsx +1 -5
  134. package/src/components/DataQualitySideBar.tsx +2 -2
  135. package/src/components/DataQualityValidationDetailPanel.tsx +182 -0
  136. package/src/components/DataQualityValidationParametersEditor.tsx +355 -0
  137. package/src/components/states/ConstraintState.ts +2 -0
  138. package/src/components/states/DataQualityClassValidationState.ts +5 -5
  139. package/src/components/states/DataQualityRelationResultState.ts +274 -0
  140. package/src/components/states/DataQualityRelationValidationConfigurationState.ts +429 -0
  141. package/src/components/states/DataQualityRelationValidationLambdaEditorState.ts +138 -0
  142. package/src/components/states/DataQualityRelationValidationState.ts +180 -0
  143. package/src/components/states/DataQualityResultState.ts +6 -8
  144. package/src/components/states/DataQualityState.ts +1 -1
  145. package/src/graph/metamodel/DSL_DataQuality_HashUtils.ts +4 -0
  146. package/src/graph/metamodel/DSL_DataQuality_PureGraphPlugin.ts +2 -0
  147. package/src/graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.ts +79 -3
  148. package/src/graph-manager/DSL_DataQuality_GraphManagerHelper.ts +13 -0
  149. package/src/graph-manager/DSL_DataQuality_GraphModifierHelper.ts +107 -0
  150. package/src/graph-manager/DSL_DataQuality_PureGraphManagerPlugin.ts +8 -0
  151. package/src/graph-manager/action/changeDetection/DSL_DataQuality_ObserverHelper.ts +54 -1
  152. package/src/graph-manager/protocol/pure/DSL_DataQuality_PureGraphManagerExtension.ts +5 -3
  153. package/src/graph-manager/protocol/pure/DSL_DataQuality_PureProtocolProcessorPlugin.ts +72 -81
  154. package/src/graph-manager/protocol/pure/v1/V1_DSL_Data_Quality_PureGraphManagerExtension.ts +20 -23
  155. package/src/graph-manager/protocol/pure/v1/{V1_DataQualityConstraintsConfiguration.ts → V1_DataQualityValidationConfiguration.ts} +63 -4
  156. package/src/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationBuilderHelper.ts +116 -2
  157. package/src/graph-manager/protocol/pure/v1/transformation/V1_DSL_DataQuality_ValueSpecificationTransformer.ts +78 -1
  158. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_DataQuality_ProtocolHelper.ts +55 -8
  159. package/style/_data-quality-relation-validation-builder.scss +454 -0
  160. package/style/index.scss +6 -0
  161. package/tsconfig.json +13 -6
  162. package/lib/components/DSL_DataQuality_ClassElementDriver.d.ts.map +0 -1
  163. package/lib/components/DSL_DataQuality_ClassElementDriver.js.map +0 -1
  164. package/lib/components/DSL_DataQuality_ServiceElementDriver.d.ts +0 -27
  165. package/lib/components/DSL_DataQuality_ServiceElementDriver.d.ts.map +0 -1
  166. package/lib/components/DSL_DataQuality_ServiceElementDriver.js +0 -41
  167. package/lib/components/DSL_DataQuality_ServiceElementDriver.js.map +0 -1
  168. package/lib/components/DSL_NewDataQualityClassValidationElement.d.ts.map +0 -1
  169. package/lib/components/DSL_NewDataQualityClassValidationElement.js +0 -64
  170. package/lib/components/DSL_NewDataQualityClassValidationElement.js.map +0 -1
  171. package/lib/components/DSL_NewDataQualityServiceValidationElement.d.ts.map +0 -1
  172. package/lib/components/DSL_NewDataQualityServiceValidationElement.js +0 -41
  173. package/lib/components/DSL_NewDataQualityServiceValidationElement.js.map +0 -1
  174. package/lib/graph-manager/protocol/pure/v1/V1_DataQualityConstraintsConfiguration.d.ts.map +0 -1
  175. package/lib/graph-manager/protocol/pure/v1/V1_DataQualityConstraintsConfiguration.js.map +0 -1
  176. package/src/components/DSL_DataQuality_ServiceElementDriver.tsx +0 -57
  177. package/src/components/DSL_NewDataQualityClassValidationElement.tsx +0 -156
  178. package/src/components/DSL_NewDataQualityServiceValidationElement.tsx +0 -74
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { observer } from 'mobx-react-lite';
17
+ import {
18
+ type Type,
19
+ type RawVariableExpression,
20
+ Class,
21
+ Enumeration,
22
+ MULTIPLICITY_INFINITE,
23
+ PrimitiveType,
24
+ Unit,
25
+ } from '@finos/legend-graph';
26
+ import type { DataQualityRelationValidationConfiguration } from '../graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.js';
27
+ import { useCallback, useRef, useState } from 'react';
28
+ import {
29
+ useEditorStore,
30
+ rawVariableExpression_setName,
31
+ rawVariableExpression_setType,
32
+ rawVariableExpression_setMultiplicity,
33
+ getElementIcon,
34
+ LEGEND_STUDIO_TEST_ID,
35
+ } from '@finos/legend-application-studio';
36
+ import { useApplicationStore } from '@finos/legend-application';
37
+ import {
38
+ type PackageableElementOption,
39
+ buildElementOption,
40
+ } from '@finos/legend-lego/graph-editor';
41
+ import { UnsupportedOperationError } from '@finos/legend-shared';
42
+ import {
43
+ ArrowCircleRightIcon,
44
+ clsx,
45
+ createFilter,
46
+ CustomSelectorInput,
47
+ LockIcon,
48
+ PanelDnDEntry,
49
+ PanelEntryDragHandle,
50
+ TimesIcon,
51
+ useDragPreviewLayer,
52
+ } from '@finos/legend-art';
53
+ import { useDrag, useDrop } from 'react-dnd';
54
+ import { dataQualityRelationValidation_swapParameters } from '../graph-manager/DSL_DataQuality_GraphModifierHelper.js';
55
+
56
+ enum FUNCTION_PARAMETER_TYPE {
57
+ CLASS = 'CLASS',
58
+ ENUMERATION = 'ENUMERATION',
59
+ PRIMITIVE = 'PRIMITIVE',
60
+ }
61
+ const getFunctionParameterType = (type: Type): FUNCTION_PARAMETER_TYPE => {
62
+ if (type instanceof PrimitiveType) {
63
+ return FUNCTION_PARAMETER_TYPE.PRIMITIVE;
64
+ } else if (type instanceof Enumeration) {
65
+ return FUNCTION_PARAMETER_TYPE.ENUMERATION;
66
+ } else if (type instanceof Class) {
67
+ return FUNCTION_PARAMETER_TYPE.CLASS;
68
+ }
69
+ throw new UnsupportedOperationError(
70
+ `Can't classify function parameter`,
71
+ type,
72
+ );
73
+ };
74
+
75
+ export type FunctionParameterDragSource = {
76
+ parameter: RawVariableExpression;
77
+ };
78
+
79
+ export const FUNCTION_PARAMETER_DND_TYPE = 'FUNCTION_PARAMETER';
80
+
81
+ export const DataQualityValidationParametersEditor = observer(
82
+ (props: {
83
+ parameter: RawVariableExpression;
84
+ _validationConfig: DataQualityRelationValidationConfiguration;
85
+ deleteParameter: () => void;
86
+ isReadOnly: boolean;
87
+ }) => {
88
+ const ref = useRef<HTMLDivElement>(null);
89
+ const handleRef = useRef<HTMLDivElement>(null);
90
+
91
+ const { parameter, _validationConfig, deleteParameter, isReadOnly } = props;
92
+ const editorStore = useEditorStore();
93
+ const applicationStore = useApplicationStore();
94
+ // Name
95
+ const changeValue: React.ChangeEventHandler<HTMLInputElement> = (event) =>
96
+ rawVariableExpression_setName(parameter, event.target.value);
97
+ // Type
98
+ const [isEditingType, setIsEditingType] = useState(false);
99
+ const typeOptions =
100
+ editorStore.graphManagerState.usableClassPropertyTypes.map(
101
+ buildElementOption,
102
+ );
103
+ const paramType = parameter.type.value;
104
+ const typeName = getFunctionParameterType(paramType);
105
+ const filterOption = createFilter({
106
+ ignoreCase: true,
107
+ ignoreAccents: false,
108
+ stringify: (option: { data: PackageableElementOption<Type> }): string =>
109
+ option.data.value.path,
110
+ });
111
+ const selectedType = { value: paramType, label: paramType.name };
112
+ const changeType = (val: PackageableElementOption<Type>): void => {
113
+ if (val.value !== parameter.type.value) {
114
+ rawVariableExpression_setType(parameter, val.value);
115
+ // updateFunctionName(editorStore, applicationStore, _func);
116
+ }
117
+ setIsEditingType(false);
118
+ };
119
+ const openElement = (): void => {
120
+ if (!(paramType instanceof PrimitiveType)) {
121
+ editorStore.graphEditorMode.openElement(
122
+ paramType instanceof Unit ? paramType.measure : paramType,
123
+ );
124
+ }
125
+ };
126
+ // Multiplicity
127
+ const [lowerBound, setLowerBound] = useState<string | number>(
128
+ parameter.multiplicity.lowerBound,
129
+ );
130
+ const [upperBound, setUpperBound] = useState<string | number>(
131
+ parameter.multiplicity.upperBound ?? MULTIPLICITY_INFINITE,
132
+ );
133
+ const updateMultiplicity = (
134
+ lower: number | string,
135
+ upper: number | string,
136
+ ): void => {
137
+ const lBound = typeof lower === 'number' ? lower : parseInt(lower, 10);
138
+ const uBound =
139
+ upper === MULTIPLICITY_INFINITE
140
+ ? undefined
141
+ : typeof upper === 'number'
142
+ ? upper
143
+ : parseInt(upper, 10);
144
+ if (!isNaN(lBound) && (uBound === undefined || !isNaN(uBound))) {
145
+ rawVariableExpression_setMultiplicity(
146
+ parameter,
147
+ editorStore.graphManagerState.graph.getMultiplicity(lBound, uBound),
148
+ );
149
+ }
150
+ };
151
+ const changeLowerBound: React.ChangeEventHandler<HTMLInputElement> = (
152
+ event,
153
+ ) => {
154
+ setLowerBound(event.target.value);
155
+ updateMultiplicity(event.target.value, upperBound);
156
+ };
157
+ const changeUpperBound: React.ChangeEventHandler<HTMLInputElement> = (
158
+ event,
159
+ ) => {
160
+ setUpperBound(event.target.value);
161
+ updateMultiplicity(lowerBound, event.target.value);
162
+ };
163
+
164
+ // Drag and Drop
165
+ const handleHover = useCallback(
166
+ (item: FunctionParameterDragSource): void => {
167
+ const draggingParameter = item.parameter;
168
+ const hoveredParameter = parameter;
169
+ dataQualityRelationValidation_swapParameters(
170
+ _validationConfig.query.parameters,
171
+ draggingParameter,
172
+ hoveredParameter,
173
+ );
174
+ },
175
+ [_validationConfig.query.parameters, parameter],
176
+ );
177
+
178
+ const [{ isBeingDraggedParameter }, dropConnector] = useDrop<
179
+ FunctionParameterDragSource,
180
+ void,
181
+ { isBeingDraggedParameter: RawVariableExpression | undefined }
182
+ >(
183
+ () => ({
184
+ accept: [FUNCTION_PARAMETER_DND_TYPE],
185
+ hover: (item) => handleHover(item),
186
+ collect: (
187
+ monitor,
188
+ ): {
189
+ isBeingDraggedParameter: RawVariableExpression | undefined;
190
+ } => ({
191
+ isBeingDraggedParameter:
192
+ monitor.getItem<FunctionParameterDragSource | null>()?.parameter,
193
+ }),
194
+ }),
195
+ [handleHover],
196
+ );
197
+ const isBeingDragged = parameter === isBeingDraggedParameter;
198
+
199
+ const [, dragConnector, dragPreviewConnector] =
200
+ useDrag<FunctionParameterDragSource>(
201
+ () => ({
202
+ type: FUNCTION_PARAMETER_DND_TYPE,
203
+ item: () => ({
204
+ parameter: parameter,
205
+ }),
206
+ }),
207
+ [parameter],
208
+ );
209
+ dragConnector(handleRef);
210
+ dropConnector(ref);
211
+ useDragPreviewLayer(dragPreviewConnector);
212
+
213
+ return (
214
+ <PanelDnDEntry
215
+ ref={ref}
216
+ placeholder={<div className="dnd__placeholder--light"></div>}
217
+ className="property-basic-editor__container"
218
+ showPlaceholder={isBeingDragged}
219
+ >
220
+ <PanelEntryDragHandle
221
+ dragSourceConnector={handleRef}
222
+ isDragging={isBeingDragged}
223
+ />
224
+ <div className="property-basic-editor">
225
+ {isReadOnly && (
226
+ <div className="property-basic-editor__lock">
227
+ <LockIcon />
228
+ </div>
229
+ )}
230
+ <input
231
+ className="property-basic-editor__name input--dark"
232
+ disabled={isReadOnly}
233
+ value={parameter.name}
234
+ spellCheck={false}
235
+ onChange={changeValue}
236
+ placeholder="Parameter name"
237
+ />
238
+ {!isReadOnly && isEditingType && (
239
+ <CustomSelectorInput
240
+ className="property-basic-editor__type"
241
+ options={typeOptions}
242
+ onChange={changeType}
243
+ value={selectedType}
244
+ placeholder="Choose a type..."
245
+ filterOption={filterOption}
246
+ darkMode={
247
+ !applicationStore.layoutService
248
+ .TEMPORARY__isLightColorThemeEnabled
249
+ }
250
+ />
251
+ )}
252
+ {!isReadOnly && !isEditingType && (
253
+ <div
254
+ className={clsx(
255
+ 'property-basic-editor__type',
256
+ 'property-basic-editor__type--show-click-hint',
257
+ `background--${typeName.toLowerCase()}`,
258
+ {
259
+ 'property-basic-editor__type--has-visit-btn':
260
+ typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE,
261
+ },
262
+ )}
263
+ >
264
+ {typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
265
+ <div className="property-basic-editor__type__abbr">
266
+ {getElementIcon(paramType, editorStore)}
267
+ </div>
268
+ )}
269
+ <div className="property-basic-editor__type__label">
270
+ {paramType.name}
271
+ </div>
272
+ <div
273
+ className="property-basic-editor__type__label property-basic-editor__type__label--hover"
274
+ onClick={(): void => setIsEditingType(true)}
275
+ >
276
+ Click to edit
277
+ </div>
278
+ {typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
279
+ <button
280
+ data-testid={LEGEND_STUDIO_TEST_ID.TYPE_VISIT}
281
+ className="property-basic-editor__type__visit-btn"
282
+ onClick={openElement}
283
+ tabIndex={-1}
284
+ title="Visit element"
285
+ >
286
+ <ArrowCircleRightIcon />
287
+ </button>
288
+ )}
289
+ </div>
290
+ )}
291
+ {isReadOnly && (
292
+ <div
293
+ className={clsx(
294
+ 'property-basic-editor__type',
295
+ `background--${typeName.toLowerCase()}`,
296
+ {
297
+ 'property-basic-editor__type--has-visit-btn':
298
+ typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE,
299
+ },
300
+ )}
301
+ >
302
+ {typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
303
+ <div className="property-basic-editor__type__abbr">
304
+ {getElementIcon(paramType, editorStore)}
305
+ </div>
306
+ )}
307
+ <div className="property-basic-editor__type__label">
308
+ {paramType.name}
309
+ </div>
310
+ {typeName !== FUNCTION_PARAMETER_TYPE.PRIMITIVE && (
311
+ <button
312
+ data-testid={LEGEND_STUDIO_TEST_ID.TYPE_VISIT}
313
+ className="property-basic-editor__type__visit-btn"
314
+ onClick={openElement}
315
+ tabIndex={-1}
316
+ title="Visit element"
317
+ >
318
+ <ArrowCircleRightIcon />
319
+ </button>
320
+ )}
321
+ </div>
322
+ )}
323
+ <div className="property-basic-editor__multiplicity">
324
+ <input
325
+ className="property-basic-editor__multiplicity-bound"
326
+ disabled={isReadOnly}
327
+ spellCheck={false}
328
+ value={lowerBound}
329
+ onChange={changeLowerBound}
330
+ />
331
+ <div className="property-basic-editor__multiplicity__range">..</div>
332
+ <input
333
+ className="property-basic-editor__multiplicity-bound"
334
+ disabled={isReadOnly}
335
+ spellCheck={false}
336
+ value={upperBound}
337
+ onChange={changeUpperBound}
338
+ />
339
+ </div>
340
+ {!isReadOnly && (
341
+ <button
342
+ className="uml-element-editor__remove-btn btn--dark btn--caution"
343
+ disabled={isReadOnly}
344
+ onClick={deleteParameter}
345
+ tabIndex={-1}
346
+ title="Remove"
347
+ >
348
+ <TimesIcon />
349
+ </button>
350
+ )}
351
+ </div>
352
+ </PanelDnDEntry>
353
+ );
354
+ },
355
+ );
@@ -23,6 +23,8 @@ import { action, makeObservable, observable } from 'mobx';
23
23
  import { uuid } from '@finos/legend-shared';
24
24
 
25
25
  export const CONSTRAINT_SOURCE_ID_LABEL = 'constraint';
26
+ export const VALIDATION_SOURCE_ID_LABEL = 'validation';
27
+ export const VALIDATION_ROW_MAP_ID_LABEL = 'validation_row_map';
26
28
 
27
29
  export class ConstraintState {
28
30
  readonly uuid = uuid();
@@ -40,7 +40,7 @@ import {
40
40
  DataSpace,
41
41
  resolveUsableDataSpaceClasses,
42
42
  } from '@finos/legend-extension-dsl-data-space/graph';
43
- import { ELEMENT_CREATION_BASIS } from '../DSL_DataQuality_ClassElementDriver.js';
43
+ import { CLASS_ELEMENT_CREATION_BASIS } from '../DSL_DataQuality_ElementDriver.js';
44
44
  import {
45
45
  type GeneratorFn,
46
46
  assertType,
@@ -62,8 +62,8 @@ import { DataQualityResultState } from './DataQualityResultState.js';
62
62
  export class DataQualityClassValidationState extends DataQualityState {
63
63
  dataSpace?: DataSpace | undefined;
64
64
  dataSpaces: DataSpaceInfo[] = [];
65
- validationElementCreationBasis: ELEMENT_CREATION_BASIS =
66
- ELEMENT_CREATION_BASIS.MAPPING_RUNTIME_BASED;
65
+ validationElementCreationBasis: CLASS_ELEMENT_CREATION_BASIS =
66
+ CLASS_ELEMENT_CREATION_BASIS.MAPPING_RUNTIME_BASED;
67
67
 
68
68
  constructor(
69
69
  editorStore: EditorStore,
@@ -112,7 +112,7 @@ export class DataQualityClassValidationState extends DataQualityState {
112
112
  MappingAndRuntimeDataQualityExecutionContext
113
113
  ) {
114
114
  this.validationElementCreationBasis =
115
- ELEMENT_CREATION_BASIS.MAPPING_RUNTIME_BASED;
115
+ CLASS_ELEMENT_CREATION_BASIS.MAPPING_RUNTIME_BASED;
116
116
  this.dataQualityQueryBuilderState.executionContextState.setMapping(
117
117
  this.constraintsConfigurationElement.context.mapping.value,
118
118
  );
@@ -130,7 +130,7 @@ export class DataQualityClassValidationState extends DataQualityState {
130
130
  DataSpaceDataQualityExecutionContext
131
131
  ) {
132
132
  this.validationElementCreationBasis =
133
- ELEMENT_CREATION_BASIS.DATASPACE_BASED;
133
+ CLASS_ELEMENT_CREATION_BASIS.DATASPACE_BASED;
134
134
  this.dataSpace =
135
135
  this.constraintsConfigurationElement.context.dataSpace.value;
136
136
  this.executionContext = this.dataSpace.defaultExecutionContext;
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ buildExecutionParameterValues,
19
+ ExecutionPlanState,
20
+ QUERY_BUILDER_EVENT,
21
+ QueryBuilderTelemetryHelper,
22
+ } from '@finos/legend-query-builder';
23
+ import { action, flow, flowResult, makeObservable, observable } from 'mobx';
24
+ import {
25
+ type GeneratorFn,
26
+ assertErrorThrown,
27
+ LogEvent,
28
+ StopWatch,
29
+ } from '@finos/legend-shared';
30
+ import {
31
+ type ExecutionResult,
32
+ type RawExecutionPlan,
33
+ GRAPH_MANAGER_EVENT,
34
+ } from '@finos/legend-graph';
35
+ import { getDataQualityPureGraphManagerExtension } from '../../graph-manager/protocol/pure/DSL_DataQuality_PureGraphManagerExtension.js';
36
+ import type { DataQualityRelationValidationConfigurationState } from './DataQualityRelationValidationConfigurationState.js';
37
+ import type { DataQualityRelationValidation } from '../../graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.js';
38
+
39
+ export const DEFAULT_LIMIT = 1000;
40
+ export class DataQualityRelationResultState {
41
+ readonly dataQualityRelationValidationConfigurationState: DataQualityRelationValidationConfigurationState;
42
+ readonly executionPlanState: ExecutionPlanState;
43
+
44
+ previewLimit = DEFAULT_LIMIT;
45
+ isRunningValidation = false;
46
+ isGeneratingPlan = false;
47
+ executionResult?: ExecutionResult | undefined;
48
+ executionDuration?: number | undefined;
49
+ latestRunHashCode?: string | undefined;
50
+ validationRunPromise: Promise<ExecutionResult> | undefined = undefined;
51
+ validationToRun: DataQualityRelationValidation | undefined;
52
+
53
+ constructor(
54
+ dataQualityRelationValidationState: DataQualityRelationValidationConfigurationState,
55
+ ) {
56
+ makeObservable(this, {
57
+ executionResult: observable,
58
+ previewLimit: observable,
59
+ executionDuration: observable,
60
+ latestRunHashCode: observable,
61
+ validationRunPromise: observable,
62
+ isGeneratingPlan: observable,
63
+ isRunningValidation: observable,
64
+ validationToRun: observable,
65
+ setIsRunningValidation: action,
66
+ setExecutionResult: action,
67
+ setExecutionDuration: action,
68
+ setPreviewLimit: action,
69
+ setValidationRunPromise: action,
70
+ setValidationToRun: action,
71
+ handleRunValidation: action,
72
+ runValidation: flow,
73
+ cancelValidation: flow,
74
+ generatePlan: flow,
75
+ });
76
+
77
+ this.dataQualityRelationValidationConfigurationState =
78
+ dataQualityRelationValidationState;
79
+ this.executionPlanState = new ExecutionPlanState(
80
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore,
81
+ this.dataQualityRelationValidationConfigurationState.editorStore.graphManagerState,
82
+ );
83
+ }
84
+
85
+ setIsRunningValidation(val: boolean): void {
86
+ this.isRunningValidation = val;
87
+ }
88
+
89
+ setExecutionResult(val: ExecutionResult | undefined): void {
90
+ this.executionResult = val;
91
+ }
92
+
93
+ setExecutionDuration(val: number | undefined): void {
94
+ this.executionDuration = val;
95
+ }
96
+
97
+ setPreviewLimit(val: number): void {
98
+ this.previewLimit = Math.max(1, val);
99
+ }
100
+
101
+ setValidationRunPromise(promise: Promise<ExecutionResult> | undefined): void {
102
+ this.validationRunPromise = promise;
103
+ }
104
+
105
+ setValidationToRun(validation: DataQualityRelationValidation): void {
106
+ this.validationToRun = validation;
107
+ }
108
+
109
+ get checkForStaleResults(): boolean {
110
+ if (
111
+ this.latestRunHashCode !==
112
+ this.dataQualityRelationValidationConfigurationState.hashCode
113
+ ) {
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+
119
+ handleRunValidation() {
120
+ if (this.isRunningValidation) {
121
+ return;
122
+ }
123
+ const queryLambda =
124
+ this.dataQualityRelationValidationConfigurationState
125
+ .bodyExpressionSequence;
126
+ const parameters = (queryLambda.parameters ?? []) as object[];
127
+ if (parameters.length) {
128
+ this.dataQualityRelationValidationConfigurationState.parametersState.openModal(
129
+ queryLambda,
130
+ );
131
+ } else {
132
+ flowResult(this.runValidation()).catch(
133
+ this.dataQualityRelationValidationConfigurationState.editorStore
134
+ .applicationStore.alertUnhandledError,
135
+ );
136
+ }
137
+ }
138
+
139
+ *runValidation(): GeneratorFn<void> {
140
+ let promise;
141
+ try {
142
+ this.setIsRunningValidation(true);
143
+ const currentHashCode =
144
+ this.dataQualityRelationValidationConfigurationState.hashCode;
145
+ const packagePath =
146
+ this.dataQualityRelationValidationConfigurationState.validationElement
147
+ .path;
148
+ const model =
149
+ this.dataQualityRelationValidationConfigurationState.editorStore
150
+ .graphManagerState.graph;
151
+
152
+ const stopWatch = new StopWatch();
153
+
154
+ promise = getDataQualityPureGraphManagerExtension(
155
+ this.dataQualityRelationValidationConfigurationState.editorStore
156
+ .graphManagerState.graphManager,
157
+ ).execute(model, packagePath, {
158
+ previewLimit: this.previewLimit,
159
+ validationName: this.validationToRun?.name,
160
+ lambdaParameterValues: buildExecutionParameterValues(
161
+ this.dataQualityRelationValidationConfigurationState.parametersState
162
+ .parameterStates,
163
+ this.dataQualityRelationValidationConfigurationState.editorStore
164
+ .graphManagerState,
165
+ ),
166
+ });
167
+
168
+ this.setValidationRunPromise(promise);
169
+ const result = (yield promise) as ExecutionResult;
170
+
171
+ if (this.validationRunPromise === promise) {
172
+ this.setExecutionResult(result);
173
+ this.latestRunHashCode = currentHashCode;
174
+ this.setExecutionDuration(stopWatch.elapsed);
175
+ }
176
+ } catch (error) {
177
+ if (this.validationRunPromise === promise) {
178
+ assertErrorThrown(error);
179
+ this.setExecutionResult(undefined);
180
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore.logService.error(
181
+ LogEvent.create(GRAPH_MANAGER_EVENT.EXECUTION_FAILURE),
182
+ error,
183
+ );
184
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore.notificationService.notifyError(
185
+ error,
186
+ );
187
+ }
188
+ } finally {
189
+ this.setIsRunningValidation(false);
190
+ }
191
+ }
192
+
193
+ *cancelValidation(): GeneratorFn<void> {
194
+ this.setIsRunningValidation(false);
195
+ this.setValidationRunPromise(undefined);
196
+ try {
197
+ yield this.dataQualityRelationValidationConfigurationState.editorStore.graphManagerState.graphManager.cancelUserExecutions(
198
+ true,
199
+ );
200
+ } catch (error) {
201
+ // Don't notify users about success or failure
202
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore.logService.error(
203
+ LogEvent.create(GRAPH_MANAGER_EVENT.EXECUTION_FAILURE),
204
+ error,
205
+ );
206
+ }
207
+ }
208
+
209
+ *generatePlan(debug: boolean): GeneratorFn<void> {
210
+ const packagePath =
211
+ this.dataQualityRelationValidationConfigurationState.validationElement
212
+ .path;
213
+ const model =
214
+ this.dataQualityRelationValidationConfigurationState.editorStore
215
+ .graphManagerState.graph;
216
+ try {
217
+ this.isGeneratingPlan = true;
218
+ let rawPlan: RawExecutionPlan;
219
+
220
+ const stopWatch = new StopWatch();
221
+
222
+ if (debug) {
223
+ const debugResult = (yield getDataQualityPureGraphManagerExtension(
224
+ this.dataQualityRelationValidationConfigurationState.editorStore
225
+ .graphManagerState.graphManager,
226
+ ).debugExecutionPlanGeneration(model, packagePath, {
227
+ validationName: this.validationToRun?.name,
228
+ })) as {
229
+ plan: RawExecutionPlan;
230
+ debug: string;
231
+ };
232
+ rawPlan = debugResult.plan;
233
+ this.executionPlanState.setDebugText(debugResult.debug);
234
+ } else {
235
+ QueryBuilderTelemetryHelper.logEvent_ExecutionPlanGenerationLaunched(
236
+ this.dataQualityRelationValidationConfigurationState.editorStore
237
+ .applicationStore.telemetryService,
238
+ );
239
+ rawPlan = (yield getDataQualityPureGraphManagerExtension(
240
+ this.dataQualityRelationValidationConfigurationState.editorStore
241
+ .graphManagerState.graphManager,
242
+ ).generatePlan(model, packagePath, {
243
+ validationName: this.validationToRun?.name,
244
+ })) as RawExecutionPlan;
245
+ }
246
+
247
+ stopWatch.record();
248
+ try {
249
+ this.executionPlanState.setRawPlan(rawPlan);
250
+ const plan =
251
+ this.dataQualityRelationValidationConfigurationState.editorStore.graphManagerState.graphManager.buildExecutionPlan(
252
+ rawPlan,
253
+ this.dataQualityRelationValidationConfigurationState.editorStore
254
+ .graphManagerState.graph,
255
+ );
256
+ this.executionPlanState.initialize(plan);
257
+ } catch {
258
+ //do nothing
259
+ }
260
+ stopWatch.record(QUERY_BUILDER_EVENT.BUILD_EXECUTION_PLAN__SUCCESS);
261
+ } catch (error) {
262
+ assertErrorThrown(error);
263
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore.logService.error(
264
+ LogEvent.create(GRAPH_MANAGER_EVENT.EXECUTION_FAILURE),
265
+ error,
266
+ );
267
+ this.dataQualityRelationValidationConfigurationState.editorStore.applicationStore.notificationService.notifyError(
268
+ error,
269
+ );
270
+ } finally {
271
+ this.isGeneratingPlan = false;
272
+ }
273
+ }
274
+ }