Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ jobs:
file: dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file_glob: true
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add Internal Note to Catalogue
- Fix issue where project associations were not copied when a CIC was cloned
- Fix issue with using Internal Catalogues in Cohort Identification Configurations
- Simplify Project Cohorts tree
- Fix bug with copying project specific Catalogues between Projects when committing a Cohort
- Remove Tree filters from UI
- Fix issue with Web File Downloader not releasing files after download complete
- Fix Extraction primary Key case sensitivity issue

## [9.1.2] - Unreleased
- Automatically fetch user settings from previous versions of RDMP when installing the latest version
- Allow new columns to be added to archive extractions
- Simplify use of Extraction Progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,5 @@ public void TestOrphanCic()
//relationship from p should resolve to the cic
Assert.That(p.GetAssociatedCohortIdentificationConfigurations(), Is.Empty);
});

//error should be reported in top right of program
var ex = Assert.Throws<Exception>(() =>
new DataExportChildProvider(new RepositoryProvider(memory), null, ThrowImmediatelyCheckNotifier.Quiet,
null));
Assert.That(
ex.Message, Does.Match(@"Failed to find Associated Cohort Identification Configuration with ID \d+ which was supposed to be associated with my proj"));

//but UI should still respond
var childProvider = new DataExportChildProvider(new RepositoryProvider(memory), null,
IgnoreAllErrorsCheckNotifier.Instance, null);

//the orphan cic should not appear in the tree view under Project=>Cohorts=>Associated Cics
var cohorts = childProvider.GetChildren(p).OfType<ProjectCohortsNode>().Single();
var cics = childProvider.GetChildren(cohorts).OfType<ProjectCohortIdentificationConfigurationAssociationsNode>()
.First();

Assert.That(childProvider.GetChildren(cics), Is.Empty);
}
}
11 changes: 2 additions & 9 deletions Rdmp.Core/CommandExecution/AtomicCommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ public IEnumerable<IAtomicCommand> CreateCommands(object o)
//associate with project
yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
{ Weight = -50.3f, OverrideCommandName = "Associate with Project" }.SetTarget(cic);
yield return new ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation(_activator)
{ Weight = -50.2f, OverrideCommandName = "Remove Association with Project" }.SetTarget(pcic != null?pcic:cic);

}

Expand Down Expand Up @@ -842,15 +844,6 @@ public IEnumerable<IAtomicCommand> CreateCommands(object o)
{ OverrideCommandName = "Add New Cohort From Table", Weight = -4.6f }.SetTarget(projCohorts.Project);
}

if (Is(o, out ProjectCohortIdentificationConfigurationAssociationsNode pccan))
{
yield return new ExecuteCommandCreateNewCohortIdentificationConfiguration(_activator)
{ OverrideCommandName = "Add New Cohort Builder Query", Weight = -5.1f }.SetTarget(pccan.Project);
yield return new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(_activator)
{ OverrideCommandName = "Add Existing Cohort Builder Query (link to)", Weight = -5f }
.SetTarget(pccan.Project);
}

