Attributes: IValidationMetaAttributes;
Attributes: Prognoz.Platform.Interop.Ms.IValidationMetaAttributes;
The Attributes property returns time series database attributes, by which the data should be compared.
Attributes can only be of series level or observation level. It is not possible to compare the metadata by series attributes and observations simultaneously.
Executing the example requires that the repository contains the TSDB_VALIDATION_PARAMETERS time series database containing a validation rule with the VALIDATION identifier. The specified time series database should also contain a series attribute with the CITY identifier.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RubrObj: IMetabaseObjectDescriptor;
Rub: IRubricator;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
RevisionComparisonData: IValidationRevisionMetadataComparison;
FactAttrs: IMetaAttributes;
ValAttrs: IValidationMetaAttributes;
Attr: IMetaAttribute;
RubInst: IRubricatorInstance;
MetaData: IMetaDictionaryData;
MetaMemb: IMetaDataMembers;
Begin
Mb := MetabaseClass.Active;
// Get time series database
RubrObj := Mb.ItemById("TSDB_VALIDATION_PARAMETERS");
Rub := RubrObj.Bind As IRubricator;
// Get validation rule
ValidObj := Mb.ItemByIdNamespace("VALIDATION", RubrObj.Key).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Specify that validation is executed by all levels of calendar frequency
ValidFilter.Level := DimCalendarLevel.None;
// Specify validation type
ValidFilter.Kind := ValidationDetailsKind.RevisionComparison;
// Get parameters of the Compare Metadata Versions validation
RevisionComparisonData := ValidFilter.Details As IValidationRevisionMetadataComparison;
// Set type of rule calculation and parameters of metadata comparison
RevisionComparisonData.CalculationType := MsCalculationType.Serie;
RevisionComparisonData.ComparisonType := ValidationRevisionMetadataComparisonType.Change;
// Set key of compared revision
RubInst := RubrObj.Open(Null) As IRubricatorInstance;
MetaData := RubInst.Revisions.GetData(1);
MetaMemb := MetaData.Record.Members;
RevisionComparisonData.Revision := MetaMemb.FindById("KEY").Value;
// Set attributes used for rule calculation
FactAttrs := Rub.Facts.Attributes;
Attr := FactAttrs.FindById("CITY");
ValAttrs := RevisionComparisonData.Attributes;
ValAttrs.Add(Attr);
// Clear execution area and validation filter
RevisionComparisonData.SelectionTargetData.Clear;
RevisionComparisonData.SelectionFilter.Clear;
// Save the rule
ValidObj.Save;
End Sub UserProc;
After executing the example the Compare with Metadata Version validation rule is set up: series with the CITY attribute value changed between the first and current revisions are detected.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
RubrObj: IMetabaseObjectDescriptor;
Rub: IRubricator;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
RevisionComparisonData: IValidationRevisionMetadataComparison;
FactAttrs: IMetaAttributes;
ValAttrs: IValidationMetaAttributes;
Attr: IMetaAttribute;
RubInst: IRubricatorInstance;
MetaData: IMetaDictionaryData;
MetaMemb: IMetaDataMembers;
i: integer;
Begin
Mb := Params.Metabase;
// Get time series database
RubrObj := Mb.ItemById["TSDB_VALIDATION_PARAMETERS"];
Rub := RubrObj.Bind() As IRubricator;
// Get validation rule
ValidObj := Mb.ItemByIdNamespace["VALIDATION", RubrObj.Key].Edit();
ValidFilter := ValidObj As IValidationFilter;
// Specify that validation is executed by all levels of calendar frequency
ValidFilter.Level := DimCalendarLevel.dclNone;
// Specify validation type
ValidFilter.Kind := ValidationDetailsKind.vdkRevisionMetadataComparison;
// Get parameters of the Compare Metadata Versions validation
RevisionComparisonData := ValidFilter.Details As IValidationRevisionMetadataComparison;
// Set type of rule calculation and parameters of metadata comparison
RevisionComparisonData.CalculationType := MsCalculationType.mctSerie;
RevisionComparisonData.ComparisonType := ValidationRevisionMetadataComparisonType.vrcmtChange;
// Set key of compared revision
RubInst := RubrObj.Open(Null) As IRubricatorInstance;
MetaData := RubInst.Revisions.GetData(1, False);
MetaMemb := MetaData.Record.Members;
i := MetaMemb.FindById("KEY").Value As integer;
RevisionComparisonData.Revision := i As uinteger;
// Set attributes used for rule calculation
FactAttrs := Rub.Facts.Attributes;
Attr := FactAttrs.FindById("CITY");
ValAttrs := RevisionComparisonData.Attributes;
ValAttrs.Add(Attr);
// Clear execution area and validation filter
RevisionComparisonData.SelectionTargetData.Clear();
RevisionComparisonData.SelectionFilter.Clear();
// Save the rule
ValidObj.Save();
End Sub;
See also: