AggregationExpr: IExpression;
AggregationExpr: Prognoz.Platform.Interop.ForeSystem.IExpression;
The AggregationExpr property returns the expression of aggregation.
To set expression used for aggregation threshold calculation, use the IMsDetermAggregationTransform.CompositionRelevanceExpr property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing the Aggregation (Basic) model with the MODEL_DETERM_AGGR identifier.
Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
DetermAggregation: IMsDetermAggregationTransform;
TermInfo: IMsFormulaTermInfo;
Stub: IVariableStub;
TransformVar: IMsFormulaTransformVariable;
SelectionFact: IDimSelectionSetFactory;
SelectionAgr, SelectionW, SelectionRel: IDimSelectionSet;
i: Integer;
DimI: IDimInstance;
Slice: IMsFormulaTransformSlice;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
ModelCont := mb.ItemById("MS");
// Get model
Model := mb.ItemByIdNamespace("MODEL_DETERM_AGGR", ModelCont.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem(0);
Formula.Kind := MsFormulaKind.DetermAggregation;
DetermAggregation := Formula.Method As IMsDetermAggregationTransform;
// Create selections to generate aggregation expressions
Stub := (ModelCont.Bind As IMsModelSpace).DefaultObject.Bind As IVariableStub;
SelectionFact := New DimSelectionSetFactory.Create;
SelectionAgr := SelectionFact.CreateDimSelectionSet;
SelectionW := SelectionFact.CreateDimSelectionSet;
SelectionRel := SelectionFact.CreateDimSelectionSet;
For i := 0 To Stub.DimensionCount - 1 Do
DimI := (Stub.Dimension(i) As IMetabaseObject).Open(Null) As IDimInstance;
SelectionAgr.Add(DimI);
SelectionAgr.Item(i).SelectElement(i, False);
SelectionW.Add(DimI);
SelectionW.Item(i).SelectElement(i + 1, False);
SelectionRel.Add(DimI);
SelectionRel.Item(i).SelectElement(i + 2, False);
End For;
// Set aggregation expression
TermInfo := Transform.CreateTermInfo;
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionAgr);
TermInfo.Slice := Slice;
DetermAggregation.AggregationExpr.AsString := TermInfo.TermInnerText;
// Set expression of weights
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionW);
TermInfo.Slice := Slice;
DetermAggregation.WeightsExpr.AsString := TermInfo.TermInnerText;
// Set expression to calculate aggregation threshold
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionRel);
TermInfo.Slice := Slice;
DetermAggregation.CompositionRelevanceExpr.AsString := TermInfo.TermInnerText;
// Save model
(Model As IMetabaseObject).Save;
// Display name of output variable
Debug.WriteLine("Output variable: " + DetermAggregation.Result.TermToText);
End Sub UserProc;
After executing the example aggregation expression, expression for calculating the aggregation threshold and expression for setting aggregation balance are set for the model. The console window displays output variable name.
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.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
DetermAggregation: IMsDetermAggregationTransform;
TermInfo: IMsFormulaTermInfo;
Stub: IVariableStub;
TransformVar: IMsFormulaTransformVariable;
SelectionFact: IDimSelectionSetFactory;
SelectionAgr, SelectionW, SelectionRel: IDimSelectionSet;
i: integer;
DimI: IDimInstance;
Slice: IMsFormulaTransformSlice;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
ModelCont := mb.ItemById["MS"];
// Get model
Model := mb.ItemByIdNamespace["MODEL_DETERM_AGGR", ModelCont.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem[0];
Formula.Kind := MsFormulaKind.mfkDetermAggregation;
DetermAggregation := Formula.Method As IMsDetermAggregationTransform;
// Create selections to generate aggregation expressions
Stub := (ModelCont.Bind() As IMsModelSpace).DefaultObject.Bind() As IVariableStub;
SelectionFact := New DimSelectionSetFactory.Create();
SelectionAgr := SelectionFact.CreateDimSelectionSet();
SelectionW := SelectionFact.CreateDimSelectionSet();
SelectionRel := SelectionFact.CreateDimSelectionSet();
For i := 0 To Stub.DimensionCount - 1 Do
DimI := (Stub.Dimension[i] As IMetabaseObject).Open(Null) As IDimInstance;
SelectionAgr.Add(DimI);
SelectionAgr.Item[i].SelectElement(i As uinteger, False);
SelectionW.Add(DimI);
SelectionW.Item[i].SelectElement((i + 1) As uinteger, False);
SelectionRel.Add(DimI);
SelectionRel.Item[i].SelectElement((i + 2) As uinteger, False);
End For;
// Set aggregation expression
TermInfo := Transform.CreateTermInfo();
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionAgr);
TermInfo.Slice := Slice;
DetermAggregation.AggregationExpr.AsString := TermInfo.TermInnerText;
// Set expression of weights
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionW);
TermInfo.Slice := Slice;
DetermAggregation.WeightsExpr.AsString := TermInfo.TermInnerText;
// Set expression to calculate aggregation threshold
TransformVar := Transform.Inputs.Add(Stub);
Slice := TransformVar.Slices.Add(SelectionRel);
TermInfo.Slice := Slice;
DetermAggregation.CompositionRelevanceExpr.AsString := TermInfo.TermInnerText;
// Save model
(Model As IMetabaseObject).Save();
// Display name of output variable
System.Diagnostics.Debug.WriteLine("Output variable: " + DetermAggregation.Result.TermToText());
End Sub;
See also: