FindByExternalStubId(Id: String): IValidationCustomMapping;
Id. Identifier of external data source that is used in mapping.
The FindByExternalStubId method searches for a mapping for external data source with the specified identifier.
If a mapping for the specified external data source is not found, the method returns Null.
Executing the example requires that the repository contains time series databases with the TSDB and SDB_VALID identifiers. Both time series databases should contain attributes of series with the same identifiers. The TSDB database should also contain a validation rule of the Compare by Expression type with the VALID_CUSTOM identifier.
Add links to the Cubes, Dimensions system assemblies. Metabase, Ms.
Sub UserProc;
Var
mb: IMetabase;
TSDBExt, TSDBVal: IMetabaseObjectDescriptor;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Custom: IValidationCustom;
Mappings: IValidationCustomMappings;
Map: IValidationCustomMapping;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Det: IMsDeterministicTransform;
Inputs: IMsFormulaTransformVariables;
TransformVar: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Term: IMsFormulaTerm;
j: Integer;
Binding: IValidationCustomDimensionsBinding;
ValidExecSett: IValidationExecuteSettings;
ValidExecRun: IValidationExecRun;
Begin
mb := MetabaseClass.Active;
// Get compared time series database (TSDB 1)
TSDBVal := Mb.ItemById("TSDB");
// Get time series database used for comparison (TSDB 2)
TSDBExt := Mb.ItemById("TSDB_VALID");
// Get validation rule
ValidObj := Mb.ItemByIdNamespace("VALID_CUSTOM", TSDBVal.Key).Edit;
ValidFilter := ValidObj As IValidationFilter;
ValidFilter.Kind := ValidationDetailsKind.Custom;
// Get rule parameters
Custom := ValidFilter.Details As IValidationCustom;
// Get rule calculation parameters
Transform := Custom.Transform;
Formula := Transform.FormulaItem(0);
Formula.Kind := MsFormulaKind.Deterministic;
Det := Formula.Method As IMsDeterministicTransform;
// Get collection of input variables
Inputs := Transform.Inputs;
// Add input variable from TSDB 2
TransformVar := Inputs.Add(TSDBExt.Bind As IVariableStub);
Tree := TransformVar.SlicesTree(TransformVar);
Slice := Tree.CreateSlice(1);
Term := Det.Operands.Add(Slice);
// Add variable to expression
Det.Expression.AsString := Term.TermToInnerText;
// Add input variable from TSDB 1
TransformVar := Transform.Inputs.Add(TSDBVal.Bind As IVariableStub);
Tree := TransformVar.SlicesTree(TransformVar);
Slice := Tree.CreateSlice(1);
Term := Det.Operands.Add(Slice);
// Form final expression with both variables
Det.Expression.AsString := Det.Expression.AsString + ">" + Term.TermToInnerText;
// Get attribute mapping parameters
Mappings := Custom.Mappings;
// Clear existing mappings
Mappings.Clear;
// Execute automatic mapping
Mappings.FillByAttributes;
// Display information about performed mappings
Debug.WriteLine("Mappings for data source '" + TSDBExt.Name + "'");
Map := Mappings.FindByExternalStubId(TSDBExt.Id);
Debug.Indent;
// Parse all dimension bindings
For j := 0 To Map.ValidationStub.DimensionCount - 1 Do
Binding := Map.FindByValidationDimKey((Map.ValidationStub.Dimension(j) As IMetabaseObject).Key);
Debug.WriteLine("Binding No" + (j + 1).ToString);
Debug.Indent;
Debug.WriteLine("Dimension from external data source: " + Binding.ExternalDim.Name);
Debug.WriteLine("Dimension from data source, by which validation is performed: " + Binding.ValidationDim.Name);
Debug.Unindent;
End For;
Debug.Unindent;
// Save changes of validation rule
ValidObj.Save;
// Execute rule
ValidExecSett := New ValidationExecuteSettings.Create;
ValidExecRun := ValidFilter.Execute(ValidExecSett);
End Sub UserProc;
After executing the example calculation expression is set for validation rule and it is based on series from two different time series databases. Dimensions of two different time series databases are mapped automatically.
See also: