Dictionary: IMetabaseObjectDescriptor;
Dictionary: Prognoz.Platform.Interop.Metabase.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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Rds;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Obj, Dictionary, Dict: IMetabaseObjectDescriptor;
RdsDictIns: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Depends: IMbElementDependents;
Depend: IMbElementDependent;
Template, Value: MbElementDependentTemplateClass;
DependTemplClassT, DependTemplClassV: MbElementDependentTemplateClassClass = New MbElementDependentTemplateClassClass();
ElemKeys: Array[2] Of uinteger;
ObjKey, DictKey, ElemKey: uinteger;
ElemDependDB: IMbElementDependentsDatabase;
i: Integer;
Begin
MB := Params.Metabase;
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.mbeledeptratypDependecies;
Obj.ElementDependents;
Obj.SaveDescriptor();
/// Settings:
DictKey := Dictionary.Key;
ObjKey := Obj.Key;
// Template:
DependTemplClassT.CreateByDictionary(DictKey);
Template := DependTemplClassT As MbElementDependentTemplateClass;
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);
DependTemplClassV.Create(ObjKey, DictKey, ElemKey);
Value := DependTemplClassV As MbElementDependentTemplateClass;
Depends.Add(Value);
Depends.Modified := True;
ElemDependDB.Update(Depends);
// Output information:
System.Diagnostics.Debug.WriteLine("Current repository parameters: " + ElemDependDB.Metabase.Name);
If ElemDependDB.Active = True Then
System.Diagnostics.Debug.WriteLine("Dependencies can be saved for repository objects");
Else
System.Diagnostics.Debug.WriteLine("Dependencies cannot be saved for repository objects");
End If;
System.Diagnostics.Debug.WriteLine("Dependencies are set up for objects:");
For i := 0 To Depends.Count - 1 Do
Depend := Depends.Item[i];
Dict := Depend.Dictionary;
System.Diagnostics.Debug.WriteLine(" " + Dict.Name + ", identifier: " + Dict.Id);
Obj := Depend.Object;
System.Diagnostics.Debug.WriteLine(" " + Obj.Name + ", identifier: " + Obj.Id);
End For;
System.Diagnostics.Debug.WriteLine("Number of element keys of MDM dictionary: "
+ Template.ElementKeysCount.ToString());
End Sub;
See also: