-
Notifications
You must be signed in to change notification settings - Fork 17
Bugfix/rdmp 362 dupe list project cic #2313
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
753673d
remove duplicate folder
JFriel e829123
add changelog
JFriel 7958b8c
fix test
JFriel 4de5922
Merge branch 'develop' of https://github.com/HicServices/RDMP into bu…
JFriel 756191c
add delete function
JFriel 9699573
update perl
JFriel c441ada
Merge branch 'develop' into bugfix/RDMP-362-dupe-list-project-cic
JFriel 1e308d3
Merge branch 'develop' into bugfix/RDMP-362-dupe-list-project-cic
JFriel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,4 +308,4 @@ jobs: | |
| file: dist/* | ||
| tag: ${{ github.ref }} | ||
| overwrite: true | ||
| file_glob: true | ||
| file_glob: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...AtomicCommands/ExecuteCommandRemoveCohortIdentificationConfigurationProjectAssociation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| 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; | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
...ders/Nodes/ProjectCohortNodes/ProjectCohortIdentificationConfigurationAssociationsNode.cs
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
...s/ProposeExecutionWhenTargetIsProjectCohortIdentificationConfigurationAssociationsNode.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity Note
Copilot Autofix
AI about 1 month ago
To fix the problem, the private field
_activatorshould be declared with thereadonlymodifier 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 fromprivate IBasicActivateItems _activator;toprivate readonly IBasicActivateItems _activator;. No other code changes are necessary, because_activatoris only assigned in the constructor and read elsewhere. No additional methods, imports, or definitions are required.