• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 9758065908

02 Jul 2024 09:03AM UTC coverage: 56.679% (-0.2%) from 56.914%
9758065908

push

github

web-flow
Release/8.2.0 (#1867)

* add extraction additions

* interim

* add test

* interim

* working dedupe

* improved checking

* add timestamp option

* fix extra looping

* add check

* start on tests

* tidy up code

* update link

* tidy up

* Rename executeFullExtractionToDatabaseMSSql.md to ExecuteFullExtractionToDatabaseMSSql.md

* fix typo

* add docs

* update

* update documentation

* attempt fix docs

* update docs

* tidy up code

* better tests

* add real test

* tidy up

* interim

* grab existiing entity

* no new data

* add basic tests

* attempt to fix test

* interim

* interim commit

* working clash

* add test

* fix test

* improved clash checker

* tidy up

* update test

* fix up test

* update from codeql

* tidy up code

* fix bad merge

* fix typo

* skip over for now

* revert change

* Task/RDMP-180 Add instance settings table (#1820)

* working settings interface

* add documentation

* add missing files

* update namespace

* add icon

* update from run

* make key unique

* add tests

* update tests

* update for tests

* fix unique name issue

* tidy up

* tidy up from review

* works

* nested deprications

* recursive deprication

* tidy up

* add newline

* Task/rdmp 174 dqe improvements (#1849)

* working scallable graph

* add changelog

* add axis override

* interim

* working increments

* working ui refresh

* update changelog

* tidy up code

* add missing file

* tidy up

* Task/rdmp 155 migrate catalogue tables (#1805)

* start of UI

* interim

* working switch

* improved ui

* fix build

* rename duped file

* imterim

* add checks

* start of tests

* local tests  working

* add tests

* improved ui

* tidy up

* add single item use

* broken test

* updated tests

* tidy up imports

* add some documentation

* fix docume... (continued)

10912 of 20750 branches covered (52.59%)

Branch coverage included in aggregate %.

369 of 831 new or added lines in 38 files covered. (44.4%)

375 existing lines in 25 files now uncovered.

30965 of 53135 relevant lines covered (58.28%)

7845.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCloneExtractionConfiguration.cs
1
// Copyright (c) The University of Dundee 2018-2024
2
// This file is part of the Research Data Management Platform (RDMP).
3
// 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.
4
// 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.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections.Generic;
9
using System.Linq;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.DataExport.Data;
12
using Rdmp.Core.Icons.IconProvision;
13
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
14
using SixLabors.ImageSharp;
15
using SixLabors.ImageSharp.PixelFormats;
16

17
namespace Rdmp.Core.CommandExecution.AtomicCommands;
18

19
public class ExecuteCommandCloneExtractionConfiguration : BasicCommandExecution, IAtomicCommand
20
{
21
    private readonly ExtractionConfiguration _extractionConfiguration;
22
    private readonly IBasicActivateItems _activeItems;
NEW
23
    private readonly List<IExtractableDataSet> toRemove = [];
×
NEW
24
    private readonly List<Catalogue> toAdd = [];
×
25
    private void CheckForDeprecatedCatalogues()
26
    {
NEW
27
        if (_extractionConfiguration.SelectedDataSets.Any(sd => sd.GetCatalogue().IsDeprecated) && _activeItems.IsInteractive)
×
28
        {
NEW
29
            if (YesNo("There are Deprecated catalogues in this Extraction Configuration. Would you like to replace them with their replacement (where available)?", "Replace Deprecated Catalogues"))
×
30
            {
NEW
31
                var repo = _activeItems.RepositoryLocator.CatalogueRepository;
×
NEW
32
                var DeprecatedDatasets = _extractionConfiguration.SelectedDataSets.Where(sd => sd.GetCatalogue().IsDeprecated).ToList();
×
NEW
33
                var replacedBy = repo.GetExtendedProperties(ExtendedProperty.ReplacedBy);
×
NEW
34
                foreach (ISelectedDataSets ds in DeprecatedDatasets)
×
35
                {
NEW
36
                    var replacement = replacedBy.Where(rb => rb.ReferencedObjectID == ds.GetCatalogue().ID).FirstOrDefault();
×
NEW
37
                    if (replacement is not null)
×
38
                    {
NEW
39
                        var replacementCatalogue = repo.GetObjectByID<Catalogue>(Int32.Parse(replacement.Value));
×
NEW
40
                        while (replacementCatalogue.IsDeprecated)
×
41
                        {
NEW
42
                            var replacementCatalogueIsReplacedBy = replacedBy.Where(rb => rb.ReferencedObjectID == replacementCatalogue.ID).FirstOrDefault();
×
NEW
43
                            if(replacementCatalogueIsReplacedBy is not null)
×
44
                            {
45
                                //have found further down the tree
NEW
46
                                replacementCatalogue = repo.GetObjectByID<Catalogue>(Int32.Parse(replacementCatalogueIsReplacedBy.Value));
×
47
                            }
48
                            else
49
                            {
50
                                //there is no replacement
51
                                break;
52
                            }
53
                        }
NEW
54
                        toRemove.Add(ds.ExtractableDataSet);
×
NEW
55
                        toAdd.Add(replacementCatalogue);
×
56
                    }
57
                }
58

59

60
            }
61
        }
NEW
62
    }
×
63

64
    public ExecuteCommandCloneExtractionConfiguration(IBasicActivateItems activator,
65
        ExtractionConfiguration extractionConfiguration) : base(activator)
×
66
    {
67
        _extractionConfiguration = extractionConfiguration;
×
NEW
68
        _activeItems = activator;
×
69
        if (!_extractionConfiguration.SelectedDataSets.Any())
×
70
            SetImpossible("ExtractionConfiguration does not have any selected datasets");
×
71
    }
×
72

73
    public override string GetCommandHelp() =>
74
        "Creates an exact copy of the Extraction Configuration including the cohort selection, all selected datasets, parameters, filter containers, filters etc";
×
75

76
    public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
77
        Image.Load<Rgba32>(CatalogueIcons.CloneExtractionConfiguration);
×
78

79
    public override void Execute()
80
    {
81
        base.Execute();
×
NEW
82
        CheckForDeprecatedCatalogues();
×
83

84
        var clone = _extractionConfiguration.DeepCloneWithNewIDs();
×
NEW
85
        foreach (ExtractableDataSet ds in toRemove)
×
86
        {
NEW
87
            clone.RemoveDatasetFromConfiguration(ds);
×
88
        }
NEW
89
        foreach (Catalogue c in toAdd)
×
90
        {
91
            //check if the eds already exis
NEW
92
            var eds = _activeItems.RepositoryLocator.DataExportRepository.GetAllObjectsWhere<ExtractableDataSet>("Catalogue_ID", c.ID).FirstOrDefault();
×
NEW
93
            if (eds is null)
×
94
            {
NEW
95
                eds = new ExtractableDataSet(_activeItems.RepositoryLocator.DataExportRepository, c);
×
NEW
96
                eds.SaveToDatabase();
×
97
            }
NEW
98
            clone.AddDatasetToConfiguration(eds);
×
99
        }
100
        Publish((DatabaseEntity)clone.Project);
×
101
        Emphasise(clone);
×
102
    }
×
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc