MbElementDependencyTemplateClass.CreateByObject

Fore Syntax

CreateByObject(ObjectKey: Integer);

Fore.NET Syntax

CreateByObject(ObjectKey: UInteger);

Parameters

ObjectKey - an object key, for which dependencies template is created.

Description

The CreateByDictionary constructor creates a new dependencies template in accordance with parameters of repository object.

Comments

To get an object key it is necessary to use the IMetabaseObjectDescriptor.Key property or the IMetabase.GetObjectKeyById method.

Fore Example

Executing the example requires that the repository contains an object with the Obj_1 identifier and an MDM dictionary with the Country identifier in repository. Monitoring dependencies from elements of MDM dictionary is included for an object. The dictionary is stored in the MDM repository with the RDS identifier.

Sub UserProc;
Var
    MB: IMetabase;
    DepDB: IMbElementDependenciesDatabase;
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependencies;
    Template: IMbElementDependencyTemplate;
    ElemKeys: Array Of Integer;
Begin
    MB := MetabaseClass.Active;
    DepDB := MB.ElementDependenciesDatabase;
    Depends := DepDB.New_;
    Obj := MB.ItemById("Obj_1");
    //Creation of a template
    Template := New MbElementDependencyTemplateClass.CreateByObject(Obj.Key);
    Dictionary := MB.ItemByIdNamespace("Country", MB.ItemById("RDS").Key);
    Elements := (Dictionary.Open(NullAs IRdsDictionaryInstance).Elements;
    //Specify a dictionary
    Template.DictionaryKey := Dictionary.Key;
    ElemKeys := New Integer[2];
    ElemKeys[0] := Elements.Element(1);
    ElemKeys[1] := Elements.Element(2);
    //Specify keys of elements
    Template.ElementKeys := ElemKeys;
    //Add dependencies
    Depends.Add(Template);
    Mb.ElementDependenciesDatabase.Update(Depends);
End Sub UserProc;

On executing the example a collection of object dependencies from elements of MDM dictionary will be obtained. Two dependencies from two elements of a dictionary will be added into a list of dependencies. A list of dependencies is saved in the repository base.

Fore.NET Example

Executing the example requires that the repository contains an object with the Obj_1 identifier and an MDM dictionary with the Country identifier in repository. Monitoring dependencies from elements of MDM dictionary is included for an object. The dictionary is stored in the MDM repository with the RDS identifier.

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    DepDB: IMbElementDependenciesDatabase;
    DependencyTemplateClass: MbElementDependencyTemplateClassClass = New MbElementDependencyTemplateClassClass();
    Obj, Dictionary: IMetabaseObjectDescriptor;
    Elements: IRdsDictionaryElements;
    Depends: IMbElementDependencies;
    Template: MbElementDependencyTemplateClass;
    ElemKeys: Array Of integer;
Begin
    MB := Params.Metabase;
    DepDB := MB.ElementDependenciesDatabase;
    Depends := DepDB.@New();
    Obj := MB.ItemById["Obj_1"];
    //Creation of a template
    DependencyTemplateClass.CreateByObject(Obj.Key);
    Template := DependencyTemplateClass As MbElementDependencyTemplateClass;
    Dictionary := MB.ItemByIdNamespace["Country", MB.ItemById["RDS"].Key];
    Elements := (Dictionary.Open(NullAs IRdsDictionaryInstance).Elements;
    //Specify a dictionary
    Template.DictionaryKey := Dictionary.Key;
    ElemKeys := New integer[2];
    ElemKeys[0] := Elements.Element[1As integer;
    ElemKeys[1] := Elements.Element[2As integer;
    //Specify keys of elements
    Template.ElementKeys := ElemKeys;
    //Add dependencies
    Depends.Add(Template);
    Mb.ElementDependenciesDatabase.Update(Depends);
End Sub;

The specified procedure is an entry point for the .NET assembly. On executing the example a collection of object dependencies from elements of MDM dictionary will be obtained. Two dependencies from two elements of a dictionary will be added into a list of dependencies. A list of dependencies is saved in the repository base.

See also:

MbElementDependencyTemplateClass