Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/HicServices/RDMP into re…
Browse files Browse the repository at this point in the history
…lease/8.4.0
  • Loading branch information
JFriel committed Oct 22, 2024
2 parents c2ce5d3 + 637e866 commit 6edf05b
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 76 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
mv `find coverage -type f` db-ui.lcov
dotnet test Rdmp.Core.Tests/Rdmp.Core.Tests.csproj --nologo --collect:"XPlat Code Coverage" --no-build --verbosity minimal -c Release -e AWS_ENDPOINT_URL="http://127.0.0.1:9000" --results-directory coverage -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=lcov
mv `find coverage -type f` db-core.lcov
- uses: coverallsapp/[email protected].0
- uses: coverallsapp/[email protected].3
with:
github-token: ${{ secrets.github_token }}
files: ./db-ui.lcov ./db-core.lcov
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
mv `find coverage -type f` fs-ui.lcov
dotnet test Rdmp.Core.Tests/Rdmp.Core.Tests.csproj --nologo --collect:"XPlat Code Coverage" --no-build --verbosity minimal -c Release -e AWS_ENDPOINT_URL="http://127.0.0.1:9000" --results-directory coverage -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=lcov
mv `find coverage -type f` fs-core.lcov
- uses: coverallsapp/[email protected].0
- uses: coverallsapp/[email protected].3
with:
github-token: ${{ secrets.github_token }}
files: ./fs-ui.lcov ./fs-core.lcov
Expand Down Expand Up @@ -176,7 +176,6 @@ jobs:
cp -r Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/runtimes ./PublishWinForms
cp -r Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/x64 ./PublishWinForms
cp Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/D3DCompiler_47_cor3.dll ./PublishWinForms
cp Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/mongocrypt.dll ./PublishWinForms
cp Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/PenImc_cor3.dll ./PublishWinForms
cp Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/PresentationNative_cor3.dll ./PublishWinForms
cp Application/ResearchDataManagementPlatform/bin/Release/net8.0-windows/win-x64/vcruntime140_cor3.dll ./PublishWinForms
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add Ordering to Filters

## [8.3.1] - Unreleased
## [8.3.1] - 2024-10-22

- Improve Performance of regenerating problems with child providers
- Update UI Tab opening Logic
Expand Down
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project>
<ItemGroup>
<PackageVersion Include="AWSSDK.S3" Version="3.7.404.5" />
<PackageVersion Include="AWSSDK.SecurityToken" Version="3.7.400.33" />
<PackageVersion Include="AWSSDK.SSO" Version="3.7.400.33" />
<PackageVersion Include="AWSSDK.SSOOIDC" Version="3.7.400.33" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.405" />
<PackageVersion Include="AWSSDK.SecurityToken" Version="3.7.400.36" />
<PackageVersion Include="AWSSDK.SSO" Version="3.7.400.36" />
<PackageVersion Include="AWSSDK.SSOOIDC" Version="3.7.400.36" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Equ" Version="2.3.0" />
<PackageVersion Include="ExcelNumberFormat" Version="1.1.0" />
<PackageVersion Include="FluentFTP" Version="51.1.0" />
<PackageVersion Include="HIC.SynthEHR" Version="2.0.1" />
<PackageVersion Include="HIC.FAnsiSql" Version="3.2.6" />
<PackageVersion Include="HIC.FAnsiSql" Version="3.2.7" />
<PackageVersion Include="LibArchive.Net" Version="0.1.5" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Minio" Version="6.0.3" />
<PackageVersion Include="MongoDB.Driver" Version="2.29.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NPOI" Version="2.7.1" />
<PackageVersion Include="NLog" Version="5.3.4" />
Expand All @@ -37,7 +37,7 @@
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0" />
<PackageVersion Include="VPKSoft.ScintillaLexers.NET" Version="1.1.16" />
<PackageVersion Include="HIC.System.Windows.Forms.DataVisualization" Version="1.0.1" />
<PackageVersion Include="NunitXml.TestLogger" Version="4.0.254" />
<PackageVersion Include="NunitXml.TestLogger" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.3.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
Expand Down
34 changes: 21 additions & 13 deletions Rdmp.Core/Logging/LogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public string[] ListDataTasks(bool hideTests = false)

