DateLevels: Array;
DateLevels: Array;
The DateLevels property returns list of calendar levels for which the source has data.
Each array element contains numeric value determining level. To check values it is possible to use the DimCalendarLevel enumeration.
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;
i: Integer;
s: String;
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 := "2000";
//Search
Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
//Source information view for the first search result
Result := Results.Item(0) As ISearchSourceDataResult;
Debug.WriteLine("Slice name: " + Result.Name);
Debug.WriteLine("Calendar levels for which there is a data:");
Debug.Indent;
For Each i In Result.DateLevels Do
Select Case i
Case 1: Debug.WriteLine("Years");
Case 2: Debug.WriteLine("Half-years");
Case 3: Debug.WriteLine("Quarters");
Case 4: Debug.WriteLine("Months");
Case 5: Debug.WriteLine("Days");
Case 6: Debug.WriteLine("9 months");
Case 7: Debug.WriteLine("Weeks");
End Select;
End For;
Debug.Unindent;
Debug.WriteLine("List of years with data:");
For Each s In Result.Time Do
Debug.Write(s + ' ');
End For;
Debug.WriteLine("");
If Result.HighlightedTime.Length > 0 Then
Debug.WriteLine("List of years with highlighted search value:");
For Each s In Result.HighlightedTime Do
Debug.Write(s + ' ');
End For;
Debug.WriteLine("");
End If;
If Result.HighlightedFreeDimensions.Length > 0 Then
Debug.WriteLine("List of free dimensions with highlighted search dimension:");
For Each s In Result.HighlightedFreeDimensions Do
Debug.Write(s + ' ');
End For;
Debug.WriteLine("");
End If;
End Sub UserProc;
After executing the example the specified value by indexed information about dimension elements will be searched. The first found result will provide information about calendar period for which there is a data. This information will be displayed to the development environment console. The information about free dimensions will be also displayed, if available.
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;
SharedParams: ISharedParams;
SearchEngine: ISolrSearchEngineService;
Schema: ISolrSearchEngineSchema;
SearchExecutor: ISearchExecutor;
SearchContext: ISolrSourceDataSearchContext;
Results: ISolrSearchResults;
Result: ISearchSourceDataResult;
i: Integer;
s: String;
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 := "2000";
//Search
Results := SearchExecutor.Search(SearchContext) As ISolrSearchResults;
//Source information view for the first search result
Result := Results.Item[0] As ISearchSourceDataResult;
System.Diagnostics.Debug.WriteLine("Slice name: " + Result.Name);
System.Diagnostics.Debug.WriteLine("Calendar levels for which there is a data:");
System.Diagnostics.Debug.Indent();
For Each i In Result.DateLevels Do
Select Case i
Case 1: System.Diagnostics.Debug.WriteLine("Years");
Case 2: System.Diagnostics.Debug.WriteLine("Half-years");
Case 3: System.Diagnostics.Debug.WriteLine("Quarters");
Case 4: System.Diagnostics.Debug.WriteLine("Months");
Case 5: System.Diagnostics.Debug.WriteLine("Days");
Case 6: System.Diagnostics.Debug.WriteLine("9 months");
Case 7: System.Diagnostics.Debug.WriteLine("Weeks");
End Select;
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("List of years for which there is a data:");
For Each s In Result.Time Do
System.Diagnostics.Debug.Write(s + ' ');
End For;
System.Diagnostics.Debug.WriteLine("");
If Result.HighlightedTime.Length > 0 Then
System.Diagnostics.Debug.WriteLine("List of years with highlighted search value:");
For Each s In Result.HighlightedTime Do
System.Diagnostics.Debug.Write(s + ' ');
End For;
System.Diagnostics.Debug.WriteLine("");
End If;
If Result.HighlightedFreeDimensions.Length > 0 Then
System.Diagnostics.Debug.WriteLine("List of free dimensions with highlighted search value:");
For Each s In Result.HighlightedFreeDimensions Do
System.Diagnostics.Debug.Write(s + ' ');
End For;
System.Diagnostics.Debug.WriteLine("");
End If;
End Sub;
See also: