Skip to content

Added SubjectCode to the table output PXWEB2-737 #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Px.Search.Lucene/LuceneIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Px.Search.Lucene
{

public class LuceneIndex : IIndex

Check warning on line 6 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

Fix this implementation of 'IDisposable' to conform to the dispose pattern. (https://rules.sonarsource.com/csharp/RSPEC-3881)

Check warning on line 6 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

Fix this implementation of 'IDisposable' to conform to the dispose pattern. (https://rules.sonarsource.com/csharp/RSPEC-3881)
{
private readonly string _indexDirectoryBase = "";
private string _indexDirectoryCurrent = "";
Expand All @@ -19,7 +19,7 @@
{
if (string.IsNullOrWhiteSpace(indexDirectory))
{
throw new ArgumentNullException("Index directory not defined for Lucene");

Check warning on line 22 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

The parameter name 'Index directory not defined for Lucene' is not declared in the argument list. (https://rules.sonarsource.com/csharp/RSPEC-3928)

Check warning on line 22 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

The parameter name 'Index directory not defined for Lucene' is not declared in the argument list. (https://rules.sonarsource.com/csharp/RSPEC-3928)
}

_indexDirectoryBase = indexDirectory;
Expand Down Expand Up @@ -74,7 +74,7 @@
{
if (string.IsNullOrWhiteSpace(language))
{
throw new ArgumentNullException("Language not specified");

Check warning on line 77 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

The parameter name 'Language not specified' is not declared in the argument list. (https://rules.sonarsource.com/csharp/RSPEC-3928)

Check warning on line 77 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

The parameter name 'Language not specified' is not declared in the argument list. (https://rules.sonarsource.com/csharp/RSPEC-3928)
}

_indexDirectoryCurrent = Path.Combine(_indexDirectoryBase, language);
Expand All @@ -83,7 +83,7 @@

if (_writer == null)
{
throw new Exception("Could not create IndexWriter. Index directory may be locked by another IndexWriter");

Check warning on line 86 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

'System.Exception' should not be thrown by user code. (https://rules.sonarsource.com/csharp/RSPEC-112)
}
}

Expand All @@ -91,7 +91,7 @@
{
if (string.IsNullOrWhiteSpace(language))
{
throw new ArgumentNullException("Language not specified");

Check warning on line 94 in Px.Search.Lucene/LuceneIndex.cs

View workflow job for this annotation

GitHub Actions / build

The parameter name 'Language not specified' is not declared in the argument list. (https://rules.sonarsource.com/csharp/RSPEC-3928)
}

_indexDirectoryCurrent = Path.Combine(_indexDirectoryBase, language);
Expand Down Expand Up @@ -209,6 +209,7 @@
doc.Add(new TextField(SearchConstants.SEARCH_FIELD_TAGS, GetAllTags(tbl.Tags), Field.Store.YES));
doc.Add(new TextField(SearchConstants.SEARCH_FIELD_SOURCE, tbl.Source, Field.Store.YES));
doc.Add(new TextField(SearchConstants.SEARCH_FIELD_TIME_UNIT, tbl.TimeUnit, Field.Store.YES));
doc.Add(new TextField(SearchConstants.SEARCH_SUBJECT_CODE, tbl.SubjectCode, Field.Store.YES));
doc.Add(new StoredField(SearchConstants.SEARCH_FIELD_PATHS, GetBytes(tbl.Paths)));
if (!string.IsNullOrEmpty(meta.Synonyms))
{
Expand Down
3 changes: 2 additions & 1 deletion Px.Search.Lucene/LuceneSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ private static SearchResult GetSearchResult(Document doc)
doc.Get(SearchConstants.SEARCH_FIELD_LASTPERIOD),
doc.Get(SearchConstants.SEARCH_FIELD_VARIABLES).Split("|"),
doc.Get(SearchConstants.SEARCH_FIELD_SOURCE),
doc.Get(SearchConstants.SEARCH_FIELD_TIME_UNIT)
doc.Get(SearchConstants.SEARCH_FIELD_TIME_UNIT),
doc.Get(SearchConstants.SEARCH_SUBJECT_CODE)

);
searchResult.Description = doc.Get(SearchConstants.SEARCH_FIELD_DESCRIPTION);
Expand Down
1 change: 1 addition & 0 deletions Px.Search.Lucene/SearchConstants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Px.Search.Lucene
{
public class SearchConstants

Check warning on line 3 in Px.Search.Lucene/SearchConstants.cs

View workflow job for this annotation

GitHub Actions / build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)

Check warning on line 3 in Px.Search.Lucene/SearchConstants.cs

View workflow job for this annotation

GitHub Actions / build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)
{
// Search field constants
public const string SEARCH_FIELD_DOCID = "docid";
Expand All @@ -27,5 +27,6 @@
public const string SEARCH_FIELD_SOURCE = "source";
public const string SEARCH_FIELD_TIME_UNIT = "timeunit";
public const string SEARCH_FIELD_PATHS = "paths";
public const string SEARCH_SUBJECT_CODE = "subjectcode";
}
}
1 change: 1 addition & 0 deletions Px.Search/Indexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
return;
}

if (item is PxMenuItem)

Check warning on line 146 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Replace this type-check-and-cast sequence to use pattern matching. (https://rules.sonarsource.com/csharp/RSPEC-3247)

Check warning on line 146 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Replace this type-check-and-cast sequence to use pattern matching. (https://rules.sonarsource.com/csharp/RSPEC-3247)
{
foreach (var subitem in ((PxMenuItem)item).SubItems)
{
Expand All @@ -155,7 +155,7 @@
{
TraverseDatabase(subitem.ID.Selection, language, index);
}
else if (subitem is TableLink)

Check warning on line 158 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Replace this type-check-and-cast sequence to use pattern matching. (https://rules.sonarsource.com/csharp/RSPEC-3247)

Check warning on line 158 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Replace this type-check-and-cast sequence to use pattern matching. (https://rules.sonarsource.com/csharp/RSPEC-3247)
{
AddTableToIndex(language, index, (TableLink)subitem);
}
Expand Down Expand Up @@ -275,12 +275,13 @@
tbl.Description = tblLink.Description;
tbl.SortCode = tblLink.SortCode;
tbl.Updated = tblLink.LastUpdated;
tbl.Discontinued = null; // TODO: Implement later

Check warning on line 278 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 278 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
tbl.SubjectCode = meta.SubjectCode ?? string.Empty;

return tbl;
}

private string GetCategory(TableLink tblLink)

Check warning on line 284 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Make 'GetCategory' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)

Check warning on line 284 in Px.Search/Indexer.cs

View workflow job for this annotation

GitHub Actions / build

Make 'GetCategory' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
switch (tblLink.Category)
{
Expand Down
3 changes: 2 additions & 1 deletion Px.Search/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
/// </summary>
public class SearchResult : TableInformation
{
public SearchResult(string id, string label, string category, string firstPeriod, string lastPeriod, string[] variableNames, string source, string timeUnit)
public SearchResult(string id, string label, string category, string firstPeriod, string lastPeriod, string[] variableNames, string source, string timeUnit, string subjectCode)
: base(id, label, category, firstPeriod, lastPeriod, variableNames)
{
Source = source;
TimeUnit = timeUnit;
SubjectCode = subjectCode;
}

public float Score { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Px.Search/TableInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FirstPeriod = firstPeriod;
LastPeriod = lastPeriod;
VariableNames = variableNames;
Tags = new string[] { }; // TODO: Implement later

Check warning on line 13 in Px.Search/TableInformation.cs

View workflow job for this annotation

GitHub Actions / build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 13 in Px.Search/TableInformation.cs

View workflow job for this annotation

GitHub Actions / build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
Paths = new List<Level[]>();
Source = "";
TimeUnit = "X";
Expand All @@ -30,5 +30,6 @@
public List<Level[]> Paths { get; set; }
public string Source { get; set; }
public string TimeUnit { get; set; }
public string SubjectCode { get; set; } = string.Empty;
}
}
3 changes: 2 additions & 1 deletion PxWeb/Mappers/TableResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public TableResponse Map(SearchResult searchResult, string lang)
VariableNames = searchResult.VariableNames.ToList(),
Links = linkList,
Language = lang,
SortCode = searchResult.SortCode ?? string.Empty
SortCode = searchResult.SortCode ?? string.Empty,
SubjectCode = searchResult.SubjectCode ?? string.Empty

};
return tableResponse;
Expand Down
3 changes: 2 additions & 1 deletion PxWeb/Mappers/TablesResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public TablesResponse Map(SearchResultContainer searchResultContainer, string la
Category = EnumConverter.ToCategoryEnum(item.Category),
Discontinued = item.Discontinued,
VariableNames = item.VariableNames.ToList(),
Links = linkList
Links = linkList,
SubjectCode = item.SubjectCode ?? string.Empty,
};
tableList.Add(tb);
}
Expand Down
2 changes: 1 addition & 1 deletion PxWeb/PxWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<PackageReference Include="PCAxis.Menu.ConfigDatamodelMenu" Version="1.0.8" />
<PackageReference Include="PCAxis.Serializers" Version="1.9.0" />
<PackageReference Include="PcAxis.Sql" Version="1.4.3" />
<PackageReference Include="PxWeb.Api2.Server" Version="2.0.0-beta.17" />
<PackageReference Include="PxWeb.Api2.Server" Version="2.0.0-beta.18" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="8.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="8.1.4" />
Expand Down
Binary file removed PxWeb/wwwroot/Database/_INDEX/en/_8.cfe
Binary file not shown.
Binary file added PxWeb/wwwroot/Database/_INDEX/en/_a.cfe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified PxWeb/wwwroot/Database/_INDEX/en/segments.gen
Binary file not shown.
Binary file removed PxWeb/wwwroot/Database/_INDEX/en/segments_9
Binary file not shown.
Binary file added PxWeb/wwwroot/Database/_INDEX/en/segments_b
Binary file not shown.
Binary file removed PxWeb/wwwroot/Database/_INDEX/sv/_8.cfe
Binary file not shown.
Binary file added PxWeb/wwwroot/Database/_INDEX/sv/_a.cfe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified PxWeb/wwwroot/Database/_INDEX/sv/segments.gen
Binary file not shown.
Binary file removed PxWeb/wwwroot/Database/_INDEX/sv/segments_9
Binary file not shown.
Binary file added PxWeb/wwwroot/Database/_INDEX/sv/segments_b
Binary file not shown.
Loading