@finos/legend-extension-dsl-data-quality
Version:
Legend extension for Data Quality
56 lines • 2 kB
JavaScript
/**
* 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 { buildSourceInformationSourceId, LAMBDA_PIPE, } from '@finos/legend-graph';
import { action, makeObservable, observable } from 'mobx';
import { uuid } from '@finos/legend-shared';
export const CONSTRAINT_SOURCE_ID_LABEL = 'constraint';
export const VALIDATION_SOURCE_ID_LABEL = 'validation';
export class ConstraintState {
uuid = uuid();
constraint;
lambdaString;
isSelected = false;
lambdaPrefix = LAMBDA_PIPE;
constructor(constraint) {
makeObservable(this, {
constraint: observable,
isSelected: observable,
lambdaString: observable,
setLambdaString: action,
setIsSelected: action,
});
this.constraint = constraint;
this.lambdaString = '';
}
setLambdaString(val) {
this.lambdaString = val;
}
setIsSelected(val) {
this.isSelected = val;
}
extractLambdaString(fullLambdaString) {
return fullLambdaString.substring(fullLambdaString.indexOf(this.lambdaPrefix) + this.lambdaPrefix.length, fullLambdaString.length);
}
get lambdaId() {
return buildSourceInformationSourceId([
this.constraint._OWNER.path,
CONSTRAINT_SOURCE_ID_LABEL,
this.constraint.name,
this.uuid, // in case of duplications
]);
}
}
//# sourceMappingURL=ConstraintState.js.map