DateLevels: Array;
DateLevels: Array;
The DateLevels property returns the list of calendar levels, for which the source has data.
Each array element contains numeric value determining level. To check values, you can use the DimCalendarLevel enumeration.
It is supposed that the repository is set up to work with search service based on Apache Solr. Search service base has indexed data about various repository data source slices. Add links to 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;
//Search and indexing parameters specified 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;
//View source information 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 the calendar period, for which there is a data. This information will be displayed in 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. Along with the assemblies determined in the Fore example, also add a link to the System 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;
//Search and indexing parameters specified 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;
//View source information 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 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: