ICustomDimAttributes.Clear

Syntax

Clear;

Description

The Clear method removes of the attributes from collection.

Comments

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.

Example

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.

See also:

ICustomDimAttributes