Skip to content
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

Task/RDMP-65 remember last used extraction pipeline #1768

Merged
merged 14 commits into from
Mar 25, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.1.5] - Unreleased

## Changed
- Extractions now remember the last used pipeline

## [8.1.4] - 2024-02-19

## Changed
Expand Down
27 changes: 25 additions & 2 deletions Rdmp.UI/PipelineUIs/Pipelines/PipelineSelectionUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using System.Windows.Forms;
using Rdmp.Core.Curation.Data.Pipelines;
using Rdmp.Core.DataExport.Data;
using Rdmp.Core.Repositories;
using Rdmp.Core.ReusableLibraryCode.Annotations;
using Rdmp.UI.ItemActivation;
Expand All @@ -29,6 +30,8 @@ public partial class PipelineSelectionUI : UserControl, IPipelineSelectionUI
public event EventHandler PipelineChanged;
private IPipeline _previousSelection;

private readonly IExtractionConfiguration _extractionConfiguration;

private ToolTip tt = new();

private const string ShowAll = "Show All/Incompatible Pipelines";
Expand All @@ -42,7 +45,14 @@ public IPipeline Pipeline
_pipeline = value;

if (ddPipelines != null)
{
if (_extractionConfiguration is not null && value is not null)
{
_extractionConfiguration.DefaultPipeline_ID = value.ID;
_extractionConfiguration.SaveToDatabase();
}
ddPipelines.SelectedItem = value;
}
}
}

Expand Down Expand Up @@ -70,8 +80,20 @@ private void RefreshPipelineList()
if (showAll)
ddPipelines.Items.AddRange(allPipelines.Where(o => !_useCase.IsAllowable(o)).ToArray());

if(_extractionConfiguration is not null)
{
var toReselect = ddPipelines.Items.OfType<Pipeline>().SingleOrDefault(p => p.ID == _extractionConfiguration.DefaultPipeline_ID);

//if we can reselect the users previously selected one
if (toReselect != null)
{
ddPipelines.SelectedItem = toReselect;
return;
}
}

//reselect if it is still there
if (ddPipelines.SelectedItem is Pipeline before)
else if (ddPipelines.SelectedItem is Pipeline before)
{
var toReselect = ddPipelines.Items.OfType<Pipeline>().SingleOrDefault(p => p.ID == before.ID);

Expand All @@ -89,11 +111,12 @@ private void RefreshPipelineList()
: "<<None>>";
}

public PipelineSelectionUI(IActivateItems activator, IPipelineUseCase useCase, ICatalogueRepository repository)
public PipelineSelectionUI(IActivateItems activator, IPipelineUseCase useCase, ICatalogueRepository repository, IExtractionConfiguration extractionConfiguration=null)
{
_activator = activator;
_useCase = useCase;
_repository = repository;
_extractionConfiguration=extractionConfiguration;
InitializeComponent();

if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) //don't connect to database in design mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Forms;
using Rdmp.Core.Curation.Data.DataLoad;
using Rdmp.Core.Curation.Data.Pipelines;
using Rdmp.Core.DataExport.Data;
using Rdmp.Core.Repositories;
using Rdmp.UI.ItemActivation;
using Rdmp.UI.PipelineUIs.DemandsInitializationUIs.ArgumentValueControls;
Expand All @@ -22,14 +23,16 @@ public class PipelineSelectionUIFactory
private readonly ICatalogueRepository _repository;
private readonly IPipelineUser _user;
private readonly IPipelineUseCase _useCase;
private readonly IExtractionConfiguration _extractionCurationConfiguration;

private IPipelineSelectionUI _pipelineSelectionUIInstance;

public PipelineSelectionUIFactory(ICatalogueRepository repository, IPipelineUser user, IPipelineUseCase useCase)
public PipelineSelectionUIFactory(ICatalogueRepository repository, IPipelineUser user, IPipelineUseCase useCase, IExtractionConfiguration extractionConfiguration = null)
{
_repository = repository;
_user = user;
_useCase = useCase;
_extractionCurationConfiguration = extractionConfiguration;
}

public PipelineSelectionUIFactory(ICatalogueRepository repository, RequiredPropertyInfo requirement,
Expand All @@ -46,7 +49,7 @@ public IPipelineSelectionUI Create(IActivateItems activator, string text = null,
Control containerControl = null)
{
//setup getter as an event handler for the selection ui
_pipelineSelectionUIInstance = new PipelineSelectionUI(activator, _useCase, _repository);
_pipelineSelectionUIInstance = new PipelineSelectionUI(activator, _useCase, _repository, _extractionCurationConfiguration);

if (_user != null)
{
Expand Down
5 changes: 3 additions & 2 deletions Rdmp.UI/ProjectUI/ExecuteExtractionUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@ public override void SetDatabaseObject(IActivateItems activator, ExtractionConfi
//create a new selection UI (pick an extraction pipeliene UI)
var useCase = ExtractionPipelineUseCase.DesignTime();
var factory =
new PipelineSelectionUIFactory(Activator.RepositoryLocator.CatalogueRepository, null, useCase);
new PipelineSelectionUIFactory(Activator.RepositoryLocator.CatalogueRepository, null, useCase,_extractionConfiguration);

_pipelineSelectionUI1 = factory.Create(activator, "Extraction Pipeline", DockStyle.Fill);
_pipelineSelectionUI1.CollapseToSingleLineMode();


//if the configuration has a default then use that pipeline
if (_extractionConfiguration.DefaultPipeline_ID != null)
_pipelineSelectionUI1.Pipeline = _extractionConfiguration.DefaultPipeline;
Expand Down Expand Up @@ -406,4 +407,4 @@ public override string GetTabToolTip() =>
[TypeDescriptionProvider(typeof(AbstractControlDescriptionProvider<ExecuteExtractionUI_Design, UserControl>))]
public abstract class ExecuteExtractionUI_Design : RDMPSingleDatabaseObjectControl<ExtractionConfiguration>
{
}
}