Clear;
Clear();
The Clear method removes of the attributes from collection.
Deleting all attributes also deletes all created dimension elements. In case of removing all attributes to support dictionary performance, new attributes with the following purposes should be created: primary key, identifier, name and order.
Executing the example requires a standard cube with the CUBE_CUSTOM identifier in the repository. In this cube list of facts and its hierarchy must be defined at the local level.
Add links to the Cubes, Dal, Dimensions, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Cube: IStandardCube;
CustDim: ICustomDimension;
CustAttrs: ICustomDimAttributes;
Attr: ICustomDimAttribute;
Elems: ICustomDimElements;
i: Integer;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get standard cube
MObj := MB.ItemById("CUBE_CUSTOM").Edit;
Cube := MObj As IStandardCube;
// Get cube facts dimension
CustDim := Cube.FactDimension.Dimension As ICustomDimension;
// Get collection of facts dimension attributes
CustAttrs := CustDim.Attributes;
// Clear attributes collection
CustAttrs.Clear;
// Add the Key attribute
Attr := CustAttrs.Add;
Attr.Id := "KEY";
Attr.Name := "Key";
Attr.DataType := DbDataType.Integer;
// Add the Name attribute
Attr := CustAttrs.Add;
Attr.Id := "NAME";
Attr.Name := "Name";
Attr.DataType := DbDataType.String;
// Add the Order attribute
Attr := CustAttrs.Add;
Attr.Id := "ORDER";
Attr.Name := "Order";
Attr.DataType := DbDataType.Integer;
// Add the Identifier attribute
Attr := CustAttrs.Add;
Attr.Id := "ID";
Attr.Name := "Identifier";
Attr.DataType := DbDataType.String;
// Add the Image attribute
Attr := CustAttrs.Add;
Attr.Id := "IMAGE";
Attr.Name := "Image";
Attr.DataType := DbDataType.Integer;
// Set created attributes
CustAttrs.Primary := CustAttrs.FindById("KEY");
CustAttrs.Name := CustAttrs.FindById("NAME");
CustAttrs.Order := CustAttrs.FindById("ORDER");
CustAttrs.Id := CustAttrs.FindById("ID");
CustAttrs.ImageIndex := CustAttrs.FindById("IMAGE");
// Set up attributes values
Elems := CustDim.Elements;
i := Elems.Add;
Elems.AttributeValue(i, 0) := 1;
Elems.AttributeValue(i, 1) := "Value";
Elems.AttributeValue(i, 2) := 1;
Elems.AttributeValue(i, 3) := "VALUE";
Elems.AttributeValue(i, 4) := 1;
// Save changes
MObj.Save;
End Sub UserProc;
After executing the example all attributes of fact dimension are deleted and new attributes are created instead. Attributes are assigned to desired options. A new element is created in fact dimensions and values of all attributes are defined for this element.
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.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Cube: IStandardCube;
CustDim: ICustomDimension;
CustAttrs: ICustomDimAttributes;
Attr: ICustomDimAttribute;
Elems: ICustomDimElements;
i: Integer;
Begin
// Get current repository
MB := Params.Metabase;
// Get standard cube
MObj := MB.ItemById["CUBE_CUSTOM"].Edit();
Cube := MObj As IStandardCube;
// Get cube facts dimension
CustDim := Cube.FactDimension.Dimension As ICustomDimension;
// Get collection of facts dimension attributes
CustAttrs := CustDim.Attributes;
// Clear attributes collection
CustAttrs.Clear();
// Add the Key attribute
Attr := CustAttrs.Add();
Attr.Id := "KEY";
Attr.Name := "Key";
Attr.DataType := DbDataType.ddtInteger;
// Add the Name attribute
Attr := CustAttrs.Add();
Attr.Id := "NAME";
Attr.Name := "Name";
Attr.DataType := DbDataType.ddtString;
// Add the Order attribute
Attr := CustAttrs.Add();
Attr.Id := "ORDER";
Attr.Name := "Order";
Attr.DataType := DbDataType.ddtInteger;
// Add the Identifier attribute
Attr := CustAttrs.Add();
Attr.Id := "ID";
Attr.Name := "Identifier";
Attr.DataType := DbDataType.ddtString;
// Add the Image attribute
Attr := CustAttrs.Add();
Attr.Id := "IMAGE";
Attr.Name := "Image";
Attr.DataType := DbDataType.ddtInteger;
// Set up created attributes
CustAttrs.Primary := CustAttrs.FindById("KEY");
CustAttrs.Name := CustAttrs.FindById("NAME");
CustAttrs.Order := CustAttrs.FindById("ORDER");
CustAttrs.Id := CustAttrs.FindById("ID");
CustAttrs.ImageIndex := CustAttrs.FindById("IMAGE");
// Set attributes values
Elems := CustDim.Elements;
i := Elems.Add();
Elems.AttributeValue[i, 0] := 1;
Elems.AttributeValue[i, 1] := "Value";
Elems.AttributeValue[i, 2] := 1;
Elems.AttributeValue[i, 3] := "VALUE";
Elems.AttributeValue[i, 4] := 1;
// Save changes
MObj.Save();
End Sub;
See also: