Skip to content

Commit

Permalink
Made ProblemProvider ignore empty parameter values when value sets de…
Browse files Browse the repository at this point in the history
…fined
  • Loading branch information
tznind committed May 23, 2022
1 parent 94e12e7 commit c63b500
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 'View Aggregate' now explicitly applies an ORDER BY count descending.
- New CatalogueItems are now always marked Core (affects drag and drop and new Catalogue creation) - [#1165](https://github.com/HicServices/RDMP/issues/1165),[#1164](https://github.com/HicServices/RDMP/issues/1164)
- If a Catalogue is defined for a Lookup TableInfo then only Core extractable columns will be released (previously all columns were released) [#692](https://github.com/HicServices/RDMP/issues/692)
- Sql Parameters with no value defined are no longer flagged as Problem by ProblemProvider if they have value sets defined [#1180](https://github.com/HicServices/RDMP/issues/1180)

### Added

Expand All @@ -22,6 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added UserSettings editing UI to Console Gui
- Added ability to suppress tree expansion when opening Cohort Builder configurations

### Fixed

- Fixed order of Sql Parameters not always being first in tree

## [7.0.12] - 2022-05-16

### Added
Expand Down
30 changes: 24 additions & 6 deletions Rdmp.Core/OrderableComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Collections;
using System.Collections.Generic;
using MapsDirectlyToDatabaseTable;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.Cohort;
using Rdmp.Core.DataExport.Data;

Expand Down Expand Up @@ -37,16 +39,19 @@ public OrderableComparer(IComparer nestedComparer)
/// <returns></returns>
public int Compare(object x, object y)
{
var xOrder = GetOrderIfAny(x);
var yOrder = GetOrderIfAny(y);

//Use IOrderable.Order
if (x is IOrderable xOrderable && y is IOrderable yOrderable)
return xOrderable.Order - yOrderable.Order;
if (xOrder.HasValue && yOrder.HasValue)
return xOrder.Value - yOrder.Value;

if (x is IOrderable xOnly)
return xOnly.Order;
if (xOrder.HasValue)
return xOrder.Value;

// The comparison is reversed (y is orderable) so the order must be negated to.
if (y is IOrderable yOnly)
return -yOnly.Order;
if (yOrder.HasValue)
return -yOrder.Value;

//or use whatever the model is
if (_nestedComparer != null)
Expand All @@ -56,6 +61,19 @@ public int Compare(object x, object y)
return string.Compare(x.ToString(), y.ToString());
}

private int? GetOrderIfAny(object o)
{
if(o is IOrderable orderable)
return orderable.Order;

if(o is ISqlParameter)
{
return -5000;
}

return null;
}

/// <summary>
/// Return true if the object should never be reordered and always ordered alphabetically based on it's <see cref="INamed.Name"/>
/// </summary>
Expand Down
21 changes: 17 additions & 4 deletions Rdmp.Core/Providers/CatalogueProblemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,26 @@ public string DescribeProblem(AllCataloguesUsedByLoadMetadataNode allCataloguesU

public string DescribeProblem(ISqlParameter parameter)
{
if (string.IsNullOrWhiteSpace(parameter.Value) || parameter.Value == AnyTableSqlParameter.DefaultValue)
return "No value defined";


if (AnyTableSqlParameter.HasProhibitedName(parameter))
return "Parameter name is a reserved name for the RDMP software";

// if parameter has no value thats a problem
if (string.IsNullOrWhiteSpace(parameter.Value) || parameter.Value == AnyTableSqlParameter.DefaultValue)
{
// unless it has ExtractionFilterParameterSets defined on it
var desc = _childProvider.GetDescendancyListIfAnyFor(parameter);
if (desc != null && parameter is ExtractionFilterParameter)
{
var filter = desc.Parents.OfType<ExtractionFilter>().FirstOrDefault();
if (filter != null && filter.ExtractionFilterParameterSets.Any())
{
return null;
}
}

return "No value defined";
}

return null;
}

Expand Down

0 comments on commit c63b500

Please sign in to comment.