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

HicServices / RDMP / 6237307473

19 Sep 2023 04:02PM UTC coverage: 57.015% (-0.4%) from 57.44%
6237307473

push

github

web-flow
Feature/rc4 (#1570)

* Syntax tidying
* Dependency updates
* Event handling singletons (ThrowImmediately and co)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: James A Sutherland <>
Co-authored-by: James Friel <jfriel001@dundee.ac.uk>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

10734 of 20259 branches covered (0.0%)

Branch coverage included in aggregate %.

5922 of 5922 new or added lines in 565 files covered. (100.0%)

30687 of 52390 relevant lines covered (58.57%)

7361.8 hits per line

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

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandSetAggregateDimension.cs
1
// Copyright (c) The University of Dundee 2018-2019
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.Linq;
8
using Rdmp.Core.Curation.Data;
9
using Rdmp.Core.Curation.Data.Aggregation;
10
using Rdmp.Core.Curation.Data.Cohort;
11

12
namespace Rdmp.Core.CommandExecution.AtomicCommands;
13

14
/// <summary>
15
/// Removes all <see cref="AggregateDimension"/> on an <see cref="AggregateConfiguration"/> and creates
16
/// a single new dimension for linkage in a <see cref="CohortIdentificationConfiguration"/> based on
17
/// a chosen <see cref="ExtractionInformation"/> which must be marked <see cref="ConcreteColumn.IsExtractionIdentifier"/>
18
/// </summary>
19
public class ExecuteCommandSetAggregateDimension : BasicCommandExecution, IAtomicCommand
20
{
21
    private AggregateConfiguration _aggregate;
22
    private ExtractionInformation[] _available;
23
    private ExtractionInformation _extractionInformation;
24

25
    public ExecuteCommandSetAggregateDimension(IBasicActivateItems activator,
26
        [DemandsInitialization("The AggregateConfiguration which you want to change the extraction identifier on")]
27
        AggregateConfiguration ac,
28
        [DemandsInitialization(
29
            "The extractable column in the Catalogue which should be created as a new AggregateDimension on the aggregate.  Or null to prompt at runtime",
30
            DefaultValue = true)]
31
        ExtractionInformation ei = null) : base(activator)
×
32
    {
33
        if (!ac.IsCohortIdentificationAggregate)
×
34
        {
35
            SetImpossible("AggregateConfiguration is not a cohort aggregate");
×
36
            return;
×
37
        }
38

39
        _extractionInformation = ei;
×
40

41
        if (_extractionInformation is { IsExtractionIdentifier: false })
×
42
        {
43
            SetImpossible($"'{_extractionInformation}' is not marked IsExtractionIdentifier");
×
44
            return;
×
45
        }
46

47
        try
48
        {
49
            var cata = ac.GetCatalogue();
×
50
            _available = cata.GetAllExtractionInformation().Where(ci => ci.IsExtractionIdentifier).ToArray();
×
51

52
            if (_extractionInformation != null)
×
53
                if (cata.ID != _extractionInformation.CatalogueItem.Catalogue_ID)
×
54
                {
55
                    SetImpossible($"'{_extractionInformation}' does not belong to the same Catalogue as '{ac}'");
×
56
                    return;
×
57
                }
58

59
            if (_available.Length == 0)
×
60
            {
61
                SetImpossible($"There are no columns in Catalogue '{cata}' that are marked IsExtractionIdentifier");
×
62
                return;
×
63
            }
64

65
            if (_available.Length == 1 && ac.AggregateDimensions.Length == 1 &&
×
66
                _available[0].ID == ac.AggregateDimensions[0].ExtractionInformation_ID)
×
67
            {
68
                SetImpossible(
×
69
                    $"AggregateConfiguration already uses the only IsExtractionIdentifier column in '{cata}'");
×
70
                return;
×
71
            }
72
        }
×
73
        catch (System.Exception ex)
×
74
        {
75
            SetImpossible($"Could not determine compatible columns:{ex.Message}");
×
76
        }
×
77

78
        _aggregate = ac;
×
79
    }
×
80

81
    public override void Execute()
82
    {
83
        base.Execute();
×
84

85
        var chosen = _extractionInformation;
×
86

87
        if (chosen == null && BasicActivator.IsInteractive)
×
88
            chosen = (ExtractionInformation)BasicActivator.SelectOne(new DialogArgs
×
89
            {
×
90
                WindowTitle = "Select AggregateDimension",
×
91
                TaskDescription =
×
92
                    "Choose which column to query and link with other datasets in the CohortIdentificationConfiguration.  All datasets in the configuration must have the same identifier type to be linkable."
×
93
            }, _available);
×
94

95
        if (chosen == null)
×
96
            return;
×
97

98
        foreach (var d in _aggregate.AggregateDimensions) d.DeleteInDatabase();
×
99

100
        var added = _aggregate.AddDimension(chosen);
×
101
        Publish(_aggregate);
×
102
        Emphasise(added);
×
103
    }
×
104
}
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