InitCustomContainer;
InitCustomContainer();
The InitCustomContainer method updates or creates a fact dimension based on a virtual cube.
This method updates or creates attributes of the dimension specified by the ICompoundDimension.CustomContainer property. If this property has empty value, the method searches in child objects of the owner (virtual cube) of this dimension for an object of the KE_CLASS_CUSTOMDIMENSION class with the IsInternal attribute and the FACTS identifier. If such an object is found, it is used, otherwise a new ICustomDimension object with the structure (owner, identifier, the IsInternal attribute) is set by the search rules specified above.
The created fact dimension can be used as an alternative hierarchy.
This method can be used for correct work of virtual cube if the schema has a binding to virtual cube's fact dimension structure.
Examples of binding to fact dimension structure:
The list of fact dimension attributes was edited.
Fact dimension attributes are used in report formulas.
NOTE. This method creates or updates only the fact dimension structure. The tree of elements needs to be created individually.
Executing the example requires that the repository contains a virtual cube with the V_CUBE identifier.
Add links to the Metabase, Dimensions, Cubes, Dal system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
CubV: IVirtualCube;
CompDim: ICompoundDimension;
CustDim: ICustomDimension;
i: Integer;
Function TypeString(CustDim: ICustomDimension; i: Integer): String;
Var
c: String;
Begin
Select Case CustDim.Attributes.Item(i).DataType.ToString
Case "1": c := "String";
Case "2": c := "Integer";
Case "3": c := "Float";
Case "4": c := "DataTime";
End Select;
Return c;
End Function TypeString;
Begin
MB := MetabaseClass.Active;
Mobj := MB.ItemById("V_CUBE").Edit;
CubV := Mobj As IVirtualCube;
CompDim := CubV.FactDimension As ICompoundDimension;
CompDim.InitCustomContainer;
CustDim := CompDim.CustomContainer;
Debug.WriteLine("No. Identifier Name Attribute type");
For i:=0 To CustDim.Attributes.Count-1 Do
Debug.WriteLine(i.ToString + " " + CustDim.Attributes.Item(i).Id + " " + CustDim.Attributes.Item(i).Name + " " + TypeString(CustDim,i))
End For;
MObj.Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
CubV: IVirtualCube;
CompDim: ICompoundDimension;
CustDim: ICustomDimension;
i: Integer;
TypeString: String;
Begin
MB := Params.Metabase;
Mobj := MB.ItemById["V_CUBE"].Edit();
CubV := Mobj As IVirtualCube;
CompDim := CubV.FactDimension As ICompoundDimension;
CompDim.InitCustomContainer();
CustDim := CompDim.CustomContainer;
TypeString := CustDim.Attributes.Item[i].DataType.ToString();
System.Diagnostics.Debug.WriteLine("No. Identifier Name Attribute type");
For i:=0 To CustDim.Attributes.Count-1 Do
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + CustDim.Attributes.Item[i].Id + " " + CustDim.Attributes.Item[i].Name + " " + TypeString)
End For;
MObj.Save();
End Sub;
After executing the example a fact dimension is created for the virtual cube. The console window displays identifier, name and type for all fact dimension attributes.
See also: