Skip to content

Commit

Permalink
Return empty table, instead of an error when no dom instance/module i…
Browse files Browse the repository at this point in the history
…s given in the input arguments. Maybe this could be intentional and then an error is not correct.
  • Loading branch information
ArneMaes0 committed Jul 1, 2024
1 parent 5006d22 commit c52ee7b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions SLC-GQIDS-DOM-History_1/SLC-GQIDS-DOM-History_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Ambachtenstraat 33
DATE VERSION AUTHOR COMMENTS
30/05/2024 1.0.0.1 AMA, Skyline Initial version
30/05/2024 1.0.1 AMA, Skyline Initial version
18/06/2024 1.0.2 AMA, Skyline Fixed exceptions when multiple sections or removed sections were present in the history
01/07/2024 1.0.3 AMA, Skyline Return empty table, when no module or instance is given. This could be intentional, for example when no row is selected in a table
****************************************************************************
*/

Expand All @@ -72,8 +74,8 @@ public class GetDOMHistory : IGQIDataSource, IGQIOnInit, IGQIInputArguments
private Guid domInstanceId;

#region IGQIInputArguments
private readonly GQIStringArgument domInstanceModuleArgs = new GQIStringArgument("DOM Module") { IsRequired = true };
private readonly GQIStringArgument domInstanceIdArgs = new GQIStringArgument("DOM Instance ID") { IsRequired = true };
private readonly GQIStringArgument domInstanceModuleArgs = new GQIStringArgument("DOM Module") { IsRequired = false, DefaultValue = String.Empty };
private readonly GQIStringArgument domInstanceIdArgs = new GQIStringArgument("DOM Instance ID") { IsRequired = false, DefaultValue = String.Empty };

public GQIArgument[] GetInputArguments()
{
Expand All @@ -82,11 +84,20 @@ public GQIArgument[] GetInputArguments()

public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
{
var domModule = args.GetArgumentValue(domInstanceModuleArgs);
var rawDomInstanceId = args.GetArgumentValue(domInstanceIdArgs);
if (!Guid.TryParse(rawDomInstanceId, out domInstanceId))
if (!args.TryGetArgumentValue(domInstanceModuleArgs, out var domModule) ||
String.IsNullOrEmpty(domModule))
{
throw new ArgumentException("DOM Instance ID, is not a valid System.Guid");
// If no valid DOM Module ID is given return an empty table.
dataProvider = null;
return new OnArgumentsProcessedOutputArgs();
}

if (!args.TryGetArgumentValue(domInstanceIdArgs, out var rawDomInstanceId) ||
!Guid.TryParse(rawDomInstanceId, out domInstanceId))
{
// If no valid DOM Instance ID is given return an empty table.
dataProvider = null;
return new OnArgumentsProcessedOutputArgs();
}

dataProvider = new DataProvider(dms, domModule);
Expand Down Expand Up @@ -120,6 +131,14 @@ public GQIColumn[] GetColumns()

public GQIPage GetNextPage(GetNextPageInputArgs args)
{
if (dataProvider == null)
{
return new GQIPage(new GQIRow[0])
{
HasNextPage = false,
};
}

var changes = dataProvider.GetHistoryForInstance(domInstanceId);

var rows = changes.Select(change => new GQIRow(
Expand Down

0 comments on commit c52ee7b

Please sign in to comment.