using var con = Server.GetConnection();
con.Open();
using var cmd = Server.GetCommand("SELECT * FROM DataLoadTask", con);
var sh = Server.GetQuerySyntaxHelper();
using var cmd = Server.GetCommand($"SELECT * FROM {sh.EnsureWrapped("DataLoadTask")}", con);
using var r = cmd.ExecuteReader();
while (r.Read())
if (!hideTests || !(bool)r["isTest"])
Expand Down Expand Up @@ -113,7 +114,8 @@ public string[] ListDataSets()
using var con = Server.GetConnection();
con.Open();

using var cmd = Server.GetCommand("SELECT * FROM DataSet", con);
var sh = Server.GetQuerySyntaxHelper();
using var cmd = Server.GetCommand($"SELECT * FROM {sh.EnsureWrapped("DataSet")}", con);
using var r = cmd.ExecuteReader();
while (r.Read())
tasks.Add(r["dataSetID"].ToString());
Expand All @@ -133,7 +135,8 @@ public IEnumerable<ArchivalDataLoadInfo> GetArchivalDataLoadInfos(string dataTas
int? specificDataLoadRunIDOnly = null, int? topX = null)
{
var db = Server.GetCurrentDatabase();
var run = db.ExpectTable("DataLoadRun");
var sh = Server.GetQuerySyntaxHelper();
var run = db.ExpectTable(sh.EnsureWrapped("DataLoadRun"));

using var con = Server.GetConnection();
con.Open();
Expand All @@ -144,11 +147,11 @@ public IEnumerable<ArchivalDataLoadInfo> GetArchivalDataLoadInfos(string dataTas
string where;
if (specificDataLoadRunIDOnly != null)
{
where = $"WHERE ID={specificDataLoadRunIDOnly.Value}";
where = $"WHERE {sh.EnsureWrapped("ID")}={specificDataLoadRunIDOnly.Value}";
}
else
{
where = "WHERE dataLoadTaskID = @dataTaskId";
where = $"WHERE {sh.EnsureWrapped("dataLoadTaskID")} = @dataTaskId";
var p = cmd.CreateParameter();
p.ParameterName = "@dataTaskId";
p.Value = dataTaskId;
Expand All @@ -158,13 +161,13 @@ public IEnumerable<ArchivalDataLoadInfo> GetArchivalDataLoadInfos(string dataTas
TopXResponse top = null;

if (topX.HasValue)
top = Server.GetQuerySyntaxHelper().HowDoWeAchieveTopX(topX.Value);
top = sh.HowDoWeAchieveTopX(topX.Value);

var sb = new StringBuilder("SELECT ");

if (top?.Location == QueryComponent.SELECT) sb.AppendLine(top.SQL);

sb.AppendLine($" * FROM {run.GetFullyQualifiedName()} {where} ORDER BY ID desc");
sb.AppendLine($" * FROM {run.GetFullyQualifiedName()} {where} ORDER BY {sh.EnsureWrapped("ID")} desc");

if (top?.Location == QueryComponent.Postfix) sb.AppendLine(top.SQL);

Expand Down Expand Up @@ -204,7 +207,8 @@ public IEnumerable<ArchivalDataLoadInfo> GetArchivalDataLoadInfos(string dataTas

private static int GetDataTaskId(string dataTask, DiscoveredServer server, DbConnection con)
{
using var cmd = server.GetCommand("SELECT ID FROM DataLoadTask WHERE name = @name", con);
var sh = server.GetQuerySyntaxHelper();
using var cmd = server.GetCommand($"SELECT {sh.EnsureWrapped("ID")} FROM {sh.EnsureWrapped("DataLoadTask")} WHERE name = @name", con);
var p = cmd.CreateParameter();
p.ParameterName = "@name";
p.Value = dataTask;
Expand Down Expand Up @@ -236,9 +240,10 @@ public IDataLoadInfo CreateDataLoadInfo(string dataLoadTaskName, string packageN
public void CreateNewLoggingTask(int id, string dataSetID)
{
using var conn = Server.GetConnection();
var sh = Server.GetQuerySyntaxHelper();
conn.Open();
var sql =
$"INSERT INTO DataLoadTask (ID, description, name, createTime, userAccount, statusID, isTest, dataSetID) VALUES ({id}, @dataSetID, @dataSetID, @date, @username, 1, 0, @dataSetID)";
$"INSERT INTO {sh.EnsureWrapped("DataLoadTask")} ({sh.EnsureWrapped("ID")}, description, name, {sh.EnsureWrapped("createTime")}, {sh.EnsureWrapped("userAccount")}, {sh.EnsureWrapped("statusID")}, {sh.EnsureWrapped("isTest")}, {sh.EnsureWrapped("dataSetID")}) VALUES ({id}, @dataSetID, @dataSetID, @date, @username, 1, {sh.False}, @dataSetID)";

using var cmd = Server.GetCommand(sql, conn);
Server.AddParameterWithValueToCommand("@date", cmd, DateTime.Now);
Expand All @@ -251,9 +256,10 @@ public void CreateNewLoggingTask(int id, string dataSetID)
private void CreateNewDataSet(string datasetName)
{
using var conn = Server.GetConnection();
var sh = Server.GetQuerySyntaxHelper();
conn.Open();
{
const string sql = "INSERT INTO DataSet (dataSetID,name) VALUES (@datasetName,@datasetName)";
var sql = $"INSERT INTO {sh.EnsureWrapped("DataSet")} ({sh.EnsureWrapped("dataSetID")},name) VALUES (@datasetName,@datasetName)";

using var cmd = Server.GetCommand(sql, conn);
Server.AddParameterWithValueToCommand("@datasetName", cmd, datasetName.Substring(Math.Max(0, datasetName.Length - 150)));
Expand All @@ -274,8 +280,9 @@ public void CreateNewLoggingTaskIfNotExists(string toCreate)
private int GetMaxTaskID()
{
using var conn = Server.GetConnection();
var sh = Server.GetQuerySyntaxHelper();
conn.Open();
const string sql = "SELECT MAX(ID) FROM DataLoadTask";
var sql = $"SELECT MAX({sh.EnsureWrapped("ID")}) FROM {sh.EnsureWrapped("DataLoadTask")}";

using var cmd = Server.GetCommand(sql, conn);
var result = cmd.ExecuteScalar();
Expand All @@ -285,9 +292,10 @@ private int GetMaxTaskID()
public void ResolveFatalErrors(int[] ids, DataLoadInfo.FatalErrorStates newState, string newExplanation)
{
using var conn = Server.GetConnection();
var sh = Server.GetQuerySyntaxHelper();
conn.Open();
var sql =
$"UPDATE FatalError SET explanation =@explanation, statusID=@statusID where ID in ({string.Join(",", ids)})";
$"UPDATE {sh.EnsureWrapped("FatalError")} SET explanation =@explanation, {sh.EnsureWrapped("statusID")}=@statusID where {sh.EnsureWrapped("ID")} in ({string.Join(",", ids)})";

using var cmd = Server.GetCommand(sql, conn);
Server.AddParameterWithValueToCommand("@explanation", cmd, newExplanation);
Expand All @@ -298,4 +306,4 @@ public void ResolveFatalErrors(int[] ids, DataLoadInfo.FatalErrorStates newState
throw new Exception(
$"Query {sql} resulted in {affectedRows}, we were expecting there to be {ids.Length} updates because that is how many FatalError IDs that were passed to this method");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,38 +140,40 @@ private void Tableview1_CellActivated(TableView.CellActivatedEventArgs obj)
var o = RowObjects[obj.Row];
if (o == null)
return;

var col = tableview1.Table.Columns[obj.Col];

if (col.ColumnName.Equals("Name"))
switch (col.ColumnName)
{
var factory = new ConsoleGuiContextMenuFactory(_activator);
var menu = factory.Create(Array.Empty<object>(), o);

if (menu != null)
case "Name":
{
var p = tableview1.CellToScreen(obj.Col, obj.Row);

if (p == null)
return;

menu.Position = p.Value;
_contextMenuShowing = true;
menu.Show();
menu.MenuBar.MenuAllClosed += () => _contextMenuShowing = false;
var factory = new ConsoleGuiContextMenuFactory(_activator);
var menu = factory.Create(p.Value.X, p.Value.Y, Array.Empty<object>(), o);
if (menu != null)
{
menu.Position = p.Value;
_contextMenuShowing = true;
menu.Show();
menu.MenuBar.MenuAllClosed += () => _contextMenuShowing = false;
}

break;
}
}

if (col.ColumnName.Equals("Working"))
{
var key = Common.GetKey(o);
if (key?.CrashMessage != null)
case "Working":
{
_activator.ShowException("Task Crashed", key.CrashMessage);
return;
var key = Common.GetKey(o);
if (key?.CrashMessage != null) _activator.ShowException("Task Crashed", key.CrashMessage);
break;
}
case "Execute":
Common.ExecuteOrCancel(o, int.MaxValue);
break;
}

if (col.ColumnName.Equals("Execute")) Common.ExecuteOrCancel(o, Common.Timeout);
}

private bool IsValidSelection(int col, int row)
Expand Down
10 changes: 4 additions & 6 deletions Tools/rdmp/CommandLine/Gui/ConsoleGuiContextMenuFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ConsoleGuiContextMenuFactory(IBasicActivateItems activator)
this.activator = activator;
}

public ContextMenu Create(object[] many, object single)
public ContextMenu Create(int x,int y,object[] many, object single)
{
var commands = GetCommands(activator, many, single).ToArray();

Expand Down Expand Up @@ -65,18 +65,16 @@ public ContextMenu Create(object[] many, object single)
items.Add(bar);
}

// we can do nothing if theres no menu items
// we can do nothing if there are no menu items
if (items.Count == 0)
return null;

var withSpacers = AddSpacers(items, order);

var menu = new ContextMenu
return new ContextMenu(x, y, new MenuBarItem(withSpacers))
{
MenuItems = new MenuBarItem(withSpacers)
UseSubMenusSingleFrame = true
};

return menu;
}

private static MenuItem[] AddSpacers(List<MenuItem> items, Dictionary<MenuItem, float> order)
Expand Down
44 changes: 19 additions & 25 deletions Tools/rdmp/CommandLine/Gui/ConsoleMainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Rdmp.Core.MapsDirectlyToDatabaseTable;
using Rdmp.Core.Providers;
using Rdmp.Core.Providers.Nodes;
using Rdmp.Core.ReusableLibraryCode.Annotations;
using Rdmp.Core.ReusableLibraryCode.Settings;
using Terminal.Gui;
using Terminal.Gui.Trees;
Expand All @@ -27,7 +28,7 @@ internal class ConsoleMainWindow
{
private Window _win;
private TreeView<object> _treeView;
private IBasicActivateItems _activator;
private readonly IBasicActivateItems _activator;

/// <summary>
/// The last <see cref="IBasicActivateItems"/> passed to this UI.
Expand Down Expand Up @@ -167,7 +168,7 @@ internal void SetUp(Toplevel top)
var statusBar = new StatusBar(new StatusItem[]
{
new(Key.Q | Key.CtrlMask, "~^Q~ Quit", Quit),
new(Key.R | Key.CtrlMask, "~^R~ Run", action: Run),
new(Key.R | Key.CtrlMask, "~^R~ Run", Run),
new(Key.F | Key.CtrlMask, "~^F~ Find", Find),
new(Key.N | Key.CtrlMask, "~^N~ New", New),
new(Key.F5, "~F5~ Refresh", Publish)
Expand Down Expand Up @@ -252,21 +253,18 @@ private void _treeView_ObjectActivated(ObjectActivatedEventArgs<object> obj)

private string AspectGetter(object model)
{
if (model is IContainer container) return $"{container} ({container.Operation})";

if (model is CohortAggregateContainer setContainer) return $"{setContainer} ({setContainer.Operation})";

if (model is ExtractionInformation ei) return $"{ei} ({ei.ExtractionCategory})";

if (model is CatalogueItemsNode cin) return $"{cin} ({cin.CatalogueItems.Length})";

if (model is TableInfoServerNode server) return $"{server.ServerName} ({server.DatabaseType})";

if (model is IDisableable d) return d.IsDisabled ? $"{d} (Disabled)" : d.ToString();

return model is IArgument arg
? $"{arg} ({(string.IsNullOrWhiteSpace(arg.Value) ? "Null" : arg.Value)})"
: model?.ToString() ?? "Null Object";
return model switch
{
IContainer container => $"{container} ({container.Operation})",
CohortAggregateContainer setContainer => $"{setContainer} ({setContainer.Operation})",
ExtractionInformation ei => $"{ei} ({ei.ExtractionCategory})",
CatalogueItemsNode cin => $"{cin} ({cin.CatalogueItems.Length})",
TableInfoServerNode server => $"{server.ServerName} ({server.DatabaseType})",
IDisableable d => d.IsDisabled ? $"{d} (Disabled)" : d.ToString(),
_ => model is IArgument arg
? $"{arg} ({(string.IsNullOrWhiteSpace(arg.Value) ? "Null" : arg.Value)})"
: model?.ToString() ?? "Null Object"
};
}

private void Publish()
Expand Down Expand Up @@ -337,7 +335,7 @@ private void Show(object selected)
_treeView.SetNeedsDisplay();
}

private void _treeView_SelectionChanged(object sender, SelectionChangedEventArgs<object> e)
private void _treeView_SelectionChanged(object sender, [NotNull] SelectionChangedEventArgs<object> e)
{
if (e.NewValue != null)
_treeView.RefreshObject(e.NewValue);
Expand All @@ -346,13 +344,9 @@ private void _treeView_SelectionChanged(object sender, SelectionChangedEventArgs
private void Menu()
{
var factory = new ConsoleGuiContextMenuFactory(_activator);
var menu = factory.Create(_treeView.GetAllSelectedObjects().ToArray(), _treeView.SelectedObject);

if (menu == null)
return;

menu.Position = DateTime.Now.Subtract(_lastMouseMove).TotalSeconds < 1 ? _lastMousePos : new Point(10, 5);
menu.Show();
var position = DateTime.Now.Subtract(_lastMouseMove).TotalSeconds < 1 ? _lastMousePos : new Point(10, 5);
var menu = factory.Create(position.X,position.Y,_treeView.GetAllSelectedObjects().ToArray(), _treeView.SelectedObject);
menu?.Show();
}


Expand Down
4 changes: 2 additions & 2 deletions rdmp-client.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.2.3.0</version>
<url>https://github.com/HicServices/RDMP/releases/download/v8.3.0/rdmp-8.3.0-client.zip</url>
<version>8.3.1.0</version>
<url>https://github.com/HicServices/RDMP/releases/download/v8.3.1/rdmp-8.3.1-client.zip</url>
<changelog>https://github.com/HicServices/RDMP/blob/main/CHANGELOG.md#7</changelog>
<mandatory>true</mandatory>
</item>

0 comments on commit 6edf05b

Please sign in to comment.