CreateSegment(SelectionSet: IDimSelectionSet): ICubeSegment;
SelectionSet. Dimension element selection, according to which data access will be determined.
The CreateSegment method creates a cube segment.
Before creating a segment all cube dimensions should be added to the collection of dimensions of segment container.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier and a segment container with the SEG_CONTAINER identifier. The list of cube dimensions includes a dimension with the COUNTRY identifier. The list of container dimensions should include all cube dimensions.
Add links to the Cubes, Db, Dimensions and Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
SegContainer: ICubeSegmentContainer;
Cube: IStandardCube;
CubeDest: ICubeInstanceDestination;
DimSS: IDimSelectionSet;
DimS: IDimSelection;
Segment: ICubeSegment;
SecDesc: ISecurityDescriptor;
Subject: ISecuritySubject;
Acl: IAccessControlList;
Begin
Mb := MetabaseClass.Active;
SegContainer := Mb.ItemById("SEG_CONTAINER").Edit As ICubeSegmentContainer;
// Specify segment container for cube
Cube := Mb.ItemById("STD_CUBE").Edit As IStandardCube;
Cube.SegmentContainer := SegContainer;
(Cube As IMetabaseObject).Save;
// Open cube
CubeDest := (Mb.ItemById("STD_CUBE").Open(Null) As ICubeInstance).Destinations.DefaultDestination;
// Create a selection, according to which a segment will be created
DimSS := CubeDest.CreateDimSelectionSet;
DimS := DimSS.FindById("COUNTRY");
DimS.DeselectAll;
DimS.SelectElement(0, False);
// Create a segment based on cube selection
Segment := SegContainer.CreateSegment(DimSS);
// Save changes
(SegContainer As IMetabaseObject).Save;
// Grant access permissions to segment
SecDesc := (Segment As IMetabaseObjectDescriptor).SecurityDescriptor;
SecDesc.Edit;
Acl := SecDesc.Acl;
Subject := Mb.Security.ResolveName("USERS");
Acl.AddAce(AceType.AccessAllowed, Subject.Sid, MetabaseObjectPredefinedRights.Read);
Subject := Mb.LogonSession.User;
Acl.AddAce(AceType.AccessAllowed, Subject.Sid, MetabaseObjectPredefinedRights.Read Or MetabaseObjectPredefinedRights.Write);
SecDesc.Apply(True);
End Sub UserProc;
After executing the example a segment container is set for a standard cube. After this a new segment is created based on the specified cube selection. Access permissions are granted for the segment: for users from the Users group - read-only permissions; for the current user who executed the code - read and write permissions.
See also: