Skip to content

Commit 1464eea

Browse files
authored
Task/rdmp 343 Cross-Project Commits Flow (#2261)
* add files * update cancel * fix cancel * moving cics * add projects column to cic tree * update text
1 parent c65317d commit 1464eea

File tree

10 files changed

+839
-7
lines changed

10 files changed

+839
-7
lines changed

Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
using Rdmp.UI.Refreshing;
5656
using Rdmp.UI.Rules;
5757
using Rdmp.UI.SimpleDialogs;
58+
using Rdmp.UI.SimpleDialogs.Cohorts;
5859
using Rdmp.UI.SimpleDialogs.ForwardEngineering;
5960
using Rdmp.UI.SingleControlForms;
6061
using Rdmp.UI.SubComponents;
@@ -904,6 +905,12 @@ public override CohortCreationRequest GetCohortCreationRequest(ExternalCohortTab
904905
return ui.ShowDialog() == DialogResult.OK ? ui.Result : null;
905906
}
906907

908+
public override IProject CohortCommitProjectSelect(IProject currentProject,Project[] projects)
909+
{
910+
var ui = new CohortCommitProjectSelectionUI(this, currentProject, projects);
911+
return ui.ShowDialog() == DialogResult.OK ? ui.Result : null; ;
912+
}
913+
907914
public override CohortHoldoutLookupRequest GetCohortHoldoutLookupRequest(ExternalCohortTable externalCohortTable,
908915
IProject project, CohortIdentificationConfiguration cic)
909916
{

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [9.1.0] - Unreleased
88
- Fix bug with duplicate searchables
9+
- Improve UI for committing cohorts across projects
910
- Add the ability to Template Cohort Identification Configurations (see [Documentation\cohorts\CohortIdentificationConfigurationTemplates.md])
1011
- Require all deletes to enter a commit message when using the commit system
1112
- Introduce ability to view Catalogues in a flat view

Rdmp.Core/CommandExecution/AtomicCommands/CohortCreationCommands/ExecuteCommandCreateNewCohortByExecutingACohortIdentificationConfiguration.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,47 @@ public override void Execute()
8383
}
8484
}
8585

86-
if (Project == null && BasicActivator.CoreChildProvider is DataExportChildProvider dx)
86+
87+
IProject currentProj = null;
88+
ProjectCohortIdentificationConfigurationAssociation[] projAssociations = Array.Empty<ProjectCohortIdentificationConfigurationAssociation>();
89+
if (BasicActivator.CoreChildProvider is DataExportChildProvider dx)
8790
{
88-
var projAssociations = dx.AllProjectAssociatedCics
91+
projAssociations = dx.AllProjectAssociatedCics
8992
.Where(c => c.CohortIdentificationConfiguration_ID == cic.ID).ToArray();
90-
if (projAssociations.Length == 1) Project = projAssociations[0].Project;
93+
if (projAssociations.Length > 0)
94+
{
95+
currentProj = Project != null ? Project : projAssociations.Length == 1 ? projAssociations[0].Project : null;
96+
Project = BasicActivator.CohortCommitProjectSelect(currentProj, BasicActivator.RepositoryLocator.DataExportRepository.GetAllObjects<Project>().ToArray());
97+
if (Project is null) return;
98+
}
9199
}
92100

93101
var auditLogBuilder = new ExtractableCohortAuditLogBuilder();
94102
var request = GetCohortCreationRequest(ExtractableCohortAuditLogBuilder.GetDescription(cic));
95103

96104
//user choose to cancel the cohort creation request dialogue
97105
if (request == null)
106+
{
107+
Project = null;
98108
return;
109+
}
99110

100111
request.CohortIdentificationConfiguration = cic;
101112

102113
var configureAndExecute = GetConfigureAndExecuteControl(request, $"Execute CIC {cic} and commit results", cic);
103114

104115
configureAndExecute.PipelineExecutionFinishedsuccessfully += (s, u) => OnImportCompletedSuccessfully(cic);
105116

106-
configureAndExecute.Run(BasicActivator.RepositoryLocator, null, null, null);
117+
var result = configureAndExecute.Run(BasicActivator.RepositoryLocator, null, null, null);
118+
if (result ==0 && currentProj != null && currentProj.ID != Project.ID)
119+
{
120+
//move cic to new project
121+
var oldAssociation = projAssociations.Where(a => a.Project_ID == currentProj.ID).FirstOrDefault();
122+
if (oldAssociation != null)
123+
{
124+
oldAssociation.DeleteInDatabase();
125+
}
126+
}
107127
}
108128

