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

HicServices / RDMP / 19465055827

18 Nov 2025 11:47AM UTC coverage: 57.142% (+0.05%) from 57.097%
19465055827

push

github

web-flow
Merge pull request #2260 from HicServices/task/RDMP-342-cic-templates

Task/rdmp-342 CIC Templates

11472 of 21559 branches covered (53.21%)

Branch coverage included in aggregate %.

1000 of 1215 new or added lines in 34 files covered. (82.3%)

2 existing lines in 2 files now uncovered.

32516 of 55421 relevant lines covered (58.67%)

8798.98 hits per line

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

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandSetContainerOperation.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 Rdmp.Core.Curation.Data.Cohort;
8
using Rdmp.Core.Icons.IconProvision;
9
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
10
using SixLabors.ImageSharp;
11
using SixLabors.ImageSharp.PixelFormats;
12

13
namespace Rdmp.Core.CommandExecution.AtomicCommands;
14

15
/// <summary>
16
/// Changes the set operation on a <see cref="CohortAggregateContainer"/>
17
/// </summary>
18
public class ExecuteCommandSetContainerOperation : BasicCommandExecution
19
{
20
    private readonly CohortAggregateContainer _container;
21
    private readonly SetOperation _operation;
22

23
    public ExecuteCommandSetContainerOperation(IBasicActivateItems activator, CohortAggregateContainer container,
24
        SetOperation operation) : base(activator)
×
25
    {
26
        if (container.Operation == operation)
×
27
            SetImpossible($"Container already uses {operation}");
×
28

29
        _container = container;
×
30
        _operation = operation;
×
31

NEW
32
        if (container.ShouldBeReadOnly(this.GetType().Name, out var reason)) SetImpossible(reason);
×
33

34
        Weight = _operation switch
×
35
        {
×
36
            SetOperation.UNION => 0.21f,
×
37
            SetOperation.EXCEPT => 0.22f,
×
38
            SetOperation.INTERSECT => 0.23f,
×
39
            _ => Weight
×
40
        };
×
41
    }
×
42

43
    public override string GetCommandName() => !string.IsNullOrWhiteSpace(OverrideCommandName)
×
44
        ? OverrideCommandName
×
45
        : $"Set operation {_operation}";
×
46

47
    public override Image<Rgba32> GetImage(IIconProvider iconProvider)
48
    {
49
        return _operation switch
×
50
        {
×
51
            SetOperation.EXCEPT => iconProvider.GetImage(Image.Load<Rgba32>(CatalogueIcons.EXCEPT)),
×
52
            SetOperation.INTERSECT => iconProvider.GetImage(Image.Load<Rgba32>(CatalogueIcons.INTERSECT)),
×
53
            SetOperation.UNION => iconProvider.GetImage(Image.Load<Rgba32>(CatalogueIcons.UNION)),
×
54
            _ => base.GetImage(iconProvider)
×
55
        };
×
56
    }
57

58
    public override void Execute()
59
    {
60
        base.Execute();
×
61

62
        var oldOperation = _container.Operation;
×
63

64
        //if the old name was UNION and we are changing to INTERSECT Operation then we should probably change the Name too! even if they have something like 'INTERSECT the people who are big and small' and they change to UNION we want it to be changed to 'UNION the people who are big and small'
65
        if (_container.Name.StartsWith(oldOperation.ToString()))
×
66
        {
67
            _container.Name = _operation + _container.Name[oldOperation.ToString().Length..];
×
68
        }
69
        else
70
        {
71
            if (BasicActivator.TypeText("New name for container?",
×
72
                    "You have changed the operation, do you want to give it a new description?", 1000, _container.Name,
×
73
                    out var newName, false))
×
74
            {
75
                _container.Name = newName;
×
76
            }
77
            else
78
            {
79
                Show("Cancelled changing operation");
×
80
                // user cancelled the operation
81
                return;
×
82
            }
83
        }
84

85
        _container.Operation = _operation;
×
86
        _container.SaveToDatabase();
×
87
        Publish(_container);
×
88
    }
×
89
}
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