if (Is(o, out ProjectSavedCohortsNode savedCohortsNode))
{
yield return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (c) The University of Dundee 2018-2019
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// 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.Linq;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.Cohort;
using Rdmp.Core.DataExport.Data;
using Rdmp.Core.Icons.IconProvision;
using Rdmp.Core.Providers;
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace Rdmp.Core.CommandExecution.AtomicCommands;

public sealed class ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation : BasicCommandExecution,
IAtomicCommandWithTarget
{
private Project _project;
private CohortIdentificationConfiguration _cic;
private ProjectCohortIdentificationConfigurationAssociation[] _existingAssociations;
private ProjectCohortIdentificationConfigurationAssociation _associationToDelete;
private IBasicActivateItems _activator;

Check notice

Code scanning / CodeQL

Missed 'readonly' opportunity Note

Field '_activator' can be 'readonly'.

Copilot Autofix

AI about 1 month ago

To fix the problem, the private field _activator should be declared with the readonly modifier so that it can only be assigned at its declaration or within the constructor, preventing later unintended mutations.

Concretely, in Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs, update the field declaration on line 27 from private IBasicActivateItems _activator; to private readonly IBasicActivateItems _activator;. No other code changes are necessary, because _activator is only assigned in the constructor and read elsewhere. No additional methods, imports, or definitions are required.

Suggested changeset 1
Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs
--- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs
+++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs
@@ -24,7 +24,7 @@
     private CohortIdentificationConfiguration _cic;
     private ProjectCohortIdentificationConfigurationAssociation[] _existingAssociations;
     private ProjectCohortIdentificationConfigurationAssociation _associationToDelete;
-    private IBasicActivateItems _activator;
+    private readonly IBasicActivateItems _activator;
     public ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation(IBasicActivateItems activator) :
         base(activator)
     {
EOF
@@ -24,7 +24,7 @@
private CohortIdentificationConfiguration _cic;
private ProjectCohortIdentificationConfigurationAssociation[] _existingAssociations;
private ProjectCohortIdentificationConfigurationAssociation _associationToDelete;
private IBasicActivateItems _activator;
private readonly IBasicActivateItems _activator;
public ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation(IBasicActivateItems activator) :
base(activator)
{
Copilot is powered by AI and may make mistakes. Always verify output.
public ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation(IBasicActivateItems activator) :
base(activator)
{
_activator = activator;
if (!activator.CoreChildProvider.AllCohortIdentificationConfigurations.Any())
SetImpossible("There are no Cohort Identification Configurations yet");

}

public override string GetCommandHelp() =>
"Specifies that the Cohort Identification Configuration (query) is only for use generating cohorts for extractions of the specified project";

public override void Execute()
{
if (_project is null && _cic is null && _associationToDelete is null)
{
_cic = (CohortIdentificationConfiguration)_activator.SelectOne("Select a Cohort Identification Configuration", _activator.RepositoryLocator.CatalogueRepository.GetAllObjects<CohortIdentificationConfiguration>().ToArray());
if (_cic is null) return;
}
if (_cic is not null && _project is null && _associationToDelete is null)
{

_existingAssociations = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere<ProjectCohortIdentificationConfigurationAssociation>("CohortIdentificationConfiguration_ID", _cic.ID);
}
if (_cic is null && _project is not null && _associationToDelete is null)
{

_existingAssociations = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere<ProjectCohortIdentificationConfigurationAssociation>("Project_ID", _project.ID);
}
if (_cic != null && _project != null && _associationToDelete is null)
{
_associationToDelete = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere<ProjectCohortIdentificationConfigurationAssociation>("Project_ID", _project.ID).Where(pac => pac.CohortIdentificationConfiguration_ID == _cic.ID).First();
}
if (_associationToDelete is null)
{
if (_cic is not null && _project is null)
{
var projects = _existingAssociations.Select(a => a.Project).ToArray();
var selectedProject = (Project)_activator.SelectOne("Select the project to remove the association with", projects);
_associationToDelete = _existingAssociations.Where(pac => pac.Project_ID == selectedProject.ID).First();

}
else if (_cic is null && _project is not null)
{
var cics = _existingAssociations.Select(a => a.CohortIdentificationConfiguration).ToArray();
var selectedCic = (CohortIdentificationConfiguration)_activator.SelectOne("Select the cohort to remove the association with", cics);
_associationToDelete = _existingAssociations.Where(pac => pac.CohortIdentificationConfiguration_ID == selectedCic.ID).First();

}
else
{
_associationToDelete = (ProjectCohortIdentificationConfigurationAssociation)_activator.SelectOne("Select the association to remove", _existingAssociations);
}
}
if (_associationToDelete is null) return;

_associationToDelete.DeleteInDatabase();
Publish(_project);
Publish(_cic);
base.Execute();
}

public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
//if we know the cic the context is 'pick a project'
_cic != null
? iconProvider.GetImage(RDMPConcept.Project, OverlayKind.Delete)
:
//if we know the _project the context is 'pick a cic' (or if we don't know either then just use this icon too)
iconProvider.GetImage(RDMPConcept.CohortIdentificationConfiguration, OverlayKind.Delete);

public IAtomicCommandWithTarget SetTarget(DatabaseEntity target)
{
switch (target)
{
case Project project:
_project = project;
break;
case CohortIdentificationConfiguration configuration:
_cic = configuration;
break;
case ProjectCohortIdentificationConfigurationAssociation association:
_associationToDelete = association;
break;
}
return this;
}
}
12 changes: 0 additions & 12 deletions Rdmp.Core/Icons/IconProvision/CatalogueIcons.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Rdmp.Core/Icons/IconProvision/CatalogueIcons.resx
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,6 @@
<data name="AllCohortsNode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\AllCohortsNode.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ProjectCohortIdentificationConfigurationAssociationsNode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ProjectCohortIdentificationConfigurationAssociationsNode.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ProjectSavedCohortsNode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ProjectSavedCohortsNode.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
1 change: 0 additions & 1 deletion Rdmp.Core/Icons/IconProvision/RDMPConcept.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public enum RDMPConcept

AllCohortsNode,
ProjectsNode,
ProjectCohortIdentificationConfigurationAssociationsNode,
ProjectSavedCohortsNode,
ExtractableDataSetsNode,
ExtractionDirectoryNode,
Expand Down
35 changes: 0 additions & 35 deletions Rdmp.Core/Providers/DataExportChildProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ private void AddChildren(ProjectCataloguesNode projectCataloguesNode, Descendanc
private void AddChildren(ProjectCohortsNode projectCohortsNode, DescendancyList descendancy)
{
var children = new HashSet<object>();
var projectCiCsNode = new ProjectCohortIdentificationConfigurationAssociationsNode(projectCohortsNode.Project);
children.Add(projectCiCsNode);
AddChildren(projectCiCsNode, descendancy.Add(projectCiCsNode));

var savedCohortsNode = new ProjectSavedCohortsNode(projectCohortsNode.Project);
children.Add(savedCohortsNode);
Expand Down Expand Up @@ -405,38 +402,6 @@ private void AddChildren(ProjectSavedCohortsNode savedCohortsNode, DescendancyLi
AddToDictionaries(children, descendancy);
}

private void AddChildren(ProjectCohortIdentificationConfigurationAssociationsNode projectCiCsNode,
DescendancyList descendancy)
{
//add the associations
var children = new HashSet<object>();
foreach (var association in AllProjectAssociatedCics.Where(assoc =>
assoc.Project_ID == projectCiCsNode.Project.ID))
{
var matchingCic = AllCohortIdentificationConfigurations.SingleOrDefault(cic =>
cic.ID == association.CohortIdentificationConfiguration_ID) ?? AllTemplateCohortIdentificationConfigurations.SingleOrDefault(cic =>
cic.ID == association.CohortIdentificationConfiguration_ID);

if (matchingCic == null)
{
_errorsCheckNotifier.OnCheckPerformed(
new CheckEventArgs(
$"Failed to find Associated Cohort Identification Configuration with ID {association.CohortIdentificationConfiguration_ID} which was supposed to be associated with {association.Project}",
CheckResult
.Fail)); //inject knowledge of what the cic is so it doesn't have to be fetched during ToString
}
else
{
association.InjectKnown(matchingCic);

//document that it is a child of the project cics node
children.Add(association);
}
}

AddToDictionaries(children, descendancy);
}

private void AddChildren(ExtractionConfigurationsNode extractionConfigurationsNode, DescendancyList descendancy)
{
var children = new HashSet<object>();
Expand Down
1 change: 0 additions & 1 deletion Rdmp.Core/Providers/DescendancyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class DescendancyList
typeof(LoadStageNode),
typeof(PreLoadDiscardedColumnsNode),
typeof(ProjectCataloguesNode),
typeof(ProjectCohortIdentificationConfigurationAssociationsNode)
});

/// <summary>
Expand Down
8 changes: 0 additions & 8 deletions Rdmp.Core/Providers/Nodes/Nodes.cd
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rdmp.Core.Providers.Nodes.ProjectCohortNodes.ProjectCohortIdentificationConfigurationAssociationsNode" Collapsed="true">
<Position X="38.75" Y="3" Width="1.5" />
<TypeIdentifier>
<HashCode>AAEAAAAAAAAAAAAEgAAACAAAAAAAAIAAAAAAAAAAAAA=</HashCode>
<FileName>Providers\Nodes\ProjectCohortNodes\ProjectCohortIdentificationConfigurationAssociationsNode.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rdmp.Core.Providers.Nodes.ProjectCohortNodes.ProjectCohortsNode" Collapsed="true">
<Position X="23" Y="4.25" Width="1.5" />
<TypeIdentifier>
Expand Down

This file was deleted.

This file was deleted.

Loading