SetIterator(Value: IRdsElementsIterator);
SetIterator(Value: Prognoz.Platform.Interop.Rds.IRdsElementsIterator);
Value. Iterator.
The SetIterator method sets the iterator, in which element search is executed.
This property is relevant only for table MDM dictionaries.
The IRdsDictionaryElementsSearch.IsIterator property returns if the search is executed in iterator elements.
On getting the iterator, the search object forms a tree of elements, that is why RAM resources may be insufficient when the sample size is too large. The following error message appears: Not enough memory to complete operation.
Executing the example requires that the repository contains an MDM repository with the RDS identifier. This repository must contain a table MDM dictionary with the DIC identifier.
Add links to the Metabase, Rds and Dimensions system assemblies.
Sub UserProc;
Var
mb: IMetabase;
rdsKey: Integer;
RdsInst: IRdsDictionaryInstance;
elSearch: IRdsDictionaryElementsSearch;
Dict: IRdsDictionary;
Filter: IRdsDictionaryFilterConditions;
Condition: IRdsDictionaryFilterCondition;
Iter: IRdsElementsIterator;
Crit: IDimTextCriteria;
Res: IRdsDictionaryElementList;
i: Integer;
Begin
mb := MetabaseClass.Active;
rdsKey := mb.GetObjectKeyById("RDS");
// Get dictionary, where the search will be run
RdsInst := mb.ItemByIdNamespace("DIC", rdsKey).Open(Null) As IRdsDictionaryInstance;
Dict := RdsInst.Dictionary;
// Create an object for dictionary search
elSearch := RdsInst.CreateSearch;
// Check whether search is performed among the elements obtained from the iterator
If Not elSearch.IsIterator Then
// Create a filter for the iterator
Filter := New RdsDictionaryFilterConditions.Create;
Condition := Filter.Add(Dict.Attributes.FindById("NAME"));
Condition.Operation := RdsConditionOperation.Like;
Condition.Value := "%1%";
// Create an iterator
Iter := RdsInst.BigElements.CreateIterator(1, RdsInst.Elements.Count, Filter, Null);
// Set the created iterator for the object that performs search
elSearch.SetIterator(Iter);
// Cast iterator to the first element
Iter.First;
// Display iterator elements in the console window
Debug.WriteLine("Iterator elements:");
While Iter.Next Do
Debug.WriteLine(Iter.Element.Name);
End While;
End If;
// Define search criteria
elSearch.Attributes.Attributes := "NAME";
Crit := New DimTextCriteria.Create;
Crit.CriteriaOptions := TextCriteriaOptions.SearchStringAttributes;
Crit.Text := "a";
elSearch.SetTextCriteria(Crit);
// Search
Res := elSearch.FindAllList;
// Show results in console window
Debug.WriteLine("Search result:");
For i := 0 To Res.Count - 1 Do
Debug.WriteLine(Res.Item(i).Name);
End For;
End Sub UserProc;
After executing the example, search is executed in MDM dictionary elements. Search options:
All elements containing character "a" in their name are searched.
Search is executed in the elements obtained from the dictionary iterator.
Elements containing character "1" are included in the iterator.
The found elements and iterator elements are displayed in the console window.
Executing the example requires that the repository contains an MDM repository with the RDS identifier. This repository must contain a table MDM dictionary with the DIC identifier.
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Dimensions;
…
[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
rdsKey: uinteger;
RdsInst: IRdsDictionaryInstance;
elSearch: IRdsDictionaryElementsSearch;
Dict: IRdsDictionary;
Filter: RdsDictionaryFilterConditions;
Condition: IRdsDictionaryFilterCondition;
Iter: IRdsElementsIterator;
Crit: DimTextCriteria;
Res: IRdsDictionaryElementList;
i: Integer;
Begin
mb := Params.Metabase;
rdsKey := mb.GetObjectKeyById("RDS");
// Get dictionary, where the search will be run
RdsInst := mb.ItemByIdNamespace["DIC", rdsKey].Open(Null) As IRdsDictionaryInstance;
// Create an object for dictionary search
elSearch := RdsInst.CreateSearch();
// Check whether search is performed among the elements obtained from the iterator
If Not elSearch.IsIterator Then
// Create a filter for the iterator
Filter := New RdsDictionaryFilterConditions.Create();
Dict := RdsInst.Dictionary;
Condition := Filter.Add(Dict.Attributes.FindById("NAME"));
Condition.Operation := RdsConditionOperation.rcoLike;
Condition.Value := "%1%";
// Create an iterator
Iter := RdsInst.BigElements.CreateIterator(1, RdsInst.Elements.Count, Filter, Null);
// Set the created iterator for the object that performs search
elSearch.SetIterator(Iter);
// Cast iterator to the first element
Iter.First;
// Display iterator elements in the console window
System.Diagnostics.Debug.WriteLine("Iterator elements:");
While Iter.Next() Do
System.Diagnostics.Debug.WriteLine(Iter.Element.Name);
End While;
End If;
// Define search criteria
elSearch.Attributes.Attributes := "NAME";
Crit := New DimTextCriteria.Create();
Crit.CriteriaOptions := TextCriteriaOptions.tecropSearchStringAttributes;
Crit.Text := "a";
elSearch.SetTextCriteria(Crit);
// Search
Res := elSearch.FindAllList();
// Show results in console window
System.Diagnostics.Debug.WriteLine("Search results:");
For i := 0 To Res.Count - 1 Do
System.Diagnostics.Debug.WriteLine(Res.Item[i].Name);
End For;
End Sub;
After executing the example, search is executed in MDM dictionary elements. Search options:
All elements containing character "a" in their name are searched.
Search is executed in the elements obtained from the dictionary iterator.
Elements containing character "1" are included in the iterator.
The found elements and iterator elements are displayed in the console window.
See also: