SourceMetadata: ISourceMetadata;
SourceMetadata: Prognoz.Platform.Interop.BISearch.ISourceMetadata;
The SourceMetadata property returns data source metadata.
It is supposed that the repository is set to work with search service based on Apache Solr. The search service base has indexed data about various repository data source slices. Connect the BISearch, Fore, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
SharedParams: ISharedParams;
SearchEngine: ISolrSearchEngineService;
Schema: ISolrSearchEngineSchema;
SearchExecutor: ISearchExecutor;
SearchContext: ISolrSourceDataSearchContext;
Results: ISolrSearchResults;
Result: ISearchSourceDataResult;
Source: ISourceMetadata;
Selections: ISearchDimSelectionSet;
Selection: ISearchDimSelection;
Elements: ISearchDimSelectionElements;
Element: ISearchDimSelectionElement;
Calendars: ICalendarInfos;
Calendar: ICalendarInfo;
MDesc: IMetabaseObjectDescriptor;
i, j: Integer;
Begin
MB := MetabaseClass.Active;
//Parameters of search and indexing set for repository
SharedParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Bind As ISharedParams;
SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
//Search parameters
SearchExecutor := Schema.SearchExecutor(SearchEngineTargetType.SourceData);
SearchContext := SearchExecutor.CreateContext As ISolrSourceDataSearchContext;
SearchContext.Locale := LocaleCodeID.Russian;
SearchContext.Text := "Russia";
//Search
Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
//Source information view for the first search result
Result := Results.Item(0) As ISearchSourceDataResult;
Source := Result.SourceMetadata;
Debug.WriteLine("Slice name: " + Result.Name);
Debug.WriteLine("Source: " + Source.SourceName + '(' + Source.SourceId + ')');
Debug.WriteLine("Object type: " + MetabaseClass.CommonClassName(Source.SourceClassId As MetabaseObjectClass));
If Source.HighlightedSourceName.Length > 0 Then
Debug.WriteLine("Name with search value highlighting: " + Source.HighlightedSourceName);
End If;
Debug.WriteLine("Selection by indexed dimensions:");
Debug.Indent;
//Dimension selection used to form the slice
Selections := Source.Selection;
For i := 0 To Selections.Count - 1 Do
Selection := Selections.Item(i);
Debug.Write("Dimension key: " + Selection.DimensionKey.ToString + ". Elements: ");
Elements := Selection.Elements;
For j := 0 To Elements.Count - 1 Do
Element := Elements.Item(j);
Debug.Write(Element.Name + '(' + Element.Key + ") ");
End For;
Debug.WriteLine("");
End For;
Debug.Unindent;
//Selection of free dimensions, if available
If Source.FreeDimensionsSelection.Count <> 0 Then
Debug.WriteLine("Free dimensions selection:");
Debug.Indent;
Selections := Source.FreeDimensionsSelection;
For i := 0 To Selections.Count - 1 Do
Selection := Selections.Item(i);
Debug.Write("Dimension key: " + Selection.DimensionKey.ToString + ". Elements: ");
Elements := Selection.Elements;
For j := 0 To Elements.Count - 1 Do
Element := Elements.Item(j);
Debug.Write(Element.Name + '(' + Element.Key + ") ");
End For;
Debug.WriteLine("");
End For;
Debug.Unindent;
End If;
//Information about calendar dimensions
Calendars := Source.CalendarInfo;
For i := 0 To Calendars.Count - 1 Do
Calendar := Calendars.Item(i);
MDesc := MB.Item(Calendar.Key);
Debug.WriteLine("Dictionary in the base of calendar dimension: " + MDesc.Name + '(' + MDesc.Id + ')');
Debug.WriteLine("Dates for which data is available: " + Calendar.DateStart.ToString + " - " +
Calendar.DateEnd.ToString);
End For;
End Sub UserProc;
After executing the example the specified value by indexed information about dimension elements will be searched. From the first obtained result you will get information about data source to which the slice belongs. Various information about source selection will be displayed to the development environment console.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Except assemblies determined in the Fore Example, connect also the ForeSystem assembly.
Imports Prognoz.Platform.Interop.BISearch;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MBClass: MetabaseClass = New MetabaseClassClass();
SharedParams: ISharedParams;
SearchEngine: ISolrSearchEngineService;
Schema: ISolrSearchEngineSchema;
SearchExecutor: ISearchExecutor;
SearchContext: ISolrSourceDataSearchContext;
Results: ISolrSearchResults;
Result: ISearchSourceDataResult;
Source: ISourceMetadata;
Selections: ISearchDimSelectionSet;
Selection: ISearchDimSelection;
Elements: ISearchDimSelectionElements;
Element: ISearchDimSelectionElement;
Calendars: ICalendarInfos;
Calendar: ICalendarInfo;
MDesc: IMetabaseObjectDescriptor;
i, j: Integer;
Begin
MB := Params.Metabase;
//Parameters of search and indexing set for repository
SharedParams := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Bind() As ISharedParams;
SearchEngine := SharedParams.SearchEngine As ISolrSearchEngineService;
Schema := SearchEngine.SearchEngineSchema As ISolrSearchEngineSchema;
//Search parameters
SearchExecutor := Schema.SearchExecutor[SearchEngineTargetType.settSourceData];
SearchContext := SearchExecutor.CreateContext() As ISolrSourceDataSearchContext;
SearchContext.Locale := LocaleCodeID.lcidRussian;
SearchContext.Text := "Russia";
//Search
Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
//Source information view for the first search result
Result := Results.Item[0] As ISearchSourceDataResult;
Source := Result.SourceMetadata;
System.Diagnostics.Debug.WriteLine("Slice name: " + Result.Name);
System.Diagnostics.Debug.WriteLine("Source: " + Source.SourceName + '(' + Source.SourceId + ')');
System.Diagnostics.Debug.WriteLine("Object type: " + MBClass.CommonClassName[Source.SourceClassId As MetabaseObjectClass,
NameCasePlural.ncNominative]);
If Source.HighlightedSourceName.Length > 0 Then
System.Diagnostics.Debug.WriteLine("Name with search value highlighting: " + Source.HighlightedSourceName);
End If;
System.Diagnostics.Debug.WriteLine("Selection by indexed dimensions:");
System.Diagnostics.Debug.Indent();
//Dimension selection used to form the slice
Selections := Source.Selection;
For i := 0 To Selections.Count - 1 Do
Selection := Selections.Item[i];
System.Diagnostics.Debug.Write("Dimension key: " + Selection.DimensionKey.ToString() + ". Elements: ");
Elements := Selection.Elements;
For j := 0 To Elements.Count - 1 Do
Element := Elements.Item[j];
System.Diagnostics.Debug.Write(Element.Name + '(' + Element.Key + ") ");
End For;
System.Diagnostics.Debug.WriteLine("");
End For;
System.Diagnostics.Debug.Unindent();
//Selection of free dimensions, if available
If Source.FreeDimensionsSelection.Count <> 0 Then
System.Diagnostics.Debug.WriteLine("Free dimensions selection:");
System.Diagnostics.Debug.Indent();
Selections := Source.FreeDimensionsSelection;
For i := 0 To Selections.Count - 1 Do
Selection := Selections.Item[i];
System.Diagnostics.Debug.Write("Dimension key: " + Selection.DimensionKey.ToString() + ". Elements: ");
Elements := Selection.Elements;
For j := 0 To Elements.Count - 1 Do
Element := Elements.Item[j];
System.Diagnostics.Debug.Write(Element.Name + '(' + Element.Key + ") ");
End For;
System.Diagnostics.Debug.WriteLine("");
End For;
System.Diagnostics.Debug.Unindent();
End If;
//Information about calendar dimensions
Calendars := Source.CalendarInfo;
For i := 0 To Calendars.Count - 1 Do
Calendar := Calendars.Item[i];
MDesc := MB.Item[Calendar.Key];
System.Diagnostics.Debug.WriteLine("Dictionary in the base of calendar dimension: " + MDesc.Name + '(' + MDesc.Id + ')');
System.Diagnostics.Debug.WriteLine("Dates for which data is available: " + Calendar.DateStart.ToString() + " - " +
Calendar.DateEnd.ToString());
End For;
End Sub;
See also: