Dictionary: IMetabaseObjectDescriptor;
The Dictionary property returns an MDM dictionary, which elements depend on repository object.
To get the object of repository, on which MDM dictionary object depends, use the IMbElementDependent.Object property.
Executing the example requires MDM dictionaries with the DICT and DICT1 identifiers.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Obj, Dictionary, Dict: IMetabaseObjectDescriptor;
RdsDictIns: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Depends: IMbElementDependents;
Depend: IMbElementDependent;
Template, Value: IMbElementDependentTemplate;
ElemKeys: Array[2] Of Integer;
ObjKey, DictKey, ElemKey: Integer;
ElemDependDB: IMbElementDependentsDatabase;
i: Integer;
Begin
MB := MetabaseClass.Active;
Obj := MB.ItemById("DICT1");
Dictionary := MB.ItemById("DICT");
RdsDictIns := Dictionary.Open(Null) As IRdsDictionaryInstance;
Elements := RdsDictIns.Elements;
// Object settings:
Obj := Obj.EditDescriptor;
Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependecies;
Obj.ElementDependents;
Obj.SaveDescriptor;
/// Settings:
DictKey := Dictionary.Key;
ObjKey := Obj.Key;
// Template:
Template := New MbElementDependentTemplateClass.CreateByDictionary(DictKey);
Template.DictionaryKey := Dictionary.Key;
ElemKeys[0] := Elements.Element(1);
ElemKeys[1] := Elements.Element(2);
//Specify keys of elements
Template.ElementKeys := ElemKeys;
// Collection of dependencies:
ElemDependDB := Mb.ElementDependentsDatabase;
Depends := ElemDependDB.Select_(Template);
Value := New MbElementDependentTemplateClass.Create(ObjKey, DictKey, ElemKey);
Depends.Add(Value);
Depends.Modified := True;
ElemDependDB.Update(Depends);
// Output information:
Debug.WriteLine("Current repository parameters: " + ElemDependDB.Metabase.Name);
If ElemDependDB.Active = True Then
Debug.WriteLine("Dependencies can be saved for repository objects");
Else
Debug.WriteLine("Dependencies cannot be saved for repository objects");
End If;
Debug.WriteLine("Object dependencies are set up:");
For i := 0 To Depends.Count - 1 Do
Depend := Depends.Item(i);
Dict := Depend.Dictionary;
Debug.WriteLine(" " + Dict.Name + ", identifier: " + Dict.Id);
Obj := Depend.Object;
Debug.WriteLine(" " + Obj.Name + ", identifier: " + Obj.Id);
End For;
Debug.WriteLine("Number of element keys of MDM dictionary: "
+ Template.ElementKeysCount.ToString);
End Sub UserProc;
After executing the example the information is displayed to the console window:
Current repository parameters.
Whether dependencies can be saved.
List of objects with set up dependencies.
See also: