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

HicServices / RDMP / 11457925069

pending completion
11457925069

push

github

JFriel
Merge branch 'develop' of https://github.com/HicServices/RDMP

11207 of 21044 branches covered (53.26%)

Branch coverage included in aggregate %.

25 of 51 new or added lines in 3 files covered. (49.02%)

705 existing lines in 27 files now uncovered.

31728 of 53779 relevant lines covered (59.0%)

4115.97 hits per line

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

88.24
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateVersionOfCohortConfiguration.cs
1
// Copyright (c) The University of Dundee 2024-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.Linq;
8
using Rdmp.Core.Curation.Data.Cohort;
9
using Rdmp.Core.DataExport.Data;
10

11

12
namespace Rdmp.Core.CommandExecution.AtomicCommands;
13

14
public class ExecuteCommandCreateVersionOfCohortConfiguration : BasicCommandExecution, IAtomicCommand
15
{
16
    readonly CohortIdentificationConfiguration _cic;
17
    readonly IBasicActivateItems _activator;
18
    readonly string _name;
19
    readonly string _description;
20

21
    public ExecuteCommandCreateVersionOfCohortConfiguration(IBasicActivateItems activator, CohortIdentificationConfiguration cic, string name = null, string description = null) : base(activator)
10✔
22
    {
23
        _cic = cic;
10✔
24
        _activator = activator;
10✔
25
        _name = name;
10✔
26
        _description = description;
10✔
27
    }
10✔
28

29

30
    public override void Execute()
31
    {
32
        base.Execute();
12✔
33
        int? version = 1;
12✔
34

35
        var previousClones = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere<CohortIdentificationConfiguration>("ClonedFrom_ID", _cic.ID).Where(cic => cic.Version != null);
16✔
36
        if (previousClones.Any())
12✔
37
        {
38
            version = previousClones.Select(pc => pc.Version).Where(v => v != null).Max() + 1;
6!
39
        }
40
        var cmd = new ExecuteCommandCloneCohortIdentificationConfiguration(_activator, _cic, _name, version, true);
12✔
41
        cmd.Execute();
12✔
42
        if (_description is not null)
12✔
43
        {
44
            var createdItem = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere<CohortIdentificationConfiguration>("ClonedFrom_ID", _cic.ID).Where(cic => cic.Name == _name);
10✔
45
            if (createdItem.Any())
2✔
46
            {
47
                createdItem.First().Description = _description;
2✔
48
                createdItem.First().SaveToDatabase();
2✔
49

50
                var associations = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere<ProjectCohortIdentificationConfigurationAssociation>("CohortIdentificationConfiguration_ID", _cic.ID);
2✔
51
                foreach (var association in associations)
4!
52
                {
UNCOV
53
                    var link = new ProjectCohortIdentificationConfigurationAssociation(_activator.RepositoryLocator.DataExportRepository, (Project)association.Project, createdItem.First());
×
UNCOV
54
                    link.SaveToDatabase();
×
55
                }
56

57
                Publish(createdItem.First());
2✔
58
            }
59
        }
60

61
    }
12✔
62
}
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