109129
private void OnImportCompletedSuccessfully(CohortIdentificationConfiguration cic)

Rdmp.Core/CommandExecution/BasicActivateItems.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,20 @@ public virtual CohortCreationRequest GetCohortCreationRequest(ExternalCohortTabl
666666
RepositoryLocator.DataExportRepository, cohortInitialDescription);
667667
}
668668

669+
public virtual IProject CohortCommitProjectSelect(IProject currentProject, Project[] projects)
670+
{
671+
return currentProject;
672+
}
673+
674+
669675
/// <inheritdoc/>
670676
public virtual CohortHoldoutLookupRequest GetCohortHoldoutLookupRequest(ExternalCohortTable externalCohortTable, IProject project, CohortIdentificationConfiguration cic)
671677
{
672678

673679
if (!TypeText("Name", "Enter name for cohort", 255, null, out var name, false))
674680
throw new Exception("User chose not to enter a name for the cohort and none was provided");
675681

676-
return new CohortHoldoutLookupRequest(cic, "empty", 1,false,"","");
682+
return new CohortHoldoutLookupRequest(cic, "empty", 1, false, "", "");
677683
}
678684

679685
/// <inheritdoc/>

Rdmp.Core/CommandExecution/IBasicActivateItems.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public interface IBasicActivateItems
173173
CohortCreationRequest GetCohortCreationRequest(ExternalCohortTable externalCohortTable, IProject project,
174174
string cohortInitialDescription);
175175

176+
IProject CohortCommitProjectSelect(IProject currentProject, Project[] projects);
176177

177178

178179
CohortHoldoutLookupRequest GetCohortHoldoutLookupRequest(ExternalCohortTable externalCohortTable, IProject project, CohortIdentificationConfiguration cic);

Rdmp.UI/Collections/CohortIdentificationCollectionUI.Designer.cs

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rdmp.UI/Collections/CohortIdentificationCollectionUI.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Rdmp.Core.Curation.Data;
1414
using Rdmp.Core.Curation.Data.Cohort;
1515
using Rdmp.Core.Icons.IconProvision;
16+
using Rdmp.Core.Providers;
1617
using Rdmp.Core.Providers.Nodes.CohortNodes;
1718
using Rdmp.UI.CommandExecution.AtomicCommands;
1819
using Rdmp.UI.CommandExecution.AtomicCommands.UIFactory;
@@ -37,6 +38,7 @@ public CohortIdentificationCollectionUI()
3738
{
3839
InitializeComponent();
3940
olvFrozen.AspectGetter = FrozenAspectGetter;
41+
olvAssociatedProjects.AspectGetter = AssociatedProjectsAspectGetter;
4042
}
4143

4244
public override void SetItemActivator(IActivateItems activator)
@@ -114,6 +116,7 @@ public override void SetItemActivator(IActivateItems activator)
114116
if (_firstTime)
115117
{
116118
CommonTreeFunctionality.SetupColumnTracking(olvName, new Guid("f8a42259-ce5a-4006-8ab8-e0305fce05aa"));
119+
CommonTreeFunctionality.SetupColumnTracking(olvAssociatedProjects, new Guid("f8a42259-ce5a-4006-8ab8-e0305fce05aa"));
117120
CommonTreeFunctionality.SetupColumnTracking(olvFrozen, new Guid("d1e155ef-a28f-41b5-81e4-b763627ddb3c"));
118121

119122
tlvCohortIdentificationConfigurations.Expand(rootFolder);
@@ -148,7 +151,17 @@ root is FolderNode<CohortIdentificationConfiguration> f
148151
public void RefreshBus_RefreshObject(object sender, RefreshObjectEventArgs e)
149152
{
150153
}
151-
154+
private string AssociatedProjectsAspectGetter(object o)
155+
{
156+
var cic = o as CohortIdentificationConfiguration;
157+
if (cic != null)
158+
{
159+
var dx = Activator.CoreChildProvider as DataExportChildProvider;
160+
var associations = dx.AllProjectAssociatedCics.Where(c => c.CohortIdentificationConfiguration_ID == cic.ID);
161+
return string.Join(", ", associations.Select(a => a.Project.ID));
162+
}
163+
return "";
164+
}
152165
private string FrozenAspectGetter(object o) =>
153166
o is CohortIdentificationConfiguration cic ? cic.Frozen ? "Yes" : "No" : null;
154167
}

Rdmp.UI/SimpleDialogs/Cohorts/CohortCommitProjectSelectionUI.Designer.cs

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)