Skip to content
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

Update the value when default ValueSet is used in DefaultSelection #270

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
4 changes: 4 additions & 0 deletions PxWeb/Code/Api2/DataSelection/SelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
/// <param name="variablesSelection">The VariablesSelection object to verify and apply codelists for</param>
/// <param name="problem">Null if everything is ok, otherwise it describes whats wrong</param>
/// <returns>True if everything was ok, else false</returns>
private bool VerifyAndApplyCodelists(IPXModelBuilder builder, VariablesSelection? variablesSelection, out Problem? problem)

Check warning on line 93 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Refactor this method to reduce its Cognitive Complexity from 32 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 93 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Refactor this method to reduce its Cognitive Complexity from 32 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
problem = null;

Expand Down Expand Up @@ -187,7 +187,7 @@
return true;
}

private bool ApplyGrouping(IPXModelBuilder builder, Variable pxVariable, VariableSelection variable, out Problem? problem)

Check warning on line 190 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 190 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'ApplyGrouping' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
problem = null;

Expand Down Expand Up @@ -221,7 +221,7 @@
return true;
}

private bool ApplyValueset(IPXModelBuilder builder, Variable pxVariable, VariableSelection variable, out Problem? problem)

Check warning on line 224 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 224 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'ApplyValueset' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
problem = null;

Expand Down Expand Up @@ -260,7 +260,7 @@
/// <param name="variablesSelection">VariablesSelection with the wanted variables and values</param>
/// <param name="problem">Will be null if everything is ok, oterwise it will describe the problem</param>
/// <returns></returns>
private bool VerifyVariableValues(PXModel model, VariablesSelection variablesSelection, out Problem? problem)

Check warning on line 263 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Refactor this method to reduce its Cognitive Complexity from 31 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 263 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Refactor this method to reduce its Cognitive Complexity from 31 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
problem = null;

Expand All @@ -268,14 +268,14 @@
{
//Verify that variables have at least one value selected for mandatory varibles
var mandatory = Mandatory(model, variable);
if (variable.ValueCodes.Count().Equals(0) && mandatory)

Check warning on line 271 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Count' property here instead. (https://rules.sonarsource.com/csharp/RSPEC-2971)

Check warning on line 271 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Count' property here instead. (https://rules.sonarsource.com/csharp/RSPEC-2971)
{
problem = ProblemUtility.NonExistentValue();
return false;
}

//Check variable values if they exists in model.Metadata
if (!variable.ValueCodes.Count().Equals(0))

Check warning on line 278 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Count' property here instead. (https://rules.sonarsource.com/csharp/RSPEC-2971)

Check warning on line 278 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Count' property here instead. (https://rules.sonarsource.com/csharp/RSPEC-2971)
{
var modelVariable = model.Meta.Variables.GetByCode(variable.VariableCode);

Expand Down Expand Up @@ -362,7 +362,7 @@
/// </summary>
/// <param name="expression">The wildcard selection expression to validate</param>
/// <returns>True if the expression is valid, else false</returns>
private bool VerifyWildcardStarExpression(string expression)

Check warning on line 365 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 365 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'VerifyWildcardStarExpression' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
if (expression.Equals("*"))
{
Expand Down Expand Up @@ -397,7 +397,7 @@
/// </summary>
/// <param name="expression">The wildcard selection expression to validate</param>
/// <returns>True if the expression is valid, else false</returns>
private bool VerifyWildcardQuestionmarkExpression(string expression)

Check warning on line 400 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 400 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Remove this unused method parameter 'expression'. (https://rules.sonarsource.com/csharp/RSPEC-1172)

Check warning on line 400 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'VerifyWildcardQuestionmarkExpression' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
// What could be wrong?
return true;
Expand All @@ -408,7 +408,7 @@
/// </summary>
/// <param name="expression">The TOP selection expression to validate</param>
/// <returns>True if the expression is valid, else false</returns>
private bool VerifyTopExpression(string expression)

Check warning on line 411 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 411 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'VerifyTopExpression' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
return Regex.IsMatch(expression, REGEX_TOP, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(100));
}
Expand All @@ -418,7 +418,7 @@
/// </summary>
/// <param name="expression">The BOTTOM selection expression to validate</param>
/// <returns>True if the expression is valid, else false</returns>
private bool VerifyBottomExpression(string expression)

Check warning on line 421 in PxWeb/Code/Api2/DataSelection/SelectionHandler.cs

View workflow job for this annotation

GitHub Actions / build

Make 'VerifyBottomExpression' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
return Regex.IsMatch(expression, REGEX_BOTTOM, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(100));
}
Expand Down Expand Up @@ -1155,6 +1155,10 @@
{
builder.ApplyGrouping(variable.Code, variable.GetGroupingInfoById(variable.CurrentGrouping.ID), GroupingIncludesType.AggregatedValues);
}
else if (variable.CurrentValueSet != null)
{
builder.ApplyValueSet(variable.Code, variable.CurrentValueSet);
}
}

var contents = meta.Variables.FirstOrDefault(v => v.IsContentVariable);
Expand Down
Loading