LevelParam: String;
LevelParam: string;
The LevelParam property determines the parameter, which sets group calculation frequency.
To set directly calculation frequency, use the IMsCalculationChainGroup.Level property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a metamodel with the META_LEVELPARAM identifier. This metamodel must contain a folder.
Add links to the Dimensions, Metabase, Ms, Transform system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Metamodel: IMsMetaModel;
Params: IMsModelParams;
Param: IMsModelParam;
Chain: IMsCalculationChainEntries;
i: Integer;
ChainEntry: IMsCalculationChainEntry;
Group: IMsCalculationChainGroup;
OutputPeriod: IMsDatePeriod;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
Metamodel := mb.ItemByIdNamespace("META_LEVELPARAM", MsKey).Edit As IMsMetaModel;
// Get metamodel parameters collection
Params := Metamodel.Params;
// Clear metamodel parameters collection
Params.Clear;
// Add a new parameter
Param := Params.Add;
// Determine parameter type - frequency
Param.ParamType := TsParamType.Frequency;
// Set default value - annual frequency
Param.DefaultValue := DimCalendarLevelSet.Year;
// Set parameter name and identifier
Param.Name := "Calculation frequency";
Param.Id := "Formula_Level";
// Get calculation chain
Chain := Metamodel.CalculationChain;
// Parse chain elements till the folder is not found
For i := 0 To Chain.Count - 1 Do
ChainEntry := Chain.Item(i);
If ChainEntry.Type = MsCalculationChainEntryType.Folder Then
Group := ChainEntry As IMsCalculationChainGroup;
Break;
End If;
End For;
// Determine that calculation frequency of elements in folder is determined by parameter
Group.LevelParam := "Formula_Level";
// Set data loading period for elements in folder
OutputPeriod := Group.OutputPeriod As IMsDatePeriod;
OutputPeriod.Start := DateTime.Parse("01.01.2016");
OutputPeriod.End_ := DateTime.Parse("01.01.2020");
// Save changes in metamodel
(Metamodel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the parameter determining calculation frequency will be set for the folder in calculation chain.Data loading period will also be set for the folder.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Transform;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
Metamodel: IMsMetaModel;
mParams: IMsModelParams;
Param: IMsModelParam;
Chain: IMsCalculationChainEntries;
i: Integer;
ChainEntry: IMsCalculationChainEntry;
Group: IMsCalculationChainGroup;
OutputPeriod: IMsDatePeriod;
Begin
// Get current repository
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
Metamodel := mb.ItemByIdNamespace["META_LEVELPARAM", MsKey].Edit() As IMsMetaModel;
// Get metamodel parameters collection
mParams := Metamodel.Params;
// Clear metamodel parameters collection
mParams.Clear();
// Add a new parameter
Param := mParams.Add();
// Determine parameter type - frequency
Param.ParamType := TsParamType.tsptFrequency;
// Set default value - annual frequency
Param.DefaultValue := DimCalendarLevelSet.dclsYear;
// Set parameter name and identifier
Param.Name := "Calculation frequency";
Param.Id := "Formula_Level";
// Get calculation chain
Chain := Metamodel.CalculationChain;
// Parse chain elements till the folder is not found
For i := 0 To Chain.Count - 1 Do
ChainEntry := Chain.Item[i];
If ChainEntry.Type = MsCalculationChainEntryType.mccetFolder Then
Group := ChainEntry As IMsCalculationChainGroup;
Break;
End If;
End For;
// Determine that calculation frequency of elements in folder is determined by parameter
Group.LevelParam := "Formula_Level";
// Set data loading period for elements in folder
OutputPeriod := Group.OutputPeriod As IMsDatePeriod;
OutputPeriod.Start := DateTime.Parse("01.01.2016");
OutputPeriod.@End := DateTime.Parse("01.01.2020");
// Save changes in metamodel
(Metamodel As IMetabaseObject).Save();
End Sub;
See also: