Setting Up Objects Properties and Parameters

After the object description is obtained, start working with it and get access to object structure, its parameters, data, access permissions.

Editing Object Descriptions

To change name, identifier and other common properties of all objects, it is required to open object description for edit using the IMetabaseObjectDescriptor.EditDescriptor method, change properties and save description using the IMetabaseObjectDescriptor.SaveDescriptor method:

Sub Main;
Var
    Mb: IMetabase;
    MDesc: IMetabaseObjectDescriptor;
Begin
    Mb := MetabaseClass.Active;
    // Get object description
    MDesc := Mb.ItemById("Report");
    // Edit object description
    MDesc := MDesc.EditDescriptor;
    // Rename
    MDesc.Name := MDesc.Name + " (latest version)";
    // Save description
    MDesc.SaveDescriptor;
End Sub Main;

Getting Object Structure

To set up object and change its specific properties, it is required to get object structure. The IMetabaseObject interface describes the common structure of all repository objects, two methods in object description are used to get it - IMetabaseObjectDescriptor.Bind and IMetabaseObjectDescriptor.Edit. The Bind method returns object structure that is available for reading; the Edit method returns structure available for editing. To continue work, the structure described by the IMetabaseObject interface must be cast to the interface that is responsible for corresponding object type. Types are cast using the As operation. The interfaces that are responsible for various repository objects are described in various assemblies, for example:

For details see the list of available assemblies and their contents. The example of getting access to unit and regular report setup:

Sub Main;
Var
    Mb: IMetabase;
    MObj: IMetabaseObject;
    Report: IPrxReport;
Begin
    Mb := MetabaseClass.Active;
    // Get object structure
    MObj := Mb.ItemById("Module").Bind;
    // Open object structure for edit
    MObj := Mb.ItemById("Report").Edit;
    // Cast structure to the interface that is used to work with regular reports
    Report := MObj As IPrxReport;
    // Change regular report settings
    Report.ActiveSheet := Report.Sheets.FindByName("Results");
    Report.Options.DisplayTabs := TriState.OffOption;
    //...
    // Save changes
    MObj.Save;
End Sub Main;

Setting Up Object Parameters

Most of the Foresight Analytics Platform objects can have a set of parameters that are used to filter selected data, to manage other objects or any other operations. Parameter values are requested on opening the object. The list of object parameters is generated in the IMetabaseObjectDescriptor.Params property.

When setting up the list of parameters, the object must be opened for edit:

Sub Main;
Var
    Mb: IMetabase;
    MObj: IMetabaseObject;
    Params: IMetabaseObjectParams;
    Param: IMetabaseObjectParam;
Begin
    Mb := MetabaseClass.Active;
    // Get object description
    MObj := Mb.ItemById("Report").Edit;
    // Edit list of parameters
    Params := MObj.Params;
    Param := Params.Add;
    Param.Id := "Start_Date";
    Param.Name := "Start date";
    Param.DataType := DbDataType.Date;
    Param := Params.Add;
    Param.Id := "End_Date";
    Param.Name := "End date";
    Param.DataType := DbDataType.Date;
    // Save object
    MObj.Save;
End Sub Main;

Some objects have their proper set of parameters, for example, access to table MDM dictionaries parameters is executed using the IRdsDictionary.Params property. This is due to the need to set any specific settings for parameters.

See also:

Developing User Application