Skip to content

Commit

Permalink
MR | Ability to select business or processing date before running val…
Browse files Browse the repository at this point in the history
…idation for milestoned class in data quality class validation (#3534)
  • Loading branch information
viju4076 authored Sep 17, 2024
1 parent 00e3837 commit 22f8e5e
Show file tree
Hide file tree
Showing 9 changed files with 399 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/odd-roses-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@finos/legend-extension-dsl-data-quality': patch
'@finos/legend-graph': patch
---

ability to select business or processing date for milestoned class in dq class validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
Dialog,
Modal,
ModalBody,
ModalFooter,
ModalFooterButton,
ModalHeader,
PanelFormSection,
} from '@finos/legend-art';
import type { DataQualityState } from './states/DataQualityState.js';
import { observer } from 'mobx-react-lite';
import {
MILESTONING_STEREOTYPE,
BUSINESS_DATE_MILESTONING_PROPERTY_NAME,
PROCESSING_DATE_MILESTONING_PROPERTY_NAME,
} from '@finos/legend-graph';

export const DataQualityDateSelectionPanel = observer(
(props: { dataQualityState: DataQualityState }) => {
const { dataQualityState } = props;
const { applicationStore, showDateSelection } = dataQualityState;
const currentClassMilestoningStrategy =
dataQualityState.currentClassMilestoningStrategy;
const showProcessingDate =
currentClassMilestoningStrategy ===
MILESTONING_STEREOTYPE.PROCESSING_TEMPORAL ||
currentClassMilestoningStrategy === MILESTONING_STEREOTYPE.BITEMPORAL;
const showBusinessDate =
currentClassMilestoningStrategy ===
MILESTONING_STEREOTYPE.BUSINESS_TEMPORAL ||
currentClassMilestoningStrategy === MILESTONING_STEREOTYPE.BITEMPORAL;

const updateAbsoluteDateValue: React.ChangeEventHandler<
HTMLInputElement
> = (event) => {
if (event.target.name === PROCESSING_DATE_MILESTONING_PROPERTY_NAME) {
dataQualityState.setProcessingDate(event.target.value);
}
if (event.target.name === BUSINESS_DATE_MILESTONING_PROPERTY_NAME) {
dataQualityState.setBusinessDate(event.target.value);
}
};

const closePlanViewer = () => {
dataQualityState.setShowDateSelection(false);
};

return (
<Dialog
open={showDateSelection}
classes={{
root: 'validation-date-selection-modal__root-container',
container: 'validation-date-selection-modal__container',
paper: 'validation-date-selection-modal__content',
}}
>
<Modal
className="validation-date-selection-modal"
darkMode={
!applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
}
>
<ModalHeader title="Validation Options" />
<ModalBody className="validation-date-selection-modal__body">
{showProcessingDate && (
<PanelFormSection>
<div className="panel__content__form__section__header__label">
Processing Date
</div>
<div className="panel__content__form__section__header__prompt">
Choose a value for this milestoning parameter
</div>
<div className="validation-date-selection-modal__absolute-date">
<input
className="panel__content__form__section__input validation-date-selection-modal__absolute-date__input input--dark"
type="date"
spellCheck={false}
value={dataQualityState.processingDate}
name={PROCESSING_DATE_MILESTONING_PROPERTY_NAME}
onChange={updateAbsoluteDateValue}
/>
</div>
</PanelFormSection>
)}
{showBusinessDate && (
<PanelFormSection>
<div className="panel__content__form__section__header__label">
Business Date
</div>
<div className="panel__content__form__section__header__prompt">
Choose a value for this milestoning parameter
</div>
<div className="validation-date-selection-modal__absolute-date">
<input
className="panel__content__form__section__input validation-date-selection-modal__absolute-date__input input--dark"
type="date"
spellCheck={false}
value={dataQualityState.businessDate}
name={BUSINESS_DATE_MILESTONING_PROPERTY_NAME}
onChange={updateAbsoluteDateValue}
/>
</div>
</PanelFormSection>
)}
</ModalBody>
<ModalFooter>
<ModalFooterButton
onClick={closePlanViewer}
text="Close"
type="secondary"
/>
</ModalFooter>
</Modal>
</Dialog>
);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@finos/legend-query-builder';
import {
type ExecutionResult,
MILESTONING_STEREOTYPE,
buildRawLambdaFromLambdaFunction,
CORE_PURE_PATH,
FunctionType,
Expand Down Expand Up @@ -62,6 +63,7 @@ import {
import { DataQualityResultValues } from './DataQualityResultValues.js';
import { dataQualityClassValidation_setFilter } from '../graph-manager/DSL_DataQuality_GraphModifierHelper.js';
import type { DataQualityClassValidationsConfiguration } from '../graph/metamodel/pure/packageableElements/data-quality/DataQualityValidationConfiguration.js';
import { DataQualityDateSelectionPanel } from './DataQualityDateSelectionPanel.js';

export const DataQualityResultPanel = observer(
(props: { dataQualityState: DataQualityState }) => {
Expand Down Expand Up @@ -121,6 +123,7 @@ export const DataQualityResultPanel = observer(
);
resultState.pressedRunQuery.complete();
};

const cancelQuery = applicationStore.guardUnhandledError(() =>
flowResult(resultState.cancelQuery()),
);
Expand Down Expand Up @@ -191,6 +194,17 @@ export const DataQualityResultPanel = observer(
const isLoading =
resultState.isRunningQuery || resultState.isGeneratingPlan;

const currentClassMilestoningStrategy =
dataQualityState.currentClassMilestoningStrategy;
const showProcessingDate =
currentClassMilestoningStrategy ===
MILESTONING_STEREOTYPE.PROCESSING_TEMPORAL ||
currentClassMilestoningStrategy === MILESTONING_STEREOTYPE.BITEMPORAL;
const showBusinessDate =
currentClassMilestoningStrategy ===
MILESTONING_STEREOTYPE.BUSINESS_TEMPORAL ||
currentClassMilestoningStrategy === MILESTONING_STEREOTYPE.BITEMPORAL;

return (
<div
data-testid={
Expand Down Expand Up @@ -226,6 +240,36 @@ export const DataQualityResultPanel = observer(
)}
</div>
<div className="panel__header__actions data-quality-validation__result__header__actions">
{showProcessingDate && (
<div className="trial-runs-result-modifier-prompt__group">
<div className="trial-runs-result-modifier-prompt__group__label">
Processing Date
</div>
<button
className="trial-runs-result-modifier-prompt__header__label editable-value"
onClick={() => dataQualityState.setShowDateSelection(true)}
>
<div className="trial-runs-result-modifier-prompt__header__label__title">
{dataQualityState.processingDate}
</div>
</button>
</div>
)}
{showBusinessDate && (
<div className="trial-runs-result-modifier-prompt__group">
<div className="trial-runs-result-modifier-prompt__group__label">
Business Date
</div>
<button
className="trial-runs-result-modifier-prompt__header__label editable-value"
onClick={() => dataQualityState.setShowDateSelection(true)}
>
<div className="trial-runs-result-modifier-prompt__header__label__title">
{dataQualityState.businessDate}
</div>
</button>
</div>
)}
{allowSettingPreviewLimit && (
<div className="data-quality-validation__result__limit">
<div className="data-quality-validation__result__limit__label">
Expand All @@ -243,7 +287,6 @@ export const DataQualityResultPanel = observer(
/>
</div>
)}

<div className="data-quality-validation__result__execute-btn btn__dropdown-combo btn__dropdown-combo--primary">
{resultState.isRunningQuery ? (
<button
Expand Down Expand Up @@ -329,6 +372,7 @@ export const DataQualityResultPanel = observer(
<ExecutionPlanViewer
executionPlanState={resultState.executionPlanState}
/>
<DataQualityDateSelectionPanel dataQualityState={dataQualityState} />
</div>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ export class DataQualityResultState {

promise = getDataQualityPureGraphManagerExtension(
this.dataQualityState.graphManagerState.graphManager,
).execute(model, packagePath, this.previewLimit);
).execute(
model,
this.dataQualityState.lambdaParameterValues,
packagePath,
this.previewLimit,
);

this.setQueryRunPromise(promise);
const result = (yield promise) as ExecutionResult;
Expand Down
Loading

0 comments on commit 22f8e5e

Please sign in to comment.